CVS: gcc/gcc-4.1.1/gcc/config/msp430 libgcc.S, NONE, 1.1 msp430-protos.h, NONE, 1.1 msp430.c, NONE, 1.1 msp430.h, NONE, 1.1 msp430.md, NONE, 1.1 msp430.opt, NONE, 1.1 predicates.md, NONE, 1.1 t-msp430, NONE, 1.1 xm-msp430.h, NONE, 1.1

Christopher Cole <[email protected]> Wed, 14 Jun 2006 19:30:04 -0700
Newsgroups gmane.comp.hardware.texas-instruments.msp430.gcc.cvs
Message-ID <[email protected]>
Update of /cvsroot/mspgcc/gcc/gcc-4.1.1/gcc/config/msp430
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv23740/gcc-4.1.1/gcc/config/msp430

Added Files:
	libgcc.S msp430-protos.h msp430.c msp430.h msp430.md 
	msp430.opt predicates.md t-msp430 xm-msp430.h 
Log Message:
Initial checkin for mspgcc 4.1.1 files.  This is a work in progress.



--- NEW FILE: libgcc.S ---

/* Low-level subroutines for Texas Instruments MSP430 MCU
   Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
   Contributed by Dmitry Diky <[email protected]>

   This file is part of GCC.
   GCC is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.
   
   In addition to the permissions in the GNU General Public License, the
   Free Software Foundation gives you unlimited permission to link the
   compiled version of this file into combinations with other programs,
   and to distribute those combinations without any restriction coming
   from the use of this file.  (The General Public License restrictions
   do apply in other respects; for example, they cover modification of
   the file, and distribution when not linked into a combine
   executable.)
[...1226 lines suppressed...]
        mov     r_arg2ll,&__OP2           ;;          HH1xLL2
        mov     &__RESLO,r_reshh

;; reload result
        mov     r_resll, r12
        mov     r_reslh, r13
        mov     r_reshl, r14
        mov     r_reshh, r15

        pop     r11
        pop     r10
        pop     r9
        pop     r8
        pop     r7
        pop     r6
        pop     r5
        pop     r4
        ret
.endfunc
#endif

--- NEW FILE: msp430-protos.h ---
/* Prototypes for exported functions defined in msp430.c
   
   Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
   Contributed by Dmitry Diky <[email protected]>

   This file is part of GCC.

   GCC is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   GCC is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with GCC; see the file COPYING.  If not, write to
   the Free Software Foundation, 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */


extern void   bootloader_section (void);
extern void   infomem_section (void);

extern void   asm_file_start            (FILE *file);
extern void   asm_file_end              (FILE *file);
extern void   msp430_init_once          (void);
extern void   msp430_override_options   (void);
extern void   gas_output_limited_string (FILE *file, const char *str);
extern void   gas_output_ascii          (FILE *file, const char *str,
							 size_t length);
extern void   order_regs_for_local_alloc (void);
extern void   msp430_trampoline_template (FILE *fd);

int msp430_current_function_noint_hwmul_function_p PARAMS((void));

extern int frame_pointer_required_p (void);
extern int msp430_empty_epilogue (void);

int msp430_regno_ok_for_base_p (int);

#ifdef HAVE_MACHINE_MODES
extern int    msp430_hard_regno_mode_ok (int regno,
					     enum machine_mode mode);
#endif

extern int initial_elimination_offset (int, int);



#ifdef TREE_CODE
extern void   asm_output_external          (FILE *file, tree decl,
						   char *name);
extern void   unique_section               (tree decl, int reloc);
extern void   encode_section_info          (tree decl);
extern void   asm_output_section_name      (FILE *file, tree decl,
						   const char *name,
						   int reloc);
extern int    valid_machine_type_attribute (tree type, tree attributes,
						   tree identifier,
						   tree args);
extern int    valid_machine_decl_attribute (tree decl, tree attributes,
						   tree attr, tree args);
extern void asm_declare_function_name (FILE *, const char *, tree);
unsigned int msp430_section_type_flags ( tree DECL, const char *NAME, int RELOC);


#ifdef RTX_CODE /* inside TREE_CODE */
extern rtx    msp430_function_value          (tree type, tree func);
extern void   init_cumulative_args           (CUMULATIVE_ARGS *cum,
						   tree fntype, rtx libname,
						   int indirect);
extern rtx    function_arg         (CUMULATIVE_ARGS *cum,
					   enum machine_mode mode,
					   tree type, int named);
extern void   init_cumulative_incoming_args           (CUMULATIVE_ARGS *cum,
						   tree fntype, rtx libname);
extern rtx    function_incoming_arg         (CUMULATIVE_ARGS *cum,
					   enum machine_mode mode,
					   tree type, int named);



#endif /* RTX_CODE inside TREE_CODE */

#ifdef HAVE_MACHINE_MODES /* inside TREE_CODE */
extern void   function_arg_advance (CUMULATIVE_ARGS *cum,
					   enum machine_mode mode, tree type,
					   int named);
#endif /* HAVE_MACHINE_MODES inside TREE_CODE*/
#endif /* TREE_CODE */

#ifdef RTX_CODE


extern enum rtx_code msp430_canonicalize_comparison (enum rtx_code,rtx *,rtx *);


extern void msp430_emit_cbranch (enum rtx_code, rtx);
extern void msp430_emit_cset (enum rtx_code, rtx);

extern int dead_or_set_in_peep (int, rtx, rtx);
extern void msp430_initialize_trampoline (rtx,rtx,rtx);   


extern enum reg_class msp430_reg_class_from_letter (int);
extern enum reg_class preferred_reload_class (rtx,enum reg_class);
enum reg_class msp430_regno_reg_class (int);

extern RTX_CODE followed_compare_condition (rtx);

extern const char * msp430_movesi_code (rtx insn, rtx operands[], int *l);
extern const char * msp430_movedi_code (rtx insn, rtx operands[], int *l);
extern const char * msp430_addsi_code (rtx insn, rtx operands[], int *l);
extern const char * msp430_subsi_code (rtx insn, rtx operands[], int *l);
extern const char * msp430_andsi_code (rtx insn, rtx operands[], int *l);
extern const char * msp430_iorsi_code (rtx insn, rtx operands[], int *l);
extern const char * msp430_xorsi_code (rtx insn, rtx operands[], int *l);
extern const char * msp430_adddi_code (rtx insn, rtx operands[], int *l);
extern const char * msp430_subdi_code (rtx insn, rtx operands[], int *l);
extern const char * msp430_anddi_code (rtx insn, rtx operands[], int *l);
extern const char * msp430_iordi_code (rtx insn, rtx operands[], int *l);
extern const char * msp430_xordi_code (rtx insn, rtx operands[], int *l);


extern int zero_shifted (rtx );
extern int indexed_location (rtx );


extern int regsi_ok_safe (rtx operands[]);
extern int regsi_ok_clobber (rtx operands[]);
extern int regdi_ok_safe (rtx operands[]);
extern int regdi_ok_clobber (rtx operands[]);
extern int sameoperand (rtx operands[], int);

extern int general_operand_msp430 (rtx, enum machine_mode ); 
extern int nonimmediate_operand_msp430 (rtx, enum machine_mode );
extern int memory_operand_msp430 (rtx, enum machine_mode );
extern int halfnibble_constant (rtx, enum machine_mode );
extern int halfnibble_integer (rtx, enum machine_mode );
extern int halfnibble_constant_shift (rtx, enum machine_mode );
extern int halfnibble_integer_shift (rtx, enum machine_mode );
extern int which_nibble (int);
extern int which_nibble_shift (int);


extern void   asm_output_external_libcall (FILE *file, rtx symref);
extern int    legitimate_address_p    (enum machine_mode mode, rtx x,
					int strict);
extern int    compare_diff_p  (rtx insn);

extern int    emit_indexed_arith (rtx insn, rtx operands[], int, const char *, int);

extern const char * msp430_emit_abssi    (rtx insn, rtx operands[], int *l);
extern const char * msp430_emit_absdi    (rtx insn, rtx operands[], int *l);

extern const char * msp430_emit_indexed_add2 (rtx insn, rtx op[], int *l);
extern const char * msp430_emit_indexed_add4 (rtx insn, rtx op[], int *l);

