home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 316 / install / g_struct.man < prev    next >
Encoding:
Text File  |  1988-10-20  |  47.6 KB  |  1,070 lines

  1.  
  2. File: internals,  Node: Passes,  Next: RTL,  Prev: Interface,  Up: Top
  3.  
  4. Passes and Files of the Compiler
  5. ********************************
  6.  
  7. The overall control structure of the compiler is in `toplev.c'.  This file
  8. is responsible for initialization, decoding arguments, opening and closing
  9. files, and sequencing the passes.
  10.  
  11. The parsing pass is invoked only once, to parse the entire input.  The RTL
  12. intermediate code for a function is generated as the function is parsed, a
  13. statement at a time.  Each statement is read in as a syntax tree and then
  14. converted to RTL; then the storage for the tree for the statement is
  15. reclaimed.  Storage for types (and the expressions for their sizes),
  16. declarations, and a representation of the binding contours and how they
  17. nest, remains until the function is finished being compiled; these are all
  18. needed to output the debugging information.
  19.  
  20. Each time the parsing pass reads a complete function definition or
  21. top-level declaration, it calls the function `rest_of_compilation' or
  22. `rest_of_decl_compilation' in `toplev.c', which are responsible for all
  23. further processing necessary, ending with output of the assembler language.
  24.  All other compiler passes run, in sequence, within `rest_of_compilation'. 
  25. When that function returns from compiling a function definition, the
  26. storage used for that function definition's compilation is entirely freed,
  27. unless it is an inline function (*Note Inline::.).
  28.  
  29. Here is a list of all the passes of the compiler and their source files. 
  30. Also included is a description of where debugging dumps can be requested
  31. with `-d' options.
  32.  
  33.    * Parsing.  This pass reads the entire text of a function definition,
  34.      constructing partial syntax trees.  This and RTL generation are no
  35.      longer truly separate passes (formerly they were), but it is easier to
  36.      think of them as separate.
  37.  
  38.      The tree representation does not entirely follow C syntax, because it
  39.      is intended to support other languages as well.
  40.  
  41.      C data type analysis is also done in this pass, and every tree node
  42.      that represents an expression has a data type attached.  Variables are
  43.      represented as declaration nodes.
  44.  
  45.      Constant folding and associative-law simplifications are also done
  46.      during this pass.
  47.  
  48.      The source files for parsing are `parse.y', `decl.c', `typecheck.c',
  49.      `stor-layout.c', `fold-const.c', and `tree.c'.  The last three are
  50.      intended to be language-independent.  There are also header files
  51.      `parse.h', `c-tree.h', `tree.h' and `tree.def'.  The last two define
  52.      the format of the tree representation.
  53.  
  54.    * RTL generation.  This is the conversion of syntax tree into RTL code. 
  55.      It is actually done statement-by-statement during parsing, but for
  56.      most purposes it can be thought of as a separate pass.
  57.  
  58.      This is where the bulk of target-parameter-dependent code is found,
  59.      since often it is necessary for strategies to apply only when certain
  60.      standard kinds of instructions are available.  The purpose of named
  61.      instruction patterns is to provide this information to the RTL
  62.      generation pass.
  63.  
  64.      Optimization is done in this pass for `if'-conditions that are
  65.      comparisons, boolean operations or conditional expressions.  Tail
  66.      recursion is detected at this time also.  Decisions are made about how
  67.      best to arrange loops and how to output `switch' statements.
  68.  
  69.      The source files for RTL generation are `stmt.c', `expr.c',
  70.      `explow.c', `expmed.c', `optabs.c' and `emit-rtl.c'.  Also, the file
  71.      `insn-emit.c', generated from the machine description by the program
  72.      `genemit', is used in this pass.  The header files `expr.h' is used
  73.      for communication within this pass.
  74.  
  75.      The header files `insn-flags.h' and `insn-codes.h', generated from the
  76.      machine description by the programs `genflags' and `gencodes', tell
  77.      this pass which standard names are available for use and which
  78.      patterns correspond to them.
  79.  
  80.      Aside from debugging information output, none of the following passes
  81.      refers to the tree structure representation of the function (only part
  82.      of which is saved).
  83.  
  84.      The decision of whether the function can and should be expanded inline
  85.      in its subsequent callers is made at the end of rtl generation.  The
  86.      function must meet certain criteria, currently related to the size of
  87.      the function and the types and number of parameters it has.  Note that
  88.      this function may contain loops, recursive calls to itself
  89.      (tail-recursive functions can be inlined!), gotos, in short, all
  90.      constructs supported by GNU CC.
  91.  
  92.      The option `-dr' causes a debugging dump of the RTL code after this
  93.      pass.  This dump file's name is made by appending `.rtl' to the input
  94.      file name.
  95.  
  96.    * Jump optimization.  This pass simplifies jumps to the following
  97.      instruction, jumps across jumps, and jumps to jumps.  It deletes
  98.      unreferenced labels and unreachable code, except that unreachable code
  99.      that contains a loop is not recognized as unreachable in this pass. 
  100.      (Such loops are deleted later in the basic block analysis.)
  101.  
  102.      Jump optimization is performed two or three times.  The first time is
  103.      immediately following RTL generation.  The second time is after CSE,
  104.      but only if CSE says repeated jump optimization is needed.  The last
  105.      time is right before the final pass.  That time, cross-jumping and
  106.      deletion of no-op move instructions are done together with the
  107.      optimizations described above.
  108.  
  109.      The source file of this pass is `jump.c'.
  110.  
  111.      The option `-dj' causes a debugging dump of the RTL code after this
  112.      pass is run for the first time.  This dump file's name is made by
  113.      appending `.jump' to the input file name.
  114.  
  115.    * Register scan.  This pass finds the first and last use of each
  116.      register, as a guide for common subexpression elimination.  Its source
  117.      is in `regclass.c'.
  118.  
  119.    * Common subexpression elimination.  This pass also does constant
  120.      propagation.  Its source file is `cse.c'.  If constant propagation
  121.      causes conditional jumps to become unconditional or to become no-ops,
  122.      jump optimization is run again when CSE is finished.
  123.  
  124.      The option `-ds' causes a debugging dump of the RTL code after this
  125.      pass.  This dump file's name is made by appending `.cse' to the input
  126.      file name.
  127.  
  128.    * Loop optimization.  This pass moves constant expressions out of loops.
  129.       Its source file is `loop.c'.
  130.  
  131.      The option `-dL' causes a debugging dump of the RTL code after this
  132.      pass.  This dump file's name is made by appending `.loop' to the input
  133.      file name.
  134.  
  135.    * Stupid register allocation is performed at this point in a
  136.      nonoptimizing compilation.  It does a little data flow analysis as
  137.      well.  When stupid register allocation is in use, the next pass
  138.      executed is the reloading pass; the others in between are skipped. 
  139.      The source file is `stupid.c'.
  140.  
  141.    * Data flow analysis (`flow.c').  This pass divides the program into
  142.      basic blocks (and in the process deletes unreachable loops); then it
  143.      computes which pseudo-registers are live at each point in the program,
  144.      and makes the first instruction that uses a value point at the
  145.      instruction that computed the value.
  146.  
  147.      This pass also deletes computations whose results are never used, and
  148.      combines memory references with add or subtract instructions to make
  149.      autoincrement or autodecrement addressing.
  150.  
  151.      The option `-df' causes a debugging dump of the RTL code after this
  152.      pass.  This dump file's name is made by appending `.flow' to the input
  153.      file name.  If stupid register allocation is in use, this dump file
  154.      reflects the full results of such allocation.
  155.  
  156.    * Instruction combination (`combine.c').  This pass attempts to combine
  157.      groups of two or three instructions that are related by data flow into
  158.      single instructions.  It combines the RTL expressions for the
  159.      instructions by substitution, simplifies the result using algebra, and
  160.      then attempts to match the result against the machine description.
  161.  
  162.      The option `-dc' causes a debugging dump of the RTL code after this
  163.      pass.  This dump file's name is made by appending `.combine' to the
  164.      input file name.
  165.  
  166.    * Register class preferencing.  The RTL code is scanned to find out
  167.      which register class is best for each pseudo register.  The source
  168.      file is `regclass.c'.
  169.  
  170.    * Local register allocation (`local-alloc.c').  This pass allocates hard
  171.      registers to pseudo registers that are used only within one basic
  172.      block.  Because the basic block is linear, it can use fast and
  173.      powerful techniques to do a very good job.
  174.  
  175.      The option `-dl' causes a debugging dump of the RTL code after this
  176.      pass.  This dump file's name is made by appending `.lreg' to the input
  177.      file name.
  178.  
  179.    * Global register allocation (`global-alloc.c').  This pass allocates
  180.      hard registers for the remaining pseudo registers (those whose life
  181.      spans are not contained in one basic block).
  182.  
  183.    * Reloading.  This pass renumbers pseudo registers with the hardware
  184.      registers numbers they were allocated.  Pseudo registers that did not
  185.      get hard registers are replaced with stack slots.  Then it finds
  186.      instructions that are invalid because a value has failed to end up in
  187.      a register, or has ended up in a register of the wrong kind.  It fixes
  188.      up these instructions by reloading the problematical values
  189.      temporarily into registers.  Additional instructions are generated to
  190.      do the copying.
  191.  
  192.      Source files are `reload.c' and `reload1.c', plus the header
  193.      `reload.h' used for communication between them.
  194.  
  195.      The option `-dg' causes a debugging dump of the RTL code after this
  196.      pass.  This dump file's name is made by appending `.greg' to the input
  197.      file name.
  198.  
  199.    * Jump optimization is repeated, this time including cross-jumping and
  200.      deletion of no-op move instructions.  Machine-specific peephole
  201.      optimizations are performed at the same time.
  202.  
  203.      The option `-dJ' causes a debugging dump of the RTL code after this
  204.      pass.  This dump file's name is made by appending `.jump2' to the
  205.      input file name.
  206.  
  207.    * Final.  This pass outputs the assembler code for the function.  It is
  208.      also responsible for identifying spurious test and compare
  209.      instructions.  The function entry and exit sequences are generated
  210.      directly as assembler code in this pass; they never exist as RTL.
  211.  
  212.      The source files are `final.c' plus `insn-output.c'; the latter is
  213.      generated automatically from the machine description by the tool
  214.      `genoutput'.  The header file `conditions.h' is used for communication
  215.      between these files.
  216.  
  217.    * Debugging information output.  This is run after final because it must
  218.      output the stack slot offsets for pseudo registers that did not get
  219.      hard registers.  Source files are `dbxout.c' for DBX symbol table
  220.      format and `symout.c' for GDB's own symbol table format.
  221.  
  222. Some additional files are used by all or many passes:
  223.  
  224.    * Every pass uses `machmode.def', which defines the machine modes.
  225.  
  226.    * All the passes that work with RTL use the header files `rtl.h' and
  227.      `rtl.def', and subroutines in file `rtl.c'.  The tools `gen*' also use
  228.      these files to read and work with the machine description RTL.
  229.  
  230.    * Several passes refer to the header file `insn-config.h' which contains
  231.      a few parameters (C macro definitions) generated automatically from
  232.      the machine description RTL by the tool `genconfig'.
  233.  
  234.    * Several passes use the instruction recognizer, which consists of
  235.      `recog.c' and `recog.h', plus the files `insn-recog.c' and
  236.      `insn-extract.c' that are generated automatically from the machine
  237.      description by the tools `genrecog' and `genextract'.
  238.  
  239.    * Several passes use the header files `regs.h' which defines the
  240.      information recorded about pseudo register usage, and `basic-block.h'
  241.      which defines the information recorded about basic blocks.
  242.  
  243.    * `hard-reg-set.h' defines the type `HARD_REG_SET', a bit-vector with a
  244.      bit for each hard register, and some macros to manipulate it.  This
  245.      type is just `int' if the machine has few enough hard registers;
  246.      otherwise it is an array of `int' and some of the macros expand into
  247.      loops.
  248.  
  249. File: internals,  Node: RTL,  Next: Machine Desc,  Prev: Passes,  Up: Top
  250.  
  251. RTL Representation
  252. ******************
  253.  
  254. Most of the work of the compiler is done on an intermediate representation
  255. called register transfer language.  In this language, the instructions to
  256. be output are described, pretty much one by one, in an algebraic form that
  257. describes what the instruction does.
  258.  
  259. RTL is inspired by Lisp lists.  It has both an internal form, made up of
  260. structures that point at other structures, and a textual form that is used
  261. in the machine description and in printed debugging dumps.  The textual
  262. form uses nested parentheses to indicate the pointers in the internal form.
  263.  
  264. * Menu:
  265.  
  266. * RTL Objects::       Expressions vs vectors vs strings vs integers.
  267. * Accessors::         Macros to access expression operands or vector elts.
  268. * Flags::             Other flags in an RTL expression.
  269. * Machine Modes::     Describing the size and format of a datum.
  270. * Constants::         Expressions with constant values.
  271. * Regs and Memory::   Expressions representing register contents or memory.
  272. * Arithmetic::        Expressions representing arithmetic on other expressions.
  273. * Comparisons::       Expressions representing comparison of expressions.
  274. * Bit Fields::        Expressions representing bit-fields in memory or reg.
  275. * Conversions::       Extending, truncating, floating or fixing.
  276. * RTL Declarations::  Declaring volatility, constancy, etc.
  277. * Side Effects::      Expressions for storing in registers, etc.
  278. * Incdec::            Embedded side-effects for autoincrement addressing.
  279. * Assembler::          Representing `asm' with operands.
  280. * Insns::             Expression types for entire insns.
  281. * Calls::          RTL representation of function call insns.
  282. * Sharing::           Some expressions are unique; others *must* be copied.
  283.  
  284.  
  285. File: internals,  Node: RTL Objects,  Next: Accessors,  Prev: RTL,  Up: RTL
  286.  
  287. RTL Object Types
  288. ================
  289.  
  290. RTL uses four kinds of objects: expressions, integers, strings and vectors.
  291.  Expressions are the most important ones.  An RTL expression (``RTX'', for
  292. short) is a C structure, but it is usually referred to with a pointer; a
  293. type that is given the typedef name `rtx'.
  294.  
  295. An integer is simply an `int', and a string is a `char *'.  Within RTL
  296. code, strings appear only inside `symbol_ref' expressions, but they appear
  297. in other contexts in the RTL expressions that make up machine descriptions.
  298.  Their written form uses decimal digits.
  299.  
  300. A string is a sequence of characters.  In core it is represented as a `char
  301. *' in usual C fashion, and it is written in C syntax as well.  However,
  302. strings in RTL may never be null.  If you write an empty string in a
  303. machine description, it is represented in core as a null pointer rather
  304. than as a pointer to a null character.  In certain contexts, these null
  305. pointers instead of strings are valid.
  306.  
  307. A vector contains an arbitrary, specified number of pointers to
  308. expressions.  The number of elements in the vector is explicitly present in
  309. the vector.  The written form of a vector consists of square brackets
  310. (`[...]') surrounding the elements, in sequence and with whitespace
  311. separating them.  Vectors of length zero are not created; null pointers are
  312. used instead.
  313.  
  314. Expressions are classified by "expression codes" (also called RTX codes). 
  315. The expression code is a name defined in `rtl.def', which is also (in upper
  316. case) a C enumeration constant.  The possible expression codes and their
  317. meanings are machine-independent.  The code of an RTX can be extracted with
  318. the macro `GET_CODE (X)' and altered with `PUT_CODE (X, NEWCODE)'.
  319.  
  320. The expression code determines how many operands the expression contains,
  321. and what kinds of objects they are.  In RTL, unlike Lisp, you cannot tell
  322. by looking at an operand what kind of object it is.  Instead, you must know
  323. from its context---from the expression code of the containing expression. 
  324. For example, in an expression of code `subreg', the first operand is to be
  325. regarded as an expression and the second operand as an integer.  In an
  326. expression of code `plus', there are two operands, both of which are to be
  327. regarded as expressions.  In a `symbol_ref' expression, there is one
  328. operand, which is to be regarded as a string.
  329.  
  330. Expressions are written as parentheses containing the name of the
  331. expression type, its flags and machine mode if any, and then the operands
  332. of the expression (separated by spaces).
  333.  
  334. Expression code names in the `md' file are written in lower case, but when
  335. they appear in C code they are written in upper case.  In this manual, they
  336. are shown as follows: `const_int'.
  337.  
  338. In a few contexts a null pointer is valid where an expression is normally
  339. wanted.  The written form of this is `(nil)'.
  340.  
  341. File: internals,  Node: Accessors,  Next: Flags,  Prev: RTL Objects,  Up: RTL
  342.  
  343. Access to Operands
  344. ==================
  345.  
  346. For each expression type `rtl.def' specifies the number of contained
  347. objects and their kinds, with four possibilities: `e' for expression
  348. (actually a pointer to an expression), `i' for integer, `s' for string, and
  349. `E' for vector of expressions.  The sequence of letters for an expression
  350. code is called its "format".  Thus, the format of `subreg' is `ei'.
  351.  
  352. Two other format characters are used occasionally: `u' and `0'.  `u' is
  353. equivalent to `e' except that it is printed differently in debugging dumps,
  354. and `0' means a slot whose contents do not fit any normal category.  `0'
  355. slots are not printed at all in dumps, and are often used in special ways
  356. by small parts of the compiler.
  357.  
  358. There are macros to get the number of operands and the format of an
  359. expression code:
  360.  
  361. `GET_RTX_LENGTH (CODE)'
  362.      Number of operands of an RTX of code CODE.
  363.  
  364. `GET_RTX_FORMAT (CODE)'
  365.      The format of an RTX of code CODE, as a C string.
  366.  
  367. Operands of expressions are accessed using the macros `XEXP', `XINT' and
  368. `XSTR'.  Each of these macros takes two arguments: an expression-pointer
  369. (RTX) and an operand number (counting from zero).  Thus,
  370.  
  371.      XEXP (X, 2)
  372.  
  373. accesses operand 2 of expression X, as an expression.
  374.  
  375.      XINT (X, 2)
  376.  
  377. accesses the same operand as an integer.  `XSTR', used in the same fashion,
  378. would access it as a string.
  379.  
  380. Any operand can be accessed as an integer, as an expression or as a string.
  381.  You must choose the correct method of access for the kind of value
  382. actually stored in the operand.  You would do this based on the expression
  383. code of the containing expression.  That is also how you would know how
  384. many operands there are.
  385.  
  386. For example, if X is a `subreg' expression, you know that it has two
  387. operands which can be correctly accessed as `XEXP (X, 0)' and `XINT (X,
  388. 1)'.  If you did `XINT (X, 0)', you would get the address of the expression
  389. operand but cast as an integer; that might occasionally be useful, but it
  390. would be cleaner to write `(int) XEXP (X, 0)'.  `XEXP (X, 1)' would also
  391. compile without error, and would return the second, integer operand cast as
  392. an expression pointer, which would probably result in a crash when
  393. accessed.  Nothing stops you from writing `XEXP (X, 28)' either, but this
  394. will access memory past the end of the expression with unpredictable results.
  395.  
  396. Access to operands which are vectors is more complicated.  You can use the
  397. macro `XVEC' to get the vector-pointer itself, or the macros `XVECEXP' and
  398. `XVECLEN' to access the elements and length of a vector.
  399.  
  400. `XVEC (EXP, IDX)'
  401.      Access the vector-pointer which is operand number IDX in EXP.
  402.  
  403. `XVECLEN (EXP, IDX)'
  404.      Access the length (number of elements) in the vector which is in
  405.      operand number IDX in EXP.  This value is an `int'.
  406.  
  407. `XVECEXP (EXP, IDX, ELTNUM)'
  408.      Access element number ELTNUM in the vector which is in operand number
  409.      IDX in EXP.  This value is an RTX.
  410.  
  411.      It is up to you to make sure that ELTNUM is not negative and is less
  412.      than `XVECLEN (EXP, IDX)'.
  413.  
  414. All the macros defined in this section expand into lvalues and therefore
  415. can be used to assign the operands, lengths and vector elements as well as
  416. to access them.
  417.  
  418. File: internals,  Node: Flags,  Next: Machine Modes,  Prev: Accessors,  Up: RTL
  419.  
  420. Flags in an RTL Expression
  421. ==========================
  422.  
  423. RTL expressions contain several flags (one-bit bit-fields) that are used in
  424. certain types of expression.
  425.  
  426. `used'
  427.      This flag is used only momentarily, at the end of RTL generation for a
  428.      function, to count the number of times an expression appears in insns.
  429.       Expressions that appear more than once are copied, according to the
  430.      rules for shared structure (*Note Sharing::.).
  431.  
  432. `volatil'
  433.      This flag is used in `mem' and `reg' expressions and in insns.  In RTL
  434.      dump files, it is printed as `/v'.
  435.  
  436.      In a `mem' expression, it is 1 if the memory reference is volatile. 
  437.      Volatile memory references may not be deleted, reordered or combined.
  438.  
  439.      In a `reg' expression, it is 1 if the value is a user-level variable. 
  440.      0 indicates an internal compiler temporary.
  441.  
  442.      In an insn, 1 means the insn has been deleted.
  443.  
  444. `in_struct'
  445.      This flag is used in `mem' expressions.  It is 1 if the memory datum
  446.      referred to is all or part of a structure or array; 0 if it is (or
  447.      might be) a scalar variable.  A reference through a C pointer has 0
  448.      because the pointer might point to a scalar variable.
  449.  
  450.      This information allows the compiler to determine something about
  451.      possible cases of aliasing.
  452.  
  453.      In an RTL dump, this flag is represented as `/s'.
  454.  
  455. `unchanging'
  456.      This flag is used in `reg' and `mem' expressions.  1 means that the
  457.      value of the expression never changes (at least within the current
  458.      function).
  459.  
  460.      In an RTL dump, this flag is represented as `/u'.
  461.  
  462. File: internals,  Node: Machine Modes,  Next: Constants,  Prev: Flags,  Up: RTL
  463.  
  464. Machine Modes
  465. =============
  466.  
  467. A machine mode describes a size of data object and the representation used
  468. for it.  In the C code, machine modes are represented by an enumeration
  469. type, `enum machine_mode', defined in `machmode.def'.  Each RTL expression
  470. has room for a machine mode and so do certain kinds of tree expressions
  471. (declarations and types, to be precise).
  472.  
  473. In debugging dumps and machine descriptions, the machine mode of an RTL
  474. expression is written after the expression code with a colon to separate
  475. them.  The letters `mode' which appear at the end of each machine mode name
  476. are omitted.  For example, `(reg:SI 38)' is a `reg' expression with machine
  477. mode `SImode'.  If the mode is `VOIDmode', it is not written at all.
  478.  
  479. Here is a table of machine modes.
  480.  
  481. `QImode'
  482.      ``Quarter-Integer'' mode represents a single byte treated as an integer.
  483.  
  484. `HImode'
  485.      ``Half-Integer'' mode represents a two-byte integer.
  486.  
  487. `SImode'
  488.      ``Single Integer'' mode represents a four-byte integer.
  489.  
  490. `DImode'
  491.      ``Double Integer'' mode represents an eight-byte integer.
  492.  
  493. `TImode'
  494.      ``Tetra Integer'' (?) mode represents a sixteen-byte integer.
  495.  
  496. `SFmode'
  497.      ``Single Floating'' mode represents a single-precision (four byte)
  498.      floating point number.
  499.  
  500. `DFmode'
  501.      ``Double Floating'' mode represents a double-precision (eight byte)
  502.      floating point number.
  503.  
  504. `TFmode'
  505.      ``Tetra Floating'' mode represents a quadruple-precision (sixteen
  506.      byte) floating point number.
  507.  
  508. `BLKmode'
  509.      ``Block'' mode represents values that are aggregates to which none of
  510.      the other modes apply.  In RTL, only memory references can have this
  511.      mode, and only if they appear in string-move or vector instructions. 
  512.      On machines which have no such instructions, `BLKmode' will not appear
  513.      in RTL.
  514.  
  515. `VOIDmode'
  516.      Void mode means the absence of a mode or an unspecified mode.  For
  517.      example, RTL expressions of code `const_int' have mode `VOIDmode'
  518.      because they can be taken to have whatever mode the context requires. 
  519.      In debugging dumps of RTL, `VOIDmode' is expressed by the absence of
  520.      any mode.
  521.  
  522. `EPmode'
  523.      ``Entry Pointer'' mode is intended to be used for function variables
  524.      in Pascal and other block structured languages.  Such values contain
  525.      both a function address and a static chain pointer for access to
  526.      automatic variables of outer levels.  This mode is only partially
  527.      implemented since C does not use it.
  528.  
  529. `CSImode, ...'
  530.      ``Complex Single Integer'' mode stands for a complex number
  531.      represented as a pair of `SImode' integers.  Any of the integer and
  532.      floating modes may have `C' prefixed to its name to obtain a complex
  533.      number mode.  For example, there are `CQImode', `CSFmode', and
  534.      `CDFmode'.  Since C does not support complex numbers, these machine
  535.      modes are only partially implemented.
  536.  
  537. `BImode'
  538.      This is the machine mode of a bit-field in a structure.  It is used
  539.      only in the syntax tree, never in RTL, and in the syntax tree it
  540.      appears only in declaration nodes.  In C, it appears only in
  541.      `FIELD_DECL' nodes for structure fields defined with a bit size.
  542.  
  543. The machine description defines `Pmode' as a C macro which expands into the
  544. machine mode used for addresses.  Normally this is `SImode'.
  545.  
  546. The only modes which a machine description must support are `QImode',
  547. `SImode', `SFmode' and `DFmode'.  The compiler will attempt to use `DImode'
  548. for two-word structures and unions, but it would not be hard to program it
  549. to avoid this.  Likewise, you can arrange for the C type `short int' to
  550. avoid using `HImode'.  In the long term it would be desirable to make the
  551. set of available machine modes machine-dependent and eliminate all
  552. assumptions about specific machine modes or their uses from the
  553. machine-independent code of the compiler.
  554.  
  555. Here are some C macros that relate to machine modes:
  556.  
  557. `GET_MODE (X)'
  558.      Returns the machine mode of the RTX X.
  559.  
  560. `PUT_MODE (X, NEWMODE)'
  561.      Alters the machine mode of the RTX X to be NEWMODE.
  562.  
  563. `GET_MODE_SIZE (M)'
  564.      Returns the size in bytes of a datum of mode M.
  565.  
  566. `GET_MODE_BITSIZE (M)'
  567.      Returns the size in bits of a datum of mode M.
  568.  
  569. `GET_MODE_UNIT_SIZE (M)'
  570.      Returns the size in bits of the subunits of a datum of mode M.  This
  571.      is the same as `GET_MODE_SIZE' except in the case of complex modes and
  572.      `EPmode'.  For them, the unit size is the size of the real or
  573.      imaginary part, or the size of the function pointer or the context
  574.      pointer.
  575.  
  576. File: internals,  Node: Constants,  Next: Regs and Memory,  Prev: Machine Modes,  Up: RTL
  577.  
  578. Constant Expression Types
  579. =========================
  580.  
  581. The simplest RTL expressions are those that represent constant values.
  582.  
  583. `(const_int I)'
  584.      This type of expression represents the integer value I.  I is
  585.      customarily accessed with the macro `INTVAL' as in `INTVAL (EXP)',
  586.      which is equivalent to `XINT (EXP, 0)'.
  587.  
  588.      There is only one expression object for the integer value zero; it is
  589.      the value of the variable `const0_rtx'.  Likewise, the only expression
  590.      for integer value one is found in `const1_rtx'.  Any attempt to create
  591.      an expression of code `const_int' and value zero or one will return
  592.      `const0_rtx' or `const1_rtx' as appropriate.
  593.  
  594. `(const_double:M I0 I1)'
  595.      Represents a floating point constant value of mode M.  The two
  596.      inteGERS I0 and I1 together contain the bits of a `double' value.  To
  597.      convert them to a `double', do
  598.  
  599.           union { double d; int i[2];} u;
  600.           u.i[0] = XINT (x, 0);
  601.           u.i[1] = XINT (x, 1);
  602.  
  603.      and then refer to `u.d'.  The value of the constant is represented as
  604.      a double in this fashion even if the value represented is
  605.      single-precision.
  606.  
  607.      The global variables `dconst0_rtx' and `fconst0_rtx' hold
  608.      `const_double' expressions with value 0, in modes `DFmode' and
  609.      `SFmode', respectively.
  610.  
  611. `(symbol_ref SYMBOL)'
  612.      Represents the value of an assembler label for data.  SYMBOL is a
  613.      string that describes the name of the assembler label.  If it starts
  614.      with a `*', the label is the rest of SYMBOL not including the `*'. 
  615.      Otherwise, the label is SYMBOL, prefixed with `_'.
  616.  
  617. `(label_ref LABEL)'
  618.      Represents the value of an assembler label for code.  It contains one
  619.      operand, an expression, which must be a `code_label' that appears in
  620.      the instruction sequence to identify the place where the label should
  621.      go.
  622.  
  623.      The reason for using a distinct expression type for code label
  624.      references is so that jump optimization can distinguish them.
  625.  
  626. `(const EXP)'
  627.      Represents a constant that is the result of an assembly-time
  628.      arithmetic computation.  The operand, EXP, is an expression that
  629.      contains only constants (`const_int', `symbol_ref' and `label_ref'
  630.      expressions) combined with `plus' and `minus'.  However, not all
  631.      combinations are valid, since the assembler cannot do arbitrary
  632.      arithmetic on relocatable symbols.
  633.  
  634. File: internals,  Node: Regs and Memory,  Next: Arithmetic,  Prev: Constants,  Up: RTL
  635.  
  636. Registers and Memory
  637. ====================
  638.  
  639. Here are the RTL expression types for describing access to machine
  640. registers and to main memory.
  641.  
  642. `(reg:M N)'
  643.      For small values of the integer N (less than `FIRST_PSEUDO_REGISTER'),
  644.      this stands for a reference to machine register number N: a "hard
  645.      register".  For larger values of N, it stands for a temporary value or
  646.      "pseudo register".  The compiler's strategy is to generate code
  647.      assuming an unlimited number of such pseudo registers, and later
  648.      convert them into hard registers or into memory references.
  649.  
  650.      The symbol `FIRST_PSEUDO_REGISTER' is defined by the machine
  651.      description, since the number of hard registers on the machine is an
  652.      invariant characteristic of the machine.  Note, however, that not all
  653.      of the machine registers must be general registers.  All the machine
  654.      registers that can be used for storage of data are given hard register
  655.      numbers, even those that can be used only in certain instructions or
  656.      can hold only certain types of data.
  657.  
  658.      Each pseudo register number used in a function's RTL code is
  659.      represented by a unique `reg' expression.
  660.  
  661.      M is the machine mode of the reference.  It is necessary because
  662.      machines can generally refer to each register in more than one mode. 
  663.      For example, a register may contain a full word but there may be
  664.      instructions to refer to it as a half word or as a single byte, as
  665.      well as instructions to refer to it as a floating point number of
  666.      various precisions.
  667.  
  668.      Even for a register that the machine can access in only one mode, the
  669.      mode must always be specified.
  670.  
  671.      A hard register may be accessed in various modes throughout one
  672.      function, but each pseudo register is given a natural mode and is
  673.      accessed only in that mode.  When it is necessary to describe an
  674.      access to a pseudo register using a nonnatural mode, a `subreg'
  675.      expression is used.
  676.  
  677.      A `reg' expression with a machine mode that specifies more than one
  678.      word of data may actually stand for several consecutive registers.  If
  679.      in addition the register number specifies a hardware register, then it
  680.      actually represents several consecutive hardware registers starting
  681.      with the specified one.
  682.  
  683.      Such multi-word hardware register `reg' expressions may not be live
  684.      across the boundary of a basic block.  The lifetime analysis pass does
  685.      not know how to record properly that several consecutive registers are
  686.      actually live there, and therefore register allocation would be
  687.      confused.  The CSE pass must go out of its way to make sure the
  688.      situation does not arise.
  689.  
  690. `(subreg:M REG WORDNUM)'
  691.      `subreg' expressions are used to refer to a register in a machine mode
  692.      other than its natural one, or to refer to one register of a
  693.      multi-word `reg' that actually refers to several registers.
  694.  
  695.      Each pseudo-register has a natural mode.  If it is necessary to
  696.      operate on it in a different mode---for example, to perform a fullword
  697.      move instruction on a pseudo-register that contains a single byte---
  698.      the pseudo-register must be enclosed in a `subreg'.  In such a case,
  699.      WORDNUM is zero.
  700.  
  701.      The other use of `subreg' is to extract the individual registers of a
  702.      multi-register value.  Machine modes such as `DImode' and `EPmode'
  703.      indicate values longer than a word, values which usually require two
  704.      consecutive registers.  To access one of the registers, use a `subreg'
  705.      with mode `SImode' and a WORDNUM that says which register.
  706.  
  707.      The compilation parameter `WORDS_BIG_ENDIAN', if defined, says that
  708.      word number zero is the most significant part; otherwise, it is the
  709.      least significant part.
  710.  
  711.      Note that it is not valid to access a `DFmode' value in `SFmode' using
  712.      a `subreg'.  On some machines the most significant part of a `DFmode'
  713.      value does not have the same format as a single-precision floating
  714.      value.
  715.  
  716. `(cc0)'
  717.      This refers to the machine's condition code register.  It has no
  718.      operands and may not have a machine mode.  It may be validly used in
  719.      only two contexts: as the destination of an assignment (in test and
  720.      compare instructions) and in comparison operators comparing against
  721.      zero (`const_int' with value zero; that is to say, `const0_rtx').
  722.  
  723.      There is only one expression object of code `cc0'; it is the value of
  724.      the variable `cc0_rtx'.  Any attempt to create an expression of code
  725.      `cc0' will return `cc0_rtx'.
  726.  
  727.      One special thing about the condition code register is that
  728.      instructions can set it implicitly.  On many machines, nearly all
  729.      instructions set the condition code based on the value that they
  730.      compute or store.  It is not necessary to record these actions
  731.      explicitly in the RTL because the machine description includes a
  732.      prescription for recognizing the instructions that do so (by means of
  733.      the macro `NOTICE_UPDATE_CC').  Only instructions whose sole purpose
  734.      is to set the condition code, and instructions that use the condition
  735.      code, need mention `(cc0)'.
  736.  
  737. `(pc)'
  738.      This represents the machine's program counter.  It has no operands and
  739.      may not have a machine mode.  `(pc)' may be validly used only in
  740.      certain specific contexts in jump instructions.
  741.  
  742.      There is only one expression object of code `pc'; it is the value of
  743.      the variable `pc_rtx'.  Any attempt to create an expression of code
  744.      `pc' will return `pc_rtx'.
  745.  
  746.      All instructions that do not jump alter the program counter implicitly
  747.      by incrementing it, but there is no need to mention this in the RTL.
  748.  
  749. `(mem:M ADDR)'
  750.      This RTX represents a reference to main memory at an address
  751.      represented by the expression ADDR.  M specifies how large a unit of
  752.      memory is accessed.
  753.  
  754. File: internals,  Node: Arithmetic,  Next: Comparisons,  Prev: Regs and Memory,  Up: RTL
  755.  
  756. RTL Expressions for Arithmetic
  757. ==============================
  758.  
  759. `(plus:M X Y)'
  760.      Represents the sum of the values represented by X and Y carried out in
  761.      machine mode M.  This is valid only if X and Y both are valid for mode
  762.      M.
  763.  
  764. `(minus:M X Y)'
  765.      Like `plus' but represents subtraction.
  766.  
  767. `(minus X Y)'
  768.      Represents the result of subtracting Y from X for purposes of
  769.      comparison.  The absence of a machine mode in the `minus' expression
  770.      indicates that the result is computed without overflow, as if with
  771.      infinite precision.
  772.  
  773.      Of course, machines can't really subtract with infinite precision. 
  774.      However, they can pretend to do so when only the sign of the result
  775.      will be used, which is the case when the result is stored in `(cc0)'. 
  776.      And that is the only way this kind of expression may validly be used:
  777.      as a value to be stored in the condition codes.
  778.  
  779. `(neg:M X)'
  780.      Represents the negation (subtraction from zero) of the value
  781.      represented by X, carried out in mode M.  X must be valid for mode M.
  782.  
  783. `(mult:M X Y)'
  784.      Represents the signed product of the values represented by X and Y
  785.      carried out in machine mode M.  If X and Y are both valid for mode M,
  786.      this is ordinary size-preserving multiplication.  Alternatively, both
  787.      X and Y may be valid for a different, narrower mode.  This represents
  788.      the kind of multiplication that generates a product wider than the
  789.      operands.  Widening multiplication and same-size multiplication are
  790.      completely distinct and supported by different machine instructions;
  791.      machines may support one but not the other.
  792.  
  793.      `mult' may be used for floating point division as well.  Then M is a
  794.      floating point machine mode.
  795.  
  796. `(umult:M X Y)'
  797.      Like `mult' but represents unsigned multiplication.  It may be used in
  798.      both same-size and widening forms, like `mult'.  `umult' is used only
  799.      for fixed-point multiplication.
  800.  
  801. `(div:M X Y)'
  802.      Represents the quotient in signed division of X by Y, carried out in
  803.      machine mode M.  If M is a floating-point mode, it represents the
  804.      exact quotient; otherwise, the integerized quotient.  If X and Y are
  805.      both valid for mode M, this is ordinary size-preserving division. 
  806.      Some machines have division instructions in which the operands and
  807.      quotient widths are not all the same; such instructions are
  808.      represented by `div' expressions in which the machine modes are not
  809.      all the same.
  810.  
  811. `(udiv:M X Y)'
  812.      Like `div' but represents unsigned division.
  813.  
  814. `(mod:M X Y)'
  815. `(umod:M X Y)'
  816.      Like `div' and `udiv' but represent the remainder instead of the
  817.      quotient.
  818.  
  819. `(not:M X)'
  820.      Represents the bitwise complement of the value represented by X,
  821.      carried out in mode M, which must be a fixed-point machine mode.  X
  822.      must be valid for mode M, which must be a fixed-point mode.
  823.  
  824. `(and:M X Y)'
  825.      Represents the bitwise logical-and of the values represented by X and
  826.      Y, carried out in machine mode M.  This is valid only if X and Y both
  827.      are valid for mode M, which must be a fixed-point mode.
  828.  
  829. `(ior:M X Y)'
  830.      Represents the bitwise inclusive-or of the values represented by X and
  831.      Y, carried out in machine mode M.  This is valid only if X and Y both
  832.      are valid for mode M, which must be a fixed-point mode.
  833.  
  834. `(xor:M X Y)'
  835.      Represents the bitwise exclusive-or of the values represented by X and
  836.      Y, carried out in machine mode M.  This is valid only if X and Y both
  837.      are valid for mode M, which must be a fixed-point mode.
  838.  
  839. `(lshift:M X C)'
  840.      Represents the result of logically shifting X left by C places.  X
  841.      must be valid for the mode M, a fixed-point machine mode.  C must be
  842.      valid for a fixed-point mode; which mode is determined by the mode
  843.      called for in the machine description entry for the left-shift
  844.      instruction.  For example, on the Vax, the mode of C is `QImode'
  845.      regardless of M.
  846.  
  847.      On some machines, negative values of C may be meaningful; this is why
  848.      logical left shift and arithmetic left shift are distinguished.  For
  849.      example, Vaxes have no right-shift instructions, and right shifts are
  850.      represented as left-shift instructions whose counts happen to be
  851.      negative constants or else computed (in a previous instruction) by
  852.      negation.
  853.  
  854. `(ashift:M X C)'
  855.      Like `lshift' but for arithmetic left shift.
  856.  
  857. `(lshiftrt:M X C)'
  858. `(ashiftrt:M X C)'
  859.      Like `lshift' and `ashift' but for right shift.
  860.  
  861. `(rotate:M X C)'
  862. `(rotatert:M X C)'
  863.      Similar but represent left and right rotate.
  864.  
  865. `(abs:M X)'
  866.      Represents the absolute value of X, computed in mode M.  X must be
  867.      valid for M.
  868.  
  869. `(sqrt:M X)'
  870.      Represents the square root of X, computed in mode M.  X must be valid
  871.      for M.  Most often M will be a floating point mode.
  872.  
  873. `(ffs:M X)'
  874.      Represents the one plus the index of the least significant 1-bit in X,
  875.      represented as an integer of mode M.  (The value is zero if X is
  876.      zero.)  The mode of X need not be M; depending on the target machine,
  877.      various mode combinations may be valid.
  878.  
  879. File: internals,  Node: Comparisons,  Next: Bit Fields,  Prev: Arithmetic,  Up: RTL
  880.  
  881. Comparison Operations
  882. =====================
  883.  
  884. Comparison operators test a relation on two operands and are considered to
  885. represent the value 1 if the relation holds, or zero if it does not.  The
  886. mode of the comparison is determined by the operands; they must both be
  887. valid for a common machine mode.  A comparison with both operands constant
  888. would be invalid as the machine mode could not be deduced from it, but such
  889. a comparison should never exist in RTL due to constant folding.
  890.  
  891. Inequality comparisons come in two flavors, signed and unsigned.  Thus,
  892. there are distinct expression codes `gt' and `gtu' for signed and unsigned
  893. greater-than.  These can produce different results for the same pair of
  894. integer values: for example, 1 is signed greater-than -1 but not unsigned
  895. greater-than, because -1 when regarded as unsigned is actually `0xffffffff'
  896. which is greater than 1.
  897.  
  898. The signed comparisons are also used for floating point values.  Floating
  899. point comparisons are distinguished by the machine modes of the operands.
  900.  
  901. The comparison operators may be used to compare the condition codes `(cc0)'
  902. against zero, as in `(eq (cc0) (const_int 0))'.  Such a construct actually
  903. refers to the result of the preceding instruction in which the condition
  904. codes were set.  The above example stands for 1 if the condition codes were
  905. set to say ``zero'' or ``equal'', 0 otherwise.  Although the same
  906. comparison operators are used for this as may be used in other contexts on
  907. actual data, no confusion can result since the machine description would
  908. never allow both kinds of uses in the same context.
  909.  
  910. `(eq X Y)'
  911.      1 if the values represented by X and Y are equal, otherwise 0.
  912.  
  913. `(ne X Y)'
  914.      1 if the values represented by X and Y are not equal, otherwise 0.
  915.  
  916. `(gt X Y)'
  917.      1 if the X is greater than Y.  If they are fixed-point, the comparison
  918.      is done in a signed sense.
  919.  
  920. `(gtu X Y)'
  921.      Like `gt' but does unsigned comparison, on fixed-point numbers only.
  922.  
  923. `(lt X Y)'
  924. `(ltu X Y)'
  925.      Like `gt' and `gtu' but test for ``less than''.
  926.  
  927. `(ge X Y)'
  928. `(geu X Y)'
  929.      Like `gt' and `gtu' but test for ``greater than or equal''.
  930.  
  931. `(le X Y)'
  932. `(leu X Y)'
  933.      Like `gt' and `gtu' but test for ``less than or equal''.
  934.  
  935. `(if_then_else COND THEN ELSE)'
  936.      This is not a comparison operation but is listed here because it is
  937.      always used in conjunction with a comparison operation.  To be
  938.      precISE, COND is a comparison expression.  This expression represents
  939.      a choice, according to COND, between the value represented by THEN and
  940.      the one represented by ELSE.
  941.  
  942.      On most machines, `if_then_else' expressions are valid only to express
  943.      conditional jumps.
  944.  
  945. File: internals,  Node: Bit Fields,  Next: Conversions,  Prev: Comparisons,  Up: RTL
  946.  
  947. Bit-fields
  948. ==========
  949.  
  950. Special expression codes exist to represent bit-field instructions.  These
  951. types of expressions are lvalues in RTL; they may appear on the left side
  952. of a assignment, indicating insertion of a value into the specified bit
  953. field.
  954.  
  955. `(sign_extract:SI LOC SIZE POS)'
  956.      This represents a reference to a sign-extended bit-field contained or
  957.      starting in LOC (a memory or register reference).  The bit field is
  958.      SIZE bits wide and starts at bit POS.  The compilation option
  959.      `BITS_BIG_ENDIAN' says which end of the memory unit POS counts from.
  960.  
  961.      Which machine modes are valid for LOC depends on the machine, but
  962.      typically LOC should be a single byte when in memory or a full word in
  963.      a register.
  964.  
  965. `(zero_extract:SI LOC SIZE POS)'
  966.      Like `sign_extract' but refers to an unsigned or zero-extended bit
  967.      field.  The same sequence of bits are extracted, but they are filled
  968.      to an entire word with zeros instead of by sign-extension.
  969.  
  970. File: internals,  Node: Conversions,  Next: RTL Declarations,  Prev: Bit Fields,  Up: RTL
  971.  
  972. Conversions
  973. ===========
  974.  
  975. All conversions between machine modes must be represented by explicit
  976. conversion operations.  For example, an expression which is the sum of a
  977. byte and a full word cannot be written as `(plus:SI (reg:QI 34) (reg:SI
  978. 80))' because the `plus' operation requires two operands of the same
  979. machine mode.  Therefore, the byte-sized operand is enclosed in a
  980. conversion operation, as in
  981.  
  982.      (plus:SI (sign_extend:SI (reg:QI 34)) (reg:SI 80))
  983.  
  984. The conversion operation is not a mere placeholder, because there may be
  985. more than one way of converting from a given starting mode to the desired
  986. final mode.  The conversion operation code says how to do it.
  987.  
  988. `(sign_extend:M X)'
  989.      Represents the result of sign-extending the value X to machine mode M.
  990.       M must be a fixed-point mode and X a fixed-point value of a mode
  991.      narrower than M.
  992.  
  993. `(zero_extend:M X)'
  994.      Represents the result of zero-extending the value X to machine mode M.
  995.       M must be a fixed-point mode and X a fixed-point value of a mode
  996.      narrower than M.
  997.  
  998. `(float_extend:M X)'
  999.      Represents the result of extending the value X to machine mode M.  M
  1000.      must be a floating point mode and X a floating point value of a mode
  1001.      narrower than M.
  1002.  
  1003. `(truncate:M X)'
  1004.      Represents the result of truncating the value X to machine mode M.  M
  1005.      must be a fixed-point mode and X a fixed-point value of a mode wider
  1006.      than M.
  1007.  
  1008. `(float_truncate:M X)'
  1009.      Represents the result of truncating the value X to machine mode M.  M
  1010.      must be a floating point mode and X a floating point value of a mode
  1011.      wider than M.
  1012.  
  1013. `(float:M X)'
  1014.      Represents the result of converting fixed point value X, regarded as
  1015.      signed, to floating point mode M.
  1016.  
  1017. `(unsigned_float:M X)'
  1018.      Represents the result of converting fixed point value X, regarded as
  1019.      unsigned, to floating point mode M.
  1020.  
  1021. `(fix:M X)'
  1022.      When M is a fixed point mode, represents the result of converting
  1023.      floating point value X to mode M, regarded as signed.  How rounding is
  1024.      done is not specified, so this operation may be used validly in
  1025.      compiling C code only for integer-valued operands.
  1026.  
  1027. `(unsigned_fix:M X)'
  1028.      Represents the result of converting floating point value X to fixed
  1029.      point mode M, regarded as unsigned.  How rounding is done is not
  1030.      specified.
  1031.  
  1032. `(fix:M X)'
  1033.      When M is a floating point mode, represents the result of converting
  1034.      floating point value X (valid for mode M) to an integer, still
  1035.      represented in floating point mode M, by rounding towards zero.
  1036.  
  1037. File: internals,  Node: RTL Declarations,  Next: Side Effects,  Prev: Conversions,  Up: RTL
  1038.  
  1039. Declarations
  1040. ============
  1041.  
  1042. Declaration expression codes do not represent arithmetic operations but
  1043. rather state assertions about their operands.
  1044.  
  1045. `(strict_low_part (subreg:M (reg:N R) 0))'
  1046.      This expression code is used in only one context: operand 0 of a `set'
  1047.      expression.  In addition, the operand of this expression must be a
  1048.      `subreg' expression.
  1049.  
  1050.      The presence of `strict_low_part' says that the part of the register
  1051.      which is meaningful in mode N, but is not part of mode M, is not to be
  1052.      altered.  Normally, an assignment to such a subreg is allowed to have
  1053.      undefined effects on the rest of the register when M is less than a
  1054.      word.
  1055.  
  1056.