home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 6 / FreshFish_September1994.bin / bbs / gnu / gcc-2.6.0-src.lha / GNU / src / amiga / gcc-2.6.0 / config / arm / arm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-13  |  64.0 KB  |  1,731 lines

  1. /* Definitions of target machine for GNU compiler, for Acorn RISC Machine.
  2.    Copyright (C) 1991, 1993, 1994 Free Software Foundation, Inc.
  3.    Contributed by Pieter `Tiggr' Schoenmakers (rcpieter@win.tue.nl)
  4.               and Martin Simmons (@harleqn.co.uk).
  5.    More major hacks by Richard Earnshaw (rwe11@cl.cam.ac.uk)
  6.    
  7. This file is part of GNU CC.
  8.  
  9. GNU CC is free software; you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation; either version 2, or (at your option)
  12. any later version.
  13.  
  14. GNU CC is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. GNU General Public License for more details.
  18.  
  19. You should have received a copy of the GNU General Public License
  20. along with GNU CC; see the file COPYING.  If not, write to
  21. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  22.  
  23. /* Sometimes the directive `riscos' is checked.  This does not imply that this
  24.    tm file can be used unchanged to build a GCC for RISC OS.
  25.    (Since in fact, it can't.)  */
  26.  
  27. extern void output_func_prologue ();
  28. extern void output_func_epilogue ();
  29. extern char *output_add_immediate ();
  30. extern char *output_call ();
  31. extern char *output_call_mem ();
  32. extern char *output_move_double ();
  33. extern char *output_mov_double_fpu_from_arm ();
  34. extern char *output_mov_double_arm_from_fpu ();
  35. extern char *output_mov_long_double_fpu_from_arm ();
  36. extern char *output_mov_long_double_arm_from_fpu ();
  37. extern char *output_mov_long_double_arm_from_arm ();
  38. extern char *output_mov_immediate ();
  39. extern char *output_multi_immediate ();
  40. extern char *output_return_instruction ();
  41. extern char *output_load_symbol ();
  42. extern char *fp_immediate_constant ();
  43. extern struct rtx_def *gen_compare_reg ();
  44. extern struct rtx_def *arm_gen_store_multiple ();
  45. extern struct rtx_def *arm_gen_load_multiple ();
  46.  
  47. extern char *arm_condition_codes[];
  48.  
  49. /* This is needed by the tail-calling peepholes */
  50. extern int frame_pointer_needed;
  51.  
  52.  
  53. #ifndef CPP_PREDEFINES
  54. #define CPP_PREDEFINES  "-Darm -Acpu(arm) -Amachine(arm)"
  55. #endif
  56.  
  57. #ifndef CPP_SPEC
  58. #define CPP_SPEC "%{m6:-D__arm6__}"
  59. #endif
  60.  
  61. /* Run-time Target Specification.  */
  62. #ifndef TARGET_VERSION
  63. #define TARGET_VERSION  \
  64.   fputs (" (ARM/generic)", stderr);
  65. #endif
  66.  
  67. /* Run-time compilation parameters selecting different hardware subsets.
  68.    On the ARM, misuse it in a different way.  */
  69. extern int target_flags;
  70.  
  71. /* Nonzero if the function prologue (and epilogue) should obey
  72.    the ARM Procedure Call Standard.  */
  73. #define TARGET_APCS    (target_flags & 1)
  74.  
  75. /* Nonzero if the function prologue should output the function name to enable
  76.    the post mortem debugger to print a backtrace (very useful on RISCOS,
  77.    unused on RISCiX).  Specifying this flag also enables -mapcs.
  78.    XXX Must still be implemented in the prologue.  */
  79. #define TARGET_POKE_FUNCTION_NAME    (target_flags & 2)
  80.  
  81. /* Nonzero if floating point instructions are emulated by the FPE, in which
  82.    case instruction scheduling becomes very uninteresting.  */
  83. #define TARGET_FPE    (target_flags & 4)
  84.  
  85. /* Nonzero if destined for an ARM6xx.  Takes out bits that assume restoration
  86.    of condition flags when returning from a branch & link (ie. a function) */
  87. #define TARGET_6        (target_flags & 8)
  88.  
  89. /* ARM_EXTRA_TARGET_SWITCHES is used in riscix.h to define some options which
  90.    are passed to the preprocessor and the assembler post-processor.  They
  91.    aren't needed in the main pass of the compiler, but if we don't define
  92.    them in target switches cc1 complains about them.  For the sake of
  93.    argument lets allocate bit 31 of target flags for such options. */
  94.  
  95. #ifndef ARM_EXTRA_TARGET_SWITCHES
  96. #define ARM_EXTRA_TARGET_SWITCHES
  97. #endif
  98.  
  99. #define TARGET_SWITCHES  \
  100. {                                     \
  101.   {"apcs",         1},            \
  102.   {"poke-function-name", 2},            \
  103.   {"fpe",         4},            \
  104.   {"6",             8},            \
  105.   {"2",            -8},            \
  106.   {"3",            -8},            \
  107.   ARM_EXTRA_TARGET_SWITCHES            \
  108.   {"",            TARGET_DEFAULT }    \
  109. }
  110.  
  111. /* Which processor we are running on.  Currently this is only used to
  112.    get the condition code clobbering attribute right when we are running on
  113.    an arm 6 */
  114.  
  115. enum processor_type 
  116. {
  117.   PROCESSOR_ARM2,
  118.   PROCESSOR_ARM3,
  119.   PROCESSOR_ARM6
  120. };
  121.  
  122. /* Recast the cpu class to be the cpu attribute. */
  123.  
  124. /* Recast the cpu class to be the cpu attribute.  */
  125. #define arm_cpu_attr ((enum attr_cpu)arm_cpu)
  126.  
  127. extern enum processor_type arm_cpu;
  128.  
  129. /* What sort of floating point unit do we have? Hardware or software.  */
  130. enum floating_point_type
  131. {
  132.   FP_HARD,
  133.   FP_SOFT
  134. };
  135.  
  136. /* Recast the floating point class to be the floating point attribute.  */
  137. #define arm_fpu_attr ((enum attr_fpu) arm_fpu)
  138.  
  139. extern enum floating_point_type arm_fpu;
  140.  
  141. #define TARGET_DEFAULT  0
  142.  
  143. #define TARGET_MEM_FUNCTIONS 1
  144.  
  145. /* OVERRIDE_OPTIONS takes care of the following:
  146.    - if -mpoke-function-name, then -mapcs.
  147.    - if doing debugging, then -mapcs; if RISCOS, then -mpoke-function-name.
  148.    - if floating point is done by emulation, forget about instruction
  149.      scheduling.  Note that this only saves compilation time; it doesn't
  150.      matter for the final code.  */
  151.  
  152. #define OVERRIDE_OPTIONS  \
  153. {                                \
  154.   if (write_symbols != NO_DEBUG && flag_omit_frame_pointer)    \
  155.     warning ("-g without a frame pointer may not give sensible debugging");\
  156.   if (TARGET_POKE_FUNCTION_NAME)                \
  157.     target_flags |= 1;                        \
  158.   if (TARGET_FPE)                        \
  159.     flag_schedule_insns = flag_schedule_insns_after_reload = 0;    \
  160.   arm_cpu = TARGET_6 ? PROCESSOR_ARM6: PROCESSOR_ARM2;        \
  161. }
  162.  
  163. /* Target machine storage Layout.  */
  164.  
  165.  
  166. /* Define this macro if it is advisable to hold scalars in registers
  167.    in a wider mode than that declared by the program.  In such cases,
  168.    the value is constrained to be within the bounds of the declared
  169.    type, but kept valid in the wider mode.  The signedness of the
  170.    extension may differ from that of the type.  */
  171.  
  172. /* It is far faster to zero extend chars than to sign extend them */
  173.  
  174. #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE)  \
  175.   if (GET_MODE_CLASS (MODE) == MODE_INT \
  176.       && GET_MODE_SIZE (MODE) < 4)      \
  177.     {                    \
  178.       if (MODE == QImode)        \
  179.     UNSIGNEDP = 1;            \
  180.       else if (MODE == HImode)        \
  181.     UNSIGNEDP = 0;            \
  182.       (MODE) = SImode;            \
  183.     }
  184.  
  185. /* Define for XFmode extended real floating point support.
  186.    This will automatically cause REAL_ARITHMETIC to be defined.  */
  187. /* For the ARM:
  188.    I think I have added all the code to make this work.  Unfortunately,
  189.    early releases of the floating point emulation code on RISCiX used a
  190.    different format for extended precision numbers.  On my RISCiX box there
  191.    is a bug somewhere which causes the machine to lock up when running enquire
  192.    with long doubles.  There is the additional aspect that Norcroft C
  193.    treats long doubles as doubles and we ought to remain compatible.
  194.    Perhaps someone with an FPA coprocessor and not running RISCiX would like
  195.    to try this someday. */
  196. /* #define LONG_DOUBLE_TYPE_SIZE 96 */
  197.  
  198. /* Disable XFmode patterns in md file */
  199. #define ENABLE_XF_PATTERNS 0
  200.  
  201. /* Define if you don't want extended real, but do want to use the
  202.    software floating point emulator for REAL_ARITHMETIC and
  203.    decimal <-> binary conversion. */
  204. /* See comment above */
  205. #define REAL_ARITHMETIC
  206.  
  207. /* Define this if most significant bit is lowest numbered
  208.    in instructions that operate on numbered bit-fields.  */
  209. #define BITS_BIG_ENDIAN  0
  210.  
  211. /* Define this if most significant byte of a word is the lowest numbered.  
  212.    Most ARM processors are run in little endian mode, but it should now be
  213.    possible to build the compiler to support big endian code. (Note: This
  214.    is currently a compiler-build-time option, not a run-time one.  */
  215. #ifndef BYTES_BIG_ENDIAN
  216. #define BYTES_BIG_ENDIAN  0
  217. #endif
  218.  
  219. /* Define this if most significant word of a multiword number is the lowest
  220.    numbered.  */
  221. #define WORDS_BIG_ENDIAN  0
  222.  
  223. /* Define this if most significant word of doubles is the lowest numbered */
  224. #define FLOAT_WORDS_BIG_ENDIAN 1
  225.  
  226. /* Number of bits in an addressable storage unit */
  227. #define BITS_PER_UNIT  8
  228.  
  229. #define BITS_PER_WORD  32
  230.  
  231. #define UNITS_PER_WORD    4
  232.  
  233. #define POINTER_SIZE  32
  234.  
  235. #define PARM_BOUNDARY      32
  236.  
  237. #define STACK_BOUNDARY  32
  238.  
  239. #define FUNCTION_BOUNDARY  32
  240.  
  241. #define EMPTY_FIELD_BOUNDARY  32
  242.  
  243. #define BIGGEST_ALIGNMENT  32
  244.  
  245. /* Make strings word-aligned so strcpy from constants will be faster.  */
  246. #define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
  247.   (TREE_CODE (EXP) == STRING_CST        \
  248.    && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
  249.  
  250. /* Every structures size must be a multiple of 32 bits.  */
  251. #define STRUCTURE_SIZE_BOUNDARY 32
  252.  
  253. /* Non-zero if move instructions will actually fail to work
  254.    when given unaligned data.  */
  255. #define STRICT_ALIGNMENT 1
  256.  
  257. #define TARGET_FLOAT_FORMAT IEEE_FLOAT_FORMAT
  258.  
  259. /* Define number of bits in most basic integer type.
  260.    (If undefined, default is BITS_PER_WORD).  */
  261. /* #define INT_TYPE_SIZE */
  262.  
  263. /* Standard register usage.  */
  264.  
  265. /* Register allocation in ARM Procedure Call Standard (as used on RISCiX):
  266.    (S - saved over call).
  267.  
  268.     r0       *    argument word/integer result
  269.     r1-r3        argument word
  270.  
  271.     r4-r8         S    register variable
  272.     r9         S    (rfp) register variable (real frame pointer)
  273.  
  274.     r10         F S    (sl) stack limit (not currently used)
  275.     r11        F S    (fp) argument pointer
  276.     r12        (ip) temp workspace
  277.     r13         F S    (sp) lower end of current stack frame
  278.     r14        (lr) link address/workspace
  279.     r15       F    (pc) program counter
  280.  
  281.     f0        floating point result
  282.     f1-f3        floating point scratch
  283.  
  284.     f4-f7         S    floating point variable
  285.  
  286.     cc        This is NOT a real register, but is used internally
  287.                     to represent things that use or set the condition
  288.             codes.
  289.     sfp             This isn't either.  It is used during rtl generation
  290.                     since the offset between the frame pointer and the
  291.             auto's isn't known until after register allocation.
  292.     afp        Nor this, we only need this because of non-local
  293.                     goto.  Without it fp appears to be used and the
  294.             elimination code won't get rid of sfp.  It tracks
  295.             fp exactly at all times.
  296.  
  297.    *: See CONDITIONAL_REGISTER_USAGE  */
  298.  
  299. /* The stack backtrace structure is as follows:
  300.   fp points to here:  |  save code pointer  |      [fp]
  301.                       |  return link value  |      [fp, #-4]
  302.                       |  return sp value    |      [fp, #-8]
  303.                       |  return fp value    |      [fp, #-12]
  304.                      [|  saved r10 value    |]
  305.                      [|  saved r9 value     |]
  306.                      [|  saved r8 value     |]
  307.                      [|  saved r7 value     |]
  308.                      [|  saved r6 value     |]
  309.                      [|  saved r5 value     |]
  310.                      [|  saved r4 value     |]
  311.                      [|  saved r3 value     |]
  312.                      [|  saved r2 value     |]
  313.                      [|  saved r1 value     |]
  314.                      [|  saved r0 value     |]
  315.                      [|  saved f7 value     |]     three words
  316.                      [|  saved f6 value     |]     three words
  317.                      [|  saved f5 value     |]     three words
  318.                      [|  saved f4 value     |]     three words
  319.   r0-r3 are not normally saved in a C function.  */
  320.  
  321. /* The number of hard registers is 16 ARM + 8 FPU + 1 CC + 1 SFP.  */
  322. #define FIRST_PSEUDO_REGISTER  27
  323.  
  324. /* 1 for registers that have pervasive standard uses
  325.    and are not available for the register allocator.  */
  326. #define FIXED_REGISTERS  \
  327. {                        \
  328.   0,0,0,0,0,0,0,0,     \
  329.   0,0,1,1,0,1,0,1,     \
  330.   0,0,0,0,0,0,0,0,     \
  331.   1,1,1             \
  332. }
  333.  
  334. /* 1 for registers not available across function calls.
  335.    These must include the FIXED_REGISTERS and also any
  336.    registers that can be used without being saved.
  337.    The latter must include the registers where values are returned
  338.    and the register where structure-value addresses are passed.
  339.    Aside from that, you can include as many other registers as you like.
  340.    The CC is not preserved over function calls on the ARM 6, so it is 
  341.    easier to assume this for all.  SFP is preserved, since FP is. */
  342. #define CALL_USED_REGISTERS  \
  343. {                            \
  344.   1,1,1,1,0,0,0,0,         \
  345.   0,0,1,1,1,1,1,1,         \
  346.   1,1,1,1,0,0,0,0,         \
  347.   1,1,1                 \
  348. }
  349.  
  350. /* If doing stupid life analysis, avoid a bug causing a return value r0 to be
  351.    trampled.  This effectively reduces the number of available registers by 1.
  352.    XXX It is a hack, I know.
  353.    XXX Is this still needed?  */
  354. #define CONDITIONAL_REGISTER_USAGE  \
  355. {            \
  356.   if (obey_regdecls)    \
  357.     fixed_regs[0] = 1;    \
  358. }
  359.  
  360. /* Return number of consecutive hard regs needed starting at reg REGNO
  361.    to hold something of mode MODE.
  362.    This is ordinarily the length in words of a value of mode MODE
  363.    but can be less for certain modes in special long registers.
  364.  
  365.    On the ARM regs are UNITS_PER_WORD bits wide; FPU regs can hold any FP
  366.    mode.  */
  367. #define HARD_REGNO_NREGS(REGNO, MODE)                      \
  368.     (((REGNO) >= 16 && REGNO != FRAME_POINTER_REGNUM            \
  369.       && (REGNO) != ARG_POINTER_REGNUM) ? 1                \
  370.      : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
  371.  
  372. /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
  373.    This is TRUE for ARM regs since they can hold anything, and TRUE for FPU
  374.    regs holding FP.  */
  375. #define HARD_REGNO_MODE_OK(REGNO, MODE)              \
  376.   ((GET_MODE_CLASS (MODE) == MODE_CC) ? (REGNO == CC_REGNUM) :    \
  377.   ((REGNO) < 16 || REGNO == FRAME_POINTER_REGNUM        \
  378.    || REGNO == ARG_POINTER_REGNUM                \
  379.    || GET_MODE_CLASS (MODE) == MODE_FLOAT))
  380.  
  381. /* Value is 1 if it is a good idea to tie two pseudo registers
  382.    when one has mode MODE1 and one has mode MODE2.
  383.    If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
  384.    for any hard reg, then this must be 0 for correct output.  */
  385. #define MODES_TIEABLE_P(MODE1, MODE2)  \
  386.   (GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2))
  387.  
  388. /* Specify the registers used for certain standard purposes.
  389.    The values of these macros are register numbers.  */
  390.  
  391. /* Define this if the program counter is overloaded on a register.  */
  392. #define PC_REGNUM        15
  393.  
  394. /* Register to use for pushing function arguments.  */
  395. #define STACK_POINTER_REGNUM    13
  396.  
  397. /* Base register for access to local variables of the function.  */
  398. #define FRAME_POINTER_REGNUM    25
  399.  
  400. /* Define this to be where the real frame pointer is if it is not possible to
  401.    work out the offset between the frame pointer and the automatic variables
  402.    until after register allocation has taken place.  FRAME_POINTER_REGNUM
  403.    should point to a special register that we will make sure is eliminated. */
  404. #define HARD_FRAME_POINTER_REGNUM 11
  405.  
  406. /* Value should be nonzero if functions must have frame pointers.
  407.    Zero means the frame pointer need not be set up (and parms may be accessed
  408.    via the stack pointer) in functions that seem suitable.  
  409.    If we have to have a frame pointer we might as well make use of it.
  410.    APCS says that the frame pointer does not need to be pushed in leaf
  411.    functions.  */
  412. #define FRAME_POINTER_REQUIRED        \
  413.   (current_function_has_nonlocal_label || (TARGET_APCS && !leaf_function_p ()))
  414.  
  415. /* Base register for access to arguments of the function.  */
  416. #define ARG_POINTER_REGNUM    26
  417.  
  418. /* The native (Norcroft) Pascal compiler for the ARM passes the static chain
  419.    as an invisible last argument (possible since varargs don't exist in
  420.    Pascal), so the following is not true.  */
  421. #define STATIC_CHAIN_REGNUM    8
  422.  
  423. /* Register in which address to store a structure value
  424.    is passed to a function.  */
  425. #define STRUCT_VALUE_REGNUM    0
  426.  
  427. /* Internal, so that we don't need to refer to a raw number */
  428. #define CC_REGNUM        24
  429.  
  430. /* The order in which register should be allocated.  It is good to use ip
  431.    since no saving is required (though calls clobber it) and it never contains
  432.    function parameters.  It is quite good to use lr since other calls may
  433.    clobber it anyway.  Allocate r0 through r3 in reverse order since r3 is 
  434.    least likely to contain a function parameter; in addition results are
  435.    returned in r0.
  436.    */
  437. #define REG_ALLOC_ORDER  \
  438. {                                   \
  439.     3, 2, 1, 0, 12, 14,    4, 5,       \
  440.     6, 7, 8, 10, 9, 11, 13, 15,     \
  441.     16, 17, 18, 19, 20, 21, 22, 23, \
  442.     24, 25                \
  443. }
  444.  
  445. /* Register and constant classes.  */
  446.  
  447. /* Register classes: all ARM regs or all FPU regs---simple! */
  448. enum reg_class
  449. {
  450.   NO_REGS,
  451.   FPU_REGS,
  452.   GENERAL_REGS,
  453.   ALL_REGS,
  454.   LIM_REG_CLASSES
  455. };
  456.  
  457. #define N_REG_CLASSES  (int) LIM_REG_CLASSES
  458.  
  459. /* Give names of register classes as strings for dump file.   */
  460. #define REG_CLASS_NAMES  \
  461. {            \
  462.   "NO_REGS",        \
  463.   "FPU_REGS",        \
  464.   "GENERAL_REGS",    \
  465.   "ALL_REGS",        \
  466. }
  467.  
  468. /* Define which registers fit in which classes.
  469.    This is an initializer for a vector of HARD_REG_SET
  470.    of length N_REG_CLASSES.  */
  471. #define REG_CLASS_CONTENTS  \
  472. {                \
  473.   0x0000000, /* NO_REGS  */    \
  474.   0x0FF0000, /* FPU_REGS */    \
  475.   0x200FFFF, /* GENERAL_REGS */    \
  476.   0x2FFFFFF  /* ALL_REGS */    \
  477. }
  478.  
  479. /* The same information, inverted:
  480.    Return the class number of the smallest class containing
  481.    reg number REGNO.  This could be a conditional expression
  482.    or could index an array.  */
  483. #define REGNO_REG_CLASS(REGNO)              \
  484.   (((REGNO) < 16 || REGNO == FRAME_POINTER_REGNUM    \
  485.     || REGNO == ARG_POINTER_REGNUM)            \
  486.    ? GENERAL_REGS : (REGNO) == CC_REGNUM        \
  487.    ? NO_REGS : FPU_REGS)
  488.  
  489. /* The class value for index registers, and the one for base regs.  */
  490. #define INDEX_REG_CLASS  GENERAL_REGS
  491. #define BASE_REG_CLASS    GENERAL_REGS
  492.  
  493. /* Get reg_class from a letter such as appears in the machine description.
  494.    We only need constraint `f' for FPU_REGS (`r' == GENERAL_REGS).  */
  495. #define REG_CLASS_FROM_LETTER(C)  \
  496.   ((C)=='f' ? FPU_REGS : NO_REGS)
  497.  
  498. /* The letters I, J, K, L and M in a register constraint string
  499.    can be used to stand for particular ranges of immediate operands.
  500.    This macro defines what the ranges are.
  501.    C is the letter, and VALUE is a constant value.
  502.    Return 1 if VALUE is in the range specified by C.
  503.     I: immediate arithmetic operand (i.e. 8 bits shifted as required).
  504.     J: valid indexing constants.  
  505.     K: ~value ok in rhs argument of data operand.
  506.     L: -value ok in rhs argument of data operand. 
  507.         M: 0..32, or a power of 2  (for shifts, or mult done by shift).  */
  508. #define CONST_OK_FOR_LETTER_P(VALUE, C)          \
  509.   ((C) == 'I' ? const_ok_for_arm (VALUE) :        \
  510.    (C) == 'J' ? ((VALUE) < 4096 && (VALUE) > -4096) :    \
  511.    (C) == 'K' ? (const_ok_for_arm (~(VALUE))) :        \
  512.    (C) == 'L' ? (const_ok_for_arm (-(VALUE))) :        \
  513.    (C) == 'M' ? (((VALUE >= 0 && VALUE <= 32))        \
  514.          || (((VALUE) & ((VALUE) - 1)) == 0))    \
  515.    : 0)
  516.  
  517. /* For the ARM, `Q' means that this is a memory operand that is just
  518.    an offset from a register.  
  519.    `S' means any symbol that has the SYMBOL_REF_FLAG set or a CONSTANT_POOL
  520.    address.  This means that the symbol is in the text segment and can be
  521.    accessed without using a load. */
  522.  
  523. #define EXTRA_CONSTRAINT(OP, C)                                         \
  524.   ((C) == 'Q' ? GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == REG  \
  525.    : (C) == 'R' ? (GET_CODE (OP) == MEM                    \
  526.            && GET_CODE (XEXP (OP, 0)) == SYMBOL_REF        \
  527.            && CONSTANT_POOL_ADDRESS_P (XEXP (OP, 0)))        \
  528.    : (C) == 'S' ? (optimize > 0 && CONSTANT_ADDRESS_P (OP)) : 0)
  529.  
  530. /* Constant letter 'G' for the FPU immediate constants. 
  531.    'H' means the same constant negated.  */
  532. #define CONST_DOUBLE_OK_FOR_LETTER_P(X,C)            \
  533.     ((C) == 'G' ? const_double_rtx_ok_for_fpu (X)         \
  534.      : (C) == 'H' ? neg_const_double_rtx_ok_for_fpu (X) : 0)
  535.  
  536. /* Given an rtx X being reloaded into a reg required to be
  537.    in class CLASS, return the class of reg to actually use.
  538.    In general this is just CLASS; but on some machines
  539.    in some cases it is preferable to use a more restrictive class.  */
  540. #define PREFERRED_RELOAD_CLASS(X, CLASS)  (CLASS)
  541.  
  542. /* Return the register class of a scratch register needed to copy IN into
  543.    or out of a register in CLASS in MODE.  If it can be done directly,
  544.    NO_REGS is returned.  */
  545. #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS,MODE,X)    \
  546.   (((MODE) == DFmode && (CLASS) == GENERAL_REGS        \
  547.     && true_regnum (X) == -1) ? GENERAL_REGS        \
  548.    : ((MODE) == HImode && true_regnum (X) == -1) ? GENERAL_REGS : NO_REGS)
  549.  
  550. /* Return the maximum number of consecutive registers
  551.    needed to represent mode MODE in a register of class CLASS.
  552.    ARM regs are UNITS_PER_WORD bits while FPU regs can hold any FP mode */
  553. #define CLASS_MAX_NREGS(CLASS, MODE)  \
  554.     ((CLASS) == FPU_REGS ? 1                           \
  555.      : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
  556.  
  557. /* Moves between FPU_REGS and GENERAL_REGS are two memory insns.  */
  558. #define REGISTER_MOVE_COST(CLASS1, CLASS2)  \
  559.   ((((CLASS1) == FPU_REGS && (CLASS2) != FPU_REGS)    \
  560.     || ((CLASS2) == FPU_REGS && (CLASS1) != FPU_REGS))    \
  561.    ? 20 : 2)
  562.  
  563. /* Stack layout; function entry, exit and calling.  */
  564.  
  565. /* Define this if pushing a word on the stack
  566.    makes the stack pointer a smaller address.  */
  567. #define STACK_GROWS_DOWNWARD  1
  568.  
  569. /* Define this if the nominal address of the stack frame
  570.    is at the high-address end of the local variables;
  571.    that is, each additional local variable allocated
  572.    goes at a more negative offset in the frame.  */
  573. #define FRAME_GROWS_DOWNWARD 1
  574.  
  575. /* Offset within stack frame to start allocating local variables at.
  576.    If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
  577.    first local allocated.  Otherwise, it is the offset to the BEGINNING
  578.    of the first local allocated.  */
  579. #define STARTING_FRAME_OFFSET  0
  580.  
  581. /* If we generate an insn to push BYTES bytes,
  582.    this says how many the stack pointer really advances by.  */
  583. #define PUSH_ROUNDING(NPUSHED)  (((NPUSHED) + 3) & ~3)
  584.  
  585. /* Offset of first parameter from the argument pointer register value.  */
  586. #define FIRST_PARM_OFFSET(FNDECL)  4
  587.  
  588. /* Value is the number of byte of arguments automatically
  589.    popped when returning from a subroutine call.
  590.    FUNTYPE is the data type of the function (as a tree),
  591.    or for a library call it is an identifier node for the subroutine name.
  592.    SIZE is the number of bytes of arguments passed on the stack.
  593.  
  594.    On the ARM, the caller does not pop any of its arguments that were passed
  595.    on the stack.  */
  596. #define RETURN_POPS_ARGS(FUNTYPE, SIZE)  0
  597.  
  598. /* Define how to find the value returned by a function.
  599.    VALTYPE is the data type of the value (as a tree).
  600.    If the precise function being called is known, FUNC is its FUNCTION_DECL;
  601.    otherwise, FUNC is 0.  */
  602. #define FUNCTION_VALUE(VALTYPE, FUNC)  \
  603.   (GET_MODE_CLASS (TYPE_MODE (VALTYPE)) == MODE_FLOAT  \
  604.    ? gen_rtx (REG, TYPE_MODE (VALTYPE), 16)            \
  605.    : gen_rtx (REG, TYPE_MODE (VALTYPE), 0))
  606.  
  607. /* Define how to find the value returned by a library function
  608.    assuming the value has mode MODE.  */
  609. #define LIBCALL_VALUE(MODE)  \
  610.   (GET_MODE_CLASS (MODE) == MODE_FLOAT  \
  611.    ? gen_rtx (REG, MODE, 16)        \
  612.    : gen_rtx (REG, MODE, 0))
  613.  
  614. /* 1 if N is a possible register number for a function value.
  615.    On the ARM, only r0 and f0 can return results.  */
  616. #define FUNCTION_VALUE_REGNO_P(REGNO)  \
  617.   ((REGNO) == 0 || (REGNO) == 16)
  618.  
  619. /* Define where to put the arguments to a function.
  620.    Value is zero to push the argument on the stack,
  621.    or a hard register in which to store the argument.
  622.  
  623.    MODE is the argument's machine mode.
  624.    TYPE is the data type of the argument (as a tree).
  625.     This is null for libcalls where that information may
  626.     not be available.
  627.    CUM is a variable of type CUMULATIVE_ARGS which gives info about
  628.     the preceding args and about the function being called.
  629.    NAMED is nonzero if this argument is a named parameter
  630.     (otherwise it is an extra parameter matching an ellipsis).
  631.  
  632.    On the ARM, normally the first 16 bytes are passed in registers r0-r3; all
  633.    other arguments are passed on the stack.  If (NAMED == 0) (which happens
  634.    only in assign_parms, since SETUP_INCOMING_VARARGS is defined), say it is
  635.    passed in the stack (function_prologue will indeed make it pass in the
  636.    stack if necessary).  */
  637. #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED)  \
  638.   ((NAMED)                        \
  639.    ? ((CUM) >= 16 ? 0 : gen_rtx (REG, MODE, (CUM) / 4))    \
  640.    : 0)
  641.  
  642. /* For an arg passed partly in registers and partly in memory,
  643.    this is the number of registers used.
  644.    For args passed entirely in registers or entirely in memory, zero.  */
  645. #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED)  \
  646.   ((CUM) < 16 && 16 < (CUM) + ((MODE) != BLKmode            \
  647.                    ? GET_MODE_SIZE (MODE)       \
  648.                    : int_size_in_bytes (TYPE))  \
  649.    ? 4 - (CUM) / 4 : 0)
  650.  
  651. /* A C type for declaring a variable that is used as the first argument of
  652.    `FUNCTION_ARG' and other related values.  For some target machines, the
  653.    type `int' suffices and can hold the number of bytes of argument so far.
  654.  
  655.    On the ARM, this is the number of bytes of arguments scanned so far.  */
  656. #define CUMULATIVE_ARGS  int
  657.  
  658. /* Initialize a variable CUM of type CUMULATIVE_ARGS
  659.    for a call to a function whose data type is FNTYPE.
  660.    For a library call, FNTYPE is 0.
  661.    On the ARM, the offset starts at 0.  */
  662. #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME)  \
  663.   ((CUM) = (((FNTYPE) && aggregate_value_p (TREE_TYPE ((FNTYPE)))) ? 4 : 0))
  664.  
  665. /* Update the data in CUM to advance over an argument
  666.    of mode MODE and data type TYPE.
  667.    (TYPE is null for libcalls where that information may not be available.)  */
  668. #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)  \
  669.   (CUM) += ((MODE) != BLKmode                       \
  670.         ? (GET_MODE_SIZE (MODE) + 3) & ~3       \
  671.         : (int_size_in_bytes (TYPE) + 3) & ~3)  \
  672.  
  673. /* 1 if N is a possible register number for function argument passing.
  674.    On the ARM, r0-r3 are used to pass args.  */
  675. #define FUNCTION_ARG_REGNO_P(REGNO)  \
  676.   ((REGNO) >= 0 && (REGNO) <= 3)
  677.  
  678. /* Perform any actions needed for a function that is receiving a variable
  679.    number of arguments.  CUM is as above.  MODE and TYPE are the mode and type
  680.    of the current parameter.  PRETEND_SIZE is a variable that should be set to
  681.    the amount of stack that must be pushed by the prolog to pretend that our
  682.    caller pushed it.
  683.  
  684.    Normally, this macro will push all remaining incoming registers on the
  685.    stack and set PRETEND_SIZE to the length of the registers pushed.
  686.  
  687.    On the ARM, PRETEND_SIZE is set in order to have the prologue push the last
  688.    named arg and all anonymous args onto the stack.
  689.    XXX I know the prologue shouldn't be pushing registers, but it is faster
  690.    that way.  */
  691. #define SETUP_INCOMING_VARARGS(CUM, MODE, TYPE, PRETEND_SIZE, NO_RTL)  \
  692. {                                    \
  693.   extern int current_function_anonymous_args;                \
  694.   current_function_anonymous_args = 1;                    \
  695.   if ((CUM) < 16)                            \
  696.     (PRETEND_SIZE) = 16 - (CUM);                    \
  697. }
  698.  
  699. /* Generate assembly output for the start of a function.  */
  700. #define FUNCTION_PROLOGUE(STREAM, SIZE)  \
  701.   output_func_prologue ((STREAM), (SIZE))
  702.  
  703. /* Call the function profiler with a given profile label.  The Acorn compiler
  704.    puts this BEFORE the prolog but gcc pust it afterwards.  The ``mov ip,lr''
  705.    seems like a good idea to stick with cc convention.  ``prof'' doesn't seem
  706.    to mind about this!  */
  707. #define FUNCTION_PROFILER(STREAM,LABELNO)                      \
  708. {                                        \
  709.     fprintf(STREAM, "\tmov\t%sip, %slr\n", ARM_REG_PREFIX, ARM_REG_PREFIX); \
  710.     fprintf(STREAM, "\tbl\tmcount\n");                        \
  711.     fprintf(STREAM, "\t.word\tLP%d\n", (LABELNO));                \
  712. }
  713.  
  714. /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
  715.    the stack pointer does not matter.  The value is tested only in
  716.    functions that have frame pointers.
  717.    No definition is equivalent to always zero.
  718.  
  719.    On the ARM, the function epilogue recovers the stack pointer from the
  720.    frame.  */
  721. #define EXIT_IGNORE_STACK 1
  722.  
  723. /* Generate the assembly code for function exit. */
  724. #define FUNCTION_EPILOGUE(STREAM, SIZE)  \
  725.   output_func_epilogue ((STREAM), (SIZE))
  726.  
  727. /* Determine if the epilogue should be output as RTL.
  728.    You should override this if you define FUNCTION_EXTRA_EPILOGUE.  */
  729. #define USE_RETURN_INSN use_return_insn ()
  730.  
  731. /* Definitions for register eliminations.
  732.  
  733.    This is an array of structures.  Each structure initializes one pair
  734.    of eliminable registers.  The "from" register number is given first,
  735.    followed by "to".  Eliminations of the same "from" register are listed
  736.    in order of preference.
  737.  
  738.    We have two registers that can be eliminated on the ARM.  First, the
  739.    arg pointer register can often be eliminated in favor of the stack
  740.    pointer register.  Secondly, the pseudo frame pointer register can always
  741.    be eliminated; it is replaced with either the stack or the real frame
  742.    pointer. */
  743.  
  744. #define ELIMINABLE_REGS                    \
  745. {{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM},        \
  746.  {ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM},    \
  747.  {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM},        \
  748.  {FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}}
  749.  
  750. /* Given FROM and TO register numbers, say whether this elimination is allowed.
  751.    Frame pointer elimination is automatically handled.
  752.  
  753.    All eliminations are permissible.  Note that ARG_POINTER_REGNUM and
  754.    HARD_FRAME_POINTER_REGNUM are infact the same thing.  If we need a frame
  755.    pointer, we must eliminate FRAME_POINTER_REGNUM into
  756.    HARD_FRAME_POINTER_REGNUM and not into STACK_POINTER_REGNUM.  */
  757. #define CAN_ELIMINATE(FROM, TO)        \
  758.   (((TO) == STACK_POINTER_REGNUM && frame_pointer_needed) ? 0 : 1)
  759.  
  760. /* Define the offset between two registers, one to be eliminated, and the other
  761.    its replacement, at the start of a routine.  */
  762. #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET)            \
  763. {                                    \
  764.   int volatile_func = arm_volatile_func ();                \
  765.   if ((FROM) == ARG_POINTER_REGNUM && (TO) == HARD_FRAME_POINTER_REGNUM)\
  766.     (OFFSET) = 0;                            \
  767.   else if ((FROM) == FRAME_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM)\
  768.     (OFFSET) = (get_frame_size () + 3 & ~3);                \
  769.   else                                    \
  770.     {                                    \
  771.       int regno;                            \
  772.       int offset = 12;                            \
  773.       int saved_hard_reg = 0;                        \
  774.                                     \
  775.       if (! volatile_func)                        \
  776.         {                                \
  777.           for (regno = 0; regno <= 10; regno++)                \
  778.         if (regs_ever_live[regno] && ! call_used_regs[regno])    \
  779.           saved_hard_reg = 1, offset += 4;                \
  780.           for (regno = 16; regno <=23; regno++)                \
  781.         if (regs_ever_live[regno] && ! call_used_regs[regno])    \
  782.           offset += 12;                        \
  783.     }                                \
  784.       if ((FROM) == FRAME_POINTER_REGNUM)                \
  785.     (OFFSET) = -offset;                        \
  786.       else                                \
  787.     {                                \
  788.        if (! frame_pointer_needed)                    \
  789.          offset -= 16;                        \
  790.        if (! volatile_func && (regs_ever_live[14] || saved_hard_reg)) \
  791.          offset += 4;                        \
  792.        (OFFSET) = (get_frame_size () + 3 & ~3) + offset;        \
  793.          }                                \
  794.     }                                    \
  795. }
  796.  
  797. /* Output assembler code for a block containing the constant parts
  798.    of a trampoline, leaving space for the variable parts.
  799.  
  800.    On the ARM, (if r8 is the static chain regnum, and remembering that
  801.    referencing pc adds an offset of 8) the trampoline looks like:
  802.        ldr         r8, [pc, #0]
  803.        ldr        pc, [pc]
  804.        .word    static chain value
  805.        .word    function's address  */
  806. #define TRAMPOLINE_TEMPLATE(FILE)                \
  807. {                                \
  808.   fprintf ((FILE), "\tldr\t%sr8, [%spc, #0]\n", ARM_REG_PREFIX,    \
  809.        ARM_REG_PREFIX);                    \
  810.   fprintf ((FILE), "\tldr\t%spc, [%spc, #0]\n", ARM_REG_PREFIX,    \
  811.        ARM_REG_PREFIX);                    \
  812.   fprintf ((FILE), "\t.word\t0\n");                \
  813.   fprintf ((FILE), "\t.word\t0\n");                \
  814. }
  815.  
  816. /* Length in units of the trampoline for entering a nested function.  */
  817. #define TRAMPOLINE_SIZE  16
  818.  
  819. /* Alignment required for a trampoline in units.  */
  820. #define TRAMPOLINE_ALIGN  4
  821.  
  822. /* Emit RTL insns to initialize the variable parts of a trampoline.
  823.    FNADDR is an RTX for the address of the function's pure code.
  824.    CXT is an RTX for the static chain value for the function.  */
  825. #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)  \
  826. {                                    \
  827.   emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 8)),    \
  828.           (CXT));                        \
  829.   emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 12)),    \
  830.           (FNADDR));                        \
  831. }
  832.  
  833.  
  834. /* Addressing modes, and classification of registers for them.  */
  835.  
  836. #define HAVE_POST_INCREMENT  1
  837. #define HAVE_PRE_INCREMENT  1
  838. #define HAVE_POST_DECREMENT  1
  839. #define HAVE_PRE_DECREMENT  1
  840.  
  841. /* Macros to check register numbers against specific register classes.  */
  842.  
  843. /* These assume that REGNO is a hard or pseudo reg number.
  844.    They give nonzero only if REGNO is a hard reg of the suitable class
  845.    or a pseudo reg currently allocated to a suitable hard reg.
  846.    Since they use reg_renumber, they are safe only once reg_renumber
  847.    has been allocated, which happens in local-alloc.c.
  848.  
  849.    On the ARM, don't allow the pc to be used.  */
  850. #define REGNO_OK_FOR_BASE_P(REGNO)                \
  851.   ((REGNO) < 15 || (REGNO) == FRAME_POINTER_REGNUM        \
  852.    || (REGNO) == ARG_POINTER_REGNUM                \
  853.    || (unsigned) reg_renumber[(REGNO)] < 15            \
  854.    || (unsigned) reg_renumber[(REGNO)] == FRAME_POINTER_REGNUM    \
  855.    || (unsigned) reg_renumber[(REGNO)] == ARG_POINTER_REGNUM)
  856. #define REGNO_OK_FOR_INDEX_P(REGNO) \
  857.   REGNO_OK_FOR_BASE_P(REGNO)
  858.  
  859. /* Maximum number of registers that can appear in a valid memory address.
  860.    Shifts in addresses can't be by a register. */
  861.  
  862. #define MAX_REGS_PER_ADDRESS 2
  863.  
  864. /* Recognize any constant value that is a valid address.  */
  865. /* XXX We can address any constant, eventually...  */
  866. #if 0
  867. #define CONSTANT_ADDRESS_P(X)    \
  868.     ( GET_CODE(X) == LABEL_REF    \
  869.   ||  GET_CODE(X) == SYMBOL_REF \
  870.   ||  GET_CODE(X) == CONST_INT    \
  871.   ||  GET_CODE(X) == CONST )
  872. #endif
  873.  
  874. #define CONSTANT_ADDRESS_P(X)              \
  875.   (GET_CODE (X) == SYMBOL_REF             \
  876.    && (CONSTANT_POOL_ADDRESS_P (X)        \
  877.        || (optimize > 0 && SYMBOL_REF_FLAG (X))))
  878.  
  879. /* Nonzero if the constant value X is a legitimate general operand.
  880.    It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.
  881.  
  882.    On the ARM, allow any integer (invalid ones are removed later by insn
  883.    patterns), nice doubles and symbol_refs which refer to the function's
  884.    constant pool XXX.  */
  885. #define LEGITIMATE_CONSTANT_P(X)                \
  886.   (GET_CODE (X) == CONST_INT                    \
  887.    || (GET_CODE (X) == CONST_DOUBLE                \
  888.        && (const_double_rtx_ok_for_fpu (X)            \
  889.        || neg_const_double_rtx_ok_for_fpu (X)))        \
  890.    || CONSTANT_ADDRESS_P (X))
  891.  
  892. /* Symbols in the text segment can be accessed without indirecting via the
  893.    constant pool; it may take an extra binary operation, but this is still
  894.    faster than indirecting via memory.  Don't do this when not optimizing,
  895.    since we won't be calculating al of the offsets necessary to do this
  896.    simplification.  */
  897.  
  898. #define ENCODE_SECTION_INFO(decl)                    \
  899. {                                    \
  900.   if (optimize > 0 && TREE_CONSTANT (decl)                \
  901.       && (!flag_writable_strings || TREE_CODE (decl) != STRING_CST))    \
  902.     {                                    \
  903.       rtx rtl = (TREE_CODE_CLASS (TREE_CODE (decl)) != 'd'        \
  904.                  ? TREE_CST_RTL (decl) : DECL_RTL (decl));        \
  905.       SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;                \
  906.     }                                    \
  907. }
  908.  
  909. /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
  910.    and check its validity for a certain class.
  911.    We have two alternate definitions for each of them.
  912.    The usual definition accepts all pseudo regs; the other rejects
  913.    them unless they have been allocated suitable hard regs.
  914.    The symbol REG_OK_STRICT causes the latter definition to be used.  */
  915. #ifndef REG_OK_STRICT
  916.  
  917. /* Nonzero if X is a hard reg that can be used as a base reg
  918.    or if it is a pseudo reg.  */
  919. #define REG_OK_FOR_BASE_P(X)                  \
  920.   (REGNO (X) < 16 || REGNO (X) >= FIRST_PSEUDO_REGISTER \
  921.    || REGNO (X) == FRAME_POINTER_REGNUM || REGNO (X) == ARG_POINTER_REGNUM)
  922.  
  923. /* Nonzero if X is a hard reg that can be used as an index
  924.    or if it is a pseudo reg.  */
  925. #define REG_OK_FOR_INDEX_P(X)  \
  926.   REG_OK_FOR_BASE_P(X)
  927.  
  928. #define REG_OK_FOR_PRE_POST_P(X)              \
  929.   (REGNO (X) < 16 || REGNO (X) >= FIRST_PSEUDO_REGISTER    \
  930.    || REGNO (X) == FRAME_POINTER_REGNUM || REGNO (X) == ARG_POINTER_REGNUM)
  931.  
  932. #else
  933.  
  934. /* Nonzero if X is a hard reg that can be used as a base reg.  */
  935. #define REG_OK_FOR_BASE_P(X)  REGNO_OK_FOR_BASE_P (REGNO (X))
  936.  
  937. /* Nonzero if X is a hard reg that can be used as an index.  */
  938. #define REG_OK_FOR_INDEX_P(X)  REGNO_OK_FOR_INDEX_P (REGNO (X))
  939.  
  940. #define REG_OK_FOR_PRE_POST_P(X)                         \
  941.   (REGNO (X) < 16 || (unsigned) reg_renumber[REGNO (X)] < 16           \
  942.    || REGNO (X) == FRAME_POINTER_REGNUM || REGNO (X) == ARG_POINTER_REGNUM \
  943.    || (unsigned) reg_renumber[REGNO (X)] == FRAME_POINTER_REGNUM       \
  944.    || (unsigned) reg_renumber[REGNO (X)] == ARG_POINTER_REGNUM)
  945.  
  946. #endif
  947.  
  948. /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
  949.    that is a valid memory address for an instruction.
  950.    The MODE argument is the machine mode for the MEM expression
  951.    that wants to use this address.
  952.  
  953.    The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS.  */
  954. #define BASE_REGISTER_RTX_P(X)  \
  955.   (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X))
  956.  
  957. #define INDEX_REGISTER_RTX_P(X)  \
  958.   (GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X))
  959.  
  960. /* A C statement (sans semicolon) to jump to LABEL for legitimate index RTXs
  961.    used by the macro GO_IF_LEGITIMATE_ADDRESS.  Floating point indices can
  962.    only be small constants. */
  963. #define GO_IF_LEGITIMATE_INDEX(MODE, BASE_REGNO, INDEX, LABEL)      \
  964. do                                    \
  965. {                                    \
  966.   HOST_WIDE_INT range;                            \
  967.   enum rtx_code code = GET_CODE (INDEX);                \
  968.                                     \
  969.   if (GET_MODE_CLASS (MODE) == MODE_FLOAT)                \
  970.     {                                    \
  971.       if (code == CONST_INT && INTVAL (INDEX) < 1024            \
  972.       && INTVAL (INDEX) > -1024                    \
  973.       && (INTVAL (INDEX) & 3) == 0)                    \
  974.     goto LABEL;                            \
  975.     }                                    \
  976.   else                                    \
  977.     {                                    \
  978.       if (INDEX_REGISTER_RTX_P (INDEX) && GET_MODE_SIZE (MODE) <= 4)    \
  979.     goto LABEL;                            \
  980.       if (GET_MODE_SIZE (MODE) <= 4  && code == MULT)            \
  981.     {                                \
  982.       rtx xiop0 = XEXP (INDEX, 0);                    \
  983.       rtx xiop1 = XEXP (INDEX, 1);                    \
  984.       if (INDEX_REGISTER_RTX_P (xiop0)                \
  985.           && power_of_two_operand (xiop1, SImode))            \
  986.         goto LABEL;                            \
  987.       if (INDEX_REGISTER_RTX_P (xiop1)                \
  988.           && power_of_two_operand (xiop0, SImode))            \
  989.         goto LABEL;                            \
  990.     }                                \
  991.       if (GET_MODE_SIZE (MODE) <= 4                    \
  992.       && (code == LSHIFTRT || code == ASHIFTRT            \
  993.           || code == ASHIFT || code == ROTATERT))            \
  994.     {                                \
  995.       rtx op = XEXP (INDEX, 1);                    \
  996.       if (INDEX_REGISTER_RTX_P (XEXP (INDEX, 0))            \
  997.           && GET_CODE (op) == CONST_INT && INTVAL (op) > 0        \
  998.           && INTVAL (op) <= 31)                    \
  999.         goto LABEL;                            \
  1000.         }                                \
  1001.       range = (MODE) == HImode ? 4095 : 4096;                \
  1002.       if (code == CONST_INT && INTVAL (INDEX) < range            \
  1003.       && INTVAL (INDEX) > -range)                            \
  1004.         goto LABEL;                            \
  1005.     }                                    \
  1006. } while (0)
  1007.  
  1008. /* Jump to LABEL if X is a valid address RTX.  This must also take
  1009.    REG_OK_STRICT into account when deciding about valid registers, but it uses
  1010.    the above macros so we are in luck.  Allow REG, REG+REG, REG+INDEX,
  1011.    INDEX+REG, REG-INDEX, and non floating SYMBOL_REF to the constant pool.
  1012.    Allow REG-only and AUTINC-REG if handling TImode or HImode.  Other symbol
  1013.    refs must be forced though a static cell to ensure addressability.  */
  1014. #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL)  \
  1015. {                                    \
  1016.   if (BASE_REGISTER_RTX_P (X))                        \
  1017.     goto LABEL;                                \
  1018.   else if ((GET_CODE (X) == POST_INC || GET_CODE (X) == PRE_DEC)    \
  1019.        && GET_CODE (XEXP (X, 0)) == REG                \
  1020.        && REG_OK_FOR_PRE_POST_P (XEXP (X, 0)))            \
  1021.     goto LABEL;                                \
  1022.   else if ((MODE) == TImode)                        \
  1023.     ;                                    \
  1024.   else if (GET_CODE (X) == PLUS)                    \
  1025.     {                                    \
  1026.       rtx xop0 = XEXP(X,0);                        \
  1027.       rtx xop1 = XEXP(X,1);                        \
  1028.                                     \
  1029.       if (BASE_REGISTER_RTX_P (xop0))                    \
  1030.     GO_IF_LEGITIMATE_INDEX (MODE, REGNO (xop0), xop1, LABEL);    \
  1031.       else if (BASE_REGISTER_RTX_P (xop1))                \
  1032.     GO_IF_LEGITIMATE_INDEX (MODE, REGNO (xop1), xop0, LABEL);    \
  1033.     }                                    \
  1034.   else if (GET_CODE (X) == MINUS)                    \
  1035.     {                                    \
  1036.       rtx xop0 = XEXP (X,0);                        \
  1037.       rtx xop1 = XEXP (X,1);                        \
  1038.                                     \
  1039.       if (BASE_REGISTER_RTX_P (xop0))                    \
  1040.     GO_IF_LEGITIMATE_INDEX (MODE, -1, xop1, LABEL);            \
  1041.     }                                    \
  1042.   else if (GET_MODE_CLASS (MODE) != MODE_FLOAT                \
  1043.        && GET_CODE (X) == SYMBOL_REF                \
  1044.        && CONSTANT_POOL_ADDRESS_P (X))                \
  1045.     goto LABEL;                                \
  1046.   else if ((GET_CODE (X) == PRE_INC || GET_CODE (X) == POST_DEC)    \
  1047.        && GET_CODE (XEXP (X, 0)) == REG                \
  1048.        && REG_OK_FOR_PRE_POST_P (XEXP (X, 0)))            \
  1049.     goto LABEL;                                \
  1050. }
  1051.  
  1052. /* Try machine-dependent ways of modifying an illegitimate address
  1053.    to be legitimate.  If we find one, return the new, valid address.
  1054.    This macro is used in only one place: `memory_address' in explow.c.
  1055.  
  1056.    OLDX is the address as it was before break_out_memory_refs was called.
  1057.    In some cases it is useful to look at this to decide what needs to be done.
  1058.  
  1059.    MODE and WIN are passed so that this macro can use
  1060.    GO_IF_LEGITIMATE_ADDRESS.
  1061.  
  1062.    It is always safe for this macro to do nothing.  It exists to recognize
  1063.    opportunities to optimize the output.
  1064.  
  1065.    On the ARM, try to convert [REG, #BIGCONST]
  1066.    into ADD BASE, REG, #UPPERCONST and [BASE, #VALIDCONST],
  1067.    where VALIDCONST == 0 in case of TImode.  */
  1068. #define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN)                 \
  1069. {                                     \
  1070.   if (GET_CODE (X) == PLUS)                         \
  1071.     {                                     \
  1072.       rtx xop0 = XEXP (X, 0);                         \
  1073.       rtx xop1 = XEXP (X, 1);                         \
  1074.                                      \
  1075.       if (CONSTANT_P (xop0) && ! LEGITIMATE_CONSTANT_P (xop0))         \
  1076.     xop0 = force_reg (SImode, xop0);                 \
  1077.       if (CONSTANT_P (xop1) && ! LEGITIMATE_CONSTANT_P (xop1))         \
  1078.     xop1 = force_reg (SImode, xop1);                 \
  1079.       if (BASE_REGISTER_RTX_P (xop0) && GET_CODE (xop1) == CONST_INT)     \
  1080.     {                                 \
  1081.       HOST_WIDE_INT n, low_n;                     \
  1082.       rtx base_reg, val;                         \
  1083.       n = INTVAL (xop1);                         \
  1084.                                      \
  1085.       if (MODE == DImode)                         \
  1086.         {                                 \
  1087.           low_n = n & 0x0f;                         \
  1088.           n &= ~0x0f;                         \
  1089.           if (low_n > 4)                         \
  1090.         {                             \
  1091.           n += 16;                         \
  1092.           low_n -= 16;                         \
  1093.         }                             \
  1094.         }                                 \
  1095.       else                                 \
  1096.         {                                 \
  1097.           low_n = ((MODE) == TImode ? 0                 \
  1098.                : n >= 0 ? (n & 0xfff) : -((-n) & 0xfff));     \
  1099.           n -= low_n;                         \
  1100.         }                                 \
  1101.       base_reg = gen_reg_rtx (SImode);                 \
  1102.       val = force_operand (gen_rtx (PLUS, SImode, xop0,         \
  1103.                     GEN_INT (n)), NULL_RTX);     \
  1104.       emit_move_insn (base_reg, val);                 \
  1105.       (X) = (low_n == 0 ? base_reg                     \
  1106.          : gen_rtx (PLUS, SImode, base_reg, GEN_INT (low_n)));     \
  1107.     }                                 \
  1108.       else if (xop0 != XEXP (X, 0) || xop1 != XEXP (x, 1))         \
  1109.     (X) = gen_rtx (PLUS, SImode, xop0, xop1);             \
  1110.     }                                     \
  1111.   else if (GET_CODE (X) == MINUS)                     \
  1112.     {                                     \
  1113.       rtx xop0 = XEXP (X, 0);                         \
  1114.       rtx xop1 = XEXP (X, 1);                         \
  1115.                                      \
  1116.       if (CONSTANT_P (xop0))                         \
  1117.     xop0 = force_reg (SImode, xop0);                 \
  1118.       if (CONSTANT_P (xop1) && ! LEGITIMATE_CONSTANT_P (xop1))         \
  1119.     xop1 = force_reg (SImode, xop1);                 \
  1120.       if (xop0 != XEXP (X, 0) || xop1 != XEXP (X, 1))             \
  1121.     (X) = gen_rtx (MINUS, SImode, xop0, xop1);             \
  1122.     }                                     \
  1123.   if (memory_address_p (MODE, X))                     \
  1124.     goto WIN;                                 \
  1125. }
  1126.  
  1127.  
  1128. /* Go to LABEL if ADDR (a legitimate address expression)
  1129.    has an effect that depends on the machine mode it is used for.  */
  1130. #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL)  \
  1131. {                                    \
  1132.   if (GET_CODE(ADDR) == PRE_DEC || GET_CODE(ADDR) == POST_DEC        \
  1133.       || GET_CODE(ADDR) == PRE_INC || GET_CODE(ADDR) == POST_INC)    \
  1134.     goto LABEL;                                \
  1135. }
  1136.  
  1137. /* Specify the machine mode that this machine uses
  1138.    for the index in the tablejump instruction.  */
  1139. #define CASE_VECTOR_MODE SImode
  1140.  
  1141. /* Define this if the tablejump instruction expects the table
  1142.    to contain offsets from the address of the table.
  1143.    Do not define this if the table should contain absolute addresses.  */
  1144. /* #define CASE_VECTOR_PC_RELATIVE */
  1145.  
  1146. /* Specify the tree operation to be used to convert reals to integers.  */
  1147. #define IMPLICIT_FIX_EXPR  FIX_ROUND_EXPR
  1148.  
  1149. /* This is the kind of divide that is easiest to do in the general case.  */
  1150. #define EASY_DIV_EXPR  TRUNC_DIV_EXPR
  1151.  
  1152. /* signed 'char' is most compatible, but RISC OS wants it unsigned.
  1153.    unsigned is probably best, but may break some code.  */
  1154. #ifndef DEFAULT_SIGNED_CHAR
  1155. #define DEFAULT_SIGNED_CHAR  0
  1156. #endif
  1157.  
  1158. /* Don't cse the address of the function being compiled.  */
  1159. #define NO_RECURSIVE_FUNCTION_CSE 1
  1160.  
  1161. /* Max number of bytes we can move from memory to memory
  1162.    in one reasonably fast instruction.  */
  1163. #define MOVE_MAX 4
  1164.  
  1165. /* Define if operations between registers always perform the operation
  1166.    on the full register even if a narrower mode is specified.  */
  1167. #define WORD_REGISTER_OPERATIONS
  1168.  
  1169. /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
  1170.    will either zero-extend or sign-extend.  The value of this macro should
  1171.    be the code that says which one of the two operations is implicitly
  1172.    done, NIL if none.  */
  1173. #define LOAD_EXTEND_OP(MODE)                        \
  1174.   ((MODE) == QImode ? ZERO_EXTEND                    \
  1175.    : ((BYTES_BIG_ENDIAN && (MODE) == HImode) ? SIGN_EXTEND : NIL))
  1176.  
  1177. /* Define this if zero-extension is slow (more than one real instruction).
  1178.    On the ARM, it is more than one instruction only if not fetching from
  1179.    memory.  */
  1180. /* #define SLOW_ZERO_EXTEND */
  1181.  
  1182. /* Nonzero if access to memory by bytes is slow and undesirable.  */
  1183. #define SLOW_BYTE_ACCESS 0
  1184.  
  1185. /* Immediate shift counts are truncated by the output routines (or was it
  1186.    the assembler?).  Shift counts in a register are truncated by ARM.  Note
  1187.    that the native compiler puts too large (> 32) immediate shift counts
  1188.    into a register and shifts by the register, letting the ARM decide what
  1189.    to do instead of doing that itself.  */
  1190. /* This is all wrong.  Defining SHIFT_COUNT_TRUNCATED tells combine that
  1191.    code like (X << (Y % 32)) for register X, Y is equivalent to (X << Y).
  1192.    On the arm, Y in a register is used modulo 256 for the shift. Only for
  1193.    rotates is modulo 32 used. */
  1194. /* #define SHIFT_COUNT_TRUNCATED 1 */
  1195.  
  1196. /* XX This is not true, is it?  */
  1197. /* All integers have the same format so truncation is easy.  */
  1198. #define TRULY_NOOP_TRUNCATION(OUTPREC,INPREC)  1
  1199.  
  1200. /* Calling from registers is a massive pain.  */
  1201. #define NO_FUNCTION_CSE 1
  1202.  
  1203. /* Chars and shorts should be passed as ints.  */
  1204. #define PROMOTE_PROTOTYPES 1
  1205.  
  1206. /* The machine modes of pointers and functions */
  1207. #define Pmode  SImode
  1208. #define FUNCTION_MODE  Pmode
  1209.  
  1210. /* The structure type of the machine dependent info field of insns
  1211.    No uses for this yet.  */
  1212. /* #define INSN_MACHINE_INFO  struct machine_info  */
  1213.  
  1214. /* The relative costs of various types of constants.  Note that cse.c defines
  1215.    REG = 1, SUBREG = 2, any node = (2 + sum of subnodes).  */
  1216. #define CONST_COSTS(RTX, CODE, OUTER_CODE)            \
  1217.   case CONST_INT:                        \
  1218.     if (const_ok_for_arm (INTVAL (RTX)))            \
  1219.       return (OUTER_CODE) == SET ? 2 : -1;                \
  1220.     else if (OUTER_CODE == AND                          \
  1221.              && const_ok_for_arm (~INTVAL (RTX)))        \
  1222.       return -1;                                          \
  1223.     else if ((OUTER_CODE == COMPARE                     \
  1224.               || OUTER_CODE == PLUS || OUTER_CODE == MINUS)     \
  1225.              && const_ok_for_arm (-INTVAL (RTX)))        \
  1226.       return -1;                                          \
  1227.     else                                                \
  1228.       return 5;                                               \
  1229.   case CONST:                             \
  1230.   case LABEL_REF:                        \
  1231.   case SYMBOL_REF:                        \
  1232.     return 6;                            \
  1233.   case CONST_DOUBLE:                        \
  1234.     if (const_double_rtx_ok_for_fpu (RTX))            \
  1235.       return (OUTER_CODE) == SET ? 2 : -1;            \
  1236.     else if (((OUTER_CODE) == COMPARE || (OUTER_CODE) == PLUS)    \
  1237.          && neg_const_double_rtx_ok_for_fpu (RTX))        \
  1238.        return -1;                        \
  1239.     return(7);
  1240.  
  1241. #define ARM_FRAME_RTX(X)                \
  1242.   ((X) == frame_pointer_rtx || (X) == stack_pointer_rtx    \
  1243.    || (X) == arg_pointer_rtx)
  1244.  
  1245. #define RTX_COSTS(X,CODE,OUTER_CODE)                                    \
  1246.   default:                                \
  1247.    return arm_rtx_costs (X, CODE, OUTER_CODE);
  1248.  
  1249. /* Moves to and from memory are quite expensive */
  1250. #define MEMORY_MOVE_COST(MODE)  10
  1251.  
  1252. /* All address computations that can be done are free, but rtx cost returns
  1253.    the same for practically all of them.  So we weight the differnt types
  1254.    of address here in the order (most pref first):
  1255.    PRE/POST_INC/DEC, SHIFT or NON-INT sum, INT sum, REG, MEM or LABEL. */
  1256. #define ADDRESS_COST(X)                                 \
  1257.   (10 - ((GET_CODE (X) == MEM || GET_CODE (X) == LABEL_REF             \
  1258.       || GET_CODE (X) == SYMBOL_REF)                     \
  1259.      ? 0                                     \
  1260.      : ((GET_CODE (X) == PRE_INC || GET_CODE (X) == PRE_DEC             \
  1261.          || GET_CODE (X) == POST_INC || GET_CODE (X) == POST_DEC)         \
  1262.         ? 10                                 \
  1263.         : (((GET_CODE (X) == PLUS || GET_CODE (X) == MINUS)             \
  1264.         ? 6 + (GET_CODE (XEXP (X, 1)) == CONST_INT ? 2              \
  1265.                : ((GET_RTX_CLASS (GET_CODE (XEXP (X, 0))) == '2'     \
  1266.                || GET_RTX_CLASS (GET_CODE (XEXP (X, 0))) == 'c'  \
  1267.                || GET_RTX_CLASS (GET_CODE (XEXP (X, 1))) == '2'  \
  1268.                || GET_RTX_CLASS (GET_CODE (XEXP (X, 1))) == 'c') \
  1269.               ? 1 : 0))                         \
  1270.         : 4)))))
  1271.      
  1272.    
  1273.  
  1274. /* Try to generate sequences that don't involve branches, we can then use
  1275.    conditional instructions */
  1276. #define BRANCH_COST 4
  1277.  
  1278. /* Condition code information. */
  1279. /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
  1280.    return the mode to be used for the comparison. 
  1281.    CCFPEmode should be used with floating inequalites,
  1282.    CCFPmode should be used with floating equalities.
  1283.    CC_NOOVmode should be used with SImode integer equalites
  1284.    CCmode should be used otherwise. */
  1285.  
  1286. #define EXTRA_CC_MODES CC_NOOVmode, CCFPmode, CCFPEmode
  1287.  
  1288. #define EXTRA_CC_NAMES "CC_NOOV", "CCFP", "CCFPE"
  1289.  
  1290. #define SELECT_CC_MODE(OP,X,Y)                              \
  1291.   (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT                \
  1292.    ? ((OP == EQ || OP == NE) ? CCFPmode : CCFPEmode)            \
  1293.    : ((GET_MODE (X) == SImode)                        \
  1294.       && ((OP) == EQ || (OP) == NE)                    \
  1295.       && (GET_CODE (X) == PLUS || GET_CODE (X) == MINUS            \
  1296.       || GET_CODE (X) == AND || GET_CODE (X) == IOR            \
  1297.       || GET_CODE (X) == XOR || GET_CODE (X) == MULT        \
  1298.       || GET_CODE (X) == NOT || GET_CODE (X) == NEG            \
  1299.       || GET_CODE (X) == LSHIFTRT                    \
  1300.       || GET_CODE (X) == ASHIFT || GET_CODE (X) == ASHIFTRT        \
  1301.       || GET_CODE (X) == ROTATERT || GET_CODE (X) == ZERO_EXTRACT)    \
  1302.       ? CC_NOOVmode                            \
  1303.       : GET_MODE (X) == QImode ? CC_NOOVmode : CCmode))
  1304.  
  1305. #define REVERSIBLE_CC_MODE(MODE) ((MODE) != CCFPEmode)
  1306.  
  1307. #define STORE_FLAG_VALUE 1
  1308.  
  1309. /* Define the information needed to generate branch insns.  This is
  1310.    stored from the compare operation.  Note that we can't use "rtx" here
  1311.    since it hasn't been defined!  */
  1312.  
  1313. extern struct rtx_def *arm_compare_op0, *arm_compare_op1;
  1314. extern int arm_compare_fp;
  1315.  
  1316. /* Define the codes that are matched by predicates in arm.c */
  1317. #define PREDICATE_CODES                            \
  1318.   {"s_register_operand", {SUBREG, REG}},                \
  1319.   {"arm_add_operand", {SUBREG, REG, CONST_INT}},            \
  1320.   {"fpu_add_operand", {SUBREG, REG, CONST_DOUBLE}},            \
  1321.   {"arm_rhs_operand", {SUBREG, REG, CONST_INT}},            \
  1322.   {"fpu_rhs_operand", {SUBREG, REG, CONST_DOUBLE}},            \
  1323.   {"arm_not_operand", {SUBREG, REG, CONST_INT}},            \
  1324.   {"shiftable_operator", {PLUS, MINUS, AND, IOR, XOR}},            \
  1325.   {"minmax_operator", {SMIN, SMAX, UMIN, UMAX}},            \
  1326.   {"shift_operator", {ASHIFT, ASHIFTRT, LSHIFTRT, ROTATERT, MULT}},    \
  1327.   {"di_operand", {SUBREG, REG, CONST_INT, CONST_DOUBLE, MEM}},        \
  1328.   {"load_multiple_operation", {PARALLEL}},                \
  1329.   {"store_multiple_operation", {PARALLEL}},                \
  1330.   {"equality_operator", {EQ, NE}},                    \
  1331.   {"arm_rhsm_operand", {SUBREG, REG, CONST_INT, MEM}},            \
  1332.   {"const_shift_operand", {CONST_INT}},                    \
  1333.   {"index_operand", {SUBREG, REG, CONST_INT}},                \
  1334.   {"reg_or_int_operand", {SUBREG, REG, CONST_INT}},            \
  1335.   {"multi_register_push", {PARALLEL}},                    \
  1336.   {"cc_register", {REG}},                        \
  1337.   {"reversible_cc_register", {REG}},
  1338.  
  1339.  
  1340. /* Assembler output control */
  1341.  
  1342. #ifndef ARM_OS_NAME
  1343. #define ARM_OS_NAME "(generic)"
  1344. #endif
  1345.  
  1346. /* The text to go at the start of the assembler file */
  1347. #define ASM_FILE_START(STREAM)                          \
  1348. {                                      \
  1349.   extern char *version_string;                          \
  1350.   fprintf (STREAM,"%c Generated by gcc %s for ARM/%s\n",          \
  1351.        ARM_COMMENT_CHAR, version_string, ARM_OS_NAME);          \
  1352.   fprintf (STREAM,"%srfp\t.req\t%sr9\n", ARM_REG_PREFIX, ARM_REG_PREFIX); \
  1353.   fprintf (STREAM,"%ssl\t.req\t%sr10\n", ARM_REG_PREFIX, ARM_REG_PREFIX); \
  1354.   fprintf (STREAM,"%sfp\t.req\t%sr11\n", ARM_REG_PREFIX, ARM_REG_PREFIX); \
  1355.   fprintf (STREAM,"%sip\t.req\t%sr12\n", ARM_REG_PREFIX, ARM_REG_PREFIX); \
  1356.   fprintf (STREAM,"%ssp\t.req\t%sr13\n", ARM_REG_PREFIX, ARM_REG_PREFIX); \
  1357.   fprintf (STREAM,"%slr\t.req\t%sr14\n", ARM_REG_PREFIX, ARM_REG_PREFIX); \
  1358.   fprintf (STREAM,"%spc\t.req\t%sr15\n", ARM_REG_PREFIX, ARM_REG_PREFIX); \
  1359. }
  1360.  
  1361. #define ASM_APP_ON  ""
  1362. #define ASM_APP_OFF  ""
  1363.  
  1364. /* Switch to the text or data segment.  */
  1365. #define TEXT_SECTION_ASM_OP  ".text"
  1366. #define DATA_SECTION_ASM_OP  ".data"
  1367.  
  1368. /* The assembler's names for the registers.  */
  1369. #ifndef REGISTER_NAMES
  1370. #define REGISTER_NAMES  \
  1371. {                                   \
  1372.   "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",  \
  1373.   "r8", "r9", "sl", "fp", "ip", "sp", "lr", "pc",  \
  1374.   "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",  \
  1375.   "cc", "sfp", "afp"                   \
  1376. }
  1377. #endif
  1378.  
  1379. #ifndef ADDITIONAL_REGISTER_NAMES
  1380. #define ADDITIONAL_REGISTER_NAMES        \
  1381. {                        \
  1382.   {"a1", 0},                    \
  1383.   {"a2", 1},                    \
  1384.   {"a3", 2},                    \
  1385.   {"a4", 3},                    \
  1386.   {"v1", 4},                    \
  1387.   {"v2", 5},                    \
  1388.   {"v3", 6},                    \
  1389.   {"v4", 7},                    \
  1390.   {"v5", 8},                    \
  1391.   {"v6", 9},                    \
  1392.   {"rfp", 9}, /* Gcc used to call it this */    \
  1393.   {"sb", 9},                    \
  1394.   {"v7", 10},                    \
  1395.   {"r10", 10},                    \
  1396.   {"r11", 11},    /* fp */            \
  1397.   {"r12", 12},    /* ip */            \
  1398.   {"r13", 13},    /* sp */            \
  1399.   {"r14", 14},    /* lr */            \
  1400.   {"r15", 15}    /* pc */            \
  1401. }
  1402. #endif
  1403.  
  1404. /* Arm Assembler barfs on dollars */
  1405. #define DOLLARS_IN_IDENTIFIERS 0
  1406.  
  1407. #define NO_DOLLAR_IN_LABEL
  1408.  
  1409. /* DBX register number for a given compiler register number */
  1410. #define DBX_REGISTER_NUMBER(REGNO)  (REGNO)
  1411.  
  1412. /* Generate DBX debugging information.  riscix.h will undefine this because
  1413.    the native assembler does not support stabs. */
  1414. #define DBX_DEBUGGING_INFO  1
  1415.  
  1416. /* Acorn dbx moans about continuation chars, so don't use any.  */
  1417. #ifndef DBX_CONTIN_LENGTH
  1418. #define DBX_CONTIN_LENGTH  0
  1419. #endif
  1420.  
  1421. /* Output a source filename for the debugger. RISCiX dbx insists that the
  1422.    ``desc'' field is set to compiler version number >= 315 (sic).  */
  1423. #define DBX_OUTPUT_MAIN_SOURCE_FILENAME(STREAM,NAME)             \
  1424. do {                                    \
  1425.   fprintf (STREAM, ".stabs \"%s\",%d,0,315,%s\n", (NAME), N_SO,        \
  1426.        <ext_label_name[1]);                    \
  1427.   text_section ();                            \
  1428.   ASM_OUTPUT_INTERNAL_LABEL (STREAM, "Ltext", 0);            \
  1429. } while (0)
  1430.   
  1431. /* Output a label definition.  */
  1432. #define ASM_OUTPUT_LABEL(STREAM,NAME)  \
  1433.   arm_asm_output_label ((STREAM), (NAME))
  1434.  
  1435. /* Output a function label definition.  */
  1436. #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \
  1437.     ASM_OUTPUT_LABEL(STREAM, NAME)
  1438.  
  1439. /* Output a globalising directive for a label.  */
  1440. #define ASM_GLOBALIZE_LABEL(STREAM,NAME)  \
  1441.   (fprintf (STREAM, "\t.global\t"),      \
  1442.    assemble_name (STREAM, NAME),      \
  1443.    fputc ('\n',STREAM))                   \
  1444.  
  1445. /* Output a reference to a label.  */
  1446. #define ASM_OUTPUT_LABELREF(STREAM,NAME)  \
  1447.   fprintf (STREAM, "_%s", NAME)
  1448.  
  1449. /* Make an internal label into a string.  */
  1450. #define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM)  \
  1451.   sprintf (STRING, "*%s%d", PREFIX, NUM)
  1452.  
  1453. /* Output an internal label definition.  */
  1454. #define ASM_OUTPUT_INTERNAL_LABEL(STREAM, PREFIX, NUM)  \
  1455.   do                                                             \
  1456.     {                                             \
  1457.       char *s = (char *) alloca (11 + strlen (PREFIX));               \
  1458.       extern int arm_target_label, arm_ccfsm_state;               \
  1459.       extern rtx arm_target_insn;                    \
  1460.                                            \
  1461.       if (arm_ccfsm_state == 3 && arm_target_label == (NUM)           \
  1462.     && !strcmp (PREFIX, "L"))                    \
  1463.     {                                \
  1464.       arm_ccfsm_state = 0;                            \
  1465.       arm_target_insn = NULL;                    \
  1466.     }                                \
  1467.     strcpy (s, "*");                              \
  1468.     sprintf (&s[strlen (s)], "%s%d", (PREFIX), (NUM));           \
  1469.     arm_asm_output_label (STREAM, s);                        \
  1470.     } while (0)
  1471.  
  1472. /* Nothing special is done about jump tables */
  1473. /* #define ASM_OUTPUT_CASE_LABEL(STREAM,PREFIX,NUM,TABLE)   */
  1474. /* #define ASM_OUTPUT_CASE_END(STREAM,NUM,TABLE)        */
  1475.  
  1476. /* Construct a private name.  */
  1477. #define ASM_FORMAT_PRIVATE_NAME(OUTVAR,NAME,NUMBER)  \
  1478.   ((OUTVAR) = (char *) alloca (strlen (NAME) + 10),  \
  1479.    sprintf ((OUTVAR), "%s.%d", (NAME), (NUMBER)))
  1480.  
  1481. /* Output a push or a pop instruction (only used when profiling).  */
  1482. #define ASM_OUTPUT_REG_PUSH(STREAM,REGNO)                    \
  1483.   fprintf(STREAM,"\tstmfd\t%ssp!,{%s%s}\n", ARM_REG_PREFIX, ARM_REG_PREFIX, \
  1484.       reg_names[REGNO])
  1485.  
  1486. #define ASM_OUTPUT_REG_POP(STREAM,REGNO)                    \
  1487.   fprintf(STREAM,"\tldmfd\t%ssp!,{%s%s}\n", ARM_REG_PREFIX, ARM_REG_PREFIX, \
  1488.       reg_names[REGNO])
  1489.  
  1490. /* Output a relative address. Not needed since jump tables are absolute
  1491.    but we must define it anyway.  */
  1492. #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,VALUE,REL)  \
  1493.   fputs ("- - - ASM_OUTPUT_ADDR_DIFF_ELT called!\n", STREAM)
  1494.  
  1495. /* Output an element of a dispatch table.  */
  1496. #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE)  \
  1497.    fprintf (STREAM, "\t.word\tL%d\n", VALUE)
  1498.  
  1499. /* Output various types of constants.  For real numbers we output hex, with
  1500.    a comment containing the "human" value, this allows us to pass NaN's which
  1501.    the riscix assembler doesn't understand (it also makes cross-assembling
  1502.    less likely to fail). */
  1503.  
  1504. #define ASM_OUTPUT_LONG_DOUBLE(STREAM,VALUE)                \
  1505. do { char dstr[30];                            \
  1506.      long l[3];                                \
  1507.      arm_increase_location (12);                    \
  1508.      REAL_VALUE_TO_TARGET_LONG_DOUBLE (VALUE, l);            \
  1509.      REAL_VALUE_TO_DECIMAL (VALUE, "%.20g", dstr);            \
  1510.      if (sizeof (int) == sizeof (long))                    \
  1511.        fprintf (STREAM, "\t.long 0x%x,0x%x,0x%x\t%c long double %s\n",    \
  1512.         l[2], l[1], l[0], ARM_COMMENT_CHAR, dstr);        \
  1513.      else                                \
  1514.        fprintf (STREAM, "\t.long 0x%lx,0x%lx,0x%lx\t%c long double %s\n",\
  1515.         l[0], l[1], l[2], ARM_COMMENT_CHAR, dstr);        \
  1516.    } while (0)
  1517.  
  1518.     
  1519. #define ASM_OUTPUT_DOUBLE(STREAM, VALUE)                  \
  1520. do { char dstr[30];                            \
  1521.      long l[2];                                \
  1522.      arm_increase_location (8);                        \
  1523.      REAL_VALUE_TO_TARGET_DOUBLE (VALUE, l);                \
  1524.      REAL_VALUE_TO_DECIMAL (VALUE, "%.14g", dstr);            \
  1525.      if (sizeof (int) == sizeof (long))                    \
  1526.        fprintf (STREAM, "\t.long 0x%x, 0x%x\t%c double %s\n", l[0],    \
  1527.         l[1], ARM_COMMENT_CHAR, dstr);                \
  1528.      else                                \
  1529.        fprintf (STREAM, "\t.long 0x%lx, 0x%lx\t%c double %s\n", l[0],    \
  1530.         l[1], ARM_COMMENT_CHAR, dstr);                \
  1531.    } while (0)
  1532.  
  1533. #define ASM_OUTPUT_FLOAT(STREAM, VALUE)                    \
  1534. do { char dstr[30];                            \
  1535.      long l;                                \
  1536.      arm_increase_location (4);                        \
  1537.      REAL_VALUE_TO_TARGET_SINGLE (VALUE, l);                \
  1538.      REAL_VALUE_TO_DECIMAL (VALUE, "%.7g", dstr);            \
  1539.      if (sizeof (int) == sizeof (long))                    \
  1540.        fprintf (STREAM, "\t.word 0x%x\t%c float %s\n", l,        \
  1541.         ARM_COMMENT_CHAR, dstr);                \
  1542.      else                                \
  1543.        fprintf (STREAM, "\t.word 0x%lx\t%c float %s\n", l,        \
  1544.         ARM_COMMENT_CHAR, dstr);                \
  1545.    } while (0);
  1546.  
  1547. #define ASM_OUTPUT_INT(STREAM, EXP)    \
  1548.   (fprintf (STREAM, "\t.word\t"),    \
  1549.    output_addr_const (STREAM, (EXP)),    \
  1550.    arm_increase_location (4),        \
  1551.    fputc ('\n', STREAM))
  1552.  
  1553. #define ASM_OUTPUT_SHORT(STREAM, EXP)  \
  1554.   (fprintf (STREAM, "\t.short\t"),     \
  1555.    output_addr_const (STREAM, (EXP)),  \
  1556.    arm_increase_location (2),          \
  1557.    fputc ('\n', STREAM))
  1558.  
  1559. #define ASM_OUTPUT_CHAR(STREAM, EXP)  \
  1560.   (fprintf (STREAM, "\t.byte\t"),      \
  1561.    output_addr_const (STREAM, (EXP)),  \
  1562.    arm_increase_location (1),          \
  1563.    fputc ('\n', STREAM))
  1564.  
  1565. #define ASM_OUTPUT_BYTE(STREAM, VALUE)  \
  1566.   (fprintf (STREAM, "\t.byte\t%d\n", VALUE),  \
  1567.    arm_increase_location (1))
  1568.  
  1569. #define ASM_OUTPUT_ASCII(STREAM, PTR, LEN)  \
  1570.   output_ascii_pseudo_op ((STREAM), (unsigned char *)(PTR), (LEN))
  1571.  
  1572. /* Output a gap.  In fact we fill it with nulls.  */
  1573. #define ASM_OUTPUT_SKIP(STREAM, NBYTES)  \
  1574.   (arm_increase_location (NBYTES),              \
  1575.    fprintf (STREAM, "\t.space\t%d\n", NBYTES))
  1576.  
  1577. /* Align output to a power of two.  Horrible /bin/as.  */
  1578. #define ASM_OUTPUT_ALIGN(STREAM, POWER)  \
  1579.   do                                                           \
  1580.     {                                                          \
  1581.       register int amount = 1 << (POWER);                      \
  1582.       extern int arm_text_location;                   \
  1583.                                                                \
  1584.       if (amount == 2)                                         \
  1585.     fprintf (STREAM, "\t.even\n");                         \
  1586.       else                                                     \
  1587.     fprintf (STREAM, "\t.align\t%d\n", amount - 4);        \
  1588.                                                                \
  1589.       if (in_text_section ())                                  \
  1590.     arm_text_location = ((arm_text_location + amount - 1)  \
  1591.                  & ~(amount - 1));                 \
  1592.     } while (0)
  1593.  
  1594. /* Output a common block */
  1595. #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED)          \
  1596.   (fprintf (STREAM, "\t.comm\t"),                          \
  1597.    assemble_name ((STREAM), (NAME)),                         \
  1598.    fprintf(STREAM, ", %d\t%c%d\n", ROUNDED, ARM_COMMENT_CHAR, SIZE))
  1599.  
  1600. /* Output a local common block.  /bin/as can't do this, so hack a `.space' into
  1601.    the bss segment.  Note that this is *bad* practice.  */
  1602. #define ASM_OUTPUT_LOCAL(STREAM,NAME,SIZE,ROUNDED)  \
  1603.   output_lcomm_directive (STREAM, NAME, SIZE, ROUNDED)
  1604.  
  1605. /* Output a source line for the debugger.  */
  1606. /* #define ASM_OUTPUT_SOURCE_LINE(STREAM,LINE) */
  1607.  
  1608. /* Output a #ident directive.  */
  1609. #define ASM_OUTPUT_IDENT(STREAM,STRING)  \
  1610.   fprintf (STREAM,"- - - ident %s\n",STRING)
  1611.  
  1612. /* The assembler's parentheses characters.  */
  1613. #define ASM_OPEN_PAREN "("
  1614. #define ASM_CLOSE_PAREN ")"
  1615.  
  1616. /* Target characters.  */
  1617. #define TARGET_BELL    007
  1618. #define TARGET_BS    010
  1619. #define TARGET_TAB    011
  1620. #define TARGET_NEWLINE    012
  1621. #define TARGET_VT    013
  1622. #define TARGET_FF    014
  1623. #define TARGET_CR    015
  1624.  
  1625. /* Only perform branch elimination (by making instructions conditional) if
  1626.    we're optimising.  Otherwise it's of no use anyway.  */
  1627. #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS)  \
  1628.   if (optimize)                        \
  1629.     final_prescan_insn (INSN, OPVEC, NOPERANDS)
  1630.  
  1631. #ifndef ARM_COMMENT_CHAR
  1632. #define ARM_COMMENT_CHAR '@'
  1633. #endif
  1634.  
  1635. /* Default is for register names not to have a prefix.  */
  1636. #ifndef ARM_REG_PREFIX
  1637. #define ARM_REG_PREFIX ""
  1638. #endif
  1639.  
  1640. #define PRINT_OPERAND_PUNCT_VALID_P(CODE)    \
  1641.   ((CODE) == '?' || (CODE) == '|' || (CODE) == '@')
  1642. /* Output an operand of an instruction.  */
  1643. #define PRINT_OPERAND(STREAM, X, CODE)  \
  1644.   arm_print_operand (STREAM, X, CODE)
  1645.  
  1646. #define ARM_SIGN_EXTEND(x)  ((HOST_WIDE_INT)        \
  1647.   (HOST_BITS_PER_WIDE_INT <= 32 ? (x)            \
  1648.    : (((x) & (unsigned HOST_WIDE_INT) 0xffffffff) |    \
  1649.       (((x) & (unsigned HOST_WIDE_INT) 0x80000000)    \
  1650.        ? ((~ (HOST_WIDE_INT) 0)                \
  1651.       & ~ (unsigned HOST_WIDE_INT) 0xffffffff)    \
  1652.        : 0))))
  1653.  
  1654. /* Output the address of an operand.  */
  1655. #define PRINT_OPERAND_ADDRESS(STREAM,X)  \
  1656. {                                    \
  1657.     int is_minus = GET_CODE (X) == MINUS;                \
  1658.                                     \
  1659.     if (GET_CODE (X) == REG)                        \
  1660.     fprintf (STREAM, "[%s%s, #0]", ARM_REG_PREFIX,            \
  1661.          reg_names[REGNO (X)]);                    \
  1662.     else if (GET_CODE (X) == PLUS || is_minus)                \
  1663.       {                                    \
  1664.     rtx base = XEXP (X, 0);                        \
  1665.     rtx index = XEXP (X, 1);                    \
  1666.     char *base_reg_name;                        \
  1667.     HOST_WIDE_INT offset = 0;                    \
  1668.     if (GET_CODE (base) != REG)                    \
  1669.       {                                \
  1670.         /* Ensure that BASE is a register (one of them must be). */    \
  1671.         rtx temp = base;                        \
  1672.         base = index;                        \
  1673.         index = temp;                        \
  1674.       }                                \
  1675.     base_reg_name = reg_names[REGNO (base)];            \
  1676.     switch (GET_CODE (index))                    \
  1677.       {                                \
  1678.       case CONST_INT:                        \
  1679.         offset = INTVAL (index);                    \
  1680.         if (is_minus)                        \
  1681.           offset = -offset;                        \
  1682.         fprintf (STREAM, "[%s%s, #%d]", ARM_REG_PREFIX,        \
  1683.              base_reg_name, offset);                \
  1684.         break;                            \
  1685.                                     \
  1686.       case REG:                            \
  1687.         fprintf (STREAM, "[%s%s, %s%s%s]", ARM_REG_PREFIX,        \
  1688.              base_reg_name, is_minus ? "-" : "",        \
  1689.              ARM_REG_PREFIX, reg_names[REGNO (index)] );    \
  1690.         break;                            \
  1691.                                     \
  1692.       case MULT:                            \
  1693.       case ASHIFTRT:                        \
  1694.       case LSHIFTRT:                        \
  1695.       case ASHIFT:                            \
  1696.       case ROTATERT:                        \
  1697.       {                                \
  1698.         fprintf (STREAM, "[%s%s, %s%s%s", ARM_REG_PREFIX,        \
  1699.              base_reg_name, is_minus ? "-" : "", ARM_REG_PREFIX,\
  1700.              reg_names[REGNO (XEXP (index, 0))]);        \
  1701.         arm_print_operand (STREAM, index, 'S');            \
  1702.         fputs ("]", STREAM);                    \
  1703.         break;                            \
  1704.       }                                \
  1705.                                         \
  1706.       default:                            \
  1707.         abort();                            \
  1708.     }                                \
  1709.     }                                        \
  1710.   else if (GET_CODE (X) == PRE_INC || GET_CODE (X) == POST_INC        \
  1711.        || GET_CODE (X) == PRE_DEC || GET_CODE (X) == POST_DEC)    \
  1712.     {                                    \
  1713.       extern int output_memory_reference_mode;                \
  1714.                                           \
  1715.       if (GET_CODE (XEXP (X, 0)) != REG)                \
  1716.     abort ();                            \
  1717.                                     \
  1718.       if (GET_CODE (X) == PRE_DEC || GET_CODE (X) == PRE_INC)        \
  1719.     fprintf (STREAM, "[%s%s, #%s%d]!", ARM_REG_PREFIX,        \
  1720.          reg_names[REGNO (XEXP (X, 0))],            \
  1721.          GET_CODE (X) == PRE_DEC ? "-" : "",            \
  1722.          GET_MODE_SIZE (output_memory_reference_mode));        \
  1723.       else                                \
  1724.     fprintf (STREAM, "[%s%s], #%s%d", ARM_REG_PREFIX,        \
  1725.          reg_names[REGNO (XEXP (X, 0))],            \
  1726.          GET_CODE (X) == POST_DEC ? "-" : "",            \
  1727.          GET_MODE_SIZE (output_memory_reference_mode));        \
  1728.     }                                    \
  1729.   else output_addr_const(STREAM, X);                    \
  1730. }
  1731.