extern const char * msp430_emit_indexed_sub2 (rtx insn, rtx operands[], int *len);
extern const char * msp430_emit_indexed_sub4 (rtx insn, rtx operands[], int *len);

extern const char * msp430_emit_indexed_and2 (rtx insn, rtx op[], int *l);
extern const char * msp430_emit_indexed_and4 (rtx insn, rtx op[], int *l);
extern const char * msp430_emit_immediate_and2 (rtx insn, rtx op[], int *l);
extern const char * msp430_emit_immediate_and4 (rtx insn, rtx op[], int *l);

extern const char * msp430_emit_indexed_ior2 (rtx insn, rtx operands[], int *len);
extern const char * msp430_emit_indexed_ior4 (rtx insn, rtx operands[], int *len);
extern const char * msp430_emit_immediate_ior2 (rtx insn, rtx op[], int *l);
extern const char * msp430_emit_immediate_ior4 (rtx insn, rtx op[], int *l);


extern int msp430_emit_indexed_mov (rtx insn, rtx operands[], int len, const char *);       
extern const char * movstrsi_insn (rtx insn, rtx operands[], int *len);
extern const char * clrstrsi_insn (rtx insn, rtx operands[], int *len);
extern const char * movstrhi_insn (rtx insn, rtx operands[], int *len);
extern const char * clrstrhi_insn (rtx insn, rtx operands[], int *len);
extern const char * msp430_emit_indexed_mov2 (rtx insn, rtx operands[], int *len);
extern const char * msp430_emit_indexed_mov4 (rtx insn, rtx operands[], int *len);
extern const char * movsisf_regmode (rtx insn, rtx operands[], int *len);
extern const char * movdidf_regmode (rtx insn, rtx operands[], int *len);


extern int is_shift_better_in_reg (rtx operands[]);
extern int msp430_emit_shift_cnt (int (*funct)(rtx, int, int), const char *, rtx insn, rtx operands[], int *len, int);
extern const char * msp430_emit_ashlqi3 (rtx insn, rtx operands[], int *len);
extern const char * msp430_emit_ashlhi3 (rtx insn, rtx operands[], int *len);
extern const char * msp430_emit_ashlsi3 (rtx insn, rtx operands[], int *len);
extern const char * msp430_emit_ashldi3 (rtx insn, rtx operands[], int *len);
extern const char * msp430_emit_ashrqi3 (rtx insn, rtx operands[], int *len);
extern const char * msp430_emit_ashrhi3 (rtx insn, rtx operands[], int *len);
extern const char * msp430_emit_ashrsi3 (rtx insn, rtx operands[], int *len);
extern const char * msp430_emit_ashrdi3 (rtx insn, rtx operands[], int *len);
extern const char * msp430_emit_lshrqi3 (rtx insn, rtx operands[], int *len);
extern const char * msp430_emit_lshrhi3 (rtx insn, rtx operands[], int *len);
extern const char * msp430_emit_lshrsi3 (rtx insn, rtx operands[], int *len);
extern const char * msp430_emit_lshrdi3 (rtx insn, rtx operands[], int *len);

extern const char * signextendqihi (rtx insn, rtx operands[], int *len);
extern const char * signextendqisi (rtx insn, rtx operands[], int *len);
extern const char * signextendqidi (rtx insn, rtx operands[], int *len);
extern const char * signextendhisi (rtx insn, rtx operands[], int *len);
extern const char * signextendhidi (rtx insn, rtx operands[], int *len);
extern const char * signextendsidi (rtx insn, rtx operands[], int *len);

extern const char * msp430_emit_indexed_sub2 (rtx insn, rtx operands[], int *len);
extern const char * msp430_emit_indexed_sub4 (rtx insn, rtx operands[], int *len);

extern const char * msp430_emit_indexed_xor2 (rtx insn, rtx operands[], int *len);
extern const char * msp430_emit_indexed_xor4 (rtx insn, rtx operands[], int *len);
extern const char * msp430_emit_indexed_xor2_3 (rtx insn, rtx operands[], int *len);
extern const char * msp430_emit_indexed_xor4_3 (rtx insn, rtx operands[], int *len);

extern const char * zeroextendqihi (rtx insn, rtx operands[], int *len);
extern const char * zeroextendqisi (rtx insn, rtx operands[], int *len);
extern const char * zeroextendqidi (rtx insn, rtx operands[], int *len);
extern const char * zeroextendhisi (rtx insn, rtx operands[], int *len);
extern const char * zeroextendhidi (rtx insn, rtx operands[], int *len);
extern const char * zeroextendsidi (rtx insn, rtx operands[], int *len);

extern const char * msp430_emit_blt0si (rtx operands[], int len);
extern const char * msp430_emit_beq (rtx operands[], int len);
extern const char * msp430_emit_bne (rtx operands[], int len);          
extern const char * msp430_emit_bgt (rtx operands[], int len);          
extern const char * msp430_emit_bgtu (rtx operands[], int len);          
extern const char * msp430_emit_blt (rtx operands[], int len);          
extern const char * msp430_emit_bltu (rtx operands[], int len);          
extern const char * msp430_emit_bge (rtx operands[], int len);          
extern const char * msp430_emit_bgeu (rtx operands[], int len);          
extern const char * msp430_emit_ble (rtx operands[], int len);          
extern const char * msp430_emit_bleu (rtx operands[], int len);          

extern const char * msp430_pushsisf (rtx insn, rtx operands[], int *len);
extern const char * msp430_pushdi   (rtx insn, rtx operands[], int *len);
extern const char * msp430_pushhi   (rtx insn, rtx operands[], int *len);
extern const char * msp430_pushqi   (rtx insn, rtx operands[], int *len);

extern const char * msp430_emit_return (rtx insn, rtx operands[], int *len);
extern const char *msp430_cbranch (rtx insn, rtx operands[], int *len);
extern const char *msp430_cset (rtx insn, rtx operands[], int *len);

extern void   notice_update_cc       (rtx body, rtx insn);
extern int    msp430_peep2_scratch_safe (rtx reg_rtx);
extern int    test_hard_reg_class    (enum reg_class class, rtx x);
extern void   machine_dependent_reorg (rtx first_insn);
extern void msp430_output_addr_vec_elt (FILE *stream, int value);
extern void   final_prescan_insn     (rtx insn, rtx *operand,
							int num_operands);
extern int    adjust_insn_length     (rtx insn, int len);


extern int    msp430_address_cost    (rtx x);
extern int    extra_constraint       (rtx x, int c);
extern rtx    legitimize_address     (rtx x, rtx oldx,
					     enum machine_mode mode);
extern rtx    msp430_libcall_value   (enum machine_mode mode);
extern int    default_rtx_costs      (rtx X, RTX_CODE code,
					     RTX_CODE outer_code);
extern void   asm_output_char        (FILE *file, rtx value);
extern void   asm_output_short       (FILE *file, rtx value);
extern void   asm_output_byte        (FILE *file, int value);

extern void   print_operand          (FILE *file, rtx x, int code);
extern void   print_operand_address  (FILE *file, rtx addr);
extern int    reg_unused_after       (rtx insn, rtx reg);
extern int    msp430_jump_dist       (rtx x, rtx insn);
extern int    call_insn_operand      (rtx op, enum machine_mode mode);
extern int    msp430_branch_mode     (rtx x, rtx insn);

extern int 	msp430_easy_mul (rtx [],int);
extern int	msp430_mul3_guard (rtx [], int );
extern int      msp430_umul3_guard       (rtx [], int );
extern int	msp430_mulhisi_guard (rtx [] );
extern int	msp430_umulhisi_guard (rtx [] );
extern int	msp430_ashlhi3 	 (rtx [] );
extern int      msp430_ashlsi3          (rtx [] );
extern int      msp430_ashrhi3          (rtx [] );
extern int      msp430_ashrsi3          (rtx [] );
extern int      msp430_lshrhi3          (rtx [] );
extern int      msp430_lshrsi3          (rtx [] );


#endif /* RTX_CODE */

#ifdef HAVE_MACHINE_MODES
extern int    class_max_nregs        (enum reg_class class,
					     enum machine_mode mode);
#endif /* HAVE_MACHINE_MODES */

#ifdef REAL_VALUE_TYPE

extern void   asm_output_float       (FILE *file, REAL_VALUE_TYPE n);

#endif



