home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / gcc / config / rs6000 / rs6000.h < prev    next >
C/C++ Source or Header  |  1995-11-08  |  96KB  |  2,558 lines

  1. /* Definitions of target machine for GNU compiler, for IBM RS/6000.
  2.    Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
  3.    Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
  4.  
  5. This file is part of GNU CC.
  6.  
  7. GNU CC is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2, or (at your option)
  10. any later version.
  11.  
  12. GNU CC is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with GNU CC; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 59 Temple Place - Suite 330,
  20. Boston, MA 02111-1307, USA.  */
  21.  
  22.  
  23. /* Note that some other tm.h files include this one and then override
  24.    many of the definitions that relate to assembler syntax.  */
  25.  
  26.  
  27. /* Names to predefine in the preprocessor for this target machine.  */
  28.  
  29. #define CPP_PREDEFINES "-D_IBMR2 -D_POWER -D_AIX -D_AIX32 \
  30. -Asystem(unix) -Asystem(aix) -Acpu(rs6000) -Amachine(rs6000)"
  31.  
  32. /* Print subsidiary information on the compiler version in use.  */
  33. #define TARGET_VERSION ;
  34.  
  35. /* Tell the assembler to assume that all undefined names are external.
  36.  
  37.    Don't do this until the fixed IBM assembler is more generally available.
  38.    When this becomes permanently defined, the ASM_OUTPUT_EXTERNAL,
  39.    ASM_OUTPUT_EXTERNAL_LIBCALL, and RS6000_OUTPUT_BASENAME macros will no
  40.    longer be needed.  Also, the extern declaration of mcount in ASM_FILE_START
  41.    will no longer be needed.  */
  42.  
  43. /* #define ASM_SPEC "-u" */
  44.  
  45. /* Define appropriate architecture macros for preprocessor depending on
  46.    target switches.  */
  47.  
  48. #define CPP_SPEC "\
  49. %{posix: -D_POSIX_SOURCE} \
  50. %{!mcpu*: \
  51.   %{mpower: %{!mpower2: -D_ARCH_PWR}} \
  52.   %{mpower2: -D_ARCH_PWR2} \
  53.   %{mpowerpc*: -D_ARCH_PPC} \
  54.   %{mno-power: %{!mpowerpc*: -D_ARCH_COM}} \
  55.   %{!mno-power: %{!mpower2: -D_ARCH_PWR}}} \
  56. %{mcpu=common: -D_ARCH_COM} \
  57. %{mcpu=power: -D_ARCH_PWR} \
  58. %{mcpu=powerpc: -D_ARCH_PPC} \
  59. %{mcpu=rios: -D_ARCH_PWR} \
  60. %{mcpu=rios1: -D_ARCH_PWR} \
  61. %{mcpu=rios2: -D_ARCH_PWR2} \
  62. %{mcpu=rsc: -D_ARCH_PWR} \
  63. %{mcpu=rsc1: -D_ARCH_PWR} \
  64. %{mcpu=403: -D_ARCH_PPC} \
  65. %{mcpu=601: -D_ARCH_PPC -D_ARCH_PWR} \
  66. %{mcpu=603: -D_ARCH_PPC} \
  67. %{mcpu=604: -D_ARCH_PPC}"
  68.  
  69. /* Define the options for the binder: Start text at 512, align all segments
  70.    to 512 bytes, and warn if there is text relocation.
  71.  
  72.    The -bhalt:4 option supposedly changes the level at which ld will abort,
  73.    but it also suppresses warnings about multiply defined symbols and is
  74.    used by the AIX cc command.  So we use it here.
  75.  
  76.    -bnodelcsect undoes a poor choice of default relating to multiply-defined
  77.    csects.  See AIX documentation for more information about this.
  78.  
  79.    -bM:SRE tells the linker that the output file is Shared REusable.  Note
  80.    that to actually build a shared library you will also need to specify an
  81.    export list with the -Wl,-bE option.  */
  82.  
  83. #define LINK_SPEC "-T512 -H512 %{!r:-btextro} -bhalt:4 -bnodelcsect\
  84.    %{static:-bnso -bI:/lib/syscalls.exp} \
  85.    %{!shared:%{g*:-bexport:/usr/lib/libg.exp}} %{shared:-bM:SRE}"
  86.  
  87. /* Profiled library versions are used by linking with special directories.  */
  88. #define LIB_SPEC "%{pg:-L/lib/profiled -L/usr/lib/profiled}\
  89.    %{p:-L/lib/profiled -L/usr/lib/profiled} %{!shared:%{g*:-lg}} -lc"
  90.  
  91. /* gcc must do the search itself to find libgcc.a, not use -l.  */
  92. #define LIBGCC_SPEC "libgcc.a%s"
  93.  
  94. /* Don't turn -B into -L if the argument specifies a relative file name.  */
  95. #define RELATIVE_PREFIX_NOT_LINKDIR
  96.  
  97. /* Architecture type.  */
  98.  
  99. extern int target_flags;
  100.  
  101. /* Use POWER architecture instructions and MQ register.  */
  102. #define MASK_POWER        0x01
  103.  
  104. /* Use POWER2 extensions to POWER architecture.  */
  105. #define MASK_POWER2        0x02
  106.  
  107. /* Use PowerPC architecture instructions.  */
  108. #define MASK_POWERPC        0x04
  109.  
  110. /* Use PowerPC General Purpose group optional instructions, e.g. fsqrt.  */
  111. #define MASK_PPC_GPOPT        0x08
  112.  
  113. /* Use PowerPC Graphics group optional instructions, e.g. fsel.  */
  114. #define MASK_PPC_GFXOPT        0x10
  115.  
  116. /* Use PowerPC-64 architecture instructions.  */
  117. #define MASK_POWERPC64        0x20
  118.  
  119. /* Use revised mnemonic names defined for PowerPC architecture.  */
  120. #define MASK_NEW_MNEMONICS    0x40
  121.  
  122. /* Disable placing fp constants in the TOC; can be turned on when the
  123.    TOC overflows.  */
  124. #define MASK_NO_FP_IN_TOC    0x80
  125.  
  126. /* Disable placing symbol+offset constants in the TOC; can be turned on when
  127.    the TOC overflows.  */
  128. #define MASK_NO_SUM_IN_TOC    0x100
  129.  
  130. /* Output only one TOC entry per module.  Normally linking fails if
  131.    there are more than 16K unique variables/constants in an executable.  With
  132.    this option, linking fails only if there are more than 16K modules, or
  133.    if there are more than 16K unique variables/constant in a single module.
  134.  
  135.    This is at the cost of having 2 extra loads and one extra store per
  136.    function, and one less allocatable register.  */
  137. #define MASK_MINIMAL_TOC    0x200
  138.  
  139. /* Nonzero for the 64bit model: ints, longs, and pointers are 64 bits.  */
  140. #define MASK_64BIT        0x400
  141.  
  142. /* Disable use of FPRs.  */
  143. #define MASK_SOFT_FLOAT        0x800
  144.  
  145. /* Enable load/store multiple, even on powerpc */
  146. #define    MASK_MULTIPLE        0x1000
  147. #define    MASK_MULTIPLE_SET    0x2000
  148.  
  149. /* Use string instructions for block moves */
  150. #define MASK_STRING        0x4000
  151. #define MASK_STRING_SET        0x8000
  152.  
  153. /* Temporary debug switches */
  154. #define MASK_DEBUG_STACK    0x10000
  155. #define MASK_DEBUG_ARG        0x20000
  156.  
  157. #define TARGET_POWER        (target_flags & MASK_POWER)
  158. #define TARGET_POWER2        (target_flags & MASK_POWER2)
  159. #define TARGET_POWERPC        (target_flags & MASK_POWERPC)
  160. #define TARGET_PPC_GPOPT    (target_flags & MASK_PPC_GPOPT)
  161. #define TARGET_PPC_GFXOPT    (target_flags & MASK_PPC_GFXOPT)
  162. #define TARGET_POWERPC64    (target_flags & MASK_POWERPC64)
  163. #define TARGET_NEW_MNEMONICS    (target_flags & MASK_NEW_MNEMONICS)
  164. #define TARGET_NO_FP_IN_TOC    (target_flags & MASK_NO_FP_IN_TOC)
  165. #define TARGET_NO_SUM_IN_TOC    (target_flags & MASK_NO_SUM_IN_TOC)
  166. #define TARGET_MINIMAL_TOC    (target_flags & MASK_MINIMAL_TOC)
  167. #define TARGET_64BIT        (target_flags & MASK_64BIT)
  168. #define TARGET_SOFT_FLOAT    (target_flags & MASK_SOFT_FLOAT)
  169. #define    TARGET_MULTIPLE        (target_flags & MASK_MULTIPLE)
  170. #define    TARGET_MULTIPLE_SET    (target_flags & MASK_MULTIPLE_SET)
  171. #define TARGET_STRING        (target_flags & MASK_STRING)
  172. #define TARGET_STRING_SET    (target_flags & MASK_STRING_SET)
  173. #define    TARGET_DEBUG_STACK    (target_flags & MASK_DEBUG_STACK)
  174. #define    TARGET_DEBUG_ARG    (target_flags & MASK_DEBUG_ARG)
  175.  
  176. #define TARGET_HARD_FLOAT    (! TARGET_SOFT_FLOAT)
  177.  
  178. /* Pseudo target to indicate whether the object format is ELF
  179.    (to get around not having conditional compilation in the md file)  */
  180. #ifndef    TARGET_ELF
  181. #define    TARGET_ELF        0
  182. #endif
  183.  
  184. /* If this isn't V.4, don't support -mno-toc.  */
  185. #ifndef TARGET_NO_TOC
  186. #define TARGET_NO_TOC        0
  187. #define    TARGET_TOC        1
  188. #endif
  189.  
  190. /* Run-time compilation parameters selecting different hardware subsets.
  191.  
  192.    Macro to define tables used to set the flags.
  193.    This is a list in braces of pairs in braces,
  194.    each pair being { "NAME", VALUE }
  195.    where VALUE is the bits to set or minus the bits to clear.
  196.    An empty string NAME is used to identify the default VALUE.  */
  197.  
  198. /* This is meant to be redefined in the host dependent files */
  199. #ifndef SUBTARGET_SWITCHES
  200. #define SUBTARGET_SWITCHES
  201. #endif
  202.  
  203. #define TARGET_SWITCHES                            \
  204.  {{"power",        MASK_POWER  | MASK_MULTIPLE | MASK_STRING},    \
  205.   {"power2",        (MASK_POWER | MASK_MULTIPLE | MASK_STRING    \
  206.              | MASK_POWER2)},                \
  207.   {"no-power2",        - MASK_POWER2},                    \
  208.   {"no-power",        - (MASK_POWER | MASK_POWER2 | MASK_MULTIPLE    \
  209.                | MASK_STRING)},                \
  210.   {"powerpc",        MASK_POWERPC},                    \
  211.   {"no-powerpc",    - (MASK_POWERPC | MASK_PPC_GPOPT        \
  212.                | MASK_PPC_GFXOPT | MASK_POWERPC64)},    \
  213.   {"powerpc-gpopt",    MASK_POWERPC | MASK_PPC_GPOPT},            \
  214.   {"no-powerpc-gpopt",    - MASK_PPC_GPOPT},                \
  215.   {"powerpc-gfxopt",    MASK_POWERPC | MASK_PPC_GFXOPT},        \
  216.   {"no-powerpc-gfxopt",    - MASK_PPC_GFXOPT},                \
  217.   {"new-mnemonics",    MASK_NEW_MNEMONICS},                \
  218.   {"old-mnemonics",    -MASK_NEW_MNEMONICS},                \
  219.   {"full-toc",        - (MASK_NO_FP_IN_TOC | MASK_NO_SUM_IN_TOC    \
  220.                | MASK_MINIMAL_TOC)},            \
  221.   {"fp-in-toc",        - MASK_NO_FP_IN_TOC},                \
  222.   {"no-fp-in-toc",    MASK_NO_FP_IN_TOC},                \
  223.   {"sum-in-toc",    - MASK_NO_SUM_IN_TOC},                \
  224.   {"no-sum-in-toc",    MASK_NO_SUM_IN_TOC},                \
  225.   {"minimal-toc",    MASK_MINIMAL_TOC},                \
  226.   {"minimal-toc",    - (MASK_NO_FP_IN_TOC | MASK_NO_SUM_IN_TOC)},    \
  227.   {"no-minimal-toc",    - MASK_MINIMAL_TOC},                \
  228.   {"hard-float",    - MASK_SOFT_FLOAT},                \
  229.   {"soft-float",    MASK_SOFT_FLOAT},                \
  230.   {"multiple",        MASK_MULTIPLE | MASK_MULTIPLE_SET},        \
  231.   {"no-multiple",    - MASK_MULTIPLE},                \
  232.   {"no-multiple",    MASK_MULTIPLE_SET},                \
  233.   {"string",        MASK_STRING | MASK_STRING_SET},            \
  234.   {"no-string",        - MASK_STRING},                    \
  235.   {"no-string",        MASK_STRING_SET},                \
  236.   {"debug-stack",    MASK_DEBUG_STACK},                \
  237.   {"debug-arg",        MASK_DEBUG_ARG},                \
  238.   SUBTARGET_SWITCHES                            \
  239.   {"",            TARGET_DEFAULT}}
  240.  
  241. #define TARGET_DEFAULT (MASK_POWER | MASK_MULTIPLE | MASK_STRING)
  242.  
  243. /* Processor type.  */
  244. enum processor_type
  245.  {PROCESSOR_RIOS1,
  246.   PROCESSOR_RIOS2,
  247.   PROCESSOR_PPC403,
  248.   PROCESSOR_PPC601,
  249.   PROCESSOR_PPC603,
  250.   PROCESSOR_PPC604,
  251.   PROCESSOR_PPC620};
  252.  
  253. extern enum processor_type rs6000_cpu;
  254.  
  255. /* Recast the processor type to the cpu attribute.  */
  256. #define rs6000_cpu_attr ((enum attr_cpu)rs6000_cpu)
  257.  
  258. /* Define generic processor types based upon current deployment.  */
  259. #define PROCESSOR_COMMON  PROCESSOR_PPC601
  260. #define PROCESSOR_POWER   PROCESSOR_RIOS1
  261. #define PROCESSOR_POWERPC PROCESSOR_PPC601
  262.  
  263. /* Define the default processor.  This is overridden by other tm.h files.  */
  264. #define PROCESSOR_DEFAULT PROCESSOR_RIOS1
  265.  
  266. /* Specify the dialect of assembler to use.  New mnemonics is dialect one
  267.    and the old mnemonics are dialect zero.  */
  268. #define ASSEMBLER_DIALECT TARGET_NEW_MNEMONICS ? 1 : 0
  269.  
  270. /* This macro is similar to `TARGET_SWITCHES' but defines names of
  271.    command options that have values.  Its definition is an
  272.    initializer with a subgrouping for each command option.
  273.  
  274.    Each subgrouping contains a string constant, that defines the
  275.    fixed part of the option name, and the address of a variable.
  276.    The variable, type `char *', is set to the variable part of the
  277.    given option if the fixed part matches.  The actual option name
  278.    is made by appending `-m' to the specified name.
  279.  
  280.    Here is an example which defines `-mshort-data-NUMBER'.  If the
  281.    given option is `-mshort-data-512', the variable `m88k_short_data'
  282.    will be set to the string `"512"'.
  283.  
  284.     extern char *m88k_short_data;
  285.     #define TARGET_OPTIONS { { "short-data-", &m88k_short_data } }  */
  286.  
  287. #define TARGET_OPTIONS        \
  288. { {"cpu=", &rs6000_cpu_string}}
  289.  
  290. extern char *rs6000_cpu_string;
  291.  
  292. /* Sometimes certain combinations of command options do not make sense
  293.    on a particular target machine.  You can define a macro
  294.    `OVERRIDE_OPTIONS' to take account of this.  This macro, if
  295.    defined, is executed once just after all the command options have
  296.    been parsed.
  297.  
  298.    On the RS/6000 this is used to define the target cpu type.  */
  299.  
  300. #define OVERRIDE_OPTIONS rs6000_override_options ()
  301.  
  302. /* Show we can debug even without a frame pointer.  */
  303. #define CAN_DEBUG_WITHOUT_FP
  304.  
  305. /* target machine storage layout */
  306.  
  307. /* Define to support cross compilation to an RS6000 target.  */
  308. #define REAL_ARITHMETIC
  309.  
  310. /* Define this macro if it is advisable to hold scalars in registers
  311.    in a wider mode than that declared by the program.  In such cases, 
  312.    the value is constrained to be within the bounds of the declared
  313.    type, but kept valid in the wider mode.  The signedness of the
  314.    extension may differ from that of the type.  */
  315.  
  316. #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE)  \
  317.   if (GET_MODE_CLASS (MODE) == MODE_INT    \
  318.       && GET_MODE_SIZE (MODE) < 4)      \
  319.     (MODE) = SImode;
  320.  
  321. /* Define this if most significant bit is lowest numbered
  322.    in instructions that operate on numbered bit-fields. */
  323. /* That is true on RS/6000. */
  324. #define BITS_BIG_ENDIAN 1
  325.  
  326. /* Define this if most significant byte of a word is the lowest numbered.  */
  327. /* That is true on RS/6000.  */
  328. #define BYTES_BIG_ENDIAN 1
  329.  
  330. /* Define this if most significant word of a multiword number is lowest
  331.    numbered. 
  332.  
  333.    For RS/6000 we can decide arbitrarily since there are no machine
  334.    instructions for them.  Might as well be consistent with bits and bytes. */
  335. #define WORDS_BIG_ENDIAN 1
  336.  
  337. /* number of bits in an addressable storage unit */
  338. #define BITS_PER_UNIT 8
  339.  
  340. /* Width in bits of a "word", which is the contents of a machine register.
  341.    Note that this is not necessarily the width of data type `int';
  342.    if using 16-bit ints on a 68000, this would still be 32.
  343.    But on a machine with 16-bit registers, this would be 16.  */
  344. #define BITS_PER_WORD (TARGET_POWERPC64 ? 64 : 32)
  345. #define MAX_BITS_PER_WORD 64
  346.  
  347. /* Width of a word, in units (bytes).  */
  348. #define UNITS_PER_WORD (TARGET_POWERPC64 ? 8 : 4)
  349. #define MIN_UNITS_PER_WORD 4
  350. #define UNITS_PER_FP_WORD 8
  351.  
  352. /* Type used for ptrdiff_t, as a string used in a declaration.  */
  353. #define PTRDIFF_TYPE "int"
  354.  
  355. /* Type used for wchar_t, as a string used in a declaration.  */
  356. #define WCHAR_TYPE "short unsigned int"
  357.  
  358. /* Width of wchar_t in bits.  */
  359. #define WCHAR_TYPE_SIZE 16
  360.  
  361. /* A C expression for the size in bits of the type `short' on the
  362.    target machine.  If you don't define this, the default is half a
  363.    word.  (If this would be less than one storage unit, it is
  364.    rounded up to one unit.)  */
  365. #define SHORT_TYPE_SIZE 16
  366.  
  367. /* A C expression for the size in bits of the type `int' on the
  368.    target machine.  If you don't define this, the default is one
  369.    word.  */
  370. #define INT_TYPE_SIZE (TARGET_64BIT ? 64 : 32)
  371. #define MAX_INT_TYPE_SIZE 64
  372.  
  373. /* A C expression for the size in bits of the type `long' on the
  374.    target machine.  If you don't define this, the default is one
  375.    word.  */
  376. #define LONG_TYPE_SIZE (TARGET_64BIT ? 64 : 32)
  377. #define MAX_LONG_TYPE_SIZE 64
  378.  
  379. /* A C expression for the size in bits of the type `long long' on the
  380.    target machine.  If you don't define this, the default is two
  381.    words.  */
  382. #define LONG_LONG_TYPE_SIZE 64
  383.  
  384. /* A C expression for the size in bits of the type `char' on the
  385.    target machine.  If you don't define this, the default is one
  386.    quarter of a word.  (If this would be less than one storage unit,
  387.    it is rounded up to one unit.)  */
  388. #define CHAR_TYPE_SIZE BITS_PER_UNIT
  389.  
  390. /* A C expression for the size in bits of the type `float' on the
  391.    target machine.  If you don't define this, the default is one
  392.    word.  */
  393. #define FLOAT_TYPE_SIZE 32
  394.  
  395. /* A C expression for the size in bits of the type `double' on the
  396.    target machine.  If you don't define this, the default is two
  397.    words.  */
  398. #define DOUBLE_TYPE_SIZE 64
  399.  
  400. /* A C expression for the size in bits of the type `long double' on
  401.    the target machine.  If you don't define this, the default is two
  402.    words.  */
  403. #define LONG_DOUBLE_TYPE_SIZE 64
  404.  
  405. /* Width in bits of a pointer.
  406.    See also the macro `Pmode' defined below.  */
  407. #define POINTER_SIZE (TARGET_64BIT ? 64 : 32)
  408.  
  409. /* Allocation boundary (in *bits*) for storing arguments in argument list.  */
  410. #define PARM_BOUNDARY (TARGET_64BIT ? 64 : 32)
  411.  
  412. /* Boundary (in *bits*) on which stack pointer should be aligned.  */
  413. #define STACK_BOUNDARY 64
  414.  
  415. /* Allocation boundary (in *bits*) for the code of a function.  */
  416. #define FUNCTION_BOUNDARY 32
  417.  
  418. /* No data type wants to be aligned rounder than this.  */
  419. #define BIGGEST_ALIGNMENT (TARGET_64BIT ? 64 : 32)
  420.  
  421. /* Alignment of field after `int : 0' in a structure.  */
  422. #define EMPTY_FIELD_BOUNDARY 32
  423.  
  424. /* Every structure's size must be a multiple of this.  */
  425. #define STRUCTURE_SIZE_BOUNDARY 8
  426.  
  427. /* A bitfield declared as `int' forces `int' alignment for the struct.  */
  428. #define PCC_BITFIELD_TYPE_MATTERS 1
  429.  
  430. /* Make strings word-aligned so strcpy from constants will be faster.  */
  431. #define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
  432.   (TREE_CODE (EXP) == STRING_CST    \
  433.    && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
  434.  
  435. /* Make arrays of chars word-aligned for the same reasons.  */
  436. #define DATA_ALIGNMENT(TYPE, ALIGN)        \
  437.   (TREE_CODE (TYPE) == ARRAY_TYPE        \
  438.    && TYPE_MODE (TREE_TYPE (TYPE)) == QImode    \
  439.    && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
  440.  
  441. /* Non-zero if move instructions will actually fail to work
  442.    when given unaligned data.  */
  443. #define STRICT_ALIGNMENT 0
  444.  
  445. /* Standard register usage.  */
  446.  
  447. /* Number of actual hardware registers.
  448.    The hardware registers are assigned numbers for the compiler
  449.    from 0 to just below FIRST_PSEUDO_REGISTER.
  450.    All registers that the compiler knows about must be given numbers,
  451.    even those that are not normally considered general registers.
  452.  
  453.    RS/6000 has 32 fixed-point registers, 32 floating-point registers,
  454.    an MQ register, a count register, a link register, and 8 condition
  455.    register fields, which we view here as separate registers.
  456.  
  457.    In addition, the difference between the frame and argument pointers is
  458.    a function of the number of registers saved, so we need to have a
  459.    register for AP that will later be eliminated in favor of SP or FP.
  460.    This is a normal register, but it is fixed.  */
  461.  
  462. #define FIRST_PSEUDO_REGISTER 76
  463.  
  464. /* 1 for registers that have pervasive standard uses
  465.    and are not available for the register allocator.
  466.  
  467.    On RS/6000, r1 is used for the stack and r2 is used as the TOC pointer.  
  468.  
  469.    cr5 is not supposed to be used.
  470.  
  471.    On System V implementations, r13 is fixed and not available for use.  */
  472.  
  473. #ifndef FIXED_R13
  474. #define FIXED_R13 0
  475. #endif
  476.  
  477. #define FIXED_REGISTERS  \
  478.   {0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FIXED_R13, 0, 0, \
  479.    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
  480.    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
  481.    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
  482.    0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0}
  483.  
  484. /* 1 for registers not available across function calls.
  485.    These must include the FIXED_REGISTERS and also any
  486.    registers that can be used without being saved.
  487.    The latter must include the registers where values are returned
  488.    and the register where structure-value addresses are passed.
  489.    Aside from that, you can include as many other registers as you like.  */
  490.  
  491. #define CALL_USED_REGISTERS  \
  492.   {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, FIXED_R13, 0, 0, \
  493.    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
  494.    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, \
  495.    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
  496.    1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1}
  497.  
  498. /* List the order in which to allocate registers.  Each register must be
  499.    listed once, even those in FIXED_REGISTERS.
  500.  
  501.    We allocate in the following order:
  502.     fp0        (not saved or used for anything)
  503.     fp13 - fp2    (not saved; incoming fp arg registers)
  504.     fp1        (not saved; return value)
  505.      fp31 - fp14    (saved; order given to save least number)
  506.     cr1, cr6, cr7    (not saved or special)
  507.     cr0        (not saved, but used for arithmetic operations)
  508.     cr2, cr3, cr4    (saved)
  509.         r0        (not saved; cannot be base reg)
  510.     r9        (not saved; best for TImode)
  511.     r11, r10, r8-r4    (not saved; highest used first to make less conflict)
  512.     r3             (not saved; return value register)
  513.     r31 - r13    (saved; order given to save least number)
  514.     r12        (not saved; if used for DImode or DFmode would use r13)
  515.     mq        (not saved; best to use it if we can)
  516.     ctr        (not saved; when we have the choice ctr is better)
  517.     lr        (saved)
  518.         cr5, r1, r2, ap    (fixed)  */
  519.  
  520. #define REG_ALLOC_ORDER                    \
  521.   {32,                             \
  522.    45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34,    \
  523.    33,                            \
  524.    63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51,    \
  525.    50, 49, 48, 47, 46,                     \
  526.    69, 74, 75, 68, 70, 71, 72,                \
  527.    0,                            \
  528.    9, 11, 10, 8, 7, 6, 5, 4,                \
  529.    3,                            \
  530.    31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19,    \
  531.    18, 17, 16, 15, 14, 13, 12,                \
  532.    64, 66, 65,                         \
  533.    73, 1, 2, 67}
  534.  
  535. /* True if register is floating-point.  */
  536. #define FP_REGNO_P(N) ((N) >= 32 && (N) <= 63)
  537.  
  538. /* True if register is a condition register.  */
  539. #define CR_REGNO_P(N) ((N) >= 68 && (N) <= 75)
  540.  
  541. /* True if register is an integer register.  */
  542. #define INT_REGNO_P(N) ((N) <= 31 || (N) == 67)
  543.  
  544. /* Return number of consecutive hard regs needed starting at reg REGNO
  545.    to hold something of mode MODE.
  546.    This is ordinarily the length in words of a value of mode MODE
  547.    but can be less for certain modes in special long registers.
  548.  
  549.    On RS/6000, ordinary registers hold 32 bits worth;
  550.    a single floating point register holds 64 bits worth.  */
  551.  
  552. #define HARD_REGNO_NREGS(REGNO, MODE)   \
  553.   (FP_REGNO_P (REGNO)            \
  554.    ? ((GET_MODE_SIZE (MODE) + UNITS_PER_FP_WORD - 1) / UNITS_PER_FP_WORD) \
  555.    : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
  556.  
  557. /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
  558.    For POWER and PowerPC, the GPRs can hold any mode, but the float
  559.    registers only can hold floating modes and DImode, and CR register only
  560.    can hold CC modes.  We cannot put TImode anywhere except general
  561.    register and it must be able to fit within the register set. */
  562.  
  563. #define HARD_REGNO_MODE_OK(REGNO, MODE) \
  564.   (FP_REGNO_P (REGNO) ?                        \
  565.    (GET_MODE_CLASS (MODE) == MODE_FLOAT                \
  566.     || (GET_MODE_CLASS (MODE) == MODE_INT            \
  567.     && GET_MODE_SIZE (MODE) == UNITS_PER_FP_WORD))        \
  568.    : CR_REGNO_P (REGNO) ? GET_MODE_CLASS (MODE) == MODE_CC    \
  569.    : ! INT_REGNO_P (REGNO) ? (GET_MODE_CLASS (MODE) == MODE_INT    \
  570.                   && GET_MODE_SIZE (MODE) <= UNITS_PER_WORD) \
  571.    : 1)
  572.  
  573. /* Value is 1 if it is a good idea to tie two pseudo registers
  574.    when one has mode MODE1 and one has mode MODE2.
  575.    If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
  576.    for any hard reg, then this must be 0 for correct output.  */
  577. #define MODES_TIEABLE_P(MODE1, MODE2) \
  578.   (GET_MODE_CLASS (MODE1) == MODE_FLOAT        \
  579.    ? GET_MODE_CLASS (MODE2) == MODE_FLOAT    \
  580.    : GET_MODE_CLASS (MODE2) == MODE_FLOAT    \
  581.    ? GET_MODE_CLASS (MODE1) == MODE_FLOAT    \
  582.    : GET_MODE_CLASS (MODE1) == MODE_CC        \
  583.    ? GET_MODE_CLASS (MODE2) == MODE_CC        \
  584.    : GET_MODE_CLASS (MODE2) == MODE_CC        \
  585.    ? GET_MODE_CLASS (MODE1) == MODE_CC        \
  586.    : 1)
  587.  
  588. /* A C expression returning the cost of moving data from a register of class
  589.    CLASS1 to one of CLASS2.
  590.  
  591.    On the RS/6000, copying between floating-point and fixed-point
  592.    registers is expensive.  */
  593.  
  594. #define REGISTER_MOVE_COST(CLASS1, CLASS2)            \
  595.   ((CLASS1) == FLOAT_REGS && (CLASS2) == FLOAT_REGS ? 2        \
  596.    : (CLASS1) == FLOAT_REGS && (CLASS2) != FLOAT_REGS ? 10    \
  597.    : (CLASS1) != FLOAT_REGS && (CLASS2) == FLOAT_REGS ? 10    \
  598.    : (((CLASS1) == SPECIAL_REGS || (CLASS1) == MQ_REGS        \
  599.        || (CLASS1) == LINK_REGS || (CLASS1) == CTR_REGS        \
  600.        || (CLASS1) == LINK_OR_CTR_REGS)                \
  601.       && ((CLASS2) == SPECIAL_REGS || (CLASS2) == MQ_REGS    \
  602.       || (CLASS2) == LINK_REGS || (CLASS2) == CTR_REGS    \
  603.       || (CLASS2) == LINK_OR_CTR_REGS)) ? 10 \
  604.    : 2)
  605.  
  606. /* A C expressions returning the cost of moving data of MODE from a register to
  607.    or from memory.
  608.  
  609.    On the RS/6000, bump this up a bit.  */
  610.  
  611. #define MEMORY_MOVE_COST(MODE)        \
  612.   ((GET_MODE_CLASS (MODE) == MODE_FLOAT    \
  613.     && (rs6000_cpu == PROCESSOR_RIOS1 || rs6000_cpu == PROCESSOR_PPC601) \
  614.     ? 3 : 2) \
  615.    + 4)
  616.  
  617. /* Specify the cost of a branch insn; roughly the number of extra insns that
  618.    should be added to avoid a branch.
  619.  
  620.    Set this to 3 on the RS/6000 since that is roughly the average cost of an
  621.    unscheduled conditional branch.  */
  622.  
  623. #define BRANCH_COST 3
  624.  
  625. /* A C statement (sans semicolon) to update the integer variable COST
  626.    based on the relationship between INSN that is dependent on
  627.    DEP_INSN through the dependence LINK.  The default is to make no
  628.    adjustment to COST.  On the RS/6000, ignore the cost of anti- and
  629.    output-dependencies.  In fact, output dependencies on the CR do have
  630.    a cost, but it is probably not worthwhile to track it.  */
  631.  
  632. #define ADJUST_COST(INSN,LINK,DEP_INSN,COST)                \
  633.   (COST) = rs6000_adjust_cost (INSN,LINK,DEP_INSN,COST)
  634.  
  635. /* Define this macro to change register usage conditional on target flags.
  636.    Set MQ register fixed (already call_used) if not POWER architecture
  637.    (RIOS1, RIOS2, RSC, and PPC601) so that it will not be allocated.
  638.    Conditionally disable FPRs.  */
  639.  
  640. #define CONDITIONAL_REGISTER_USAGE    \
  641. {                    \
  642.   if (! TARGET_POWER)            \
  643.     fixed_regs[64] = 1;            \
  644.   if (TARGET_SOFT_FLOAT)        \
  645.     for (i = 32; i < 64; i++)        \
  646.       fixed_regs[i] = call_used_regs[i] = 1; \
  647. }
  648.  
  649. /* Specify the registers used for certain standard purposes.
  650.    The values of these macros are register numbers.  */
  651.  
  652. /* RS/6000 pc isn't overloaded on a register that the compiler knows about.  */
  653. /* #define PC_REGNUM  */
  654.  
  655. /* Register to use for pushing function arguments.  */
  656. #define STACK_POINTER_REGNUM 1
  657.  
  658. /* Base register for access to local variables of the function.  */
  659. #define FRAME_POINTER_REGNUM 31
  660.  
  661. /* Value should be nonzero if functions must have frame pointers.
  662.    Zero means the frame pointer need not be set up (and parms
  663.    may be accessed via the stack pointer) in functions that seem suitable.
  664.    This is computed in `reload', in reload1.c.  */
  665. #define FRAME_POINTER_REQUIRED 0
  666.  
  667. /* Base register for access to arguments of the function.  */
  668. #define ARG_POINTER_REGNUM 67
  669.  
  670. /* Place to put static chain when calling a function that requires it.  */
  671. #define STATIC_CHAIN_REGNUM 11
  672.  
  673. /* Place that structure value return address is placed.
  674.  
  675.    On the RS/6000, it is passed as an extra parameter.  */
  676. #define STRUCT_VALUE    0
  677.  
  678. /* Define the classes of registers for register constraints in the
  679.    machine description.  Also define ranges of constants.
  680.  
  681.    One of the classes must always be named ALL_REGS and include all hard regs.
  682.    If there is more than one class, another class must be named NO_REGS
  683.    and contain no registers.
  684.  
  685.    The name GENERAL_REGS must be the name of a class (or an alias for
  686.    another name such as ALL_REGS).  This is the class of registers
  687.    that is allowed by "g" or "r" in a register constraint.
  688.    Also, registers outside this class are allocated only when
  689.    instructions express preferences for them.
  690.  
  691.    The classes must be numbered in nondecreasing order; that is,
  692.    a larger-numbered class must never be contained completely
  693.    in a smaller-numbered class.
  694.  
  695.    For any two classes, it is very desirable that there be another
  696.    class that represents their union.  */
  697.    
  698. /* The RS/6000 has three types of registers, fixed-point, floating-point,
  699.    and condition registers, plus three special registers, MQ, CTR, and the
  700.    link register.
  701.  
  702.    However, r0 is special in that it cannot be used as a base register.
  703.    So make a class for registers valid as base registers.
  704.  
  705.    Also, cr0 is the only condition code register that can be used in
  706.    arithmetic insns, so make a separate class for it. */
  707.  
  708. enum reg_class { NO_REGS, BASE_REGS, GENERAL_REGS, FLOAT_REGS,
  709.   NON_SPECIAL_REGS, MQ_REGS, LINK_REGS, CTR_REGS, LINK_OR_CTR_REGS,
  710.   SPECIAL_REGS, SPEC_OR_GEN_REGS, CR0_REGS, CR_REGS, NON_FLOAT_REGS,
  711.   ALL_REGS, LIM_REG_CLASSES };
  712.  
  713. #define N_REG_CLASSES (int) LIM_REG_CLASSES
  714.  
  715. /* Give names of register classes as strings for dump file.   */
  716.  
  717. #define REG_CLASS_NAMES                         \
  718.   { "NO_REGS", "BASE_REGS", "GENERAL_REGS", "FLOAT_REGS",    \
  719.     "NON_SPECIAL_REGS", "MQ_REGS", "LINK_REGS", "CTR_REGS",    \
  720.     "LINK_OR_CTR_REGS", "SPECIAL_REGS", "SPEC_OR_GEN_REGS",    \
  721.     "CR0_REGS", "CR_REGS", "NON_FLOAT_REGS", "ALL_REGS" }
  722.  
  723. /* Define which registers fit in which classes.
  724.    This is an initializer for a vector of HARD_REG_SET
  725.    of length N_REG_CLASSES.  */
  726.  
  727. #define REG_CLASS_CONTENTS                \
  728.   { {0, 0, 0}, {0xfffffffe, 0, 8}, {~0, 0, 8},        \
  729.     {0, ~0, 0}, {~0, ~0, 8}, {0, 0, 1}, {0, 0, 2},    \
  730.     {0, 0, 4}, {0, 0, 6}, {0, 0, 7}, {~0, 0, 15},    \
  731.     {0, 0, 16}, {0, 0, 0xff0}, {~0, 0, 0xffff},        \
  732.     {~0, ~0, 0xffff} }
  733.  
  734. /* The same information, inverted:
  735.    Return the class number of the smallest class containing
  736.    reg number REGNO.  This could be a conditional expression
  737.    or could index an array.  */
  738.  
  739. #define REGNO_REG_CLASS(REGNO)    \
  740.  ((REGNO) == 0 ? GENERAL_REGS    \
  741.   : (REGNO) < 32 ? BASE_REGS    \
  742.   : FP_REGNO_P (REGNO) ? FLOAT_REGS \
  743.   : (REGNO) == 68 ? CR0_REGS    \
  744.   : CR_REGNO_P (REGNO) ? CR_REGS \
  745.   : (REGNO) == 64 ? MQ_REGS    \
  746.   : (REGNO) == 65 ? LINK_REGS    \
  747.   : (REGNO) == 66 ? CTR_REGS    \
  748.   : (REGNO) == 67 ? BASE_REGS    \
  749.   : NO_REGS)
  750.  
  751. /* The class value for index registers, and the one for base regs.  */
  752. #define INDEX_REG_CLASS GENERAL_REGS
  753. #define BASE_REG_CLASS BASE_REGS
  754.  
  755. /* Get reg_class from a letter such as appears in the machine description.  */
  756.  
  757. #define REG_CLASS_FROM_LETTER(C) \
  758.   ((C) == 'f' ? FLOAT_REGS    \
  759.    : (C) == 'b' ? BASE_REGS    \
  760.    : (C) == 'h' ? SPECIAL_REGS    \
  761.    : (C) == 'q' ? MQ_REGS    \
  762.    : (C) == 'c' ? CTR_REGS    \
  763.    : (C) == 'l' ? LINK_REGS    \
  764.    : (C) == 'x' ? CR0_REGS    \
  765.    : (C) == 'y' ? CR_REGS    \
  766.    : NO_REGS)
  767.  
  768. /* The letters I, J, K, L, M, N, and P in a register constraint string
  769.    can be used to stand for particular ranges of immediate operands.
  770.    This macro defines what the ranges are.
  771.    C is the letter, and VALUE is a constant value.
  772.    Return 1 if VALUE is in the range specified by C.
  773.  
  774.    `I' is signed 16-bit constants 
  775.    `J' is a constant with only the high-order 16 bits non-zero
  776.    `K' is a constant with only the low-order 16 bits non-zero
  777.    `L' is a constant that can be placed into a mask operand
  778.    `M' is a constant that is greater than 31
  779.    `N' is a constant that is an exact power of two
  780.    `O' is the constant zero
  781.    `P' is a constant whose negation is a signed 16-bit constant */
  782.  
  783. #define CONST_OK_FOR_LETTER_P(VALUE, C)                \
  784.    ( (C) == 'I' ? (unsigned) ((VALUE) + 0x8000) < 0x10000    \
  785.    : (C) == 'J' ? ((VALUE) & 0xffff) == 0            \
  786.    : (C) == 'K' ? ((VALUE) & 0xffff0000) == 0            \
  787.    : (C) == 'L' ? mask_constant (VALUE)                \
  788.    : (C) == 'M' ? (VALUE) > 31                    \
  789.    : (C) == 'N' ? exact_log2 (VALUE) >= 0            \
  790.    : (C) == 'O' ? (VALUE) == 0                    \
  791.    : (C) == 'P' ? (unsigned) ((- (VALUE)) + 0x8000) < 0x1000    \
  792.    : 0)
  793.  
  794. /* Similar, but for floating constants, and defining letters G and H.
  795.    Here VALUE is the CONST_DOUBLE rtx itself.
  796.  
  797.    We flag for special constants when we can copy the constant into
  798.    a general register in two insns for DF and one insn for SF.  */
  799.  
  800. #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C)  \
  801.   ((C) == 'G' ? easy_fp_constant (VALUE, GET_MODE (VALUE)) : 0)
  802.  
  803. /* Optional extra constraints for this machine.
  804.  
  805.    For the RS/6000, `Q' means that this is a memory operand that is just
  806.    an offset from a register.  */
  807.  
  808. #define EXTRA_CONSTRAINT(OP, C)                        \
  809.   ((C) == 'Q' ? GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == REG    \
  810.    : (C) == 'R' ? LEGITIMATE_CONSTANT_POOL_ADDRESS_P (OP)        \
  811.    : 0)
  812.  
  813. /* Given an rtx X being reloaded into a reg required to be
  814.    in class CLASS, return the class of reg to actually use.
  815.    In general this is just CLASS; but on some machines
  816.    in some cases it is preferable to use a more restrictive class. 
  817.  
  818.    On the RS/6000, we have to return NO_REGS when we want to reload a
  819.    floating-point CONST_DOUBLE to force it to be copied to memory.  */
  820.  
  821. #define PREFERRED_RELOAD_CLASS(X,CLASS)    \
  822.   ((GET_CODE (X) == CONST_DOUBLE            \
  823.     && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT)    \
  824.    ? NO_REGS : (CLASS))
  825.    
  826. /* Return the register class of a scratch register needed to copy IN into
  827.    or out of a register in CLASS in MODE.  If it can be done directly,
  828.    NO_REGS is returned.  */
  829.  
  830. #define SECONDARY_RELOAD_CLASS(CLASS,MODE,IN) \
  831.   secondary_reload_class (CLASS, MODE, IN)
  832.  
  833. /* If we are copying between FP registers and anything else, we need a memory
  834.    location.  */
  835.  
  836. #define SECONDARY_MEMORY_NEEDED(CLASS1,CLASS2,MODE) \
  837.  ((CLASS1) != (CLASS2) && ((CLASS1) == FLOAT_REGS || (CLASS2) == FLOAT_REGS))
  838.  
  839. /* Return the maximum number of consecutive registers
  840.    needed to represent mode MODE in a register of class CLASS.
  841.  
  842.    On RS/6000, this is the size of MODE in words,
  843.    except in the FP regs, where a single reg is enough for two words.  */
  844. #define CLASS_MAX_NREGS(CLASS, MODE)    \
  845.  ((CLASS) == FLOAT_REGS            \
  846.   ? ((GET_MODE_SIZE (MODE) + UNITS_PER_FP_WORD - 1) / UNITS_PER_FP_WORD) \
  847.   : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
  848.  
  849. /* If defined, gives a class of registers that cannot be used as the
  850.    operand of a SUBREG that changes the size of the object.  */
  851.  
  852. #define CLASS_CANNOT_CHANGE_SIZE    FLOAT_REGS
  853.  
  854. /* Stack layout; function entry, exit and calling.  */
  855.  
  856. /* Enumeration to give which calling sequence to use.  */
  857. enum rs6000_abi {
  858.   ABI_NONE,
  859.   ABI_AIX,            /* IBM's AIX */
  860.   ABI_V4            /* System V.4/eabi */
  861. };
  862.  
  863. /* Structure used to define the rs6000 stack */
  864. typedef struct rs6000_stack {
  865.   int first_gp_reg_save;    /* first callee saved GP register used */
  866.   int first_fp_reg_save;    /* first callee saved FP register used */
  867.   int lr_save_p;        /* true if the link reg needs to be saved */
  868.   int cr_save_p;        /* true if the CR reg needs to be saved */
  869.   int push_p;            /* true if we need to allocate stack space */
  870.   int calls_p;            /* true if the function makes any calls */
  871.   enum rs6000_abi abi;        /* which ABI to use */
  872.   int gp_save_offset;        /* offset to save GP regs from initial SP */
  873.   int fp_save_offset;        /* offset to save FP regs from initial SP */
  874.   int lr_save_offset;        /* offset to save LR from initial SP */
  875.   int cr_save_offset;        /* offset to save CR from initial SP */
  876.   int varargs_save_offset;    /* offset to save the varargs registers */
  877.   int reg_size;            /* register size (4 or 8) */
  878.   int varargs_size;        /* size to hold V.4 args passed in regs */
  879.   int vars_size;        /* variable save area size */
  880.   int parm_size;        /* outgoing parameter size */
  881.   int save_size;        /* save area size */
  882.   int fixed_size;        /* fixed size of stack frame */
  883.   int gp_size;            /* size of saved GP registers */
  884.   int fp_size;            /* size of saved FP registers */
  885.   int cr_size;            /* size to hold CR if not in save_size */
  886.   int total_size;        /* total bytes allocated for stack */
  887. } rs6000_stack_t;
  888.  
  889. /* Define this if pushing a word on the stack
  890.    makes the stack pointer a smaller address.  */
  891. #define STACK_GROWS_DOWNWARD
  892.  
  893. /* Define this if the nominal address of the stack frame
  894.    is at the high-address end of the local variables;
  895.    that is, each additional local variable allocated
  896.    goes at a more negative offset in the frame.
  897.  
  898.    On the RS/6000, we grow upwards, from the area after the outgoing
  899.    arguments.  */
  900. /* #define FRAME_GROWS_DOWNWARD */
  901.  
  902. /* Size of the outgoing register save area */
  903. #define RS6000_REG_SAVE (TARGET_64BIT ? 64 : 32)
  904.  
  905. /* Size of the fixed area on the stack */
  906. #define RS6000_SAVE_AREA (TARGET_64BIT ? 48 : 24)
  907.  
  908. /* Size of the V.4 varargs area if needed */
  909. #define RS6000_VARARGS_AREA 0
  910.  
  911. /* Whether a V.4 varargs area is needed */
  912. extern int rs6000_sysv_varargs_p;
  913.  
  914. /* Align an address */
  915. #define ALIGN(n,a) (((n) + (a) - 1) & ~((a) - 1))
  916.  
  917. /* Size of V.4 varargs area in bytes */
  918. #define RS6000_VARARGS_SIZE \
  919.   ((GP_ARG_NUM_REG * (TARGET_64BIT ? 8 : 4)) + (FP_ARG_NUM_REG * 8) + 8)
  920.  
  921. /* Offset of V.4 varargs area */
  922. #define RS6000_VARARGS_OFFSET \
  923.   (ALIGN (current_function_outgoing_args_size, 8) + RS6000_SAVE_AREA)
  924.  
  925. /* Offset within stack frame to start allocating local variables at.
  926.    If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
  927.    first local allocated.  Otherwise, it is the offset to the BEGINNING
  928.    of the first local allocated. 
  929.  
  930.    On the RS/6000, the frame pointer is the same as the stack pointer,
  931.    except for dynamic allocations.  So we start after the fixed area and
  932.    outgoing parameter area.  */
  933.  
  934. #define STARTING_FRAME_OFFSET (ALIGN (current_function_outgoing_args_size, 8) \
  935.                    + RS6000_VARARGS_AREA \
  936.                    + RS6000_SAVE_AREA)
  937.  
  938. /* If we generate an insn to push BYTES bytes,
  939.    this says how many the stack pointer really advances by.
  940.    On RS/6000, don't define this because there are no push insns.  */
  941. /*  #define PUSH_ROUNDING(BYTES) */
  942.  
  943. /* Offset of first parameter from the argument pointer register value.
  944.    On the RS/6000, we define the argument pointer to the start of the fixed
  945.    area.  */
  946. #define FIRST_PARM_OFFSET(FNDECL) RS6000_SAVE_AREA
  947.  
  948. /* Define this if stack space is still allocated for a parameter passed
  949.    in a register.  The value is the number of bytes allocated to this
  950.    area.  */
  951. #define REG_PARM_STACK_SPACE(FNDECL)    RS6000_REG_SAVE
  952.  
  953. /* Define this if the above stack space is to be considered part of the
  954.    space allocated by the caller.  */
  955. #define OUTGOING_REG_PARM_STACK_SPACE
  956.  
  957. /* This is the difference between the logical top of stack and the actual sp.
  958.  
  959.    For the RS/6000, sp points past the fixed area. */
  960. #define STACK_POINTER_OFFSET RS6000_SAVE_AREA
  961.  
  962. /* Define this if the maximum size of all the outgoing args is to be
  963.    accumulated and pushed during the prologue.  The amount can be
  964.    found in the variable current_function_outgoing_args_size.  */
  965. #define ACCUMULATE_OUTGOING_ARGS
  966.  
  967. /* Value is the number of bytes of arguments automatically
  968.    popped when returning from a subroutine call.
  969.    FUNDECL is the declaration node of the function (as a tree),
  970.    FUNTYPE is the data type of the function (as a tree),
  971.    or for a library call it is an identifier node for the subroutine name.
  972.    SIZE is the number of bytes of arguments passed on the stack.  */
  973.  
  974. #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
  975.  
  976. /* Define how to find the value returned by a function.
  977.    VALTYPE is the data type of the value (as a tree).
  978.    If the precise function being called is known, FUNC is its FUNCTION_DECL;
  979.    otherwise, FUNC is 0.
  980.  
  981.    On RS/6000 an integer value is in r3 and a floating-point value is in 
  982.    fp1, unless -msoft-float.  */
  983.  
  984. #define FUNCTION_VALUE(VALTYPE, FUNC)    \
  985.   gen_rtx (REG, TYPE_MODE (VALTYPE),    \
  986.        TREE_CODE (VALTYPE) == REAL_TYPE && TARGET_HARD_FLOAT ? 33 : 3)
  987.  
  988. /* Define how to find the value returned by a library function
  989.    assuming the value has mode MODE.  */
  990.  
  991. #define LIBCALL_VALUE(MODE)        \
  992.   gen_rtx (REG, MODE, GET_MODE_CLASS (MODE) == MODE_FLOAT && TARGET_HARD_FLOAT ? 33 : 3)
  993.  
  994. /* The definition of this macro implies that there are cases where
  995.    a scalar value cannot be returned in registers.
  996.  
  997.    For the RS/6000, any structure or union type is returned in memory.  */
  998.  
  999. #define RETURN_IN_MEMORY(TYPE) \
  1000.   (TYPE_MODE (TYPE) == BLKmode)
  1001.  
  1002. /* Minimum and maximum general purpose registers used to hold arguments.  */
  1003. #define GP_ARG_MIN_REG 3
  1004. #define GP_ARG_MAX_REG 10
  1005. #define GP_ARG_NUM_REG (GP_ARG_MAX_REG - GP_ARG_MIN_REG + 1)
  1006.  
  1007. /* Minimum and maximum floating point registers used to hold arguments.  */
  1008. #define FP_ARG_MIN_REG 33
  1009. #define FP_ARG_MAX_REG 45
  1010. #define FP_ARG_NUM_REG (FP_ARG_MAX_REG - FP_ARG_MIN_REG + 1)
  1011.  
  1012. /* Return registers */
  1013. #define GP_ARG_RETURN GP_ARG_MIN_REG
  1014. #define FP_ARG_RETURN FP_ARG_MIN_REG
  1015.  
  1016. /* Define cutoff for using external functions to save floating point */
  1017. #define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) == 62 || (FIRST_REG) == 63)
  1018.  
  1019. /* 1 if N is a possible register number for a function value
  1020.    as seen by the caller.
  1021.  
  1022.    On RS/6000, this is r3 and fp1.  */
  1023. #define FUNCTION_VALUE_REGNO_P(N)  ((N) == GP_ARG_RETURN || ((N) == FP_ARG_RETURN))
  1024.  
  1025. /* 1 if N is a possible register number for function argument passing.
  1026.    On RS/6000, these are r3-r10 and fp1-fp13.  */
  1027. #define FUNCTION_ARG_REGNO_P(N)                        \
  1028.   (((unsigned)((N) - GP_ARG_MIN_REG) < (unsigned)(GP_ARG_NUM_REG))    \
  1029.    || ((unsigned)((N) - FP_ARG_MIN_REG) < (unsigned)(FP_ARG_NUM_REG)))
  1030.  
  1031.  
  1032. /* Define a data type for recording info about an argument list
  1033.    during the scan of that argument list.  This data type should
  1034.    hold all necessary information about the function itself
  1035.    and about the args processed so far, enough to enable macros
  1036.    such as FUNCTION_ARG to determine where the next arg should go.
  1037.  
  1038.    On the RS/6000, this is a structure.  The first element is the number of
  1039.    total argument words, the second is used to store the next
  1040.    floating-point register number, and the third says how many more args we
  1041.    have prototype types for.
  1042.  
  1043.    The System V.4 varargs/stdarg support requires that this structure's size
  1044.    be a multiple of sizeof(int), and that WORDS, FREGNO, NARGS_PROTOTYPE,
  1045.    ORIG_NARGS, and VARARGS_OFFSET be the first five ints.  */
  1046.  
  1047. typedef struct rs6000_args
  1048. {
  1049.   int words;            /* # words uses for passing GP registers */
  1050.   int fregno;            /* next available FP register */
  1051.   int nargs_prototype;        /* # args left in the current prototype */
  1052.   int orig_nargs;        /* Original value of nargs_prototype */
  1053.   int varargs_offset;        /* offset of the varargs save area */
  1054.   int prototype;        /* Whether a prototype was defined */
  1055. } CUMULATIVE_ARGS;
  1056.  
  1057. /* Define intermediate macro to compute the size (in registers) of an argument
  1058.    for the RS/6000.  */
  1059.  
  1060. #define RS6000_ARG_SIZE(MODE, TYPE, NAMED)                \
  1061. (! (NAMED) ? 0                                \
  1062.  : (MODE) != BLKmode                            \
  1063.  ? (GET_MODE_SIZE (MODE) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD     \
  1064.  : (int_size_in_bytes (TYPE) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
  1065.  
  1066. /* Initialize a variable CUM of type CUMULATIVE_ARGS
  1067.    for a call to a function whose data type is FNTYPE.
  1068.    For a library call, FNTYPE is 0.  */
  1069.  
  1070. #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME) \
  1071.   init_cumulative_args (&CUM, FNTYPE, LIBNAME, FALSE)
  1072.  
  1073. /* Similar, but when scanning the definition of a procedure.  We always
  1074.    set NARGS_PROTOTYPE large so we never return an EXPR_LIST.  */
  1075.  
  1076. #define INIT_CUMULATIVE_INCOMING_ARGS(CUM,FNTYPE,LIBNAME) \
  1077.   init_cumulative_args (&CUM, FNTYPE, LIBNAME, TRUE)
  1078.  
  1079. /* Update the data in CUM to advance over an argument
  1080.    of mode MODE and data type TYPE.
  1081.    (TYPE is null for libcalls where that information may not be available.)  */
  1082.  
  1083. #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)    \
  1084.   function_arg_advance (&CUM, MODE, TYPE, NAMED)
  1085.  
  1086. /* Non-zero if we can use a floating-point register to pass this arg.  */
  1087. #define USE_FP_FOR_ARG_P(CUM,MODE,TYPE) \
  1088.   (GET_MODE_CLASS (MODE) == MODE_FLOAT  \
  1089.    && (CUM).fregno <= FP_ARG_MAX_REG    \
  1090.    && TARGET_HARD_FLOAT)
  1091.  
  1092. /* Determine where to put an argument to a function.
  1093.    Value is zero to push the argument on the stack,
  1094.    or a hard register in which to store the argument.
  1095.  
  1096.    MODE is the argument's machine mode.
  1097.    TYPE is the data type of the argument (as a tree).
  1098.     This is null for libcalls where that information may
  1099.     not be available.
  1100.    CUM is a variable of type CUMULATIVE_ARGS which gives info about
  1101.     the preceding args and about the function being called.
  1102.    NAMED is nonzero if this argument is a named parameter
  1103.     (otherwise it is an extra parameter matching an ellipsis).
  1104.  
  1105.    On RS/6000 the first eight words of non-FP are normally in registers
  1106.    and the rest are pushed.  The first 13 FP args are in registers.
  1107.  
  1108.    If this is floating-point and no prototype is specified, we use
  1109.    both an FP and integer register (or possibly FP reg and stack).  Library
  1110.    functions (when TYPE is zero) always have the proper types for args,
  1111.    so we can pass the FP value just in one register.  emit_library_function
  1112.    doesn't support EXPR_LIST anyway.  */
  1113.  
  1114. #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
  1115.   function_arg (&CUM, MODE, TYPE, NAMED)
  1116.  
  1117. /* For an arg passed partly in registers and partly in memory,
  1118.    this is the number of registers used.
  1119.    For args passed entirely in registers or entirely in memory, zero.  */
  1120.  
  1121. #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
  1122.   function_arg_partial_nregs (&CUM, MODE, TYPE, NAMED)
  1123.  
  1124. /* A C expression that indicates when an argument must be passed by
  1125.    reference.  If nonzero for an argument, a copy of that argument is
  1126.    made in memory and a pointer to the argument is passed instead of
  1127.    the argument itself.  The pointer is passed in whatever way is
  1128.    appropriate for passing a pointer to that type. */
  1129.  
  1130. #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
  1131.   function_arg_pass_by_reference(&CUM, MODE, TYPE, NAMED)
  1132.  
  1133. /* Perform any needed actions needed for a function that is receiving a
  1134.    variable number of arguments. 
  1135.  
  1136.    CUM is as above.
  1137.  
  1138.    MODE and TYPE are the mode and type of the current parameter.
  1139.  
  1140.    PRETEND_SIZE is a variable that should be set to the amount of stack
  1141.    that must be pushed by the prolog to pretend that our caller pushed
  1142.    it.
  1143.  
  1144.    Normally, this macro will push all remaining incoming registers on the
  1145.    stack and set PRETEND_SIZE to the length of the registers pushed.  */
  1146.  
  1147. #define SETUP_INCOMING_VARARGS(CUM,MODE,TYPE,PRETEND_SIZE,NO_RTL) \
  1148.   setup_incoming_varargs (&CUM, MODE, TYPE, &PRETEND_SIZE, NO_RTL)
  1149.  
  1150. /* If defined, is a C expression that produces the machine-specific
  1151.    code for a call to `__builtin_saveregs'.  This code will be moved
  1152.    to the very beginning of the function, before any parameter access
  1153.    are made.  The return value of this function should be an RTX that
  1154.    contains the value to use as the return of `__builtin_saveregs'.
  1155.  
  1156.    The argument ARGS is a `tree_list' containing the arguments that
  1157.    were passed to `__builtin_saveregs'.
  1158.  
  1159.    If this macro is not defined, the compiler will output an ordinary
  1160.    call to the library function `__builtin_saveregs'.  */
  1161.  
  1162. #define EXPAND_BUILTIN_SAVEREGS(ARGS) \
  1163.   expand_builtin_saveregs (ARGS)
  1164.  
  1165. /* This macro generates the assembly code for function entry.
  1166.    FILE is a stdio stream to output the code to.
  1167.    SIZE is an int: how many units of temporary storage to allocate.
  1168.    Refer to the array `regs_ever_live' to determine which registers
  1169.    to save; `regs_ever_live[I]' is nonzero if register number I
  1170.    is ever used in the function.  This macro is responsible for
  1171.    knowing which registers should not be saved even if used.  */
  1172.  
  1173. #define FUNCTION_PROLOGUE(FILE, SIZE) output_prolog (FILE, SIZE)
  1174.  
  1175. /* Output assembler code to FILE to increment profiler label # LABELNO
  1176.    for profiling a function entry.  */
  1177.  
  1178. #define FUNCTION_PROFILER(FILE, LABELNO)    \
  1179.   output_function_profiler ((FILE), (LABELNO));
  1180.  
  1181. /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
  1182.    the stack pointer does not matter. No definition is equivalent to
  1183.    always zero.
  1184.  
  1185.    On the RS/6000, this is non-zero because we can restore the stack from
  1186.    its backpointer, which we maintain.  */
  1187. #define EXIT_IGNORE_STACK    1
  1188.  
  1189. /* This macro generates the assembly code for function exit,
  1190.    on machines that need it.  If FUNCTION_EPILOGUE is not defined
  1191.    then individual return instructions are generated for each
  1192.    return statement.  Args are same as for FUNCTION_PROLOGUE.
  1193.  
  1194.    The function epilogue should not depend on the current stack pointer!
  1195.    It should use the frame pointer only.  This is mandatory because
  1196.    of alloca; we also take advantage of it to omit stack adjustments
  1197.    before returning.  */
  1198.  
  1199. #define FUNCTION_EPILOGUE(FILE, SIZE) output_epilog (FILE, SIZE)
  1200.  
  1201. /* Output assembler code for a block containing the constant parts
  1202.    of a trampoline, leaving space for the variable parts.
  1203.  
  1204.    The trampoline should set the static chain pointer to value placed
  1205.    into the trampoline and should branch to the specified routine.
  1206.  
  1207.    On the RS/6000, this is not code at all, but merely a data area,
  1208.    since that is the way all functions are called.  The first word is
  1209.    the address of the function, the second word is the TOC pointer (r2),
  1210.    and the third word is the static chain value.  */
  1211.  
  1212. #define TRAMPOLINE_TEMPLATE(FILE) { fprintf (FILE, "\t.long 0, 0, 0\n"); }
  1213.  
  1214. /* Length in units of the trampoline for entering a nested function.  */
  1215.  
  1216. #define TRAMPOLINE_SIZE    12
  1217.  
  1218. /* Emit RTL insns to initialize the variable parts of a trampoline.
  1219.    FNADDR is an RTX for the address of the function's pure code.
  1220.    CXT is an RTX for the static chain value for the function.  */
  1221.  
  1222. #define INITIALIZE_TRAMPOLINE(ADDR, FNADDR, CXT)        \
  1223. {                                \
  1224.   emit_move_insn (gen_rtx (MEM, SImode,                \
  1225.                memory_address (SImode, (ADDR))),    \
  1226.           gen_rtx (MEM, SImode,                \
  1227.                memory_address (SImode, (FNADDR))));    \
  1228.   emit_move_insn (gen_rtx (MEM, SImode,                \
  1229.                memory_address (SImode,        \
  1230.                        plus_constant ((ADDR), 4))), \
  1231.           gen_rtx (MEM, SImode,                \
  1232.                memory_address (SImode,        \
  1233.                        plus_constant ((FNADDR), 4)))); \
  1234.   emit_move_insn (gen_rtx (MEM, SImode,                \
  1235.                memory_address (SImode,        \
  1236.                        plus_constant ((ADDR), 8))), \
  1237.           force_reg (SImode, (CXT)));            \
  1238. }
  1239.  
  1240. /* Definitions for __builtin_return_address and __builtin_frame_address.
  1241.    __builtin_return_address (0) should give link register (65), enable
  1242.    this. */
  1243. /* This should be uncommented, so that the link register is used, but
  1244.    currently this would result in unmatched insns and spilling fixed
  1245.    registers so we'll leave it for another day.  When these problems are
  1246.    taken care of one additional fetch will be necessary in RETURN_ADDR_RTX.
  1247.    (mrs) */
  1248. /* #define RETURN_ADDR_IN_PREVIOUS_FRAME */
  1249.  
  1250. /* Number of bytes into the frame return addresses can be found.  */
  1251. #ifndef TARGET_V4_CALLS
  1252. #define RETURN_ADDRESS_OFFSET 8
  1253. #else
  1254. #define RETURN_ADDRESS_OFFSET \
  1255.  ((TARGET_V4_CALLS) ?  (TARGET_64BIT ? 8 : 4) : 8)
  1256. #endif
  1257.  
  1258. /* The current return address is in link register (65).  The return address
  1259.    of anything farther back is accessed normally at an offset of 8 from the
  1260.    frame pointer.  */
  1261. #define RETURN_ADDR_RTX(count, frame)            \
  1262.   ((count == -1)                    \
  1263.    ? gen_rtx (REG, Pmode, 65)                \
  1264.    : gen_rtx (MEM, Pmode,                \
  1265.           memory_address (Pmode,             \
  1266.                   plus_constant (copy_to_reg (gen_rtx (MEM, Pmode, \
  1267.                                    memory_address (Pmode, frame))), \
  1268.                          RETURN_ADDRESS_OFFSET))))
  1269.  
  1270. /* Definitions for register eliminations.
  1271.  
  1272.    We have two registers that can be eliminated on the RS/6000.  First, the
  1273.    frame pointer register can often be eliminated in favor of the stack
  1274.    pointer register.  Secondly, the argument pointer register can always be
  1275.    eliminated; it is replaced with either the stack or frame pointer.
  1276.  
  1277.    In addition, we use the elimination mechanism to see if r30 is needed
  1278.    Initially we assume that it isn't.  If it is, we spill it.  This is done
  1279.    by making it an eliminable register.  We replace it with itself so that
  1280.    if it isn't needed, then existing uses won't be modified.  */
  1281.  
  1282. /* This is an array of structures.  Each structure initializes one pair
  1283.    of eliminable registers.  The "from" register number is given first,
  1284.    followed by "to".  Eliminations of the same "from" register are listed
  1285.    in order of preference.  */
  1286. #define ELIMINABLE_REGS                \
  1287. {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM},    \
  1288.  { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM},    \
  1289.  { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM},    \
  1290.  { 30, 30} }
  1291.  
  1292. /* Given FROM and TO register numbers, say whether this elimination is allowed.
  1293.    Frame pointer elimination is automatically handled.
  1294.  
  1295.    For the RS/6000, if frame pointer elimination is being done, we would like
  1296.    to convert ap into fp, not sp.
  1297.  
  1298.    We need r30 if -mminimal-toc was specified, and there are constant pool
  1299.    references.  */
  1300.  
  1301. #define CAN_ELIMINATE(FROM, TO)                    \
  1302.  ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM    \
  1303.   ? ! frame_pointer_needed                    \
  1304.   : (FROM) == 30 ? ! TARGET_MINIMAL_TOC || TARGET_NO_TOC || get_pool_size () == 0 \
  1305.   : 1)
  1306.  
  1307. /* Define the offset between two registers, one to be eliminated, and the other
  1308.    its replacement, at the start of a routine.  */
  1309. #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET)            \
  1310. {                                    \
  1311.   rs6000_stack_t *info = rs6000_stack_info ();                \
  1312.                                     \
  1313.  if ((FROM) == FRAME_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM)    \
  1314.    (OFFSET) = (info->push_p) ? 0 : - info->total_size;            \
  1315.  else if ((FROM) == ARG_POINTER_REGNUM && (TO) == FRAME_POINTER_REGNUM)    \
  1316.    (OFFSET) = info->total_size;                        \
  1317.  else if ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM)    \
  1318.    (OFFSET) = (info->push_p) ? info->total_size : 0;            \
  1319.   else if ((FROM) == 30)                        \
  1320.     (OFFSET) = 0;                            \
  1321.   else                                    \
  1322.     abort ();                                \
  1323. }
  1324.  
  1325. /* Addressing modes, and classification of registers for them.  */
  1326.  
  1327. /* #define HAVE_POST_INCREMENT */
  1328. /* #define HAVE_POST_DECREMENT */
  1329.  
  1330. #define HAVE_PRE_DECREMENT
  1331. #define HAVE_PRE_INCREMENT
  1332.  
  1333. /* Macros to check register numbers against specific register classes.  */
  1334.  
  1335. /* These assume that REGNO is a hard or pseudo reg number.
  1336.    They give nonzero only if REGNO is a hard reg of the suitable class
  1337.    or a pseudo reg currently allocated to a suitable hard reg.
  1338.    Since they use reg_renumber, they are safe only once reg_renumber
  1339.    has been allocated, which happens in local-alloc.c.  */
  1340.  
  1341. #define REGNO_OK_FOR_INDEX_P(REGNO)                \
  1342. ((REGNO) < FIRST_PSEUDO_REGISTER                \
  1343.  ? (REGNO) <= 31 || (REGNO) == 67                \
  1344.  : (reg_renumber[REGNO] >= 0                    \
  1345.     && (reg_renumber[REGNO] <= 31 || reg_renumber[REGNO] == 67)))
  1346.  
  1347. #define REGNO_OK_FOR_BASE_P(REGNO)                \
  1348. ((REGNO) < FIRST_PSEUDO_REGISTER                \
  1349.  ? ((REGNO) > 0 && (REGNO) <= 31) || (REGNO) == 67        \
  1350.  : (reg_renumber[REGNO] > 0                    \
  1351.     && (reg_renumber[REGNO] <= 31 || reg_renumber[REGNO] == 67)))
  1352.  
  1353. /* Maximum number of registers that can appear in a valid memory address.  */
  1354.  
  1355. #define MAX_REGS_PER_ADDRESS 2
  1356.  
  1357. /* Recognize any constant value that is a valid address.  */
  1358.  
  1359. #define CONSTANT_ADDRESS_P(X)   \
  1360.   (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF        \
  1361.    || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST        \
  1362.    || GET_CODE (X) == HIGH)
  1363.  
  1364. /* Nonzero if the constant value X is a legitimate general operand.
  1365.    It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.
  1366.  
  1367.    On the RS/6000, all integer constants are acceptable, most won't be valid
  1368.    for particular insns, though.  Only easy FP constants are
  1369.    acceptable.  */
  1370.  
  1371. #define LEGITIMATE_CONSTANT_P(X)                \
  1372.   (GET_CODE (X) != CONST_DOUBLE || GET_MODE (X) == VOIDmode    \
  1373.    || easy_fp_constant (X, GET_MODE (X)))
  1374.  
  1375. /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
  1376.    and check its validity for a certain class.
  1377.    We have two alternate definitions for each of them.
  1378.    The usual definition accepts all pseudo regs; the other rejects
  1379.    them unless they have been allocated suitable hard regs.
  1380.    The symbol REG_OK_STRICT causes the latter definition to be used.
  1381.  
  1382.    Most source files want to accept pseudo regs in the hope that
  1383.    they will get allocated to the class that the insn wants them to be in.
  1384.    Source files for reload pass need to be strict.
  1385.    After reload, it makes no difference, since pseudo regs have
  1386.    been eliminated by then.  */
  1387.  
  1388. #ifndef REG_OK_STRICT
  1389.  
  1390. /* Nonzero if X is a hard reg that can be used as an index
  1391.    or if it is a pseudo reg.  */
  1392. #define REG_OK_FOR_INDEX_P(X)            \
  1393.   (REGNO (X) <= 31 || REGNO (X) == 67 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
  1394.  
  1395. /* Nonzero if X is a hard reg that can be used as a base reg
  1396.    or if it is a pseudo reg.  */
  1397. #define REG_OK_FOR_BASE_P(X)                     \
  1398.   (REGNO (X) > 0 && REG_OK_FOR_INDEX_P (X))
  1399.  
  1400. #else
  1401.  
  1402. /* Nonzero if X is a hard reg that can be used as an index.  */
  1403. #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
  1404. /* Nonzero if X is a hard reg that can be used as a base reg.  */
  1405. #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
  1406.  
  1407. #endif
  1408.  
  1409. /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
  1410.    that is a valid memory address for an instruction.
  1411.    The MODE argument is the machine mode for the MEM expression
  1412.    that wants to use this address.
  1413.  
  1414.    On the RS/6000, there are four valid address: a SYMBOL_REF that
  1415.    refers to a constant pool entry of an address (or the sum of it
  1416.    plus a constant), a short (16-bit signed) constant plus a register,
  1417.    the sum of two registers, or a register indirect, possibly with an
  1418.    auto-increment.  For DFmode and DImode with an constant plus register,
  1419.    we must ensure that both words are addressable.  */
  1420.  
  1421. #define LEGITIMATE_CONSTANT_POOL_BASE_P(X)                \
  1422.   (TARGET_TOC && GET_CODE (X) == SYMBOL_REF                \
  1423.    && CONSTANT_POOL_ADDRESS_P (X)                    \
  1424.    && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (X)))
  1425.  
  1426. #define LEGITIMATE_CONSTANT_POOL_ADDRESS_P(X)                \
  1427.   (LEGITIMATE_CONSTANT_POOL_BASE_P (X)                    \
  1428.    || (TARGET_TOC                            \
  1429.        && GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS    \
  1430.        && GET_CODE (XEXP (XEXP (X, 0), 1)) == CONST_INT            \
  1431.        && LEGITIMATE_CONSTANT_POOL_BASE_P (XEXP (XEXP (X, 0), 0))))
  1432.  
  1433. #define LEGITIMATE_ADDRESS_INTEGER_P(X,OFFSET)                \
  1434.  (GET_CODE (X) == CONST_INT                        \
  1435.   && (unsigned) (INTVAL (X) + (OFFSET) + 0x8000) < 0x10000)
  1436.  
  1437. #define LEGITIMATE_OFFSET_ADDRESS_P(MODE,X)        \
  1438.  (GET_CODE (X) == PLUS                    \
  1439.   && GET_CODE (XEXP (X, 0)) == REG            \
  1440.   && REG_OK_FOR_BASE_P (XEXP (X, 0))            \
  1441.   && LEGITIMATE_ADDRESS_INTEGER_P (XEXP (X, 1), 0)    \
  1442.   && (((MODE) != DFmode && (MODE) != DImode)        \
  1443.       || LEGITIMATE_ADDRESS_INTEGER_P (XEXP (X, 1), 4)))
  1444.  
  1445. #define LEGITIMATE_INDEXED_ADDRESS_P(X)        \
  1446.  (GET_CODE (X) == PLUS                \
  1447.   && GET_CODE (XEXP (X, 0)) == REG        \
  1448.   && GET_CODE (XEXP (X, 1)) == REG        \
  1449.   && ((REG_OK_FOR_BASE_P (XEXP (X, 0))        \
  1450.        && REG_OK_FOR_INDEX_P (XEXP (X, 1)))    \
  1451.       || (REG_OK_FOR_BASE_P (XEXP (X, 1))    \
  1452.       && REG_OK_FOR_INDEX_P (XEXP (X, 0)))))
  1453.  
  1454. #define LEGITIMATE_INDIRECT_ADDRESS_P(X)    \
  1455.   (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X))
  1456.  
  1457. #define LEGITIMATE_LO_SUM_ADDRESS_P(MODE, X)        \
  1458.   (TARGET_ELF                        \
  1459.    && (MODE) != DImode                    \
  1460.    && (MODE) != TImode                    \
  1461.    && (TARGET_HARD_FLOAT || (MODE) != DFmode)        \
  1462.    && GET_CODE (X) == LO_SUM                \
  1463.    && GET_CODE (XEXP (X, 0)) == REG            \
  1464.    && REG_OK_FOR_BASE_P (XEXP (X, 0))            \
  1465.    && CONSTANT_P (XEXP (X, 1)))
  1466.  
  1467. #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR)        \
  1468. { if (LEGITIMATE_INDIRECT_ADDRESS_P (X))        \
  1469.     goto ADDR;                        \
  1470.   if (GET_CODE (X) == PRE_INC                \
  1471.       && LEGITIMATE_INDIRECT_ADDRESS_P (XEXP (X, 0)))    \
  1472.     goto ADDR;                        \
  1473.   if (GET_CODE (X) == PRE_DEC                \
  1474.       && LEGITIMATE_INDIRECT_ADDRESS_P (XEXP (X, 0)))    \
  1475.     goto ADDR;                        \
  1476.   if (LEGITIMATE_CONSTANT_POOL_ADDRESS_P (X))        \
  1477.     goto ADDR;                        \
  1478.   if (LEGITIMATE_OFFSET_ADDRESS_P (MODE, X))        \
  1479.     goto ADDR;                        \
  1480.   if ((MODE) != DImode && (MODE) != TImode        \
  1481.       && (TARGET_HARD_FLOAT || (MODE) != DFmode)    \
  1482.       && LEGITIMATE_INDEXED_ADDRESS_P (X))        \
  1483.     goto ADDR;                        \
  1484.   if (LEGITIMATE_LO_SUM_ADDRESS_P (MODE, X))        \
  1485.     goto ADDR;                        \
  1486. }
  1487.  
  1488. /* Try machine-dependent ways of modifying an illegitimate address
  1489.    to be legitimate.  If we find one, return the new, valid address.
  1490.    This macro is used in only one place: `memory_address' in explow.c.
  1491.  
  1492.    OLDX is the address as it was before break_out_memory_refs was called.
  1493.    In some cases it is useful to look at this to decide what needs to be done.
  1494.  
  1495.    MODE and WIN are passed so that this macro can use
  1496.    GO_IF_LEGITIMATE_ADDRESS.
  1497.  
  1498.    It is always safe for this macro to do nothing.  It exists to recognize
  1499.    opportunities to optimize the output.
  1500.  
  1501.    On RS/6000, first check for the sum of a register with a constant
  1502.    integer that is out of range.  If so, generate code to add the
  1503.    constant with the low-order 16 bits masked to the register and force
  1504.    this result into another register (this can be done with `cau').
  1505.    Then generate an address of REG+(CONST&0xffff), allowing for the 
  1506.    possibility of bit 16 being a one.
  1507.  
  1508.    Then check for the sum of a register and something not constant, try to
  1509.    load the other things into a register and return the sum.  */
  1510.  
  1511. #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN)                \
  1512. { if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == REG        \
  1513.     && GET_CODE (XEXP (X, 1)) == CONST_INT                \
  1514.     && (unsigned) (INTVAL (XEXP (X, 1)) + 0x8000) >= 0x10000)        \
  1515.     { int high_int, low_int;                        \
  1516.       high_int = INTVAL (XEXP (X, 1)) >> 16;                \
  1517.       low_int = INTVAL (XEXP (X, 1)) & 0xffff;                \
  1518.       if (low_int & 0x8000)                        \
  1519.     high_int += 1, low_int |= 0xffff0000;                \
  1520.       (X) = gen_rtx (PLUS, SImode,                    \
  1521.              force_operand                    \
  1522.                  (gen_rtx (PLUS, SImode, XEXP (X, 0),        \
  1523.                   gen_rtx (CONST_INT, VOIDmode,        \
  1524.                               high_int << 16)), 0), \
  1525.              gen_rtx (CONST_INT, VOIDmode, low_int));        \
  1526.       goto WIN;                                \
  1527.     }                                    \
  1528.   else if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == REG    \
  1529.        && GET_CODE (XEXP (X, 1)) != CONST_INT            \
  1530.        && (TARGET_HARD_FLOAT || (MODE) != DFmode)            \
  1531.        && (MODE) != DImode && (MODE) != TImode)            \
  1532.     {                                    \
  1533.       (X) = gen_rtx (PLUS, SImode, XEXP (X, 0),                \
  1534.              force_reg (SImode, force_operand (XEXP (X, 1), 0))); \
  1535.       goto WIN;                                \
  1536.     }                                    \
  1537.   else if (TARGET_ELF && !TARGET_64BIT && TARGET_NO_TOC            \
  1538.        && GET_CODE (X) != CONST_INT                    \
  1539.        && GET_CODE (X) != CONST_DOUBLE && CONSTANT_P (X)        \
  1540.        && (TARGET_HARD_FLOAT || (MODE) != DFmode)            \
  1541.        && (MODE) != DImode && (MODE) != TImode)            \
  1542.     {                                    \
  1543.       rtx reg = gen_reg_rtx (Pmode);                    \
  1544.       emit_insn (gen_elf_high (reg, (X)));                \
  1545.       (X) = gen_rtx (LO_SUM, Pmode, reg, (X));                \
  1546.     }                                    \
  1547. }
  1548.  
  1549. /* Go to LABEL if ADDR (a legitimate address expression)
  1550.    has an effect that depends on the machine mode it is used for.
  1551.  
  1552.    On the RS/6000 this is true if the address is valid with a zero offset
  1553.    but not with an offset of four (this means it cannot be used as an
  1554.    address for DImode or DFmode) or is a pre-increment or decrement.  Since
  1555.    we know it is valid, we just check for an address that is not valid with
  1556.    an offset of four.  */
  1557.  
  1558. #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL)        \
  1559. { if (GET_CODE (ADDR) == PLUS                    \
  1560.       && LEGITIMATE_ADDRESS_INTEGER_P (XEXP (ADDR, 1), 0)    \
  1561.       && ! LEGITIMATE_ADDRESS_INTEGER_P (XEXP (ADDR, 1), 4))    \
  1562.     goto LABEL;                            \
  1563.   if (GET_CODE (ADDR) == PRE_INC)                \
  1564.     goto LABEL;                            \
  1565.   if (GET_CODE (ADDR) == PRE_DEC)                \
  1566.     goto LABEL;                            \
  1567.   if (GET_CODE (ADDR) == LO_SUM)                \
  1568.     goto LABEL;                            \
  1569. }
  1570.  
  1571. /* Define this if some processing needs to be done immediately before
  1572.    emitting code for an insn.  */
  1573.  
  1574. /* #define FINAL_PRESCAN_INSN(INSN,OPERANDS,NOPERANDS) */
  1575.  
  1576. /* Specify the machine mode that this machine uses
  1577.    for the index in the tablejump instruction.  */
  1578. #define CASE_VECTOR_MODE SImode
  1579.  
  1580. /* Define this if the tablejump instruction expects the table
  1581.    to contain offsets from the address of the table.
  1582.    Do not define this if the table should contain absolute addresses.  */
  1583. #define CASE_VECTOR_PC_RELATIVE
  1584.  
  1585. /* Specify the tree operation to be used to convert reals to integers.  */
  1586. #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
  1587.  
  1588. /* This is the kind of divide that is easiest to do in the general case.  */
  1589. #define EASY_DIV_EXPR TRUNC_DIV_EXPR
  1590.  
  1591. /* Define this as 1 if `char' should by default be signed; else as 0.  */
  1592. #define DEFAULT_SIGNED_CHAR 0
  1593.  
  1594. /* This flag, if defined, says the same insns that convert to a signed fixnum
  1595.    also convert validly to an unsigned one.  */
  1596.  
  1597. /* #define FIXUNS_TRUNC_LIKE_FIX_TRUNC */
  1598.  
  1599. /* Max number of bytes we can move from memory to memory
  1600.    in one reasonably fast instruction.  */
  1601. #define MOVE_MAX (TARGET_POWERPC64 ? 8 : 4)
  1602. #define MAX_MOVE_MAX 8
  1603.  
  1604. /* Nonzero if access to memory by bytes is no faster than for words.
  1605.    Also non-zero if doing byte operations (specifically shifts) in registers
  1606.    is undesirable.  */
  1607. #define SLOW_BYTE_ACCESS 1
  1608.  
  1609. /* Define if operations between registers always perform the operation
  1610.    on the full register even if a narrower mode is specified.  */
  1611. #define WORD_REGISTER_OPERATIONS
  1612.  
  1613. /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
  1614.    will either zero-extend or sign-extend.  The value of this macro should
  1615.    be the code that says which one of the two operations is implicitly
  1616.    done, NIL if none.  */
  1617. #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
  1618.  
  1619. /* Define if loading short immediate values into registers sign extends.  */
  1620. #define SHORT_IMMEDIATES_SIGN_EXTEND
  1621.  
  1622. /* The RS/6000 uses the XCOFF format.  */
  1623.  
  1624. #define XCOFF_DEBUGGING_INFO
  1625.  
  1626. /* Define if the object format being used is COFF or a superset.  */
  1627. #define OBJECT_FORMAT_COFF
  1628.  
  1629. /* Define the magic numbers that we recognize as COFF.  */
  1630.  
  1631. #define MY_ISCOFF(magic) \
  1632.   ((magic) == U802WRMAGIC || (magic) == U802ROMAGIC || (magic) == U802TOCMAGIC)
  1633.  
  1634. /* This is the only version of nm that collect2 can work with.  */
  1635. #define REAL_NM_FILE_NAME "/usr/ucb/nm"
  1636.  
  1637. /* We don't have GAS for the RS/6000 yet, so don't write out special
  1638.    .stabs in cc1plus.  */
  1639.    
  1640. #define FASCIST_ASSEMBLER
  1641. #define ASM_OUTPUT_CONSTRUCTOR(file, name)
  1642. #define ASM_OUTPUT_DESTRUCTOR(file, name)
  1643.  
  1644. /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
  1645.    is done just by pretending it is already truncated.  */
  1646. #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
  1647.  
  1648. /* Specify the machine mode that pointers have.
  1649.    After generation of rtl, the compiler makes no further distinction
  1650.    between pointers and any other objects of this machine mode.  */
  1651. #define Pmode (TARGET_64BIT ? DImode : SImode)
  1652.  
  1653. /* Mode of a function address in a call instruction (for indexing purposes).
  1654.  
  1655.    Doesn't matter on RS/6000.  */
  1656. #define FUNCTION_MODE (TARGET_64BIT ? DImode : SImode)
  1657.  
  1658. /* Define this if addresses of constant functions
  1659.    shouldn't be put through pseudo regs where they can be cse'd.
  1660.    Desirable on machines where ordinary constants are expensive
  1661.    but a CALL with constant address is cheap.  */
  1662. #define NO_FUNCTION_CSE
  1663.  
  1664. /* Define this to be nonzero if shift instructions ignore all but the low-order
  1665.    few bits.
  1666.  
  1667.    The sle and sre instructions which allow SHIFT_COUNT_TRUNCATED
  1668.    have been dropped from the PowerPC architecture.  */
  1669.  
  1670. #define SHIFT_COUNT_TRUNCATED (TARGET_POWER ? 1 : 0)
  1671.  
  1672. /* Use atexit for static constructors/destructors, instead of defining
  1673.    our own exit function.  */
  1674. #define HAVE_ATEXIT
  1675.  
  1676. /* Compute the cost of computing a constant rtl expression RTX
  1677.    whose rtx-code is CODE.  The body of this macro is a portion
  1678.    of a switch statement.  If the code is computed here,
  1679.    return it with a return statement.  Otherwise, break from the switch.
  1680.  
  1681.    On the RS/6000, if it is valid in the insn, it is free.  So this
  1682.    always returns 0.  */
  1683.  
  1684. #define CONST_COSTS(RTX,CODE,OUTER_CODE)            \
  1685.   case CONST_INT:                        \
  1686.   case CONST:                            \
  1687.   case LABEL_REF:                        \
  1688.   case SYMBOL_REF:                        \
  1689.   case CONST_DOUBLE:                        \
  1690.   case HIGH:                            \
  1691.     return 0;
  1692.  
  1693. /* Provide the costs of a rtl expression.  This is in the body of a
  1694.    switch on CODE.  */
  1695.  
  1696. #define RTX_COSTS(X,CODE,OUTER_CODE)            \
  1697.   case MULT:                        \
  1698.   switch (rs6000_cpu)                    \
  1699.     {                            \
  1700.     case PROCESSOR_RIOS1:                \
  1701.       return (GET_CODE (XEXP (X, 1)) != CONST_INT    \
  1702.           ? COSTS_N_INSNS (5)            \
  1703.           : INTVAL (XEXP (X, 1)) >= -256 && INTVAL (XEXP (X, 1)) <= 255 \
  1704.           ? COSTS_N_INSNS (3) : COSTS_N_INSNS (4));    \
  1705.     case PROCESSOR_RIOS2:                \
  1706.       return COSTS_N_INSNS (2);                \
  1707.     case PROCESSOR_PPC601:                \
  1708.     case PROCESSOR_PPC603:                \
  1709.       return COSTS_N_INSNS (5);                \
  1710.     case PROCESSOR_PPC403:                \
  1711.     case PROCESSOR_PPC604:                \
  1712.     case PROCESSOR_PPC620:                \
  1713.       return COSTS_N_INSNS (4);                \
  1714.     }                            \
  1715.   case DIV:                        \
  1716.   case MOD:                        \
  1717.     if (GET_CODE (XEXP (X, 1)) == CONST_INT        \
  1718.     && exact_log2 (INTVAL (XEXP (X, 1))) >= 0)    \
  1719.       return COSTS_N_INSNS (2);                \
  1720.     /* otherwise fall through to normal divide.  */    \
  1721.   case UDIV:                        \
  1722.   case UMOD:                        \
  1723.   switch (rs6000_cpu)                    \
  1724.     {                            \
  1725.     case PROCESSOR_RIOS1:                \
  1726.       return COSTS_N_INSNS (19);            \
  1727.     case PROCESSOR_RIOS2:                \
  1728.       return COSTS_N_INSNS (13);            \
  1729.     case PROCESSOR_PPC403:                \
  1730.       return COSTS_N_INSNS (33);            \
  1731.     case PROCESSOR_PPC601:                \
  1732.       return COSTS_N_INSNS (36);            \
  1733.     case PROCESSOR_PPC603:                \
  1734.       return COSTS_N_INSNS (37);            \
  1735.     case PROCESSOR_PPC604:                \
  1736.     case PROCESSOR_PPC620:                \
  1737.       return COSTS_N_INSNS (20);            \
  1738.     }                            \
  1739.   case FFS:                        \
  1740.     return COSTS_N_INSNS (4);                \
  1741.   case MEM:                        \
  1742.     /* MEM should be slightly more expensive than (plus (reg) (const)) */ \
  1743.     return 5;
  1744.  
  1745. /* Compute the cost of an address.  This is meant to approximate the size
  1746.    and/or execution delay of an insn using that address.  If the cost is
  1747.    approximated by the RTL complexity, including CONST_COSTS above, as
  1748.    is usually the case for CISC machines, this macro should not be defined.
  1749.    For aggressively RISCy machines, only one insn format is allowed, so
  1750.    this macro should be a constant.  The value of this macro only matters
  1751.    for valid addresses.
  1752.  
  1753.    For the RS/6000, everything is cost 0.  */
  1754.  
  1755. #define ADDRESS_COST(RTX) 0
  1756.  
  1757. /* Adjust the length of an INSN.  LENGTH is the currently-computed length and
  1758.    should be adjusted to reflect any required changes.  This macro is used when
  1759.    there is some systematic length adjustment required that would be difficult
  1760.    to express in the length attribute.  */
  1761.  
  1762. /* #define ADJUST_INSN_LENGTH(X,LENGTH) */
  1763.  
  1764. /* Add any extra modes needed to represent the condition code.
  1765.  
  1766.    For the RS/6000, we need separate modes when unsigned (logical) comparisons
  1767.    are being done and we need a separate mode for floating-point.  We also
  1768.    use a mode for the case when we are comparing the results of two
  1769.    comparisons.  */
  1770.  
  1771. #define EXTRA_CC_MODES CCUNSmode, CCFPmode, CCEQmode
  1772.  
  1773. /* Define the names for the modes specified above.  */
  1774. #define EXTRA_CC_NAMES "CCUNS", "CCFP", "CCEQ"
  1775.  
  1776. /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
  1777.    return the mode to be used for the comparison.  For floating-point, CCFPmode
  1778.    should be used.  CCUNSmode should be used for unsigned comparisons.
  1779.    CCEQmode should be used when we are doing an inequality comparison on
  1780.    the result of a comparison. CCmode should be used in all other cases.  */
  1781.  
  1782. #define SELECT_CC_MODE(OP,X,Y) \
  1783.   (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT ? CCFPmode    \
  1784.    : (OP) == GTU || (OP) == LTU || (OP) == GEU || (OP) == LEU ? CCUNSmode \
  1785.    : (((OP) == EQ || (OP) == NE) && GET_RTX_CLASS (GET_CODE (X)) == '<'   \
  1786.       ? CCEQmode : CCmode))
  1787.  
  1788. /* Define the information needed to generate branch and scc insns.  This is
  1789.    stored from the compare operation.  Note that we can't use "rtx" here
  1790.    since it hasn't been defined!  */
  1791.  
  1792. extern struct rtx_def *rs6000_compare_op0, *rs6000_compare_op1;
  1793. extern int rs6000_compare_fp_p;
  1794.  
  1795. /* Set to non-zero by "fix" operation to indicate that itrunc and
  1796.    uitrunc must be defined.  */
  1797.  
  1798. extern int rs6000_trunc_used;
  1799.  
  1800. /* Function names to call to do floating point truncation.  */
  1801.  
  1802. #define RS6000_ITRUNC "itrunc"
  1803. #define RS6000_UITRUNC "uitrunc"
  1804.  
  1805. /* Prefix and suffix to use to saving floating point */
  1806. #ifndef SAVE_FP_PREFIX
  1807. #define    SAVE_FP_PREFIX "._savef"
  1808. #define SAVE_FP_SUFFIX ""
  1809. #endif
  1810.  
  1811. /* Prefix and suffix to use to restoring floating point */
  1812. #ifndef RESTORE_FP_PREFIX
  1813. #define    RESTORE_FP_PREFIX "._restf"
  1814. #define RESTORE_FP_SUFFIX ""
  1815. #endif
  1816.  
  1817.  
  1818. /* Control the assembler format that we output.  */
  1819.  
  1820. /* Common macro to output the options used to the asm file.  */
  1821. #define ASM_OUTPUT_OPTIONS(FILE)                     \
  1822.   output_options (FILE,                             \
  1823.           f_options, sizeof (f_options) / sizeof (f_options[0]), \
  1824.           W_options, sizeof (W_options) / sizeof (W_options[0])) \
  1825.  
  1826. /* Output at beginning of assembler file.
  1827.  
  1828.    Initialize the section names for the RS/6000 at this point.
  1829.  
  1830.    Specify filename to assembler.
  1831.  
  1832.    We want to go into the TOC section so at least one .toc will be emitted.
  1833.    Also, in order to output proper .bs/.es pairs, we need at least one static
  1834.    [RW] section emitted.
  1835.  
  1836.    We then switch back to text to force the gcc2_compiled. label and the space
  1837.    allocated after it (when profiling) into the text section.  
  1838.  
  1839.    Finally, declare mcount when profiling to make the assembler happy.  */
  1840.  
  1841. #define ASM_FILE_START(FILE)                    \
  1842. {                                \
  1843.   ASM_OUTPUT_OPTIONS (FILE);                    \
  1844.   rs6000_gen_section_name (&xcoff_bss_section_name,        \
  1845.                main_input_filename, ".bss_");    \
  1846.   rs6000_gen_section_name (&xcoff_private_data_section_name,    \
  1847.                main_input_filename, ".rw_");    \
  1848.   rs6000_gen_section_name (&xcoff_read_only_section_name,    \
  1849.                main_input_filename, ".ro_");    \
  1850.                                 \
  1851.   output_file_directive (FILE, main_input_filename);        \
  1852.   toc_section ();                        \
  1853.   if (write_symbols != NO_DEBUG)                \
  1854.     private_data_section ();                    \
  1855.   text_section ();                        \
  1856.   if (profile_flag)                        \
  1857.     fprintf (FILE, "\t.extern .mcount\n");            \
  1858. }
  1859.  
  1860. /* Output at end of assembler file.
  1861.  
  1862.    On the RS/6000, referencing data should automatically pull in text.  */
  1863.  
  1864. #define ASM_FILE_END(FILE)                    \
  1865. {                                \
  1866.   text_section ();                        \
  1867.   fprintf (FILE, "_section_.text:\n");                \
  1868.   data_section ();                        \
  1869.   fprintf (FILE, "\t.long _section_.text\n");            \
  1870. }
  1871.  
  1872. /* We define this to prevent the name mangler from putting dollar signs into
  1873.    function names.  */
  1874.  
  1875. #define NO_DOLLAR_IN_LABEL
  1876.  
  1877. /* We define this to 0 so that gcc will never accept a dollar sign in a
  1878.    variable name.  This is needed because the AIX assembler will not accept
  1879.    dollar signs.  */
  1880.  
  1881. #define DOLLARS_IN_IDENTIFIERS 0
  1882.  
  1883. /* Implicit library calls should use memcpy, not bcopy, etc.  */
  1884.  
  1885. #define TARGET_MEM_FUNCTIONS
  1886.  
  1887. /* Define the extra sections we need.  We define three: one is the read-only
  1888.    data section which is used for constants.  This is a csect whose name is
  1889.    derived from the name of the input file.  The second is for initialized
  1890.    global variables.  This is a csect whose name is that of the variable.
  1891.    The third is the TOC.  */
  1892.  
  1893. #define EXTRA_SECTIONS \
  1894.    read_only_data, private_data, read_only_private_data, toc, bss
  1895.  
  1896. /* Define the name of our readonly data section.  */
  1897.  
  1898. #define READONLY_DATA_SECTION read_only_data_section
  1899.  
  1900. /* If we are referencing a function that is static or is known to be
  1901.    in this file, make the SYMBOL_REF special.  We can use this to indicate
  1902.    that we can branch to this function without emitting a no-op after the
  1903.    call.  */
  1904.  
  1905. #define ENCODE_SECTION_INFO(DECL)  \
  1906.   if (TREE_CODE (DECL) == FUNCTION_DECL            \
  1907.       && (TREE_ASM_WRITTEN (DECL) || ! TREE_PUBLIC (DECL))) \
  1908.     SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 1;
  1909.  
  1910. /* Indicate that jump tables go in the text section.  */
  1911.  
  1912. #define JUMP_TABLES_IN_TEXT_SECTION
  1913.  
  1914. /* Define the routines to implement these extra sections.  */
  1915.  
  1916. #define EXTRA_SECTION_FUNCTIONS                \
  1917.                             \
  1918. void                            \
  1919. read_only_data_section ()                \
  1920. {                            \
  1921.   if (in_section != read_only_data)            \
  1922.     {                            \
  1923.       fprintf (asm_out_file, ".csect %s[RO]\n",        \
  1924.            xcoff_read_only_section_name);        \
  1925.       in_section = read_only_data;            \
  1926.     }                            \
  1927. }                            \
  1928.                             \
  1929. void                            \
  1930. private_data_section ()                    \
  1931. {                            \
  1932.   if (in_section != private_data)            \
  1933.     {                            \
  1934.       fprintf (asm_out_file, ".csect %s[RW]\n",        \
  1935.            xcoff_private_data_section_name);    \
  1936.                             \
  1937.       in_section = private_data;            \
  1938.     }                            \
  1939. }                            \
  1940.                             \
  1941. void                            \
  1942. read_only_private_data_section ()            \
  1943. {                            \
  1944.   if (in_section != read_only_private_data)        \
  1945.     {                            \
  1946.       fprintf (asm_out_file, ".csect %s[RO]\n",        \
  1947.            xcoff_private_data_section_name);    \
  1948.       in_section = read_only_private_data;        \
  1949.     }                            \
  1950. }                            \
  1951.                             \
  1952. void                            \
  1953. toc_section ()                        \
  1954. {                            \
  1955.   if (TARGET_MINIMAL_TOC)                \
  1956.     {                            \
  1957.       static int toc_initialized = 0;            \
  1958.                             \
  1959.       /* toc_section is always called at least once from ASM_FILE_START, \
  1960.      so this is guaranteed to always be defined once and only once   \
  1961.      in each file.  */                         \
  1962.       if (! toc_initialized)                \
  1963.     {                        \
  1964.       fprintf (asm_out_file, ".toc\nLCTOC..0:\n");    \
  1965.       fprintf (asm_out_file, "\t.tc toc_table[TC],toc_table[RW]\n"); \
  1966.       toc_initialized = 1;                \
  1967.     }                        \
  1968.                             \
  1969.       if (in_section != toc)                \
  1970.     fprintf (asm_out_file, ".csect toc_table[RW]\n"); \
  1971.     }                            \
  1972.   else                            \
  1973.     {                            \
  1974.       if (in_section != toc)                \
  1975.         fprintf (asm_out_file, ".toc\n");        \
  1976.     }                            \
  1977.   in_section = toc;                    \
  1978. }
  1979.  
  1980. /* This macro produces the initial definition of a function name.
  1981.    On the RS/6000, we need to place an extra '.' in the function name and
  1982.    output the function descriptor.  
  1983.  
  1984.    The csect for the function will have already been created by the
  1985.    `text_section' call previously done.  We do have to go back to that
  1986.    csect, however.  */
  1987.  
  1988. /* ??? What do the 16 and 044 in the .function line really mean?  */
  1989.  
  1990. #define ASM_DECLARE_FUNCTION_NAME(FILE,NAME,DECL)        \
  1991. { if (TREE_PUBLIC (DECL))                    \
  1992.     {                                \
  1993.       fprintf (FILE, "\t.globl .");                \
  1994.       RS6000_OUTPUT_BASENAME (FILE, NAME);            \
  1995.       fprintf (FILE, "\n");                    \
  1996.     }                                \
  1997.   else                                \
  1998.     {                                \
  1999.       fprintf (FILE, "\t.lglobl .");                \
  2000.       RS6000_OUTPUT_BASENAME (FILE, NAME);            \
  2001.       fprintf (FILE, "\n");                    \
  2002.     }                                \
  2003.   fprintf (FILE, ".csect ");                    \
  2004.   RS6000_OUTPUT_BASENAME (FILE, NAME);                \
  2005.   fprintf (FILE, "[DS]\n");                    \
  2006.   RS6000_OUTPUT_BASENAME (FILE, NAME);                \
  2007.   fprintf (FILE, ":\n");                    \
  2008.   fprintf (FILE, "\t.long .");                    \
  2009.   RS6000_OUTPUT_BASENAME (FILE, NAME);                \
  2010.   fprintf (FILE, ", TOC[tc0], 0\n");                \
  2011.   fprintf (FILE, ".csect .text[PR]\n.");            \
  2012.   RS6000_OUTPUT_BASENAME (FILE, NAME);                \
  2013.   fprintf (FILE, ":\n");                    \
  2014.   if (write_symbols == XCOFF_DEBUG)                \
  2015.     xcoffout_declare_function (FILE, DECL, NAME);        \
  2016. }
  2017.  
  2018. /* Return non-zero if this entry is to be written into the constant pool
  2019.    in a special way.  We do so if this is a SYMBOL_REF, LABEL_REF or a CONST
  2020.    containing one of them.  If -mfp-in-toc (the default), we also do
  2021.    this for floating-point constants.  We actually can only do this
  2022.    if the FP formats of the target and host machines are the same, but
  2023.    we can't check that since not every file that uses
  2024.    GO_IF_LEGITIMATE_ADDRESS_P includes real.h.  */
  2025.  
  2026. #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X)                \
  2027.   (TARGET_TOC                                \
  2028.    && (GET_CODE (X) == SYMBOL_REF                    \
  2029.        || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS    \
  2030.        && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF)        \
  2031.        || GET_CODE (X) == LABEL_REF                    \
  2032.        || (! (TARGET_NO_FP_IN_TOC && ! TARGET_MINIMAL_TOC)        \
  2033.        && GET_CODE (X) == CONST_DOUBLE                \
  2034.        && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT        \
  2035.        && BITS_PER_WORD == HOST_BITS_PER_INT)))
  2036.  
  2037. /* Select section for constant in constant pool.
  2038.  
  2039.    On RS/6000, all constants are in the private read-only data area.
  2040.    However, if this is being placed in the TOC it must be output as a
  2041.    toc entry.  */
  2042.  
  2043. #define SELECT_RTX_SECTION(MODE, X)        \
  2044. { if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (X))    \
  2045.     toc_section ();                \
  2046.   else                        \
  2047.     read_only_private_data_section ();        \
  2048. }
  2049.  
  2050. /* Macro to output a special constant pool entry.  Go to WIN if we output
  2051.    it.  Otherwise, it is written the usual way.
  2052.  
  2053.    On the RS/6000, toc entries are handled this way.  */
  2054.  
  2055. #define ASM_OUTPUT_SPECIAL_POOL_ENTRY(FILE, X, MODE, ALIGN, LABELNO, WIN)  \
  2056. { if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (X))    \
  2057.     {                        \
  2058.       output_toc (FILE, X, LABELNO);        \
  2059.       goto WIN;                    \
  2060.     }                        \
  2061. }
  2062.  
  2063. /* Select the section for an initialized data object.
  2064.  
  2065.    On the RS/6000, we have a special section for all variables except those
  2066.    that are static.  */
  2067.  
  2068. #define SELECT_SECTION(EXP,RELOC)            \
  2069. {                            \
  2070.   if ((TREE_CODE (EXP) == STRING_CST            \
  2071.        && !flag_writable_strings)            \
  2072.       || (TREE_CODE_CLASS (TREE_CODE (EXP)) == 'd'    \
  2073.       && TREE_READONLY (EXP) && ! TREE_THIS_VOLATILE (EXP) \
  2074.       && DECL_INITIAL (EXP)                \
  2075.       && (DECL_INITIAL (EXP) == error_mark_node    \
  2076.           || TREE_CONSTANT (DECL_INITIAL (EXP)))    \
  2077.       && ! (RELOC)))                \
  2078.     {                            \
  2079.       if (TREE_PUBLIC (EXP))                \
  2080.         read_only_data_section ();            \
  2081.       else                        \
  2082.         read_only_private_data_section ();        \
  2083.     }                            \
  2084.   else                            \
  2085.     {                            \
  2086.       if (TREE_PUBLIC (EXP))                \
  2087.         data_section ();                \
  2088.       else                        \
  2089.         private_data_section ();            \
  2090.     }                            \
  2091. }
  2092.  
  2093. /* This outputs NAME to FILE up to the first null or '['.  */
  2094.  
  2095. #define RS6000_OUTPUT_BASENAME(FILE, NAME)    \
  2096.   {                        \
  2097.     char *_p;                    \
  2098.                         \
  2099.     STRIP_NAME_ENCODING (_p, (NAME));        \
  2100.     assemble_name ((FILE), _p);            \
  2101.   }
  2102.  
  2103. /* Remove any trailing [DS] or the like from the symbol name.  */
  2104.  
  2105. #define STRIP_NAME_ENCODING(VAR,NAME)                    \
  2106.   do                                    \
  2107.     {                                    \
  2108.       char *_name = (NAME);                        \
  2109.       if (_name[0] == '*')                        \
  2110.     (VAR) = _name+1;                        \
  2111.       else                                \
  2112.     {                                \
  2113.       int _len = strlen (_name);                    \
  2114.       if (_name[_len - 1] != ']')                    \
  2115.         (VAR) = _name;                        \
  2116.       else                                \
  2117.         {                                \
  2118.           (VAR) = (char *) alloca (_len + 1);            \
  2119.           strcpy ((VAR), _name);                    \
  2120.           (VAR)[_len - 4] = '\0';                    \
  2121.         }                                \
  2122.     }                                \
  2123.     }                                    \
  2124.   while (0)
  2125.  
  2126. /* Output something to declare an external symbol to the assembler.  Most
  2127.    assemblers don't need this.  
  2128.  
  2129.    If we haven't already, add "[RW]" (or "[DS]" for a function) to the
  2130.    name.  Normally we write this out along with the name.  In the few cases
  2131.    where we can't, it gets stripped off.  */
  2132.  
  2133. #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME)    \
  2134. { rtx _symref = XEXP (DECL_RTL (DECL), 0);    \
  2135.   if ((TREE_CODE (DECL) == VAR_DECL        \
  2136.        || TREE_CODE (DECL) == FUNCTION_DECL)    \
  2137.       && (NAME)[0] != '*'            \
  2138.       && (NAME)[strlen (NAME) - 1] != ']')    \
  2139.     {                        \
  2140.       char *_name = (char *) permalloc (strlen (XSTR (_symref, 0)) + 5); \
  2141.       strcpy (_name, XSTR (_symref, 0));    \
  2142.       strcat (_name, TREE_CODE (DECL) == FUNCTION_DECL ? "[DS]" : "[RW]"); \
  2143.       XSTR (_symref, 0) = _name;        \
  2144.     }                        \
  2145.   fprintf (FILE, "\t.extern ");            \
  2146.   assemble_name (FILE, XSTR (_symref, 0));    \
  2147.   if (TREE_CODE (DECL) == FUNCTION_DECL)    \
  2148.     {                        \
  2149.       fprintf (FILE, "\n\t.extern .");        \
  2150.       RS6000_OUTPUT_BASENAME (FILE, XSTR (_symref, 0));    \
  2151.     }                        \
  2152.   fprintf (FILE, "\n");                \
  2153. }
  2154.  
  2155. /* Similar, but for libcall.  We only have to worry about the function name,
  2156.    not that of the descriptor. */
  2157.  
  2158. #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN)    \
  2159. { fprintf (FILE, "\t.extern .");        \
  2160.   assemble_name (FILE, XSTR (FUN, 0));        \
  2161.   fprintf (FILE, "\n");                \
  2162. }
  2163.  
  2164. /* Output to assembler file text saying following lines
  2165.    may contain character constants, extra white space, comments, etc.  */
  2166.  
  2167. #define ASM_APP_ON ""
  2168.  
  2169. /* Output to assembler file text saying following lines
  2170.    no longer contain unusual constructs.  */
  2171.  
  2172. #define ASM_APP_OFF ""
  2173.  
  2174. /* Output before instructions.  */
  2175.  
  2176. #define TEXT_SECTION_ASM_OP ".csect .text[PR]"
  2177.  
  2178. /* Output before writable data.  */
  2179.  
  2180. #define DATA_SECTION_ASM_OP ".csect .data[RW]"
  2181.  
  2182. /* How to refer to registers in assembler output.
  2183.    This sequence is indexed by compiler's hard-register-number (see above).  */
  2184.  
  2185. #define REGISTER_NAMES \
  2186.  {"0", "1", "2", "3", "4", "5", "6", "7",         \
  2187.   "8", "9", "10", "11", "12", "13", "14", "15",        \
  2188.   "16", "17", "18", "19", "20", "21", "22", "23",    \
  2189.   "24", "25", "26", "27", "28", "29", "30", "31",    \
  2190.   "0", "1", "2", "3", "4", "5", "6", "7",        \
  2191.   "8", "9", "10", "11", "12", "13", "14", "15",        \
  2192.   "16", "17", "18", "19", "20", "21", "22", "23",    \
  2193.   "24", "25", "26", "27", "28", "29", "30", "31",    \
  2194.   "mq", "lr", "ctr", "ap",                \
  2195.   "0", "1", "2", "3", "4", "5", "6", "7" }
  2196.  
  2197. /* Table of additional register names to use in user input.  */
  2198.  
  2199. #define ADDITIONAL_REGISTER_NAMES \
  2200.  {"r0",    0, "r1",    1, "r2",    2, "r3",    3,    \
  2201.   "r4",    4, "r5",    5, "r6",    6, "r7",    7,    \
  2202.   "r8",    8, "r9",    9, "r10",  10, "r11",  11,    \
  2203.   "r12",  12, "r13",  13, "r14",  14, "r15",  15,    \
  2204.   "r16",  16, "r17",  17, "r18",  18, "r19",  19,    \
  2205.   "r20",  20, "r21",  21, "r22",  22, "r23",  23,    \
  2206.   "r24",  24, "r25",  25, "r26",  26, "r27",  27,    \
  2207.   "r28",  28, "r29",  29, "r30",  30, "r31",  31,    \
  2208.   "fr0",  32, "fr1",  33, "fr2",  34, "fr3",  35,    \
  2209.   "fr4",  36, "fr5",  37, "fr6",  38, "fr7",  39,    \
  2210.   "fr8",  40, "fr9",  41, "fr10", 42, "fr11", 43,    \
  2211.   "fr12", 44, "fr13", 45, "fr14", 46, "fr15", 47,    \
  2212.   "fr16", 48, "fr17", 49, "fr18", 50, "fr19", 51,    \
  2213.   "fr20", 52, "fr21", 53, "fr22", 54, "fr23", 55,    \
  2214.   "fr24", 56, "fr25", 57, "fr26", 58, "fr27", 59,    \
  2215.   "fr28", 60, "fr29", 61, "fr30", 62, "fr31", 63,    \
  2216.   /* no additional names for: mq, lr, ctr, ap */    \
  2217.   "cr0",  68, "cr1",  69, "cr2",  70, "cr3",  71,    \
  2218.   "cr4",  72, "cr5",  73, "cr6",  74, "cr7",  75,    \
  2219.   "cc",   68 }
  2220.  
  2221. /* How to renumber registers for dbx and gdb.  */
  2222.  
  2223. #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
  2224.  
  2225. /* Text to write out after a CALL that may be replaced by glue code by
  2226.    the loader.  This depends on the AIX version.  */
  2227. #define RS6000_CALL_GLUE "cror 31,31,31"
  2228.  
  2229. /* This is how to output the definition of a user-level label named NAME,
  2230.    such as the label on a static function or variable NAME.  */
  2231.  
  2232. #define ASM_OUTPUT_LABEL(FILE,NAME)    \
  2233.   do { RS6000_OUTPUT_BASENAME (FILE, NAME); fputs (":\n", FILE); } while (0)
  2234.  
  2235. /* This is how to output a command to make the user-level label named NAME
  2236.    defined for reference from other files.  */
  2237.  
  2238. #define ASM_GLOBALIZE_LABEL(FILE,NAME)    \
  2239.   do { fputs ("\t.globl ", FILE);    \
  2240.        RS6000_OUTPUT_BASENAME (FILE, NAME); fputs ("\n", FILE);} while (0)
  2241.  
  2242. /* This is how to output a reference to a user-level label named NAME.
  2243.    `assemble_name' uses this.  */
  2244.  
  2245. #define ASM_OUTPUT_LABELREF(FILE,NAME)    \
  2246.   fprintf (FILE, NAME)
  2247.  
  2248. /* This is how to output an internal numbered label where
  2249.    PREFIX is the class of label and NUM is the number within the class.  */
  2250.  
  2251. #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)    \
  2252.   fprintf (FILE, "%s..%d:\n", PREFIX, NUM)
  2253.  
  2254. /* This is how to output an internal label prefix.  rs6000.c uses this
  2255.    when generating traceback tables.  */
  2256.  
  2257. #define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX)    \
  2258.   fprintf (FILE, "%s..", PREFIX)
  2259.  
  2260. /* This is how to output a label for a jump table.  Arguments are the same as
  2261.    for ASM_OUTPUT_INTERNAL_LABEL, except the insn for the jump table is
  2262.    passed. */
  2263.  
  2264. #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLEINSN)    \
  2265. { ASM_OUTPUT_ALIGN (FILE, 2); ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM); }
  2266.  
  2267. /* This is how to store into the string LABEL
  2268.    the symbol_ref name of an internal numbered label where
  2269.    PREFIX is the class of label and NUM is the number within the class.
  2270.    This is suitable for output with `assemble_name'.  */
  2271.  
  2272. #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)    \
  2273.   sprintf (LABEL, "%s..%d", PREFIX, NUM)
  2274.  
  2275. /* This is how to output an assembler line defining a `double' constant.  */
  2276.  
  2277. #define ASM_OUTPUT_DOUBLE(FILE, VALUE)                    \
  2278.   {                                    \
  2279.     if (REAL_VALUE_ISINF (VALUE)                    \
  2280.         || REAL_VALUE_ISNAN (VALUE)                    \
  2281.     || REAL_VALUE_MINUS_ZERO (VALUE))                \
  2282.       {                                    \
  2283.     long t[2];                            \
  2284.     REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), t);            \
  2285.     fprintf (FILE, "\t.long 0x%lx\n\t.long 0x%lx\n",        \
  2286.         t[0] & 0xffffffff, t[1] & 0xffffffff);            \
  2287.       }                                    \
  2288.     else                                \
  2289.       {                                    \
  2290.     char str[30];                            \
  2291.     REAL_VALUE_TO_DECIMAL (VALUE, "%.20e", str);            \
  2292.     fprintf (FILE, "\t.double 0d%s\n", str);            \
  2293.       }                                    \
  2294.   }
  2295.  
  2296. /* This is how to output an assembler line defining a `float' constant.  */
  2297.  
  2298. #define ASM_OUTPUT_FLOAT(FILE, VALUE)                    \
  2299.   {                                    \
  2300.     if (REAL_VALUE_ISINF (VALUE)                    \
  2301.         || REAL_VALUE_ISNAN (VALUE)                    \
  2302.     || REAL_VALUE_MINUS_ZERO (VALUE))                \
  2303.       {                                    \
  2304.     long t;                                \
  2305.     REAL_VALUE_TO_TARGET_SINGLE ((VALUE), t);            \
  2306.     fprintf (FILE, "\t.long 0x%lx\n", t & 0xffffffff);        \
  2307.       }                                    \
  2308.     else                                \
  2309.       {                                    \
  2310.     char str[30];                            \
  2311.     REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", str);            \
  2312.     fprintf (FILE, "\t.float 0d%s\n", str);                \
  2313.       }                                    \
  2314.   }
  2315.  
  2316. /* This is how to output an assembler line defining an `int' constant.  */
  2317.  
  2318. #define ASM_OUTPUT_INT(FILE,VALUE)  \
  2319. ( fprintf (FILE, "\t.long "),            \
  2320.   output_addr_const (FILE, (VALUE)),        \
  2321.   fprintf (FILE, "\n"))
  2322.  
  2323. /* Likewise for `char' and `short' constants.  */
  2324.  
  2325. #define ASM_OUTPUT_SHORT(FILE,VALUE)  \
  2326. ( fprintf (FILE, "\t.short "),            \
  2327.   output_addr_const (FILE, (VALUE)),        \
  2328.   fprintf (FILE, "\n"))
  2329.  
  2330. #define ASM_OUTPUT_CHAR(FILE,VALUE)  \
  2331. ( fprintf (FILE, "\t.byte "),            \
  2332.   output_addr_const (FILE, (VALUE)),        \
  2333.   fprintf (FILE, "\n"))
  2334.  
  2335. /* This is how to output an assembler line for a numeric constant byte.  */
  2336.  
  2337. #define ASM_OUTPUT_BYTE(FILE,VALUE)  \
  2338.   fprintf (FILE, "\t.byte 0x%x\n", (VALUE))
  2339.  
  2340. /* This is how to output an assembler line to define N characters starting
  2341.    at P to FILE.  */
  2342.  
  2343. #define ASM_OUTPUT_ASCII(FILE, P, N)  output_ascii ((FILE), (P), (N))
  2344.  
  2345. /* This is how to output code to push a register on the stack.
  2346.    It need not be very fast code.  */
  2347.  
  2348. #define ASM_OUTPUT_REG_PUSH(FILE,REGNO)                    \
  2349. do {                                    \
  2350.   extern char *reg_names[];                        \
  2351.   asm_fprintf (FILE, "\{tstu|stwu} %s,-4(%s)\n", reg_names[REGNO],    \
  2352.            reg_names[1]);                        \
  2353. } while (0)
  2354.  
  2355. /* This is how to output an insn to pop a register from the stack.
  2356.    It need not be very fast code.  */
  2357.  
  2358. #define ASM_OUTPUT_REG_POP(FILE,REGNO)                    \
  2359. do {                                    \
  2360.   extern char *reg_names[];                        \
  2361.   asm_fprintf (FILE, "\t{l|lwz} %s,0(%s)\n\t{ai|addic} %s,%s,4\n",    \
  2362.            reg_names[REGNO], reg_names[1], reg_names[1],        \
  2363.            reg_names[1]);                        \
  2364. } while (0)
  2365.  
  2366. /* This is how to output an element of a case-vector that is absolute. 
  2367.    (RS/6000 does not use such vectors, but we must define this macro
  2368.    anyway.)   */
  2369.  
  2370. #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE)        \
  2371.   do { char buf[100];                    \
  2372.        fprintf (FILE, "\t.long ");            \
  2373.        ASM_GENERATE_INTERNAL_LABEL (buf, "L", VALUE);    \
  2374.        assemble_name (FILE, buf);            \
  2375.        fprintf (FILE, "\n");                \
  2376.      } while (0)
  2377.  
  2378. /* This is how to output an element of a case-vector that is relative.  */
  2379.  
  2380. #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL)    \
  2381.   do { char buf[100];                    \
  2382.        fprintf (FILE, "\t.long ");            \
  2383.        ASM_GENERATE_INTERNAL_LABEL (buf, "L", VALUE);    \
  2384.        assemble_name (FILE, buf);            \
  2385.        fprintf (FILE, "-");                \
  2386.        ASM_GENERATE_INTERNAL_LABEL (buf, "L", REL);    \
  2387.        assemble_name (FILE, buf);            \
  2388.        fprintf (FILE, "\n");                \
  2389.      } while (0)
  2390.  
  2391. /* This is how to output an assembler line
  2392.    that says to advance the location counter
  2393.    to a multiple of 2**LOG bytes.  */
  2394.  
  2395. #define ASM_OUTPUT_ALIGN(FILE,LOG)    \
  2396.   if ((LOG) != 0)            \
  2397.     fprintf (FILE, "\t.align %d\n", (LOG))
  2398.  
  2399. #define ASM_OUTPUT_SKIP(FILE,SIZE)  \
  2400.   fprintf (FILE, "\t.space %d\n", (SIZE))
  2401.  
  2402. /* This says how to output an assembler line
  2403.    to define a global common symbol.  */
  2404.  
  2405. #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)    \
  2406.   do { fputs (".comm ", (FILE));            \
  2407.        RS6000_OUTPUT_BASENAME ((FILE), (NAME));        \
  2408.        fprintf ((FILE), ",%d\n", (SIZE)); } while (0)
  2409.  
  2410. /* This says how to output an assembler line
  2411.    to define a local common symbol.  */
  2412.  
  2413. #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE,ROUNDED)    \
  2414.   do { fputs (".lcomm ", (FILE));            \
  2415.        RS6000_OUTPUT_BASENAME ((FILE), (NAME));        \
  2416.        fprintf ((FILE), ",%d,%s\n", (SIZE), xcoff_bss_section_name); \
  2417.      } while (0)
  2418.  
  2419. /* Store in OUTPUT a string (made with alloca) containing
  2420.    an assembler-name for a local static variable named NAME.
  2421.    LABELNO is an integer which is different for each call.  */
  2422.  
  2423. #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO)    \
  2424. ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10),    \
  2425.   sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
  2426.  
  2427. /* Define the parentheses used to group arithmetic operations
  2428.    in assembler code.  */
  2429.  
  2430. #define ASM_OPEN_PAREN "("
  2431. #define ASM_CLOSE_PAREN ")"
  2432.  
  2433. /* Define results of standard character escape sequences.  */
  2434. #define TARGET_BELL 007
  2435. #define TARGET_BS 010
  2436. #define TARGET_TAB 011
  2437. #define TARGET_NEWLINE 012
  2438. #define TARGET_VT 013
  2439. #define TARGET_FF 014
  2440. #define TARGET_CR 015
  2441.  
  2442. /* Print operand X (an rtx) in assembler syntax to file FILE.
  2443.    CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
  2444.    For `%' followed by punctuation, CODE is the punctuation and X is null.  */
  2445.  
  2446. #define PRINT_OPERAND(FILE, X, CODE)  print_operand (FILE, X, CODE)
  2447.  
  2448. /* Define which CODE values are valid.  */
  2449.  
  2450. #define PRINT_OPERAND_PUNCT_VALID_P(CODE)  ((CODE) == '.' || (CODE) == '*')
  2451.  
  2452. /* Print a memory address as an operand to reference that memory location.  */
  2453.  
  2454. #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR)
  2455.  
  2456. /* Define the codes that are matched by predicates in rs6000.c.  */
  2457.  
  2458. #define PREDICATE_CODES \
  2459.   {"short_cint_operand", {CONST_INT}},                \
  2460.   {"u_short_cint_operand", {CONST_INT}},            \
  2461.   {"non_short_cint_operand", {CONST_INT}},            \
  2462.   {"gpc_reg_operand", {SUBREG, REG}},                \
  2463.   {"cc_reg_operand", {SUBREG, REG}},                \
  2464.   {"reg_or_short_operand", {SUBREG, REG, CONST_INT}},        \
  2465.   {"reg_or_neg_short_operand", {SUBREG, REG, CONST_INT}},    \
  2466.   {"reg_or_u_short_operand", {SUBREG, REG, CONST_INT}},        \
  2467.   {"reg_or_cint_operand", {SUBREG, REG, CONST_INT}},        \
  2468.   {"easy_fp_constant", {CONST_DOUBLE}},                \
  2469.   {"reg_or_mem_operand", {SUBREG, MEM, REG}},            \
  2470.   {"lwa_operand", {SUBREG, MEM, REG}},                \
  2471.   {"offsettable_addr_operand", {REG, SUBREG, PLUS}},        \
  2472.   {"fp_reg_or_mem_operand", {SUBREG, MEM, REG}},        \
  2473.   {"mem_or_easy_const_operand", {SUBREG, MEM, CONST_DOUBLE}},    \
  2474.   {"add_operand", {SUBREG, REG, CONST_INT}},            \
  2475.   {"non_add_cint_operand", {CONST_INT}},            \
  2476.   {"and_operand", {SUBREG, REG, CONST_INT}},            \
  2477.   {"non_and_cint_operand", {CONST_INT}},            \
  2478.   {"logical_operand", {SUBREG, REG, CONST_INT}},        \
  2479.   {"non_logical_cint_operand", {CONST_INT}},            \
  2480.   {"mask_operand", {CONST_INT}},                \
  2481.   {"call_operand", {SYMBOL_REF, REG}},                \
  2482.   {"current_file_function_operand", {SYMBOL_REF}},        \
  2483.   {"input_operand", {SUBREG, MEM, REG, CONST_INT, SYMBOL_REF}},    \
  2484.   {"load_multiple_operation", {PARALLEL}},            \
  2485.   {"store_multiple_operation", {PARALLEL}},            \
  2486.   {"branch_comparison_operator", {EQ, NE, LE, LT, GE,        \
  2487.                   GT, LEU, LTU, GEU, GTU}},    \
  2488.   {"scc_comparison_operator", {EQ, NE, LE, LT, GE,        \
  2489.                    GT, LEU, LTU, GEU, GTU}},
  2490.  
  2491. /* Declare functions in rs6000.c */
  2492. extern void output_options ();
  2493. extern void rs6000_override_options ();
  2494. extern struct rtx_def *rs6000_float_const ();
  2495. extern struct rtx_def *rs6000_immed_double_const ();
  2496. extern int direct_return ();
  2497. extern int any_operand ();
  2498. extern int short_cint_operand ();
  2499. extern int u_short_cint_operand ();
  2500. extern int non_short_cint_operand ();
  2501. extern int gpc_reg_operand ();
  2502. extern int cc_reg_operand ();
  2503. extern int reg_or_short_operand ();
  2504. extern int reg_or_neg_short_operand ();
  2505. extern int reg_or_u_short_operand ();
  2506. extern int reg_or_cint_operand ();
  2507. extern int easy_fp_constant ();
  2508. extern int volatile_mem_operand ();
  2509. extern int offsettable_addr_operand ();
  2510. extern int fp_reg_or_mem_operand ();
  2511. extern int mem_or_easy_const_operand ();
  2512. extern int add_operand ();
  2513. extern int non_add_cint_operand ();
  2514. extern int logical_operand ();
  2515. extern int non_logical_operand ();
  2516. extern int mask_constant ();
  2517. extern int mask_operand ();
  2518. extern int and_operand ();
  2519. extern int non_and_cint_operand ();
  2520. extern int reg_or_mem_operand ();
  2521. extern int lwa_operand ();
  2522. extern int call_operand ();
  2523. extern int current_file_function_operand ();
  2524. extern int input_operand ();
  2525. extern void init_cumulative_args ();
  2526. extern void function_arg_advance ();
  2527. extern struct rtx_def *function_arg ();
  2528. extern int function_arg_partial_nregs ();
  2529. extern int function_arg_pass_by_reference ();
  2530. extern void setup_incoming_varargs ();
  2531. extern struct rtx_def *expand_builtin_saveregs ();
  2532. extern struct rtx_def *rs6000_stack_temp ();
  2533. extern int expand_block_move ();
  2534. extern int load_multiple_operation ();
  2535. extern int store_multiple_operation ();
  2536. extern int branch_comparison_operator ();
  2537. extern int scc_comparison_operator ();
  2538. extern int includes_lshift_p ();
  2539. extern int includes_rshift_p ();
  2540. extern int registers_ok_for_quad_peep ();
  2541. extern int addrs_ok_for_quad_peep ();
  2542. extern enum reg_class secondary_reload_class ();
  2543. extern int ccr_bit ();
  2544. extern void print_operand ();
  2545. extern void print_operand_address ();
  2546. extern int first_reg_to_save ();
  2547. extern int first_fp_reg_to_save ();
  2548. extern int rs6000_makes_calls ();
  2549. extern rs6000_stack_t *rs6000_stack_info ();
  2550. extern void svr4_traceback ();
  2551. extern void output_prolog ();
  2552. extern void output_epilog ();
  2553. extern void output_toc ();
  2554. extern void output_ascii ();
  2555. extern void rs6000_gen_section_name ();
  2556. extern void output_function_profiler ();
  2557. extern int rs6000_adjust_cost ();
  2558.