home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / gcc / gcc.info-21 (.txt) < prev    next >
GNU Info File  |  1995-06-16  |  45KB  |  743 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.55 from the input
  2. file gcc.texi.
  3.    This file documents the use and the internals of the GNU compiler.
  4.    Published by the Free Software Foundation 59 Temple Place - Suite 330
  5. Boston, MA 02111-1307 USA
  6.    Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995 Free Software
  7. Foundation, Inc.
  8.    Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.    Permission is granted to copy and distribute modified versions of
  12. this manual under the conditions for verbatim copying, provided also
  13. that the sections entitled "GNU General Public License," "Funding for
  14. Free Software," and "Protect Your Freedom--Fight `Look And Feel'" are
  15. included exactly as in the original, and provided that the entire
  16. resulting derived work is distributed under the terms of a permission
  17. notice identical to this one.
  18.    Permission is granted to copy and distribute translations of this
  19. manual into another language, under the above conditions for modified
  20. versions, except that the sections entitled "GNU General Public
  21. License," "Funding for Free Software," and "Protect Your Freedom--Fight
  22. `Look And Feel'", and this permission notice, may be included in
  23. translations approved by the Free Software Foundation instead of in the
  24. original English.
  25. File: gcc.info,  Node: Register Arguments,  Next: Scalar Return,  Prev: Stack Arguments,  Up: Stack and Calling
  26. Passing Arguments in Registers
  27. ------------------------------
  28.    This section describes the macros which let you control how various
  29. types of arguments are passed in registers or how they are arranged in
  30. the stack.
  31. `FUNCTION_ARG (CUM, MODE, TYPE, NAMED)'
  32.      A C expression that controls whether a function argument is passed
  33.      in a register, and which register.
  34.      The arguments are CUM, which summarizes all the previous
  35.      arguments; MODE, the machine mode of the argument; TYPE, the data
  36.      type of the argument as a tree node or 0 if that is not known
  37.      (which happens for C support library functions); and NAMED, which
  38.      is 1 for an ordinary argument and 0 for nameless arguments that
  39.      correspond to `...' in the called function's prototype.
  40.      The value of the expression should either be a `reg' RTX for the
  41.      hard register in which to pass the argument, or zero to pass the
  42.      argument on the stack.
  43.      For machines like the Vax and 68000, where normally all arguments
  44.      are pushed, zero suffices as a definition.
  45.      The usual way to make the ANSI library `stdarg.h' work on a machine
  46.      where some arguments are usually passed in registers, is to cause
  47.      nameless arguments to be passed on the stack instead.  This is done
  48.      by making `FUNCTION_ARG' return 0 whenever NAMED is 0.
  49.      You may use the macro `MUST_PASS_IN_STACK (MODE, TYPE)' in the
  50.      definition of this macro to determine if this argument is of a
  51.      type that must be passed in the stack.  If `REG_PARM_STACK_SPACE'
  52.      is not defined and `FUNCTION_ARG' returns non-zero for such an
  53.      argument, the compiler will abort.  If `REG_PARM_STACK_SPACE' is
  54.      defined, the argument will be computed in the stack and then
  55.      loaded into a register.
  56. `FUNCTION_INCOMING_ARG (CUM, MODE, TYPE, NAMED)'
  57.      Define this macro if the target machine has "register windows", so
  58.      that the register in which a function sees an arguments is not
  59.      necessarily the same as the one in which the caller passed the
  60.      argument.
  61.      For such machines, `FUNCTION_ARG' computes the register in which
  62.      the caller passes the value, and `FUNCTION_INCOMING_ARG' should be
  63.      defined in a similar fashion to tell the function being called
  64.      where the arguments will arrive.
  65.      If `FUNCTION_INCOMING_ARG' is not defined, `FUNCTION_ARG' serves
  66.      both purposes.
  67. `FUNCTION_ARG_PARTIAL_NREGS (CUM, MODE, TYPE, NAMED)'
  68.      A C expression for the number of words, at the beginning of an
  69.      argument, must be put in registers.  The value must be zero for
  70.      arguments that are passed entirely in registers or that are
  71.      entirely pushed on the stack.
  72.      On some machines, certain arguments must be passed partially in
  73.      registers and partially in memory.  On these machines, typically
  74.      the first N words of arguments are passed in registers, and the
  75.      rest on the stack.  If a multi-word argument (a `double' or a
  76.      structure) crosses that boundary, its first few words must be
  77.      passed in registers and the rest must be pushed.  This macro tells
  78.      the compiler when this occurs, and how many of the words should go
  79.      in registers.
  80.      `FUNCTION_ARG' for these arguments should return the first
  81.      register to be used by the caller for this argument; likewise
  82.      `FUNCTION_INCOMING_ARG', for the called function.
  83. `FUNCTION_ARG_PASS_BY_REFERENCE (CUM, MODE, TYPE, NAMED)'
  84.      A C expression that indicates when an argument must be passed by
  85.      reference.  If nonzero for an argument, a copy of that argument is
  86.      made in memory and a pointer to the argument is passed instead of
  87.      the argument itself.  The pointer is passed in whatever way is
  88.      appropriate for passing a pointer to that type.
  89.      On machines where `REG_PARM_STACK_SPACE' is not defined, a suitable
  90.      definition of this macro might be
  91.           #define FUNCTION_ARG_PASS_BY_REFERENCE\
  92.           (CUM, MODE, TYPE, NAMED)  \
  93.             MUST_PASS_IN_STACK (MODE, TYPE)
  94. `FUNCTION_ARG_CALLEE_COPIES (CUM, MODE, TYPE, NAMED)'
  95.      If defined, a C expression that indicates when it is the called
  96.      function's responsibility to make a copy of arguments passed by
  97.      invisible reference.  Normally, the caller makes a copy and passes
  98.      the address of the copy to the routine being called.  When
  99.      FUNCTION_ARG_CALLEE_COPIES is defined and is nonzero, the caller
  100.      does not make a copy.  Instead, it passes a pointer to the "live"
  101.      value.  The called function must not modify this value.  If it can
  102.      be determined that the value won't be modified, it need not make a
  103.      copy; otherwise a copy must be made.
  104. `CUMULATIVE_ARGS'
  105.      A C type for declaring a variable that is used as the first
  106.      argument of `FUNCTION_ARG' and other related values.  For some
  107.      target machines, the type `int' suffices and can hold the number
  108.      of bytes of argument so far.
  109.      There is no need to record in `CUMULATIVE_ARGS' anything about the
  110.      arguments that have been passed on the stack.  The compiler has
  111.      other variables to keep track of that.  For target machines on
  112.      which all arguments are passed on the stack, there is no need to
  113.      store anything in `CUMULATIVE_ARGS'; however, the data structure
  114.      must exist and should not be empty, so use `int'.
  115. `INIT_CUMULATIVE_ARGS (CUM, FNTYPE, LIBNAME)'
  116.      A C statement (sans semicolon) for initializing the variable CUM
  117.      for the state at the beginning of the argument list.  The variable
  118.      has type `CUMULATIVE_ARGS'.  The value of FNTYPE is the tree node
  119.      for the data type of the function which will receive the args, or 0
  120.      if the args are to a compiler support library function.
  121.      When processing a call to a compiler support library function,
  122.      LIBNAME identifies which one.  It is a `symbol_ref' rtx which
  123.      contains the name of the function, as a string.  LIBNAME is 0 when
  124.      an ordinary C function call is being processed.  Thus, each time
  125.      this macro is called, either LIBNAME or FNTYPE is nonzero, but
  126.      never both of them at once.
  127. `INIT_CUMULATIVE_INCOMING_ARGS (CUM, FNTYPE, LIBNAME)'
  128.      Like `INIT_CUMULATIVE_ARGS' but overrides it for the purposes of
  129.      finding the arguments for the function being compiled.  If this
  130.      macro is undefined, `INIT_CUMULATIVE_ARGS' is used instead.
  131.      The value passed for LIBNAME is always 0, since library routines
  132.      with special calling conventions are never compiled with GNU CC.
  133.      The argument LIBNAME exists for symmetry with
  134.      `INIT_CUMULATIVE_ARGS'.
  135. `FUNCTION_ARG_ADVANCE (CUM, MODE, TYPE, NAMED)'
  136.      A C statement (sans semicolon) to update the summarizer variable
  137.      CUM to advance past an argument in the argument list.  The values
  138.      MODE, TYPE and NAMED describe that argument.  Once this is done,
  139.      the variable CUM is suitable for analyzing the *following*
  140.      argument with `FUNCTION_ARG', etc.
  141.      This macro need not do anything if the argument in question was
  142.      passed on the stack.  The compiler knows how to track the amount
  143.      of stack space used for arguments without any special help.
  144. `FUNCTION_ARG_PADDING (MODE, TYPE)'
  145.      If defined, a C expression which determines whether, and in which
  146.      direction, to pad out an argument with extra space.  The value
  147.      should be of type `enum direction': either `upward' to pad above
  148.      the argument, `downward' to pad below, or `none' to inhibit
  149.      padding.
  150.      The *amount* of padding is always just enough to reach the next
  151.      multiple of `FUNCTION_ARG_BOUNDARY'; this macro does not control
  152.      it.
  153.      This macro has a default definition which is right for most
  154.      systems.  For little-endian machines, the default is to pad
  155.      upward.  For big-endian machines, the default is to pad downward
  156.      for an argument of constant size shorter than an `int', and upward
  157.      otherwise.
  158. `FUNCTION_ARG_BOUNDARY (MODE, TYPE)'
  159.      If defined, a C expression that gives the alignment boundary, in
  160.      bits, of an argument with the specified mode and type.  If it is
  161.      not defined, `PARM_BOUNDARY' is used for all arguments.
  162. `FUNCTION_ARG_REGNO_P (REGNO)'
  163.      A C expression that is nonzero if REGNO is the number of a hard
  164.      register in which function arguments are sometimes passed.  This
  165.      does *not* include implicit arguments such as the static chain and
  166.      the structure-value address.  On many machines, no registers can be
  167.      used for this purpose since all function arguments are pushed on
  168.      the stack.
  169. File: gcc.info,  Node: Scalar Return,  Next: Aggregate Return,  Prev: Register Arguments,  Up: Stack and Calling
  170. How Scalar Function Values Are Returned
  171. ---------------------------------------
  172.    This section discusses the macros that control returning scalars as
  173. values--values that can fit in registers.
  174. `TRADITIONAL_RETURN_FLOAT'
  175.      Define this macro if `-traditional' should not cause functions
  176.      declared to return `float' to convert the value to `double'.
  177. `FUNCTION_VALUE (VALTYPE, FUNC)'
  178.      A C expression to create an RTX representing the place where a
  179.      function returns a value of data type VALTYPE.  VALTYPE is a tree
  180.      node representing a data type.  Write `TYPE_MODE (VALTYPE)' to get
  181.      the machine mode used to represent that type.  On many machines,
  182.      only the mode is relevant.  (Actually, on most machines, scalar
  183.      values are returned in the same place regardless of mode).
  184.      If `PROMOTE_FUNCTION_RETURN' is defined, you must apply the same
  185.      promotion rules specified in `PROMOTE_MODE' if VALTYPE is a scalar
  186.      type.
  187.      If the precise function being called is known, FUNC is a tree node
  188.      (`FUNCTION_DECL') for it; otherwise, FUNC is a null pointer.  This
  189.      makes it possible to use a different value-returning convention
  190.      for specific functions when all their calls are known.
  191.      `FUNCTION_VALUE' is not used for return vales with aggregate data
  192.      types, because these are returned in another way.  See
  193.      `STRUCT_VALUE_REGNUM' and related macros, below.
  194. `FUNCTION_OUTGOING_VALUE (VALTYPE, FUNC)'
  195.      Define this macro if the target machine has "register windows" so
  196.      that the register in which a function returns its value is not the
  197.      same as the one in which the caller sees the value.
  198.      For such machines, `FUNCTION_VALUE' computes the register in which
  199.      the caller will see the value.  `FUNCTION_OUTGOING_VALUE' should be
  200.      defined in a similar fashion to tell the function where to put the
  201.      value.
  202.      If `FUNCTION_OUTGOING_VALUE' is not defined, `FUNCTION_VALUE'
  203.      serves both purposes.
  204.      `FUNCTION_OUTGOING_VALUE' is not used for return vales with
  205.      aggregate data types, because these are returned in another way.
  206.      See `STRUCT_VALUE_REGNUM' and related macros, below.
  207. `LIBCALL_VALUE (MODE)'
  208.      A C expression to create an RTX representing the place where a
  209.      library function returns a value of mode MODE.  If the precise
  210.      function being called is known, FUNC is a tree node
  211.      (`FUNCTION_DECL') for it; otherwise, FUNC is a null pointer.  This
  212.      makes it possible to use a different value-returning convention
  213.      for specific functions when all their calls are known.
  214.      Note that "library function" in this context means a compiler
  215.      support routine, used to perform arithmetic, whose name is known
  216.      specially by the compiler and was not mentioned in the C code being
  217.      compiled.
  218.      The definition of `LIBRARY_VALUE' need not be concerned aggregate
  219.      data types, because none of the library functions returns such
  220.      types.
  221. `FUNCTION_VALUE_REGNO_P (REGNO)'
  222.      A C expression that is nonzero if REGNO is the number of a hard
  223.      register in which the values of called function may come back.
  224.      A register whose use for returning values is limited to serving as
  225.      the second of a pair (for a value of type `double', say) need not
  226.      be recognized by this macro.  So for most machines, this definition
  227.      suffices:
  228.           #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
  229.      If the machine has register windows, so that the caller and the
  230.      called function use different registers for the return value, this
  231.      macro should recognize only the caller's register numbers.
  232. `APPLY_RESULT_SIZE'
  233.      Define this macro if `untyped_call' and `untyped_return' need more
  234.      space than is implied by `FUNCTION_VALUE_REGNO_P' for saving and
  235.      restoring an arbitrary return value.
  236. File: gcc.info,  Node: Aggregate Return,  Next: Caller Saves,  Prev: Scalar Return,  Up: Stack and Calling
  237. How Large Values Are Returned
  238. -----------------------------
  239.    When a function value's mode is `BLKmode' (and in some other cases),
  240. the value is not returned according to `FUNCTION_VALUE' (*note Scalar
  241. Return::.).  Instead, the caller passes the address of a block of
  242. memory in which the value should be stored.  This address is called the
  243. "structure value address".
  244.    This section describes how to control returning structure values in
  245. memory.
  246. `RETURN_IN_MEMORY (TYPE)'
  247.      A C expression which can inhibit the returning of certain function
  248.      values in registers, based on the type of value.  A nonzero value
  249.      says to return the function value in memory, just as large
  250.      structures are always returned.  Here TYPE will be a C expression
  251.      of type `tree', representing the data type of the value.
  252.      Note that values of mode `BLKmode' must be explicitly handled by
  253.      this macro.  Also, the option `-fpcc-struct-return' takes effect
  254.      regardless of this macro.  On most systems, it is possible to
  255.      leave the macro undefined; this causes a default definition to be
  256.      used, whose value is the constant 1 for `BLKmode' values, and 0
  257.      otherwise.
  258.      Do not use this macro to indicate that structures and unions
  259.      should always be returned in memory.  You should instead use
  260.      `DEFAULT_PCC_STRUCT_RETURN' to indicate this.
  261. `DEFAULT_PCC_STRUCT_RETURN'
  262.      Define this macro to be 1 if all structure and union return values
  263.      must be in memory.  Since this results in slower code, this should
  264.      be defined only if needed for compatibility with other compilers
  265.      or with an ABI.  If you define this macro to be 0, then the
  266.      conventions used for structure and union return values are decided
  267.      by the `RETURN_IN_MEMORY' macro.
  268.      If not defined, this defaults to the value 1.
  269. `STRUCT_VALUE_REGNUM'
  270.      If the structure value address is passed in a register, then
  271.      `STRUCT_VALUE_REGNUM' should be the number of that register.
  272. `STRUCT_VALUE'
  273.      If the structure value address is not passed in a register, define
  274.      `STRUCT_VALUE' as an expression returning an RTX for the place
  275.      where the address is passed.  If it returns 0, the address is
  276.      passed as an "invisible" first argument.
  277. `STRUCT_VALUE_INCOMING_REGNUM'
  278.      On some architectures the place where the structure value address
  279.      is found by the called function is not the same place that the
  280.      caller put it.  This can be due to register windows, or it could
  281.      be because the function prologue moves it to a different place.
  282.      If the incoming location of the structure value address is in a
  283.      register, define this macro as the register number.
  284. `STRUCT_VALUE_INCOMING'
  285.      If the incoming location is not a register, then you should define
  286.      `STRUCT_VALUE_INCOMING' as an expression for an RTX for where the
  287.      called function should find the value.  If it should find the
  288.      value on the stack, define this to create a `mem' which refers to
  289.      the frame pointer.  A definition of 0 means that the address is
  290.      passed as an "invisible" first argument.
  291. `PCC_STATIC_STRUCT_RETURN'
  292.      Define this macro if the usual system convention on the target
  293.      machine for returning structures and unions is for the called
  294.      function to return the address of a static variable containing the
  295.      value.
  296.      Do not define this if the usual system convention is for the
  297.      caller to pass an address to the subroutine.
  298.      This macro has effect in `-fpcc-struct-return' mode, but it does
  299.      nothing when you use `-freg-struct-return' mode.
  300. File: gcc.info,  Node: Caller Saves,  Next: Function Entry,  Prev: Aggregate Return,  Up: Stack and Calling
  301. Caller-Saves Register Allocation
  302. --------------------------------
  303.    If you enable it, GNU CC can save registers around function calls.
  304. This makes it possible to use call-clobbered registers to hold
  305. variables that must live across calls.
  306. `DEFAULT_CALLER_SAVES'
  307.      Define this macro if function calls on the target machine do not
  308.      preserve any registers; in other words, if `CALL_USED_REGISTERS'
  309.      has 1 for all registers.  This macro enables `-fcaller-saves' by
  310.      default.  Eventually that option will be enabled by default on all
  311.      machines and both the option and this macro will be eliminated.
  312. `CALLER_SAVE_PROFITABLE (REFS, CALLS)'
  313.      A C expression to determine whether it is worthwhile to consider
  314.      placing a pseudo-register in a call-clobbered hard register and
  315.      saving and restoring it around each function call.  The expression
  316.      should be 1 when this is worth doing, and 0 otherwise.
  317.      If you don't define this macro, a default is used which is good on
  318.      most machines: `4 * CALLS < REFS'.
  319. File: gcc.info,  Node: Function Entry,  Next: Profiling,  Prev: Caller Saves,  Up: Stack and Calling
  320. Function Entry and Exit
  321. -----------------------
  322.    This section describes the macros that output function entry
  323. ("prologue") and exit ("epilogue") code.
  324. `FUNCTION_PROLOGUE (FILE, SIZE)'
  325.      A C compound statement that outputs the assembler code for entry
  326.      to a function.  The prologue is responsible for setting up the
  327.      stack frame, initializing the frame pointer register, saving
  328.      registers that must be saved, and allocating SIZE additional bytes
  329.      of storage for the local variables.  SIZE is an integer.  FILE is
  330.      a stdio stream to which the assembler code should be output.
  331.      The label for the beginning of the function need not be output by
  332.      this macro.  That has already been done when the macro is run.
  333.      To determine which registers to save, the macro can refer to the
  334.      array `regs_ever_live': element R is nonzero if hard register R is
  335.      used anywhere within the function.  This implies the function
  336.      prologue should save register R, provided it is not one of the
  337.      call-used registers.  (`FUNCTION_EPILOGUE' must likewise use
  338.      `regs_ever_live'.)
  339.      On machines that have "register windows", the function entry code
  340.      does not save on the stack the registers that are in the windows,
  341.      even if they are supposed to be preserved by function calls;
  342.      instead it takes appropriate steps to "push" the register stack,
  343.      if any non-call-used registers are used in the function.
  344.      On machines where functions may or may not have frame-pointers, the
  345.      function entry code must vary accordingly; it must set up the frame
  346.      pointer if one is wanted, and not otherwise.  To determine whether
  347.      a frame pointer is in wanted, the macro can refer to the variable
  348.      `frame_pointer_needed'.  The variable's value will be 1 at run
  349.      time in a function that needs a frame pointer.  *Note
  350.      Elimination::.
  351.      The function entry code is responsible for allocating any stack
  352.      space required for the function.  This stack space consists of the
  353.      regions listed below.  In most cases, these regions are allocated
  354.      in the order listed, with the last listed region closest to the
  355.      top of the stack (the lowest address if `STACK_GROWS_DOWNWARD' is
  356.      defined, and the highest address if it is not defined).  You can
  357.      use a different order for a machine if doing so is more convenient
  358.      or required for compatibility reasons.  Except in cases where
  359.      required by standard or by a debugger, there is no reason why the
  360.      stack layout used by GCC need agree with that used by other
  361.      compilers for a machine.
  362.         * A region of `current_function_pretend_args_size' bytes of
  363.           uninitialized space just underneath the first argument
  364.           arriving on the stack.  (This may not be at the very start of
  365.           the allocated stack region if the calling sequence has pushed
  366.           anything else since pushing the stack arguments.  But
  367.           usually, on such machines, nothing else has been pushed yet,
  368.           because the function prologue itself does all the pushing.)
  369.           This region is used on machines where an argument may be
  370.           passed partly in registers and partly in memory, and, in some
  371.           cases to support the features in `varargs.h' and `stdargs.h'.
  372.         * An area of memory used to save certain registers used by the
  373.           function.  The size of this area, which may also include
  374.           space for such things as the return address and pointers to
  375.           previous stack frames, is machine-specific and usually
  376.           depends on which registers have been used in the function.
  377.           Machines with register windows often do not require a save
  378.           area.
  379.         * A region of at least SIZE bytes, possibly rounded up to an
  380.           allocation boundary, to contain the local variables of the
  381.           function.  On some machines, this region and the save area
  382.           may occur in the opposite order, with the save area closer to
  383.           the top of the stack.
  384.         * Optionally, when `ACCUMULATE_OUTGOING_ARGS' is defined, a
  385.           region of `current_function_outgoing_args_size' bytes to be
  386.           used for outgoing argument lists of the function.  *Note
  387.           Stack Arguments::.
  388.      Normally, it is necessary for the macros `FUNCTION_PROLOGUE' and
  389.      `FUNCTION_EPILOGUE' to treat leaf functions specially.  The C
  390.      variable `leaf_function' is nonzero for such a function.
  391. `EXIT_IGNORE_STACK'
  392.      Define this macro as a C expression that is nonzero if the return
  393.      instruction or the function epilogue ignores the value of the stack
  394.      pointer; in other words, if it is safe to delete an instruction to
  395.      adjust the stack pointer before a return from the function.
  396.      Note that this macro's value is relevant only for functions for
  397.      which frame pointers are maintained.  It is never safe to delete a
  398.      final stack adjustment in a function that has no frame pointer,
  399.      and the compiler knows this regardless of `EXIT_IGNORE_STACK'.
  400. `FUNCTION_EPILOGUE (FILE, SIZE)'
  401.      A C compound statement that outputs the assembler code for exit
  402.      from a function.  The epilogue is responsible for restoring the
  403.      saved registers and stack pointer to their values when the
  404.      function was called, and returning control to the caller.  This
  405.      macro takes the same arguments as the macro `FUNCTION_PROLOGUE',
  406.      and the registers to restore are determined from `regs_ever_live'
  407.      and `CALL_USED_REGISTERS' in the same way.
  408.      On some machines, there is a single instruction that does all the
  409.      work of returning from the function.  On these machines, give that
  410.      instruction the name `return' and do not define the macro
  411.      `FUNCTION_EPILOGUE' at all.
  412.      Do not define a pattern named `return' if you want the
  413.      `FUNCTION_EPILOGUE' to be used.  If you want the target switches
  414.      to control whether return instructions or epilogues are used,
  415.      define a `return' pattern with a validity condition that tests the
  416.      target switches appropriately.  If the `return' pattern's validity
  417.      condition is false, epilogues will be used.
  418.      On machines where functions may or may not have frame-pointers, the
  419.      function exit code must vary accordingly.  Sometimes the code for
  420.      these two cases is completely different.  To determine whether a
  421.      frame pointer is wanted, the macro can refer to the variable
  422.      `frame_pointer_needed'.  The variable's value will be 1 when
  423.      compiling a function that needs a frame pointer.
  424.      Normally, `FUNCTION_PROLOGUE' and `FUNCTION_EPILOGUE' must treat
  425.      leaf functions specially.  The C variable `leaf_function' is
  426.      nonzero for such a function.  *Note Leaf Functions::.
  427.      On some machines, some functions pop their arguments on exit while
  428.      others leave that for the caller to do.  For example, the 68020
  429.      when given `-mrtd' pops arguments in functions that take a fixed
  430.      number of arguments.
  431.      Your definition of the macro `RETURN_POPS_ARGS' decides which
  432.      functions pop their own arguments.  `FUNCTION_EPILOGUE' needs to
  433.      know what was decided.  The variable that is called
  434.      `current_function_pops_args' is the number of bytes of its
  435.      arguments that a function should pop.  *Note Scalar Return::.
  436. `DELAY_SLOTS_FOR_EPILOGUE'
  437.      Define this macro if the function epilogue contains delay slots to
  438.      which instructions from the rest of the function can be "moved".
  439.      The definition should be a C expression whose value is an integer
  440.      representing the number of delay slots there.
  441. `ELIGIBLE_FOR_EPILOGUE_DELAY (INSN, N)'
  442.      A C expression that returns 1 if INSN can be placed in delay slot
  443.      number N of the epilogue.
  444.      The argument N is an integer which identifies the delay slot now
  445.      being considered (since different slots may have different rules of
  446.      eligibility).  It is never negative and is always less than the
  447.      number of epilogue delay slots (what `DELAY_SLOTS_FOR_EPILOGUE'
  448.      returns).  If you reject a particular insn for a given delay slot,
  449.      in principle, it may be reconsidered for a subsequent delay slot.
  450.      Also, other insns may (at least in principle) be considered for
  451.      the so far unfilled delay slot.
  452.      The insns accepted to fill the epilogue delay slots are put in an
  453.      RTL list made with `insn_list' objects, stored in the variable
  454.      `current_function_epilogue_delay_list'.  The insn for the first
  455.      delay slot comes first in the list.  Your definition of the macro
  456.      `FUNCTION_EPILOGUE' should fill the delay slots by outputting the
  457.      insns in this list, usually by calling `final_scan_insn'.
  458.      You need not define this macro if you did not define
  459.      `DELAY_SLOTS_FOR_EPILOGUE'.
  460. File: gcc.info,  Node: Profiling,  Prev: Function Entry,  Up: Stack and Calling
  461. Generating Code for Profiling
  462. -----------------------------
  463.    These macros will help you generate code for profiling.
  464. `FUNCTION_PROFILER (FILE, LABELNO)'
  465.      A C statement or compound statement to output to FILE some
  466.      assembler code to call the profiling subroutine `mcount'.  Before
  467.      calling, the assembler code must load the address of a counter
  468.      variable into a register where `mcount' expects to find the
  469.      address.  The name of this variable is `LP' followed by the number
  470.      LABELNO, so you would generate the name using `LP%d' in a
  471.      `fprintf'.
  472.      The details of how the address should be passed to `mcount' are
  473.      determined by your operating system environment, not by GNU CC.  To
  474.      figure them out, compile a small program for profiling using the
  475.      system's installed C compiler and look at the assembler code that
  476.      results.
  477. `PROFILE_BEFORE_PROLOGUE'
  478.      Define this macro if the code for function profiling should come
  479.      before the function prologue.  Normally, the profiling code comes
  480.      after.
  481. `FUNCTION_BLOCK_PROFILER (FILE, LABELNO)'
  482.      A C statement or compound statement to output to FILE some
  483.      assembler code to initialize basic-block profiling for the current
  484.      object module.  This code should call the subroutine
  485.      `__bb_init_func' once per object module, passing it as its sole
  486.      argument the address of a block allocated in the object module.
  487.      The name of the block is a local symbol made with this statement:
  488.           ASM_GENERATE_INTERNAL_LABEL (BUFFER, "LPBX", 0);
  489.      Of course, since you are writing the definition of
  490.      `ASM_GENERATE_INTERNAL_LABEL' as well as that of this macro, you
  491.      can take a short cut in the definition of this macro and use the
  492.      name that you know will result.
  493.      The first word of this block is a flag which will be nonzero if the
  494.      object module has already been initialized.  So test this word
  495.      first, and do not call `__bb_init_func' if the flag is nonzero.
  496. `BLOCK_PROFILER (FILE, BLOCKNO)'
  497.      A C statement or compound statement to increment the count
  498.      associated with the basic block number BLOCKNO.  Basic blocks are
  499.      numbered separately from zero within each compilation.  The count
  500.      associated with block number BLOCKNO is at index BLOCKNO in a
  501.      vector of words; the name of this array is a local symbol made
  502.      with this statement:
  503.           ASM_GENERATE_INTERNAL_LABEL (BUFFER, "LPBX", 2);
  504.      Of course, since you are writing the definition of
  505.      `ASM_GENERATE_INTERNAL_LABEL' as well as that of this macro, you
  506.      can take a short cut in the definition of this macro and use the
  507.      name that you know will result.
  508. `BLOCK_PROFILER_CODE'
  509.      A C function or functions which are needed in the library to
  510.      support block profiling.
  511. File: gcc.info,  Node: Varargs,  Next: Trampolines,  Prev: Stack and Calling,  Up: Target Macros
  512. Implementing the Varargs Macros
  513. ===============================
  514.    GNU CC comes with an implementation of `varargs.h' and `stdarg.h'
  515. that work without change on machines that pass arguments on the stack.
  516. Other machines require their own implementations of varargs, and the
  517. two machine independent header files must have conditionals to include
  518.    ANSI `stdarg.h' differs from traditional `varargs.h' mainly in the
  519. calling convention for `va_start'.  The traditional implementation
  520. takes just one argument, which is the variable in which to store the
  521. argument pointer.  The ANSI implementation of `va_start' takes an
  522. additional second argument.  The user is supposed to write the last
  523. named argument of the function here.
  524.    However, `va_start' should not use this argument.  The way to find
  525. the end of the named arguments is with the built-in functions described
  526. below.
  527. `__builtin_saveregs ()'
  528.      Use this built-in function to save the argument registers in
  529.      memory so that the varargs mechanism can access them.  Both ANSI
  530.      and traditional versions of `va_start' must use
  531.      `__builtin_saveregs', unless you use `SETUP_INCOMING_VARARGS' (see
  532.      below) instead.
  533.      On some machines, `__builtin_saveregs' is open-coded under the
  534.      control of the macro `EXPAND_BUILTIN_SAVEREGS'.  On other machines,
  535.      it calls a routine written in assembler language, found in
  536.      `libgcc2.c'.
  537.      Code generated for the call to `__builtin_saveregs' appears at the
  538.      beginning of the function, as opposed to where the call to
  539.      `__builtin_saveregs' is written, regardless of what the code is.
  540.      This is because the registers must be saved before the function
  541.      starts to use them for its own purposes.
  542. `__builtin_args_info (CATEGORY)'
  543.      Use this built-in function to find the first anonymous arguments in
  544.      registers.
  545.      In general, a machine may have several categories of registers
  546.      used for arguments, each for a particular category of data types.
  547.      (For example, on some machines, floating-point registers are used
  548.      for floating-point arguments while other arguments are passed in
  549.      the general registers.) To make non-varargs functions use the
  550.      proper calling convention, you have defined the `CUMULATIVE_ARGS'
  551.      data type to record how many registers in each category have been
  552.      used so far
  553.      `__builtin_args_info' accesses the same data structure of type
  554.      `CUMULATIVE_ARGS' after the ordinary argument layout is finished
  555.      with it, with CATEGORY specifying which word to access.  Thus, the
  556.      value indicates the first unused register in a given category.
  557.      Normally, you would use `__builtin_args_info' in the implementation
  558.      of `va_start', accessing each category just once and storing the
  559.      value in the `va_list' object.  This is because `va_list' will
  560.      have to update the values, and there is no way to alter the values
  561.      accessed by `__builtin_args_info'.
  562. `__builtin_next_arg (LASTARG)'
  563.      This is the equivalent of `__builtin_args_info', for stack
  564.      arguments.  It returns the address of the first anonymous stack
  565.      argument, as type `void *'. If `ARGS_GROW_DOWNWARD', it returns
  566.      the address of the location above the first anonymous stack
  567.      argument.  Use it in `va_start' to initialize the pointer for
  568.      fetching arguments from the stack.  Also use it in `va_start' to
  569.      verify that the second parameter LASTARG is the last named argument
  570.      of the current function.
  571. `__builtin_classify_type (OBJECT)'
  572.      Since each machine has its own conventions for which data types are
  573.      passed in which kind of register, your implementation of `va_arg'
  574.      has to embody these conventions.  The easiest way to categorize the
  575.      specified data type is to use `__builtin_classify_type' together
  576.      with `sizeof' and `__alignof__'.
  577.      `__builtin_classify_type' ignores the value of OBJECT, considering
  578.      only its data type.  It returns an integer describing what kind of
  579.      type that is--integer, floating, pointer, structure, and so on.
  580.      The file `typeclass.h' defines an enumeration that you can use to
  581.      interpret the values of `__builtin_classify_type'.
  582.    These machine description macros help implement varargs:
  583. `EXPAND_BUILTIN_SAVEREGS (ARGS)'
  584.      If defined, is a C expression that produces the machine-specific
  585.      code for a call to `__builtin_saveregs'.  This code will be moved
  586.      to the very beginning of the function, before any parameter access
  587.      are made.  The return value of this function should be an RTX that
  588.      contains the value to use as the return of `__builtin_saveregs'.
  589.      The argument ARGS is a `tree_list' containing the arguments that
  590.      were passed to `__builtin_saveregs'.
  591.      If this macro is not defined, the compiler will output an ordinary
  592.      call to the library function `__builtin_saveregs'.
  593. `SETUP_INCOMING_VARARGS (ARGS_SO_FAR, MODE, TYPE,'
  594.      PRETEND_ARGS_SIZE, SECOND_TIME) This macro offers an alternative
  595.      to using `__builtin_saveregs' and defining the macro
  596.      `EXPAND_BUILTIN_SAVEREGS'.  Use it to store the anonymous register
  597.      arguments into the stack so that all the arguments appear to have
  598.      been passed consecutively on the stack.  Once this is done, you
  599.      can use the standard implementation of varargs that works for
  600.      machines that pass all their arguments on the stack.
  601.      The argument ARGS_SO_FAR is the `CUMULATIVE_ARGS' data structure,
  602.      containing the values that obtain after processing of the named
  603.      arguments.  The arguments MODE and TYPE describe the last named
  604.      argument--its machine mode and its data type as a tree node.
  605.      The macro implementation should do two things: first, push onto the
  606.      stack all the argument registers *not* used for the named
  607.      arguments, and second, store the size of the data thus pushed into
  608.      the `int'-valued variable whose name is supplied as the argument
  609.      PRETEND_ARGS_SIZE.  The value that you store here will serve as
  610.      additional offset for setting up the stack frame.
  611.      Because you must generate code to push the anonymous arguments at
  612.      compile time without knowing their data types,
  613.      `SETUP_INCOMING_VARARGS' is only useful on machines that have just
  614.      a single category of argument register and use it uniformly for
  615.      all data types.
  616.      If the argument SECOND_TIME is nonzero, it means that the
  617.      arguments of the function are being analyzed for the second time.
  618.      This happens for an inline function, which is not actually
  619.      compiled until the end of the source file.  The macro
  620.      `SETUP_INCOMING_VARARGS' should not generate any instructions in
  621.      this case.
  622. `STRICT_ARGUMENT_NAMING'
  623.      Define this macro if the location where a function argument is
  624.      passed depends on whether or not it is a named argument.
  625.      This macro controls how the NAMED argument to `FUNCTION_ARG' is
  626.      set for varargs and stdarg functions.  With this macro defined,
  627.      the NAMED argument is always true for named arguments, and false
  628.      for unnamed arguments.  If this is not defined, but
  629.      `SETUP_INCOMING_VARARGS' is defined, then all arguments are
  630.      treated as named.  Otherwise, all named arguments except the last
  631.      are treated as named.
  632. File: gcc.info,  Node: Trampolines,  Next: Library Calls,  Prev: Varargs,  Up: Target Macros
  633. Trampolines for Nested Functions
  634. ================================
  635.    A "trampoline" is a small piece of code that is created at run time
  636. when the address of a nested function is taken.  It normally resides on
  637. the stack, in the stack frame of the containing function.  These macros
  638. tell GNU CC how to generate code to allocate and initialize a
  639. trampoline.
  640.    The instructions in the trampoline must do two things: load a
  641. constant address into the static chain register, and jump to the real
  642. address of the nested function.  On CISC machines such as the m68k,
  643. this requires two instructions, a move immediate and a jump.  Then the
  644. two addresses exist in the trampoline as word-long immediate operands.
  645. On RISC machines, it is often necessary to load each address into a
  646. register in two parts.  Then pieces of each address form separate
  647. immediate operands.
  648.    The code generated to initialize the trampoline must store the
  649. variable parts--the static chain value and the function address--into
  650. the immediate operands of the instructions.  On a CISC machine, this is
  651. simply a matter of copying each address to a memory reference at the
  652. proper offset from the start of the trampoline.  On a RISC machine, it
  653. may be necessary to take out pieces of the address and store them
  654. separately.
  655. `TRAMPOLINE_TEMPLATE (FILE)'
  656.      A C statement to output, on the stream FILE, assembler code for a
  657.      block of data that contains the constant parts of a trampoline.
  658.      This code should not include a label--the label is taken care of
  659.      automatically.
  660. `TRAMPOLINE_SECTION'
  661.      The name of a subroutine to switch to the section in which the
  662.      trampoline template is to be placed (*note Sections::.).  The
  663.      default is a value of `readonly_data_section', which places the
  664.      trampoline in the section containing read-only data.
  665. `TRAMPOLINE_SIZE'
  666.      A C expression for the size in bytes of the trampoline, as an
  667.      integer.
  668. `TRAMPOLINE_ALIGNMENT'
  669.      Alignment required for trampolines, in bits.
  670.      If you don't define this macro, the value of `BIGGEST_ALIGNMENT'
  671.      is used for aligning trampolines.
  672. `INITIALIZE_TRAMPOLINE (ADDR, FNADDR, STATIC_CHAIN)'
  673.      A C statement to initialize the variable parts of a trampoline.
  674.      aDDR is an RTX for the address of the trampoline; FNADDR is an RTX
  675.      for the address of the nested function; STATIC_CHAIN is an RTX for
  676.      the static chain value that should be passed to the function when
  677.      it is called.
  678. `ALLOCATE_TRAMPOLINE (FP)'
  679.      A C expression to allocate run-time space for a trampoline.  The
  680.      expression value should be an RTX representing a memory reference
  681.      to the space for the trampoline.
  682.      If this macro is not defined, by default the trampoline is
  683.      allocated as a stack slot.  This default is right for most
  684.      machines.  The exceptions are machines where it is impossible to
  685.      execute instructions in the stack area.  On such machines, you may
  686.      have to implement a separate stack, using this macro in
  687.      conjunction with `FUNCTION_PROLOGUE' and `FUNCTION_EPILOGUE'.
  688.      FP points to a data structure, a `struct function', which
  689.      describes the compilation status of the immediate containing
  690.      function of the function which the trampoline is for.  Normally
  691.      (when `ALLOCATE_TRAMPOLINE' is not defined), the stack slot for the
  692.      trampoline is in the stack frame of this containing function.
  693.      Other allocation strategies probably must do something analogous
  694.      with this information.
  695.    Implementing trampolines is difficult on many machines because they
  696. have separate instruction and data caches.  Writing into a stack
  697. location fails to clear the memory in the instruction cache, so when
  698. the program jumps to that location, it executes the old contents.
  699.    Here are two possible solutions.  One is to clear the relevant parts
  700. of the instruction cache whenever a trampoline is set up.  The other is
  701. to make all trampolines identical, by having them jump to a standard
  702. subroutine.  The former technique makes trampoline execution faster; the
  703. latter makes initialization faster.
  704.    To clear the instruction cache when a trampoline is initialized,
  705. define the following macros which describe the shape of the cache.
  706. `INSN_CACHE_SIZE'
  707.      The total size in bytes of the cache.
  708. `INSN_CACHE_LINE_WIDTH'
  709.      The length in bytes of each cache line.  The cache is divided into
  710.      cache lines which are disjoint slots, each holding a contiguous
  711.      chunk of data fetched from memory.  Each time data is brought into
  712.      the cache, an entire line is read at once.  The data loaded into a
  713.      cache line is always aligned on a boundary equal to the line size.
  714. `INSN_CACHE_DEPTH'
  715.      The number of alternative cache lines that can hold any particular
  716.      memory location.
  717.    Alternatively, if the machine has system calls or instructions to
  718. clear the instruction cache directly, you can define the following
  719. macro.
  720. `CLEAR_INSN_CACHE (BEG, END)'
  721.      If defined, expands to a C expression clearing the *instruction
  722.      cache* in the specified interval.  If it is not defined, and the
  723.      macro INSN_CACHE_SIZE is defined, some generic code is generated
  724.      to clear the cache.  The definition of this macro would typically
  725.      be a series of `asm' statements.  Both BEG and END are both pointer
  726.      expressions.
  727.    To use a standard subroutine, define the following macro.  In
  728. addition, you must make sure that the instructions in a trampoline fill
  729. an entire cache line with identical instructions, or else ensure that
  730. the beginning of the trampoline code is always aligned at the same
  731. point in its cache line.  Look in `m68k.h' as a guide.
  732. `TRANSFER_FROM_TRAMPOLINE'
  733.      Define this macro if trampolines need a special subroutine to do
  734.      their work.  The macro should expand to a series of `asm'
  735.      statements which will be compiled with GNU CC.  They go in a
  736.      library function named `__transfer_from_trampoline'.
  737.      If you need to avoid executing the ordinary prologue code of a
  738.      compiled C function when you jump to the subroutine, you can do so
  739.      by placing a special label of your own in the assembler code.  Use
  740.      one `asm' statement to generate an assembler label, and another to
  741.      make the label global.  Then trampolines can use that label to
  742.      jump directly to your special assembler code.
  743.