--- NEW FILE: msp430.c ---
/* Subroutines for insn-output.c for Texas Instruments MSP430 MCU
 Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
 Contributed by Dmitry Diky <[email protected]>
 
 This file is part of GCC. 
 GCC is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2, or (at your option)
 any later version.
 
 GNU CC is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING.  If not, write to
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
[...7468 lines suppressed...]
	gen_rtx_UNSPEC_VOLATILE(HImode,
	  gen_rtvec(2,arg, GEN_INT(4200002)),42));
  else if(code == CODE_FOR_get_frame_address)
  {
    retval = gen_reg_rtx(HImode);
    insn = gen_rtx_SET(HImode, retval, 
	gen_rtx_UNSPEC_VOLATILE(HImode,
	  gen_rtvec(2,frame_offset_n, GEN_INT(4300003)),43));
  }
  else
    error("Unknown built-in function");
  
  if(insn)
    emit_insn(insn);
  else
    error("Unknown built-in function");
  
  return retval;
}


--- NEW FILE: msp430.h ---

/* Definitions of target machine for GNU compiler,
   for Texas Instruments MSP430 microcontrollers.
   Copyright (C) 2001,2002,2003 Free Software Foundation, Inc.
   Contributed by Dmitry Diky <[email protected]>

   This file is part of GCC.

   GCC is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   GCC is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with GCC; see the file COPYING.  If not, write to
   the Free Software Foundation, 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */

/* $Id: */

#ifndef __MSP430_H__
#define __MSP430_H__

extern const char *msp430_endup;
extern const char *msp430_init_stack;
extern const char *msp430_mcu_name;
extern int msp430_has_hwmul;

#define TARGET_CPU_CPP_BUILTINS()                       \
do{							\
  builtin_define_std ("MSP430");			\
  builtin_define_std ("__MSP430__");			\
  if(msp430_has_hwmul)					\
    builtin_define ("MSP430_HAS_HWMUL");		\
  else							\
    builtin_define ("MSP430_NO_HWMUL");		        \
}while(0)

extern int target_flags;

int msp430_current_function_hwmul_no_int_function_p(void);
#define MSP430_NOINT_HWMUL (msp430_current_function_noint_hwmul_function_p())

#define TARGET_VERSION fprintf (stderr, " (GNU assembler syntax)");

#define OVERRIDE_OPTIONS msp430_override_options()

#define FRAME_POINTER_CFA_OFFSET(FNDECL) 0

#define CAN_DEBUG_WITHOUT_FP

#define BITS_BIG_ENDIAN 0
#define BYTES_BIG_ENDIAN 0
#define WORDS_BIG_ENDIAN 0
#define BITS_PER_UNIT 8
#define BITS_PER_WORD 16

#define UNITS_PER_WORD 2

#define POINTER_SIZE 16
#define MAX_FIXED_MODE_SIZE 32
#define PARM_BOUNDARY 16
#define FUNCTION_BOUNDARY 16
#define EMPTY_FIELD_BOUNDARY 16
#define BIGGEST_ALIGNMENT 16
#define STRICT_ALIGNMENT TARGET_STRICT_ALIGN
#define INT_TYPE_SIZE  16
#define SHORT_TYPE_SIZE 16
#define LONG_TYPE_SIZE 32
#define LONG_LONG_TYPE_SIZE 64
#define  CHAR_TYPE_SIZE 8
#define FLOAT_TYPE_SIZE 32
#define DOUBLE_TYPE_SIZE 32
#define LONG_DOUBLE_TYPE_SIZE 32
#define DEFAULT_SIGNED_CHAR 1

#define SIZE_TYPE ("unsigned int")
#define PTRDIFF_TYPE ("int")
#define WCHAR_TYPE_SIZE 16


#define FIRST_PSEUDO_REGISTER 16

#define FIXED_REGISTERS {\
  1,1,/* r0 r1 == PC  SP */\
  1,1,/* r2 r3 == CG1(SR) CG2*/\
  0,0,/* r4 r5 */\
  0,0,/* r6 r7 */\
  0,0,/* r8 r9 */\
  0,0,/* r10 r11 */\
  0,0,/* r12 r13 */\
  0,0,/* r14 r15 */\
}

#define CALL_USED_REGISTERS {			\
    1,1,/* r0 r1 */				\
    1,1,/* r2 r3 */				\
    0,0,/* r4 r5 */				\
    0,0,/* r6 r7 */				\
    0,0,/* r8 r9 */				\
    0,0,/* r10 r11 */				\
    1,1,/* r12 r13 */				\
    1,1,/* r14 r15 */				\
}

#define REG_ALLOC_ORDER { 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 }

#define ORDER_REGS_FOR_LOCAL_ALLOC order_regs_for_local_alloc ()

#define HARD_REGNO_NREGS(REGNO, MODE) \
((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)

#define HARD_REGNO_MODE_OK(REGNO, MODE) 1

#define MODES_TIEABLE_P(MODE1, MODE2)           	0

enum reg_class {
  NO_REGS,
  PC_REG,			/* r0  - PC	*/
  SP_REG,			/* r1  - SP	*/
  STACK_REGS,			/* r2  - SR	*/
  CG1_REG,			/* r2  - CG1	*/
  CG2_REG,			/* r3  - CG2	*/
  CG_REGS,			/* r2, r3	*/
  GENERAL_REGS,			/* r4 - r15 	*/
  POINTER_REGS,
  BASE_POINTER_REGS,
  FFOUR_REG,
  ALL_REGS, LIM_REG_CLASSES
};
  
#define N_REG_CLASSES (int) LIM_REG_CLASSES

#define REG_CLASS_NAMES {		\
		"NO_REGS",		\
		"PC_REG",		\
		"SP_REG",		\
		"STACK_REGS",		\
		"CG1_REG",		\
		"CG2_REG",		\
		"CG_REGS",		\
		"GENERAL_REGS",		\
		"POINTER_REGS",		\
		"BASE_POINTER_REGS",		\
		"FFOUR_REG",		\
		"ALL_REGS" 		\
}


#define REG_CLASS_CONTENTS {				\
  {0x00000000ul},	/* NO_REGS	*/	\
  {0x00000001ul},	/* PC_REG 	*/	\
  {0x00000002ul},	/* SP_REG 	*/	\
  {0x00000004ul},	/* r2		*/	\
  {0x00000004ul},	/* r2		*/	\
  {0x00000008ul},	/* r3		*/	\
  {0x0000000cul},	/* r2,r3	*/	\
  {0x0000fff2ul}, /* r4 - r15,r1  */      \
  {0x0000fff2ul}, /* r4 - r15,r1  */      \
  {0x0000fff0ul},	/* r4 - r15	*/	\
  {0x0000fffful}	/* ALL_REGS */		\
}

enum reg_class msp430_regno_reg_class (int);
#define REGNO_REG_CLASS(R) msp430_regno_reg_class(R)

#define BASE_REG_CLASS (reload_completed ? BASE_POINTER_REGS : POINTER_REGS)

#define INDEX_REG_CLASS NO_REGS

#define REG_CLASS_FROM_LETTER(C) msp430_reg_class_from_letter(C)

#define REGNO_OK_FOR_BASE_P(r) msp430_regno_ok_for_base_p(r) 
					
#define REGNO_OK_FOR_INDEX_P(NUM) 0

#define PREFERRED_RELOAD_CLASS(X, CLASS) FFOUR_REG

#define SMALL_REGISTER_CLASSES 1

#define CLASS_MAX_NREGS(CLASS, MODE)	\
	((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)

/* In the following defenition only 'P' matters. All other left here for 
 backward compatibility */
#define CONST_OK_FOR_LETTER_P(VALUE, C)				\
   ((C) == 'P' ? ((VALUE)==-1||(VALUE)==1||(VALUE)==2||(VALUE)==4||(VALUE)==8 ||(VALUE)==0) : 0)

#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
  ((C) == 'G' ? (VALUE) == CONST0_RTX (SFmode)	\
   : 0)

#define EXTRA_CONSTRAINT(x, c) extra_constraint(x, c)

#define STACK_PUSH_CODE POST_DEC

#define STACK_GROWS_DOWNWARD

#define STARTING_FRAME_OFFSET 0

#define STACK_POINTER_OFFSET 0

#define FIRST_PARM_OFFSET(FUNDECL) 0

#define STACK_BOUNDARY 16

#define STACK_POINTER_REGNUM 1

#define FRAME_POINTER_REGNUM 4

#define ARG_POINTER_REGNUM 5

#define STATIC_CHAIN_REGNUM 6

#define FRAME_POINTER_REQUIRED   frame_pointer_required_p()

#define ELIMINABLE_REGS {			\
   {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
   {ARG_POINTER_REGNUM, STACK_POINTER_REGNUM} \
}

#define CAN_ELIMINATE(FROM, TO) 1

#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET)			\
     OFFSET = initial_elimination_offset (FROM, TO)

#define PUSH_ROUNDING(NPUSHED) ((NPUSHED+1) & ~1)

#define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, STACK_SIZE) 0

#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
(function_arg (&(CUM), MODE, TYPE, NAMED))

typedef struct msp430_args {
  int nregs;			/* # registers available for passing */
  int regno;			/* next available register number */
} CUMULATIVE_ARGS;

#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS ) \
init_cumulative_args (&(CUM), FNTYPE, LIBNAME, FNDECL)

#define  INIT_CUMULATIVE_INCOMING_ARGS(CUM, FNTYPE, LIBNAME) \
init_cumulative_incoming_args(&(CUM), FNTYPE, LIBNAME)

#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)	\
  (function_arg_advance (&CUM, MODE, TYPE, NAMED))

#define FUNCTION_ARG_REGNO_P(r) (r >= 12 && r <= 15)

extern int msp430_reg_order[];

#define RET_REGISTER  15 /* msp430_ret_register ()*/

#define FUNCTION_VALUE(VALTYPE, FUNC) msp430_function_value (VALTYPE, FUNC)

#define LIBCALL_VALUE(MODE)  msp430_libcall_value (MODE)

#define FUNCTION_VALUE_REGNO_P(N) ((N) == RET_REGISTER)

#define RETURN_IN_MEMORY(TYPE) ((TYPE_MODE (TYPE) == BLKmode)	\
				? int_size_in_bytes (TYPE) > 8	\
				: 0)

#define DEFAULT_PCC_STRUCT_RETURN 0

#define STRUCT_VALUE 0

#define HAVE_POST_INCREMENT 	1

#define CONSTANT_ADDRESS_P(X) CONSTANT_P (X)

#define MAX_REGS_PER_ADDRESS 1

#ifdef REG_OK_STRICT
#  define GO_IF_LEGITIMATE_ADDRESS(mode, operand, ADDR)	\
{							\
  if (legitimate_address_p (mode, operand, 1))		\
    goto ADDR;						\
}
#  else
#  define GO_IF_LEGITIMATE_ADDRESS(mode, operand, ADDR)	\
{							\
  if (legitimate_address_p (mode, operand, 0))		\
    goto ADDR;						\
}
#endif

#define REG_OK_FOR_BASE_NOSTRICT_P(X) \
  (REGNO (X) >= FIRST_PSEUDO_REGISTER || REG_OK_FOR_BASE_STRICT_P(X))

#define REG_OK_FOR_BASE_STRICT_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))

#ifdef REG_OK_STRICT
#  define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_STRICT_P (X)
#else
#  define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_NOSTRICT_P (X)
#endif

#define REG_OK_FOR_INDEX_P(X) 0 /*( REGNO(X)!=3 && REGNO(X)!=2 &&REGNO(X)<=15) */

#define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN)				\
GO_IF_LEGITIMATE_ADDRESS (MODE, X, WIN)

#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL)			{}

#define LEGITIMATE_CONSTANT_P(X) 1

#define REGISTER_MOVE_COST(MODE, FROM, TO) ((MODE)==QImode ? 4 :   \
					    (MODE)==HImode ? 4 :   \
					    (MODE)==SImode ? 8 :   \
					    (MODE)==SFmode ? 8 : 16)

#define MEMORY_MOVE_COST(MODE,CLASS,IN) ((MODE)==QImode ? 8 :	\
					 (MODE)==HImode ? 8 :	\
					 (MODE)==SImode ? 18:	\
					 (MODE)==SFmode ? 18: 32)
#define BRANCH_COSTS 0
#define SLOW_BYTE_ACCESS 0


#define TEXT_SECTION_ASM_OP "\t.text"
#define DATA_SECTION_ASM_OP "\t.data"
#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
#define EXTRA_SECTIONS in_bootloader, in_infomem

#undef CTORS_SECTION_ASM_OP
#define CTORS_SECTION_ASM_OP "\t.section .ctors,\"a\",@progbits"

#undef DTORS_SECTION_ASM_OP
#define DTORS_SECTION_ASM_OP "\t.section .dtors,\"a\",@progbits"

#define TARGET_ASM_CONSTRUCTOR msp430_asm_out_ctor

#define TARGET_ASM_DESTRUCTOR msp430_asm_out_dtor
  
#define EXTRA_SECTION_FUNCTIONS						      \
									      \
void									      \
bootloader_section (void)							\
{									      \
  if (in_section != in_bootloader)						\
    {									      \
      fprintf (asm_out_file,						      \
	       "\t.section .bootloader, \"ax\", @progbits\n");	      		\
      /* Should already be aligned, this is just to be safe if it isn't.  */  \
      fprintf (asm_out_file, "\t.p2align 1\n");				      \
      in_section = in_bootloader;						\
    }									      \
}										\
									      \
void									      \
infomem_section (void)							      \
{									      \
  if (in_section != in_infomem)						      \
    {									      \
      fprintf (asm_out_file,						      \
	       "\t.section .infomem, \"a\", @progbits\n");	      		\
      /* Should already be aligned, this is just to be safe if it isn't.  */  \
      fprintf (asm_out_file, "\t.p2align 1\n");				      \
      in_section = in_infomem;						      \
    }									      \
}

#define JUMP_TABLES_IN_TEXT_SECTION 0


#define ASM_COMMENT_START " ; "
#define ASM_APP_ON ";; APP\n"
#define ASM_APP_OFF ";; NOAPP\n"

#define ASM_OUTPUT_INT(FILE, VALUE)			\
 ( fprintf (FILE, "\t.long "),				\
   output_addr_const (FILE, (VALUE)),			\
   fputs ("\n", FILE))

#define ASM_OUTPUT_SHORT(FILE,VALUE) asm_output_short(FILE,VALUE)
#define ASM_OUTPUT_CHAR(FILE,VALUE) asm_output_char(FILE,VALUE)
#define ASM_OUTPUT_BYTE(FILE,VALUE) asm_output_byte (FILE,VALUE)
#define ASM_BYTE_OP "\t.byte "
#define ASM_OUTPUT_ASCII(FILE, P, SIZE)	 gas_output_ascii (FILE,P,SIZE)
#define IS_ASM_LOGICAL_LINE_SEPARATOR(C) ((C) == '\n')

#define ASM_OUTPUT_LABELREF(FILE,NAME) 			\
do{							\
	const char *p = NAME;					\
	while(*p == '_') p++;				\
	if(*p == 'r' || *p == 'R')			\
	{						\
	    int val;					\
	    char *endptr;				\
	    p++;					\
	    val = strtol (p, &endptr, 10);		\
	    if(val >= 0 && val <= 15 &&			\
	    	*endptr == 0 )				\
	    {						\
	    	asm_fprintf ((FILE), "_%U%s", (NAME));	\
	    }						\
	    else					\
	    	asm_fprintf ((FILE), "%U%s", (NAME));   \
	}						\
	else						\
		asm_fprintf ((FILE), "%U%s", (NAME));	\
} while(0)

#define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED)	\
do {							\
     const char *p = NAME;					\
     if(*p == '*' || *p == '@' ) p++;			\
     if(*p >= '0' && *p <= '9' ) break;			\
     fputs ("\t.comm ", (STREAM));			\
     assemble_name ((STREAM), (NAME));			\
     fprintf ((STREAM), ",%d%s", (SIZE), (SIZE)>1?",2\n":"\n");\
} while (0)

#define ASM_OUTPUT_LOCAL(STREAM, NAME, SIZE, ROUNDED)	\
do {							\
     const char *p = NAME;					\
     if(*p == '*' || *p == '@' ) p++;			\
     if(*p >= '0' && *p <= '9' ) break;			\
     fputs ("\t.local ", (STREAM));			\
     assemble_name ((STREAM), (NAME));			\
     fputs ("\n",(STREAM));				\
     fputs ("\t.comm ", (STREAM));                     	\
     assemble_name ((STREAM), (NAME));			\
     fprintf ((STREAM), ",%d%s", (SIZE),(SIZE)>1?",2\n":"\n");\
} while (0)

#define BSS_SECTION_ASM_OP	"\t.section\t.bss"

#define ASM_OUTPUT_BSS(FILE, DECL, NAME, SIZE, ROUNDED)                 \
do { \
  const char *p = (NAME); \
  if(*p == '*' || *p == '@' ) p++; \
  if(*p >= '0' && *p <= '9' ) break; \
  asm_output_bss ((FILE), (DECL), (NAME), (SIZE), (ROUNDED)); \
} while(0)
  


#define ASM_OUTPUT_LABEL(STREAM, NAME)		\
{						\
  assemble_name (STREAM, NAME);			\
  fprintf (STREAM, ":\n");			\
}

#undef TYPE_ASM_OP
#undef SIZE_ASM_OP
#undef WEAK_ASM_OP
#define TYPE_ASM_OP	"\t.type\t"
#define SIZE_ASM_OP	"\t.size\t"
#define WEAK_ASM_OP	"\t.weak\t"

#undef TYPE_OPERAND_FMT
#define TYPE_OPERAND_FMT	"@%s"

#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
asm_declare_function_name (FILE, NAME, DECL)

#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)			\
  do {									\
    if (!flag_inhibit_size_directive)					\
      {									\
        char label[256];						\
	static int labelno;						\
	labelno++;							\
	ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno);		\
	fprintf(FILE, ".%s%d:\n", "Lfe", labelno) ;		\
	fprintf (FILE, "%s", SIZE_ASM_OP);				\
	assemble_name (FILE, (FNAME));					\
        fprintf (FILE, ",");						\
	assemble_name (FILE, label);					\
        fprintf (FILE, "-");						\
	assemble_name (FILE, (FNAME));					\
	fprintf (FILE,"\n;; End of function \n\n");	\
      }									\
  } while (0)

#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)			  \
do {									  \
      fprintf (FILE, "%s", TYPE_ASM_OP);				  \
      assemble_name (FILE, NAME);					  \
      putc (',', FILE);							  \
      fprintf (FILE, TYPE_OPERAND_FMT, "object");			  \
      putc ('\n', FILE);						  \
      size_directive_output = 0;					  \
      if (!flag_inhibit_size_directive && DECL_SIZE (DECL))		  \
	{								  \
	  size_directive_output = 1;					  \
	  fprintf (FILE, "%s", SIZE_ASM_OP);				  \
	  assemble_name (FILE, NAME);					  \
	  fprintf (FILE, ",%ld\n",  int_size_in_bytes (TREE_TYPE (DECL))); \
    }									  \
  ASM_OUTPUT_LABEL(FILE, NAME);						  \
} while (0)

#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)	 \
do {									 \
     const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);		 \
     if (!flag_inhibit_size_directive && DECL_SIZE (DECL)		 \
         && ! AT_END && TOP_LEVEL					 \
	 && DECL_INITIAL (DECL) == error_mark_node			 \
	 && !size_directive_output)					 \
       {								 \
	 size_directive_output = 1;					 \
	 fprintf (FILE, "%s", SIZE_ASM_OP);				 \
	 assemble_name (FILE, name);					 \
	 fprintf (FILE, ",%d\n",  int_size_in_bytes (TREE_TYPE (DECL))); \
       }								 \
   } while (0)

#define ESCAPES \
"\1\1\1\1\1\1\1\1btn\1fr\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
\0\0\"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\\\0\0\0\
\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\
\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1"

#define STRING_LIMIT	((unsigned) 64)
#define STRING_ASM_OP	"\t.string\t"
#define GLOBAL_ASM_OP ".global\t"
     
#define ASM_WEAKEN_LABEL(FILE, NAME) 	\
  do					\
    {					\
      fputs ("\t.weak\t", (FILE));	\
      assemble_name ((FILE), (NAME)); 	\
      fputc ('\n', (FILE));		\
    }					\
  while (0)

#define SUPPORTS_WEAK 1

#define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM)	\
sprintf (STRING, "*.%s%d", PREFIX, NUM)

#define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO)	\
( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10),	\
  sprintf ((OUTPUT), "%s.%ld", (NAME), (LABELNO)))

#define HAS_INIT_SECTION 1

#define REGISTER_NAMES {				\
  "r0","r1","r2","r3","r4","r5","r6","r7",		\
  "r8","r9","r10","r11","r12","r13","r14","r15"		\
}

#define FINAL_PRESCAN_INSN(insn, operand, nop) final_prescan_insn (insn, operand,nop)

#define PRINT_OPERAND(STREAM, X, CODE) print_operand (STREAM, X, CODE)
#define PRINT_OPERAND_PUNCT_VALID_P(CODE) ((CODE) == '~')
#define PRINT_OPERAND_ADDRESS(STREAM, X) print_operand_address(STREAM, X)
#define USER_LABEL_PREFIX ""

#define ASM_OUTPUT_REG_PUSH(STREAM, REGNO)	\
{						\
  if (REGNO > 15)				\
    abort ();					\
  fprintf (STREAM, "\tpush\tr%d", REGNO);	\
}

#define ASM_OUTPUT_REG_POP(STREAM, REGNO)	\
{						\
  if (REGNO > 15)				\
    abort ();					\
  fprintf (STREAM, "\tpop\tr%d", REGNO);	\
}

#define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE)		\
  msp430_output_addr_vec_elt(STREAM, VALUE)

#define ASM_OUTPUT_SKIP(STREAM, N)		\
  fprintf (STREAM, "\t.skip %d,0\n", N)
#define ASM_OUTPUT_ALIGN(STREAM, POWER) \
  fprintf (STREAM, "\t.p2align %d,0\n", POWER)

#define CASE_VECTOR_MODE HImode

extern struct rtx_def *msp430_compare_op0, *msp430_compare_op1;
extern int msp430_case_values_threshold;
#define CASE_VALUES_THRESHOLD msp430_case_values_threshold

#undef WORD_REGISTER_OPERATIONS

#define MOVE_MAX 2

#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1

#define Pmode HImode
#define FUNCTION_MODE HImode
     
#define DOLLARS_IN_IDENTIFIERS 0

#define NO_DOLLAR_IN_LABEL 1

#define TRAMPOLINE_TEMPLATE(FILE) msp430_trampoline_template((FILE))

#define TRAMPOLINE_SIZE 8
#define TRAMPOLINE_ALIGNMENT 16


#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)	\
	msp430_initialize_trampoline (TRAMP, FNADDR, CXT)

#define NOTICE_UPDATE_CC(EXP, INSN) notice_update_cc(EXP, INSN)

#define CC_OVERFLOW_UNUSABLE 01000
/* The mov,and,or,xor insns don't set carry.  That's ok though as the
   Z bit is all we need when doing unsigned comparisons on the result of
   these insns (since they're always with 0).  However, conditions.h has
   CC_NO_OVERFLOW defined for this purpose.  Rename it to something more
   understandable.  */
#define CC_NO_CARRY CC_NO_OVERFLOW

#define FUNCTION_PROFILER(FILE, LABELNO)  \
  fprintf (FILE, "/* profiler %d */", (LABELNO))

#define ADJUST_INSN_LENGTH(INSN, LENGTH) (LENGTH =\
					  adjust_insn_length (INSN, LENGTH))

#define CPP_SPEC "\
  %{!mmcu*|mmcu=msp1:%(cpp_msp1)} \
  %{mmcu=msp2:%(cpp_msp2)} \
  %{mmcu=msp430x*:-D__MSP430_%* } \
  %{posix:-D_POSIX_SOURCE}"
  /*
  %{mmcu=msp430x110|mmcu=msp430x112|mmcu=msp430x1101|mmcu=msp430x1111|mmcu=msp430x1121|\
    mmcu=msp430x1122|mmcu=msp430x1132|mmcu=msp430x122|mmcu=msp430x123|mmcu=msp430x1222|\
    mmcu=msp430x1232|mmcu=msp430x133|mmcu=msp430x135|mmcu=msp430x1331|mmcu=msp430x1351|\
    mmcu=msp430x155|mmcu=msp430x156|mmcu=msp430x157|mmcu=msp430x311|mmcu=msp430x312|\
    mmcu=msp430x313|mmcu=msp430x314|mmcu=msp430x315|mmcu=msp430x323|mmcu=msp430x325|\
    mmcu=msp430x412|mmcu=msp430x413|mmcu=msp430x415|mmcu=msp430x417|mmcu=msp430xW423|\
    mmcu=msp430xW425|mmcu=msp430xW427|mmcu=msp430xG437|mmcu=msp430xG438|mmcu=msp430xG439|\
    mmcu=msp430x435|mmcu=msp430x436:%(cpp_msp1)} \
  %{mmcu=msp430xE423|mmcu=msp430xE425|mmcu=msp430xE427|mmcu=msp430x336|mmcu=msp430x337|\
    mmcu=msp430x167|mmcu=msp430x168|mmcu=msp430x169|mmcu=msp430x1610|mmcu=msp430x1611|\
    mmcu=msp430x1612|mmcu=msp430x147|mmcu=msp430x148|mmcu=msp430x149|mmcu=msp430x1471|\
    mmcu=msp430x1481|mmcu=msp430x1491|mmcu=msp430x437|mmcu=msp430x447|mmcu=msp430x448|\
    mmcu=msp430x449:%(cpp_msp2)} \
  */


#define CC1_SPEC "%{profile:-p}"

#define CC1PLUS_SPEC "%{!frtti:-fno-rtti} \
%{!fenforce-eh-specs:-fno-enforce-eh-specs} \
%{!fexceptions:-fno-exceptions}"

#define ASM_SPEC ""
#define ASM_FINAL_SPEC ""

/* This works with the older version of the linker */
/* #define LINK_SPEC "%{!mmcu*:-m msp430x110} %{mmcu=msp1:-m msp430x110} %{mmcu=msp2:-m msp430x336} %{mmcu=*:-m %*}" */

#define LINK_SPEC "\
  %{!mmcu*|mmcu=msp1|mmcu=msp430x1101|mmcu=msp430x110:-m msp430A --defsym __stack=0x0280 -Ttext=0xfc00 } \
  %{mmcu=msp430x1111|mmcu=msp430x311:-m msp430A --defsym __stack=0x0280 -Ttext=0xf800 } \
  %{mmcu=msp430x1121|mmcu=msp430x1122|mmcu=msp430x112|mmcu=msp430x1222|mmcu=msp430x122| \
    mmcu=msp430x1232|mmcu=msp430x123|mmcu=msp430x312|mmcu=msp430x412|mmcu=msp430xE423| \
    mmcu=msp430xW423:-m msp430A --defsym __stack=0x0300 -Ttext=0xf000 } \
  %{mmcu=msp430x1132|mmcu=msp430x1331|mmcu=msp430x133|mmcu=msp430x313| \
    mmcu=msp430x323|mmcu=msp430x413:-m msp430A --defsym __stack=0x0300 -Ttext=0xe000 } \
  %{mmcu=msp430x314:-m msp430A --defsym __stack=0x0400 -Ttext=0xd000 } \
  %{mmcu=msp430x1351|mmcu=msp430x135|mmcu=msp430x155|mmcu=msp430x315|mmcu=msp430x325| \
    mmcu=msp430x415|mmcu=msp430x435|mmcu=msp430xE425|mmcu=msp430xW425:-m msp430A --defsym __stack=0x0400 -Ttext=0xc000 } \
  %{mmcu=msp2|mmcu=msp430x156|mmcu=msp430x336|mmcu=msp430x436:-m msp430A --defsym __stack=0x0400 -Ttext=0xa000 } \
  %{mmcu=msp430x147|mmcu=msp430x157|mmcu=msp430x167|mmcu=msp430x337|mmcu=msp430x417| \
    mmcu=msp430x437|mmcu=msp430x447|mmcu=msp430xE427|mmcu=msp430xG437|mmcu=msp430xW427| \
    mmcu=msp430x1471:-m msp430A --defsym __stack=0x0600 -Ttext=0x8000 } \
  %{mmcu=msp430x1481|mmcu=msp430x148|mmcu=msp430x1491|mmcu=msp430x168|mmcu=msp430x448| \
    mmcu=msp430xG438:-m msp430A --defsym __stack=0x0a00 -Ttext=0x4000 } \
  %{mmcu=msp430x1610:-m msp430B --defsym __stack=0x2500 -Ttext=0x8000 -Tdata=0x1100 } \
  %{mmcu=msp430x1611:-m msp430B --defsym __stack=0x3900 -Ttext=0x4000 -Tdata=0x1100 } \
  %{mmcu=msp430x1612:-m msp430B --defsym __stack=0x2500 -Ttext=0x2500 -Tdata=0x1100 } \
  %{mmcu=msp430x149|mmcu=msp430x169|mmcu=msp430xG439|mmcu=msp430x449:-m msp430A --defsym __stack=0x0a00 -Ttext=0x1100 }"

/*
#define LINK_SPEC "\
  %{!mmcu*|mmcu=msp1|mmcu=msp430x1101|mmcu=msp430x110:-m msp430s1k128 } \
  %{mmcu=msp430x1111|mmcu=msp430x311:-m msp430s2k128 } \
  %{mmcu=msp430x1121|mmcu=msp430x1122|mmcu=msp430x112|mmcu=msp430x1222|mmcu=msp430x122| \
    mmcu=msp430x1232|mmcu=msp430x123|mmcu=msp430x312|mmcu=msp430x412|mmcu=msp430xE423| \
    mmcu=msp430xW423:-m msp430s4k256 } \
  %{mmcu=msp430x1132|mmcu=msp430x1331|mmcu=msp430x133|mmcu=msp430x313| \
    mmcu=msp430x323|mmcu=msp430x413:-m msp430s8k256 } \
  %{mmcu=msp430x314:-m msp430s12k512 } \
  %{mmcu=msp430x1351|mmcu=msp430x135|mmcu=msp430x155|mmcu=msp430x315|mmcu=msp430x325| \
    mmcu=msp430x415|mmcu=msp430x435|mmcu=msp430xE425|mmcu=msp430xW425:-m msp430s16k512 } \
  %{mmcu=msp2|mmcu=msp430x156|mmcu=msp430x336|mmcu=msp430x436:-m msp430s24k1024 } \
  %{mmcu=msp430x147|mmcu=msp430x157|mmcu=msp430x167|mmcu=msp430x337|mmcu=msp430x417| \
    mmcu=msp430x437|mmcu=msp430x447|mmcu=msp430xE427|mmcu=msp430xG437|mmcu=msp430xW427| \
    mmcu=msp430x1471:-m msp430s32k1024 } \
  %{mmcu=msp430x1610:-m msp430s32k5k } \
  %{mmcu=msp430x1611:-m msp430s48k10k } \
  %{mmcu=msp430x1481|mmcu=msp430x148|mmcu=msp430x1491|mmcu=msp430x168|mmcu=msp430x448| \
    mmcu=msp430xG438:-m msp430s48k2048 } \
  %{mmcu=msp430x1612:-m msp430s56k5k } \
  %{mmcu=msp430x149|mmcu=msp430x169|mmcu=msp430xG439|mmcu=msp430x449:-m msp430s60k2048 }"
*/
/*
#define LINK_SPEC "\
%{!mmcu*:-m msp430s1k128} \
  %{mmcu=msp1:-m msp430s1k128} \
  %{mmcu=msp2:-m msp430s8k256} \
  %{mmcu=msp430x110:-m msp430s1k128 } \
  %{mmcu=msp430x112:-m msp430s4k256 } \
  %{mmcu=msp430x1101:-m msp430s1k128 } \
  %{mmcu=msp430x1111:-m msp430s2k128 } \
  %{mmcu=msp430x1121:-m msp430s4k256 } \
  %{mmcu=msp430x1122:-m msp430s4k256 } \
  %{mmcu=msp430x1132:-m msp430s8k256 } \
  %{mmcu=msp430x122:-m msp430s4k256 } \
  %{mmcu=msp430x123:-m msp430s4k256 } \
  %{mmcu=msp430x1222:-m msp430s4k256 } \
  %{mmcu=msp430x1232:-m msp430s4k256 } \
  %{mmcu=msp430x133:-m msp430s8k256 } \
  %{mmcu=msp430x135:-m msp430s16k512 } \
  %{mmcu=msp430x1331:-m msp430s8k256 } \
  %{mmcu=msp430x1351:-m msp430s16k512 } \
  %{mmcu=msp430x147:-m msp430s32k1024 } \
  %{mmcu=msp430x148:-m msp430s48k2048 } \
  %{mmcu=msp430x149:-m msp430s60k2048 } \
  %{mmcu=msp430x1471:-m msp430s32k1024 } \
  %{mmcu=msp430x1481:-m msp430s48k2048 } \
  %{mmcu=msp430x1491:-m msp430s48k2048 } \
  %{mmcu=msp430x155:-m msp430s16k512 } \
  %{mmcu=msp430x156:-m msp430s24k1024 } \
  %{mmcu=msp430x157:-m msp430s32k1024 } \
  %{mmcu=msp430x167:-m msp430s32k1024 } \
  %{mmcu=msp430x168:-m msp430s48k2048 } \
  %{mmcu=msp430x169:-m msp430s60k2048 } \
  %{mmcu=msp430x1610:-m msp430s32k5k } \
  %{mmcu=msp430x1611:-m msp430s48k10k } \
  %{mmcu=msp430x1612:-m msp430s56k5k } \
  %{mmcu=msp430x311:-m msp430s2k128 } \
  %{mmcu=msp430x312:-m msp430s4k256 } \
  %{mmcu=msp430x313:-m msp430s8k256 } \
  %{mmcu=msp430x314:-m msp430s12k512 } \
  %{mmcu=msp430x315:-m msp430s16k512 } \
  %{mmcu=msp430x323:-m msp430s8k256 } \
  %{mmcu=msp430x325:-m msp430s16k512 } \
  %{mmcu=msp430x336:-m msp430s24k1024 } \
  %{mmcu=msp430x337:-m msp430s32k1024 } \
  %{mmcu=msp430x412:-m msp430s4k256 } \
  %{mmcu=msp430x413:-m msp430s8k256 } \
  %{mmcu=msp430x415:-m msp430s16k512 } \
  %{mmcu=msp430x417:-m msp430s32k1024 } \
  %{mmcu=msp430xE423:-m msp430s4k256 } \
  %{mmcu=msp430xE425:-m msp430s16k512 } \
  %{mmcu=msp430xE427:-m msp430s32k1024 } \
  %{mmcu=msp430xW423:-m msp430s4k256 } \
  %{mmcu=msp430xW425:-m msp430s16k512 } \
  %{mmcu=msp430xW427:-m msp430s32k1024 } \
  %{mmcu=msp430xG437:-m msp430s32k1024 } \
  %{mmcu=msp430xG438:-m msp430s48k2048 } \
  %{mmcu=msp430xG439:-m msp430s60k2048 } \
  %{mmcu=msp430x435:-m msp430s16k512 } \
  %{mmcu=msp430x436:-m msp430s24k1024 } \
  %{mmcu=msp430x437:-m msp430s32k1024 } \
  %{mmcu=msp430x447:-m msp430s32k1024 } \
  %{mmcu=msp430x448:-m msp430s48k2048 } \
  %{mmcu=msp430x449:-m msp430s60k2048 }"
*/


#define LIB_SPEC "-lc"
#define LIBGCC_SPEC "-lgcc"
#define LIBSTDCXX "-lgcc"

#define STARTFILE_SPEC "%(crt_binutils)"
#define ENDFILE_SPEC ""

#define CRT_BINUTILS_SPECS "gcrt0.o%s"


#define EXTRA_SPECS                           	\
{"crt_binutils", CRT_BINUTILS_SPECS},

#define MULTILIB_DEFAULTS { "mmcu=msp430x110" }
#define LINKER_NAME "msp430-ld"

#define TEST_HARD_REG_CLASS(CLASS, REGNO) \
  TEST_HARD_REG_BIT (reg_class_contents[ (int) (CLASS)], REGNO)

#define TARGET_FLOAT_FORMAT IEEE_FLOAT_FORMAT

#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
#define DWARF2_DEBUGGING_INFO
#define OBJECT_FORMAT_ELF

#endif


--- NEW FILE: msp430.md ---
;;   Machine description for GNU compiler,
;;   for Texas Instruments msp430 MCUs
;;   Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
;;   Contributed by Dmitry Diky <[email protected]>

;; This file is part of GCC.

;; GCC is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; GCC is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GCC; see the file COPYING.  If not, write to
[...3793 lines suppressed...]
	swpb	%2"
[(set_attr "length" "3")
   (set_attr "cc" "clobber")])

(define_peephole2
  [(set (match_operand:HI 0 "register_operand" "") 
	(ior:HI (match_dup 0) 
		(match_operand:HI 1 "register_operand" "")))
   (set (match_operand:SI 2 "register_operand" "") 
	(match_operand:SI 3 "register_operand" ""))]
"(REGNO(operands[0]) == REGNO(operands[2])
  && REGNO(operands[3])+1 == REGNO(operands[0]))"
  [(set (match_dup 1) 
	(ior:HI (match_dup 1) 
		(match_dup 0)))
   (set (subreg:HI (match_dup 2) 0)
	(subreg:HI (match_dup 3) 0))]
"")



--- NEW FILE: msp430.opt ---
; Options for the MSP430 port of the compiler.

; Copyright (C) 2006 Free Software Foundation, Inc.
;
; This file is part of GCC.
;
; GCC is free software; you can redistribute it and/or modify it under
; the terms of the GNU General Public License as published by the Free
; Software Foundation; either version 2, or (at your option) any later
; version.
;
; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
; WARRANTY; without even the implied warranty of MERCHANTABILITY or
; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
; for more details.
;
; You should have received a copy of the GNU General Public License
; along with GCC; see the file COPYING.  If not, write to the Free
; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
; 02110-1301, USA.

mstrict-align
Target Report Mask(STRICT_ALIGN)
Force data to be aligned at the word boundary

mdisable-hwmul
Target Report Mask(NO_HWMUL)
Disable hardware multiplier

mhwmul
Target Report Mask(HWMUL)
Hardware multiplier

mforce-hwmul
Target Report Mask(FORCE_HWMUL)
Force hardware multiplier

mnoint-hwmul
Target Report Mask(NOINT_HWMUL)
Assume deeper interrupt routines does not do hardware multiply

mdeb
Target Report Undocumented Mask(ALL_DEBUG)

;mno-stack-init
mnsi
Target Report Mask(NSI)
No stack init in main()

;mnvwa
mno-volatile-workaround
Target Report Mask(NVWA)
Do not perform volatile workaround for bitwise operations

minline-hwmul
Target Report Mask(INLINE_HWMUL)
Issue inline multiplication code for 32-bit integers

msave-prologue
Target Report Mask(SAVE_PROLOGUE)
Use subroutine call for function prologue/epilogue when possible

mcall-prologues
Target Report Mask(CALL_PROLOGUES)
Use subroutines for function prologues and epilogues

mmcu=
Target RejectNegative Joined Var(msp430_mcu_name) Init("msp430x169")
-mmcu=MCU	Select the target MCU

mendup-at=
Target RejectNegative Joined Var(msp430_endup) Init("__stop_progExec__")
-mendup-at=ENDUP	Jump to specified routine at the end of main()

minit-stack=
Target RejectNegative Joined Var(msp430_init_stack) Init("__stack")
-minit-stack=STACK	Use STACK as the initial value of the stack pointer

mint8
Target Report Mask(INT8)
Use an 8-bit 'int' type

mno-interrupts
Target Report RejectNegative Mask(NO_INTERRUPTS)
Change the stack pointer without disabling interrupts

mno-tablejump
Target Report RejectNegative Mask(NO_TABLEJUMP)
Do not generate tablejump insns

morder1
Target Report Undocumented Mask(ORDER_1)

morder2
Target Report Undocumented Mask(ORDER_2)

mshort-calls
Target Report Mask(SHORT_CALLS)
Use rjmp/rcall (limited range) on >8K devices

msize
Target Report Mask(INSN_SIZE_DUMP)
Output instruction sizes to the asm file

mtiny-stack
Target Report Mask(TINY_STACK)
Change only the low 8 bits of the stack pointer

--- NEW FILE: predicates.md ---
;; Predicate definitions for MSP430
;; Copyright (C) 2006 Free Software Foundation, Inc.

;; This file is part of GCC.

;; GCC is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published
;; by the Free Software Foundation; either version 2, or (at your
;; option) any later version.

;; GCC is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
;; License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GCC; see the file COPYING.  If not, write to
;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

(define_special_predicate "equality_operator"
  (match_code "eq,ne")
{
  return ((mode == VOIDmode || GET_MODE (op) == mode) && (GET_CODE (op) == EQ || GET_CODE (op) == NE));
})

(define_special_predicate "inequality_operator"
  (match_code "ge,gt,le,lt,geu,gtu,leu,ltu")
{
  return comparison_operator (op, mode) && !equality_operator (op, mode);
})

(define_predicate "nonimmediate_operand_msp430"
  (match_code "reg,subreg,mem")
{
  int save_volatile_ok = volatile_ok;
  int niop = 0;

  if (!TARGET_NVWA)
    volatile_ok = 1;
  niop = nonimmediate_operand (op, mode);
  volatile_ok = save_volatile_ok;

  return niop;
})

(define_predicate "memory_operand_msp430"
  (match_code "subreg,mem")
{
  int save_volatile_ok = volatile_ok;
  int mop = 0;

  if (!TARGET_NVWA)
    volatile_ok = 1;
  mop = memory_operand (op, mode);
  volatile_ok = save_volatile_ok;
  return mop;
})

(define_predicate "general_operand_msp430"
  (match_code "const_int,const_double,const,symbol_ref,label_ref,subreg,reg,mem")
{
  int save_volatile_ok = volatile_ok;
  int gop = 0;

  if (!TARGET_NVWA)
    volatile_ok = 1;
  gop = general_operand (op, mode);
  volatile_ok = save_volatile_ok;
  return gop;
})

(define_predicate "three_operands_msp430"
  (match_code "plus,minus,and,ior,xor")
{
  enum rtx_code code = GET_CODE (op);
  if (GET_MODE (op) != mode)
    return 0;

  return (code == PLUS || code == MINUS || code == AND || code == IOR || code == XOR);
})


--- NEW FILE: t-msp430 ---
# Specific names for MSP430 tools
AR_FOR_TARGET = msp430-ar
RANLIB_FOR_TARGET = msp430-ranlib
NM_FOR_TARGET = msp430-nm

#CROSS_LIBGCC1 = libgcc1-asm.a
LIB1ASMSRC = msp430/libgcc.S
LIB1ASMFUNCS = _cmpdi2 \
	_cmpsf2 \
	__stop_progExec__ \
	_mulqi3 \
	_mulhi3 \
	_mulsi3 \
	_mulsi3hw \
	_umulqihi3 \
	_umulhisi3 \
	_mulqihi3 \
	_mulhisi3 \
	_udivmodqi4 \
	_divmodqi4 \
	_udivmodhi4 \
	_divmodhi4 \
	_udivmodsi4 \
	_divmodsi4 \
	_reset_vector__ \
	__prologue_saver \
	__epilogue_restorer \
	__epilogue_restorer_intr \
	_udivmoddi3_parts \
	_udivdi3 \
	_umoddi3 \
	_divdi3 \
	_moddi3 \
	_muldi3	\
	_ctors \
	_dtors
	

# libgcc...
LIBGCC1_TEST =

# We do not have the DF type.
# Most of the C functions in libgcc2 use almost all registers,
TARGET_LIBGCC2_CFLAGS = -DDF=SF -Dinhibit_libc -g

fp-bit.c: $(srcdir)/config/fp-bit.c $(srcdir)/config/msp430/t-msp430
	echo '#define FLOAT' > fp-bit.c
	echo '#define FLOAT_ONLY' >> fp-bit.c
	echo '#define CMPtype HItype' >> fp-bit.c
	echo '#define DF SF' >> fp-bit.c
	echo '#define DI SI' >> fp-bit.c
	echo '#define FLOAT_BIT_ORDER_MISMATCH' >> fp-bit.c
	echo '#define SMALL_MACHINE' >> fp-bit.c
	cat $(srcdir)/config/fp-bit.c >> fp-bit.c

FPBIT = fp-bit.c

MULTILIB_OPTIONS = mmcu=msp1/mmcu=msp2
MULTILIB_DIRNAMES = msp1 msp2

MULTILIB_MATCHES = \
	mmcu?msp1=mmcu?msp430x110  mmcu?msp1=mmcu?msp430x112 \
	mmcu?msp1=mmcu?msp430x1101 mmcu?msp1=mmcu?msp430x1111 mmcu?msp1=mmcu?msp430x1121 \
	mmcu?msp1=mmcu?msp430x1122 mmcu?msp1=mmcu?msp430x1132 \
	mmcu?msp1=mmcu?msp430x122  mmcu?msp1=mmcu?msp430x123 \
	mmcu?msp1=mmcu?msp430x1222 mmcu?msp1=mmcu?msp430x1232 \
	mmcu?msp1=mmcu?msp430x133  mmcu?msp1=mmcu?msp430x135 \
	mmcu?msp1=mmcu?msp430x1331 mmcu?msp1=mmcu?msp430x1351 \
	mmcu?msp2=mmcu?msp430x147  mmcu?msp2=mmcu?msp430x148  mmcu?msp2=mmcu?msp430x149 \
	mmcu?msp2=mmcu?msp430x1471 mmcu?msp2=mmcu?msp430x1481 mmcu?msp2=mmcu?msp430x1491 \
	mmcu?msp1=mmcu?msp430x155  mmcu?msp1=mmcu?msp430x156  mmcu?msp1=mmcu?msp430x157 \
	mmcu?msp2=mmcu?msp430x167  mmcu?msp2=mmcu?msp430x168  mmcu?msp2=mmcu?msp430x169 \
	mmcu?msp2=mmcu?msp430x1610 mmcu?msp2=mmcu?msp430x1611 mmcu?msp2=mmcu?msp430x1612 \
	mmcu?msp1=mmcu?msp430x2101 mmcu?msp1=mmcu?msp430x2111 mmcu?msp1=mmcu?msp430x2121 \
	mmcu?msp1=mmcu?msp430x2131 \
	mmcu?msp1=mmcu?msp430x311  mmcu?msp1=mmcu?msp430x312  mmcu?msp1=mmcu?msp430x313 \
	mmcu?msp1=mmcu?msp430x314  mmcu?msp1=mmcu?msp430x315 \
	mmcu?msp1=mmcu?msp430x323  mmcu?msp1=mmcu?msp430x325 \
	mmcu?msp2=mmcu?msp430x336  mmcu?msp2=mmcu?msp430x337 \
	mmcu?msp1=mmcu?msp430x412  mmcu?msp1=mmcu?msp430x413 \
	mmcu?msp1=mmcu?msp430x415  mmcu?msp1=mmcu?msp430x417 \
	mmcu?msp2=mmcu?msp430x423  mmcu?msp2=mmcu?msp430x425  mmcu?msp2=mmcu?msp430x427 \
	mmcu?msp1=mmcu?msp430x4250 mmcu?msp1=mmcu?msp430x4260 mmcu?msp1=mmcu?msp430x4270 \
	mmcu?msp2=mmcu?msp430xE423 mmcu?msp2=mmcu?msp430xE425 mmcu?msp2=mmcu?msp430xE427 \
	mmcu?msp1=mmcu?msp430xW423 mmcu?msp1=mmcu?msp430xW425 mmcu?msp1=mmcu?msp430xW427 \
	mmcu?msp1=mmcu?msp430xG437 mmcu?msp1=mmcu?msp430xG438 mmcu?msp1=mmcu?msp430xG439 \
	mmcu?msp1=mmcu?msp430x435  mmcu?msp1=mmcu?msp430x436  mmcu?msp1=mmcu?msp430x437 \
	mmcu?msp2=mmcu?msp430x447  mmcu?msp2=mmcu?msp430x448  mmcu?msp2=mmcu?msp430x449

MULTILIB_EXCEPTIONS =

LIBGCC = stmp-multilib
INSTALL_LIBGCC = install-multilib

STMP_FIXINC = 


--- NEW FILE: xm-msp430.h ---
#include "tm.h"