|
|
1.1.1.5 ! root 1: This is Info file gcc.info, produced by Makeinfo-1.54 from the input 1.1 root 2: file gcc.texi. 3: 4: This file documents the use and the internals of the GNU compiler. 5: 1.1.1.5 ! root 6: Published by the Free Software Foundation 675 Massachusetts Avenue ! 7: Cambridge, MA 02139 USA ! 8: ! 9: Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc. 1.1 root 10: 1.1.1.3 root 11: Permission is granted to make and distribute verbatim copies of this 12: manual provided the copyright notice and this permission notice are 13: preserved on all copies. 1.1 root 14: 15: Permission is granted to copy and distribute modified versions of 16: this manual under the conditions for verbatim copying, provided also 1.1.1.4 root 17: that the sections entitled "GNU General Public License" and "Protect 18: Your Freedom--Fight `Look And Feel'" are included exactly as in the 19: original, and provided that the entire resulting derived work is 20: distributed under the terms of a permission notice identical to this 21: one. 1.1 root 22: 23: Permission is granted to copy and distribute translations of this 24: manual into another language, under the above conditions for modified 1.1.1.3 root 25: versions, except that the sections entitled "GNU General Public 1.1.1.4 root 26: License" and "Protect Your Freedom--Fight `Look And Feel'", and this 27: permission notice, may be included in translations approved by the Free 28: Software Foundation instead of in the original English. 1.1.1.3 root 29: 30: 1.1.1.5 ! root 31: File: gcc.info, Node: Machine Modes, Next: Constants, Prev: Flags, Up: RTL 1.1.1.3 root 32: 1.1.1.5 ! root 33: Machine Modes ! 34: ============= 1.1.1.3 root 35: 1.1.1.5 ! root 36: A machine mode describes a size of data object and the ! 37: representation used for it. In the C code, machine modes are ! 38: represented by an enumeration type, `enum machine_mode', defined in ! 39: `machmode.def'. Each RTL expression has room for a machine mode and so ! 40: do certain kinds of tree expressions (declarations and types, to be ! 41: precise). ! 42: ! 43: In debugging dumps and machine descriptions, the machine mode of an ! 44: RTL expression is written after the expression code with a colon to ! 45: separate them. The letters `mode' which appear at the end of each ! 46: machine mode name are omitted. For example, `(reg:SI 38)' is a `reg' ! 47: expression with machine mode `SImode'. If the mode is `VOIDmode', it ! 48: is not written at all. ! 49: ! 50: Here is a table of machine modes. The term "byte" below refers to an ! 51: object of `BITS_PER_UNIT' bits (*note Storage Layout::.). ! 52: ! 53: `QImode' ! 54: "Quarter-Integer" mode represents a single byte treated as an ! 55: integer. ! 56: ! 57: `HImode' ! 58: "Half-Integer" mode represents a two-byte integer. ! 59: ! 60: `PSImode' ! 61: "Partial Single Integer" mode represents an integer which occupies ! 62: four bytes but which doesn't really use all four. On some ! 63: machines, this is the right mode to use for pointers. ! 64: ! 65: `SImode' ! 66: "Single Integer" mode represents a four-byte integer. ! 67: ! 68: `PDImode' ! 69: "Partial Double Integer" mode represents an integer which occupies ! 70: eight bytes but which doesn't really use all eight. On some ! 71: machines, this is the right mode to use for certain pointers. ! 72: ! 73: `DImode' ! 74: "Double Integer" mode represents an eight-byte integer. ! 75: ! 76: `TImode' ! 77: "Tetra Integer" (?) mode represents a sixteen-byte integer. ! 78: ! 79: `SFmode' ! 80: "Single Floating" mode represents a single-precision (four byte) ! 81: floating point number. ! 82: ! 83: `DFmode' ! 84: "Double Floating" mode represents a double-precision (eight byte) ! 85: floating point number. ! 86: ! 87: `XFmode' ! 88: "Extended Floating" mode represents a triple-precision (twelve ! 89: byte) floating point number. This mode is used for IEEE extended ! 90: floating point. ! 91: ! 92: `TFmode' ! 93: "Tetra Floating" mode represents a quadruple-precision (sixteen ! 94: byte) floating point number. ! 95: ! 96: `CCmode' ! 97: "Condition Code" mode represents the value of a condition code, ! 98: which is a machine-specific set of bits used to represent the ! 99: result of a comparison operation. Other machine-specific modes ! 100: may also be used for the condition code. These modes are not used ! 101: on machines that use `cc0' (see *note Condition Code::.). ! 102: ! 103: `BLKmode' ! 104: "Block" mode represents values that are aggregates to which none of ! 105: the other modes apply. In RTL, only memory references can have ! 106: this mode, and only if they appear in string-move or vector ! 107: instructions. On machines which have no such instructions, ! 108: `BLKmode' will not appear in RTL. ! 109: ! 110: `VOIDmode' ! 111: Void mode means the absence of a mode or an unspecified mode. For ! 112: example, RTL expressions of code `const_int' have mode `VOIDmode' ! 113: because they can be taken to have whatever mode the context ! 114: requires. In debugging dumps of RTL, `VOIDmode' is expressed by ! 115: the absence of any mode. ! 116: ! 117: `SCmode, DCmode, XCmode, TCmode' ! 118: These modes stand for a complex number represented as a pair of ! 119: floating point values. The values are in `SFmode', `DFmode', ! 120: `XFmode', and `TFmode', respectively. Since C does not support ! 121: complex numbers, these machine modes are only partially ! 122: implemented. ! 123: ! 124: The machine description defines `Pmode' as a C macro which expands ! 125: into the machine mode used for addresses. Normally this is the mode ! 126: whose size is `BITS_PER_WORD', `SImode' on 32-bit machines. ! 127: ! 128: The only modes which a machine description must support are ! 129: `QImode', and the modes corresponding to `BITS_PER_WORD', ! 130: `FLOAT_TYPE_SIZE' and `DOUBLE_TYPE_SIZE'. The compiler will attempt to ! 131: use `DImode' for 8-byte structures and unions, but this can be ! 132: prevented by overriding the definition of `MAX_FIXED_MODE_SIZE'. ! 133: Alternatively, you can have the compiler use `TImode' for 16-byte ! 134: structures and unions. Likewise, you can arrange for the C type `short ! 135: int' to avoid using `HImode'. ! 136: ! 137: Very few explicit references to machine modes remain in the compiler ! 138: and these few references will soon be removed. Instead, the machine ! 139: modes are divided into mode classes. These are represented by the ! 140: enumeration type `enum mode_class' defined in `machmode.h'. The ! 141: possible mode classes are: ! 142: ! 143: `MODE_INT' ! 144: Integer modes. By default these are `QImode', `HImode', `SImode', ! 145: `DImode', and `TImode'. ! 146: ! 147: `MODE_PARTIAL_INT' ! 148: The "partial integer" modes, `PSImode' and `PDImode'. ! 149: ! 150: `MODE_FLOAT' ! 151: floating point modes. By default these are `SFmode', `DFmode', ! 152: `XFmode' and `TFmode'. ! 153: ! 154: `MODE_COMPLEX_INT' ! 155: Complex integer modes. (These are not currently implemented). ! 156: ! 157: `MODE_COMPLEX_FLOAT' ! 158: Complex floating point modes. By default these are `SCmode', ! 159: `DCmode', `XCmode', and `TCmode'. ! 160: ! 161: `MODE_FUNCTION' ! 162: Algol or Pascal function variables including a static chain. ! 163: (These are not currently implemented). ! 164: ! 165: `MODE_CC' ! 166: Modes representing condition code values. These are `CCmode' plus ! 167: any modes listed in the `EXTRA_CC_MODES' macro. *Note Jump ! 168: Patterns::, also see *Note Condition Code::. ! 169: ! 170: `MODE_RANDOM' ! 171: This is a catchall mode class for modes which don't fit into the ! 172: above classes. Currently `VOIDmode' and `BLKmode' are in ! 173: `MODE_RANDOM'. ! 174: ! 175: Here are some C macros that relate to machine modes: ! 176: ! 177: `GET_MODE (X)' ! 178: Returns the machine mode of the RTX X. ! 179: ! 180: `PUT_MODE (X, NEWMODE)' ! 181: Alters the machine mode of the RTX X to be NEWMODE. ! 182: ! 183: `NUM_MACHINE_MODES' ! 184: Stands for the number of machine modes available on the target ! 185: machine. This is one greater than the largest numeric value of any ! 186: machine mode. ! 187: ! 188: `GET_MODE_NAME (M)' ! 189: Returns the name of mode M as a string. ! 190: ! 191: `GET_MODE_CLASS (M)' ! 192: Returns the mode class of mode M. ! 193: ! 194: `GET_MODE_WIDER_MODE (M)' ! 195: Returns the next wider natural mode. For example, the expression ! 196: `GET_MODE_WIDER_MODE (QImode)' returns `HImode'. ! 197: ! 198: `GET_MODE_SIZE (M)' ! 199: Returns the size in bytes of a datum of mode M. ! 200: ! 201: `GET_MODE_BITSIZE (M)' ! 202: Returns the size in bits of a datum of mode M. ! 203: ! 204: `GET_MODE_MASK (M)' ! 205: Returns a bitmask containing 1 for all bits in a word that fit ! 206: within mode M. This macro can only be used for modes whose ! 207: bitsize is less than or equal to `HOST_BITS_PER_INT'. ! 208: ! 209: `GET_MODE_ALIGNMENT (M))' ! 210: Return the required alignment, in bits, for an object of mode M. ! 211: ! 212: `GET_MODE_UNIT_SIZE (M)' ! 213: Returns the size in bytes of the subunits of a datum of mode M. ! 214: This is the same as `GET_MODE_SIZE' except in the case of complex ! 215: modes. For them, the unit size is the size of the real or ! 216: imaginary part. ! 217: ! 218: `GET_MODE_NUNITS (M)' ! 219: Returns the number of units contained in a mode, i.e., ! 220: `GET_MODE_SIZE' divided by `GET_MODE_UNIT_SIZE'. ! 221: ! 222: `GET_CLASS_NARROWEST_MODE (C)' ! 223: Returns the narrowest mode in mode class C. ! 224: ! 225: The global variables `byte_mode' and `word_mode' contain modes whose ! 226: classes are `MODE_INT' and whose bitsizes are either `BITS_PER_UNIT' or ! 227: `BITS_PER_WORD', respectively. On 32-bit machines, these are `QImode' ! 228: and `SImode', respectively. ! 229: ! 230: ! 231: File: gcc.info, Node: Constants, Next: Regs and Memory, Prev: Machine Modes, Up: RTL ! 232: ! 233: Constant Expression Types ! 234: ========================= ! 235: ! 236: The simplest RTL expressions are those that represent constant ! 237: values. ! 238: ! 239: `(const_int I)' ! 240: This type of expression represents the integer value I. I is ! 241: customarily accessed with the macro `INTVAL' as in `INTVAL (EXP)', ! 242: which is equivalent to `XWINT (EXP, 0)'. ! 243: ! 244: There is only one expression object for the integer value zero; it ! 245: is the value of the variable `const0_rtx'. Likewise, the only ! 246: expression for integer value one is found in `const1_rtx', the only ! 247: expression for integer value two is found in `const2_rtx', and the ! 248: only expression for integer value negative one is found in ! 249: `constm1_rtx'. Any attempt to create an expression of code ! 250: `const_int' and value zero, one, two or negative one will return ! 251: `const0_rtx', `const1_rtx', `const2_rtx' or `constm1_rtx' as ! 252: appropriate. ! 253: ! 254: Similarly, there is only one object for the integer whose value is ! 255: `STORE_FLAG_VALUE'. It is found in `const_true_rtx'. If ! 256: `STORE_FLAG_VALUE' is one, `const_true_rtx' and `const1_rtx' will ! 257: point to the same object. If `STORE_FLAG_VALUE' is -1, ! 258: `const_true_rtx' and `constm1_rtx' will point to the same object. ! 259: ! 260: `(const_double:M ADDR I0 I1 ...)' ! 261: Represents either a floating-point constant of mode M or an ! 262: integer constant too large to fit into `HOST_BITS_PER_WIDE_INT' ! 263: bits but small enough to fit within twice that number of bits (GNU ! 264: CC does not provide a mechanism to represent even larger ! 265: constants). In the latter case, M will be `VOIDmode'. ! 266: ! 267: ADDR is used to contain the `mem' expression that corresponds to ! 268: the location in memory that at which the constant can be found. If ! 269: it has not been allocated a memory location, but is on the chain ! 270: of all `const_double' expressions in this compilation (maintained ! 271: using an undisplayed field), ADDR contains `const0_rtx'. If it is ! 272: not on the chain, ADDR contains `cc0_rtx'. ADDR is customarily ! 273: accessed with the macro `CONST_DOUBLE_MEM' and the chain field via ! 274: `CONST_DOUBLE_CHAIN'. ! 275: ! 276: If M is `VOIDmode', the bits of the value are stored in I0 and I1. ! 277: I0 is customarily accessed with the macro `CONST_DOUBLE_LOW' and ! 278: I1 with `CONST_DOUBLE_HIGH'. ! 279: ! 280: If the constant is floating point (regardless of its precision), ! 281: then the number of integers used to store the value depends on the ! 282: size of `REAL_VALUE_TYPE' (*note Cross-compilation::.). The ! 283: integers represent a floating point number, but not precisely in ! 284: the target machine's or host machine's floating point format. To ! 285: convert them to the precise bit pattern used by the target ! 286: machine, use the macro `REAL_VALUE_TO_TARGET_DOUBLE' and friends ! 287: (*note Data Output::.). ! 288: ! 289: The macro `CONST0_RTX (MODE)' refers to an expression with value 0 ! 290: in mode MODE. If mode MODE is of mode class `MODE_INT', it ! 291: returns `const0_rtx'. Otherwise, it returns a `CONST_DOUBLE' ! 292: expression in mode MODE. Similarly, the macro `CONST1_RTX (MODE)' ! 293: refers to an expression with value 1 in mode MODE and similarly ! 294: for `CONST2_RTX'. ! 295: ! 296: `(const_string STR)' ! 297: Represents a constant string with value STR. Currently this is ! 298: used only for insn attributes (*note Insn Attributes::.) since ! 299: constant strings in C are placed in memory. ! 300: ! 301: `(symbol_ref:MODE SYMBOL)' ! 302: Represents the value of an assembler label for data. SYMBOL is a ! 303: string that describes the name of the assembler label. If it ! 304: starts with a `*', the label is the rest of SYMBOL not including ! 305: the `*'. Otherwise, the label is SYMBOL, usually prefixed with ! 306: `_'. ! 307: ! 308: The `symbol_ref' contains a mode, which is usually `Pmode'. ! 309: Usually that is the only mode for which a symbol is directly valid. ! 310: ! 311: `(label_ref LABEL)' ! 312: Represents the value of an assembler label for code. It contains ! 313: one operand, an expression, which must be a `code_label' that ! 314: appears in the instruction sequence to identify the place where ! 315: the label should go. ! 316: ! 317: The reason for using a distinct expression type for code label ! 318: references is so that jump optimization can distinguish them. ! 319: ! 320: `(const:M EXP)' ! 321: Represents a constant that is the result of an assembly-time ! 322: arithmetic computation. The operand, EXP, is an expression that ! 323: contains only constants (`const_int', `symbol_ref' and `label_ref' ! 324: expressions) combined with `plus' and `minus'. However, not all ! 325: combinations are valid, since the assembler cannot do arbitrary ! 326: arithmetic on relocatable symbols. ! 327: ! 328: M should be `Pmode'. ! 329: ! 330: `(high:M EXP)' ! 331: Represents the high-order bits of EXP, usually a `symbol_ref'. ! 332: The number of bits is machine-dependent and is normally the number ! 333: of bits specified in an instruction that initializes the high ! 334: order bits of a register. It is used with `lo_sum' to represent ! 335: the typical two-instruction sequence used in RISC machines to ! 336: reference a global memory location. ! 337: ! 338: M should be `Pmode'. ! 339: ! 340: ! 341: File: gcc.info, Node: Regs and Memory, Next: Arithmetic, Prev: Constants, Up: RTL ! 342: ! 343: Registers and Memory ! 344: ==================== ! 345: ! 346: Here are the RTL expression types for describing access to machine ! 347: registers and to main memory. ! 348: ! 349: `(reg:M N)' ! 350: For small values of the integer N (those that are less than ! 351: `FIRST_PSEUDO_REGISTER'), this stands for a reference to machine ! 352: register number N: a "hard register". For larger values of N, it ! 353: stands for a temporary value or "pseudo register". The compiler's ! 354: strategy is to generate code assuming an unlimited number of such ! 355: pseudo registers, and later convert them into hard registers or ! 356: into memory references. ! 357: ! 358: M is the machine mode of the reference. It is necessary because ! 359: machines can generally refer to each register in more than one ! 360: mode. For example, a register may contain a full word but there ! 361: may be instructions to refer to it as a half word or as a single ! 362: byte, as well as instructions to refer to it as a floating point ! 363: number of various precisions. ! 364: ! 365: Even for a register that the machine can access in only one mode, ! 366: the mode must always be specified. ! 367: ! 368: The symbol `FIRST_PSEUDO_REGISTER' is defined by the machine ! 369: description, since the number of hard registers on the machine is ! 370: an invariant characteristic of the machine. Note, however, that ! 371: not all of the machine registers must be general registers. All ! 372: the machine registers that can be used for storage of data are ! 373: given hard register numbers, even those that can be used only in ! 374: certain instructions or can hold only certain types of data. ! 375: ! 376: A hard register may be accessed in various modes throughout one ! 377: function, but each pseudo register is given a natural mode and is ! 378: accessed only in that mode. When it is necessary to describe an ! 379: access to a pseudo register using a nonnatural mode, a `subreg' ! 380: expression is used. ! 381: ! 382: A `reg' expression with a machine mode that specifies more than ! 383: one word of data may actually stand for several consecutive ! 384: registers. If in addition the register number specifies a ! 385: hardware register, then it actually represents several consecutive ! 386: hardware registers starting with the specified one. ! 387: ! 388: Each pseudo register number used in a function's RTL code is ! 389: represented by a unique `reg' expression. ! 390: ! 391: Some pseudo register numbers, those within the range of ! 392: `FIRST_VIRTUAL_REGISTER' to `LAST_VIRTUAL_REGISTER' only appear ! 393: during the RTL generation phase and are eliminated before the ! 394: optimization phases. These represent locations in the stack frame ! 395: that cannot be determined until RTL generation for the function ! 396: has been completed. The following virtual register numbers are ! 397: defined: ! 398: ! 399: `VIRTUAL_INCOMING_ARGS_REGNUM' ! 400: This points to the first word of the incoming arguments ! 401: passed on the stack. Normally these arguments are placed ! 402: there by the caller, but the callee may have pushed some ! 403: arguments that were previously passed in registers. ! 404: ! 405: When RTL generation is complete, this virtual register is ! 406: replaced by the sum of the register given by ! 407: `ARG_POINTER_REGNUM' and the value of `FIRST_PARM_OFFSET'. ! 408: ! 409: `VIRTUAL_STACK_VARS_REGNUM' ! 410: If `FRAME_GROWS_DOWNWARDS' is defined, this points to ! 411: immediately above the first variable on the stack. ! 412: Otherwise, it points to the first variable on the stack. ! 413: ! 414: `VIRTUAL_STACK_VARS_REGNUM' is replaced with the sum of the ! 415: register given by `FRAME_POINTER_REGNUM' and the value ! 416: `STARTING_FRAME_OFFSET'. ! 417: ! 418: `VIRTUAL_STACK_DYNAMIC_REGNUM' ! 419: This points to the location of dynamically allocated memory ! 420: on the stack immediately after the stack pointer has been ! 421: adjusted by the amount of memory desired. ! 422: ! 423: This virtual register is replaced by the sum of the register ! 424: given by `STACK_POINTER_REGNUM' and the value ! 425: `STACK_DYNAMIC_OFFSET'. ! 426: ! 427: `VIRTUAL_OUTGOING_ARGS_REGNUM' ! 428: This points to the location in the stack at which outgoing ! 429: arguments should be written when the stack is pre-pushed ! 430: (arguments pushed using push insns should always use ! 431: `STACK_POINTER_REGNUM'). ! 432: ! 433: This virtual register is replaced by the sum of the register ! 434: given by `STACK_POINTER_REGNUM' and the value ! 435: `STACK_POINTER_OFFSET'. ! 436: ! 437: `(subreg:M REG WORDNUM)' ! 438: `subreg' expressions are used to refer to a register in a machine ! 439: mode other than its natural one, or to refer to one register of a ! 440: multi-word `reg' that actually refers to several registers. ! 441: ! 442: Each pseudo-register has a natural mode. If it is necessary to ! 443: operate on it in a different mode--for example, to perform a ! 444: fullword move instruction on a pseudo-register that contains a ! 445: single byte--the pseudo-register must be enclosed in a `subreg'. ! 446: In such a case, WORDNUM is zero. ! 447: ! 448: Usually M is at least as narrow as the mode of REG, in which case ! 449: it is restricting consideration to only the bits of REG that are ! 450: in M. However, sometimes M is wider than the mode of REG. These ! 451: `subreg' expressions are often called "paradoxical". They are ! 452: used in cases where we want to refer to an object in a wider mode ! 453: but do not care what value the additional bits have. The reload ! 454: pass ensures that paradoxical references are only made to hard 1.1.1.4 root 455: registers. 456: 1.1.1.5 ! root 457: The other use of `subreg' is to extract the individual registers of ! 458: a multi-register value. Machine modes such as `DImode' and ! 459: `TImode' can indicate values longer than a word, values which ! 460: usually require two or more consecutive registers. To access one ! 461: of the registers, use a `subreg' with mode `SImode' and a WORDNUM ! 462: that says which register. ! 463: ! 464: The compilation parameter `WORDS_BIG_ENDIAN', if set to 1, says ! 465: that word number zero is the most significant part; otherwise, it ! 466: is the least significant part. ! 467: ! 468: Between the combiner pass and the reload pass, it is possible to ! 469: have a paradoxical `subreg' which contains a `mem' instead of a ! 470: `reg' as its first operand. After the reload pass, it is also ! 471: possible to have a non-paradoxical `subreg' which contains a ! 472: `mem'; this usually occurs when the `mem' is a stack slot which ! 473: replaced a pseudo register. ! 474: ! 475: Note that it is not valid to access a `DFmode' value in `SFmode' ! 476: using a `subreg'. On some machines the most significant part of a ! 477: `DFmode' value does not have the same format as a single-precision ! 478: floating value. ! 479: ! 480: It is also not valid to access a single word of a multi-word value ! 481: in a hard register when less registers can hold the value than ! 482: would be expected from its size. For example, some 32-bit ! 483: machines have floating-point registers that can hold an entire ! 484: `DFmode' value. If register 10 were such a register `(subreg:SI ! 485: (reg:DF 10) 1)' would be invalid because there is no way to ! 486: convert that reference to a single machine register. The reload ! 487: pass prevents `subreg' expressions such as these from being formed. ! 488: ! 489: The first operand of a `subreg' expression is customarily accessed ! 490: with the `SUBREG_REG' macro and the second operand is customarily ! 491: accessed with the `SUBREG_WORD' macro. ! 492: ! 493: `(scratch:M)' ! 494: This represents a scratch register that will be required for the ! 495: execution of a single instruction and not used subsequently. It is ! 496: converted into a `reg' by either the local register allocator or ! 497: the reload pass. ! 498: ! 499: `scratch' is usually present inside a `clobber' operation (*note ! 500: Side Effects::.). ! 501: ! 502: `(cc0)' ! 503: This refers to the machine's condition code register. It has no ! 504: operands and may not have a machine mode. There are two ways to ! 505: use it: ! 506: ! 507: * To stand for a complete set of condition code flags. This is ! 508: best on most machines, where each comparison sets the entire ! 509: series of flags. ! 510: ! 511: With this technique, `(cc0)' may be validly used in only two ! 512: contexts: as the destination of an assignment (in test and ! 513: compare instructions) and in comparison operators comparing ! 514: against zero (`const_int' with value zero; that is to say, ! 515: `const0_rtx'). ! 516: ! 517: * To stand for a single flag that is the result of a single ! 518: condition. This is useful on machines that have only a ! 519: single flag bit, and in which comparison instructions must ! 520: specify the condition to test. ! 521: ! 522: With this technique, `(cc0)' may be validly used in only two ! 523: contexts: as the destination of an assignment (in test and ! 524: compare instructions) where the source is a comparison ! 525: operator, and as the first operand of `if_then_else' (in a ! 526: conditional branch). ! 527: ! 528: There is only one expression object of code `cc0'; it is the value ! 529: of the variable `cc0_rtx'. Any attempt to create an expression of ! 530: code `cc0' will return `cc0_rtx'. ! 531: ! 532: Instructions can set the condition code implicitly. On many ! 533: machines, nearly all instructions set the condition code based on ! 534: the value that they compute or store. It is not necessary to ! 535: record these actions explicitly in the RTL because the machine ! 536: description includes a prescription for recognizing the ! 537: instructions that do so (by means of the macro ! 538: `NOTICE_UPDATE_CC'). *Note Condition Code::. Only instructions ! 539: whose sole purpose is to set the condition code, and instructions ! 540: that use the condition code, need mention `(cc0)'. ! 541: ! 542: On some machines, the condition code register is given a register ! 543: number and a `reg' is used instead of `(cc0)'. This is usually the ! 544: preferable approach if only a small subset of instructions modify ! 545: the condition code. Other machines store condition codes in ! 546: general registers; in such cases a pseudo register should be used. ! 547: ! 548: Some machines, such as the Sparc and RS/6000, have two sets of ! 549: arithmetic instructions, one that sets and one that does not set ! 550: the condition code. This is best handled by normally generating ! 551: the instruction that does not set the condition code, and making a ! 552: pattern that both performs the arithmetic and sets the condition ! 553: code register (which would not be `(cc0)' in this case). For ! 554: examples, search for `addcc' and `andcc' in `sparc.md'. ! 555: ! 556: `(pc)' ! 557: This represents the machine's program counter. It has no operands ! 558: and may not have a machine mode. `(pc)' may be validly used only ! 559: in certain specific contexts in jump instructions. ! 560: ! 561: There is only one expression object of code `pc'; it is the value ! 562: of the variable `pc_rtx'. Any attempt to create an expression of ! 563: code `pc' will return `pc_rtx'. ! 564: ! 565: All instructions that do not jump alter the program counter ! 566: implicitly by incrementing it, but there is no need to mention ! 567: this in the RTL. ! 568: ! 569: `(mem:M ADDR)' ! 570: This RTX represents a reference to main memory at an address ! 571: represented by the expression ADDR. M specifies how large a unit ! 572: of memory is accessed. ! 573: ! 574: ! 575: File: gcc.info, Node: Arithmetic, Next: Comparisons, Prev: Regs and Memory, Up: RTL ! 576: ! 577: RTL Expressions for Arithmetic ! 578: ============================== ! 579: ! 580: Unless otherwise specified, all the operands of arithmetic ! 581: expressions must be valid for mode M. An operand is valid for mode M ! 582: if it has mode M, or if it is a `const_int' or `const_double' and M is ! 583: a mode of class `MODE_INT'. ! 584: ! 585: For commutative binary operations, constants should be placed in the ! 586: second operand. ! 587: ! 588: `(plus:M X Y)' ! 589: Represents the sum of the values represented by X and Y carried ! 590: out in machine mode M. ! 591: ! 592: `(lo_sum:M X Y)' ! 593: Like `plus', except that it represents that sum of X and the ! 594: low-order bits of Y. The number of low order bits is ! 595: machine-dependent but is normally the number of bits in a `Pmode' ! 596: item minus the number of bits set by the `high' code (*note ! 597: Constants::.). ! 598: ! 599: M should be `Pmode'. ! 600: ! 601: `(minus:M X Y)' ! 602: Like `plus' but represents subtraction. ! 603: ! 604: `(compare:M X Y)' ! 605: Represents the result of subtracting Y from X for purposes of ! 606: comparison. The result is computed without overflow, as if with ! 607: infinite precision. ! 608: ! 609: Of course, machines can't really subtract with infinite precision. ! 610: However, they can pretend to do so when only the sign of the ! 611: result will be used, which is the case when the result is stored ! 612: in the condition code. And that is the only way this kind of ! 613: expression may validly be used: as a value to be stored in the ! 614: condition codes. ! 615: ! 616: The mode M is not related to the modes of X and Y, but instead is ! 617: the mode of the condition code value. If `(cc0)' is used, it is ! 618: `VOIDmode'. Otherwise it is some mode in class `MODE_CC', often ! 619: `CCmode'. *Note Condition Code::. ! 620: ! 621: Normally, X and Y must have the same mode. Otherwise, `compare' ! 622: is valid only if the mode of X is in class `MODE_INT' and Y is a ! 623: `const_int' or `const_double' with mode `VOIDmode'. The mode of X ! 624: determines what mode the comparison is to be done in; thus it must ! 625: not be `VOIDmode'. ! 626: ! 627: If one of the operands is a constant, it should be placed in the ! 628: second operand and the comparison code adjusted as appropriate. ! 629: ! 630: A `compare' specifying two `VOIDmode' constants is not valid since ! 631: there is no way to know in what mode the comparison is to be ! 632: performed; the comparison must either be folded during the ! 633: compilation or the first operand must be loaded into a register ! 634: while its mode is still known. ! 635: ! 636: `(neg:M X)' ! 637: Represents the negation (subtraction from zero) of the value ! 638: represented by X, carried out in mode M. ! 639: ! 640: `(mult:M X Y)' ! 641: Represents the signed product of the values represented by X and Y ! 642: carried out in machine mode M. ! 643: ! 644: Some machines support a multiplication that generates a product ! 645: wider than the operands. Write the pattern for this as ! 646: ! 647: (mult:M (sign_extend:M X) (sign_extend:M Y)) ! 648: ! 649: where M is wider than the modes of X and Y, which need not be the ! 650: same. ! 651: ! 652: Write patterns for unsigned widening multiplication similarly using ! 653: `zero_extend'. ! 654: ! 655: `(div:M X Y)' ! 656: Represents the quotient in signed division of X by Y, carried out ! 657: in machine mode M. If M is a floating point mode, it represents ! 658: the exact quotient; otherwise, the integerized quotient. ! 659: ! 660: Some machines have division instructions in which the operands and ! 661: quotient widths are not all the same; you should represent such ! 662: instructions using `truncate' and `sign_extend' as in, ! 663: ! 664: (truncate:M1 (div:M2 X (sign_extend:M2 Y))) ! 665: ! 666: `(udiv:M X Y)' ! 667: Like `div' but represents unsigned division. ! 668: ! 669: `(mod:M X Y)' ! 670: `(umod:M X Y)' ! 671: Like `div' and `udiv' but represent the remainder instead of the ! 672: quotient. ! 673: ! 674: `(smin:M X Y)' ! 675: `(smax:M X Y)' ! 676: Represents the smaller (for `smin') or larger (for `smax') of X ! 677: and Y, interpreted as signed integers in mode M. ! 678: ! 679: `(umin:M X Y)' ! 680: `(umax:M X Y)' ! 681: Like `smin' and `smax', but the values are interpreted as unsigned ! 682: integers. ! 683: ! 684: `(not:M X)' ! 685: Represents the bitwise complement of the value represented by X, ! 686: carried out in mode M, which must be a fixed-point machine mode. ! 687: ! 688: `(and:M X Y)' ! 689: Represents the bitwise logical-and of the values represented by X ! 690: and Y, carried out in machine mode M, which must be a fixed-point ! 691: machine mode. ! 692: ! 693: `(ior:M X Y)' ! 694: Represents the bitwise inclusive-or of the values represented by X ! 695: and Y, carried out in machine mode M, which must be a fixed-point ! 696: mode. ! 697: ! 698: `(xor:M X Y)' ! 699: Represents the bitwise exclusive-or of the values represented by X ! 700: and Y, carried out in machine mode M, which must be a fixed-point ! 701: mode. ! 702: ! 703: `(ashift:M X C)' ! 704: Represents the result of arithmetically shifting X left by C ! 705: places. X have mode M, a fixed-point machine mode. C be a ! 706: fixed-point mode or be a constant with mode `VOIDmode'; which mode ! 707: is determined by the mode called for in the machine description ! 708: entry for the left-shift instruction. For example, on the Vax, ! 709: the mode of C is `QImode' regardless of M. ! 710: ! 711: `(lshift:M X C)' ! 712: Like `ashift' but for logical left shift. `ashift' and `lshift' ! 713: are identical operations; we customarily use `ashift' for both. ! 714: ! 715: `(lshiftrt:M X C)' ! 716: `(ashiftrt:M X C)' ! 717: Like `lshift' and `ashift' but for right shift. Unlike the case ! 718: for left shift, these two operations are distinct. ! 719: ! 720: `(rotate:M X C)' ! 721: `(rotatert:M X C)' ! 722: Similar but represent left and right rotate. If C is a constant, ! 723: use `rotate'. ! 724: ! 725: `(abs:M X)' ! 726: Represents the absolute value of X, computed in mode M. ! 727: ! 728: `(sqrt:M X)' ! 729: Represents the square root of X, computed in mode M. Most often M ! 730: will be a floating point mode. ! 731: ! 732: `(ffs:M X)' ! 733: Represents one plus the index of the least significant 1-bit in X, ! 734: represented as an integer of mode M. (The value is zero if X is ! 735: zero.) The mode of X need not be M; depending on the target ! 736: machine, various mode combinations may be valid. ! 737: ! 738: ! 739: File: gcc.info, Node: Comparisons, Next: Bit Fields, Prev: Arithmetic, Up: RTL ! 740: ! 741: Comparison Operations ! 742: ===================== ! 743: ! 744: Comparison operators test a relation on two operands and are ! 745: considered to represent a machine-dependent nonzero value described by, ! 746: but not necessarily equal to, `STORE_FLAG_VALUE' (*note Misc::.) if the ! 747: relation holds, or zero if it does not. The mode of the comparison ! 748: operation is independent of the mode of the data being compared. If ! 749: the comparison operation is being tested (e.g., the first operand of an ! 750: `if_then_else'), the mode must be `VOIDmode'. If the comparison ! 751: operation is producing data to be stored in some variable, the mode ! 752: must be in class `MODE_INT'. All comparison operations producing data ! 753: must use the same mode, which is machine-specific. ! 754: ! 755: There are two ways that comparison operations may be used. The ! 756: comparison operators may be used to compare the condition codes `(cc0)' ! 757: against zero, as in `(eq (cc0) (const_int 0))'. Such a construct ! 758: actually refers to the result of the preceding instruction in which the ! 759: condition codes were set. The instructing setting the condition code ! 760: must be adjacent to the instruction using the condition code; only ! 761: `note' insns may separate them. ! 762: ! 763: Alternatively, a comparison operation may directly compare two data ! 764: objects. The mode of the comparison is determined by the operands; they ! 765: must both be valid for a common machine mode. A comparison with both ! 766: operands constant would be invalid as the machine mode could not be ! 767: deduced from it, but such a comparison should never exist in RTL due to ! 768: constant folding. ! 769: ! 770: In the example above, if `(cc0)' were last set to `(compare X Y)', ! 771: the comparison operation is identical to `(eq X Y)'. Usually only one ! 772: style of comparisons is supported on a particular machine, but the ! 773: combine pass will try to merge the operations to produce the `eq' shown ! 774: in case it exists in the context of the particular insn involved. ! 775: ! 776: Inequality comparisons come in two flavors, signed and unsigned. ! 777: Thus, there are distinct expression codes `gt' and `gtu' for signed and ! 778: unsigned greater-than. These can produce different results for the same ! 779: pair of integer values: for example, 1 is signed greater-than -1 but not ! 780: unsigned greater-than, because -1 when regarded as unsigned is actually ! 781: `0xffffffff' which is greater than 1. ! 782: ! 783: The signed comparisons are also used for floating point values. ! 784: Floating point comparisons are distinguished by the machine modes of ! 785: the operands. ! 786: ! 787: `(eq:M X Y)' ! 788: 1 if the values represented by X and Y are equal, otherwise 0. ! 789: ! 790: `(ne:M X Y)' ! 791: 1 if the values represented by X and Y are not equal, otherwise 0. ! 792: ! 793: `(gt:M X Y)' ! 794: 1 if the X is greater than Y. If they are fixed-point, the ! 795: comparison is done in a signed sense. ! 796: ! 797: `(gtu:M X Y)' ! 798: Like `gt' but does unsigned comparison, on fixed-point numbers ! 799: only. ! 800: ! 801: `(lt:M X Y)' ! 802: `(ltu:M X Y)' ! 803: Like `gt' and `gtu' but test for "less than". ! 804: ! 805: `(ge:M X Y)' ! 806: `(geu:M X Y)' ! 807: Like `gt' and `gtu' but test for "greater than or equal". ! 808: ! 809: `(le:M X Y)' ! 810: `(leu:M X Y)' ! 811: Like `gt' and `gtu' but test for "less than or equal". ! 812: ! 813: `(if_then_else COND THEN ELSE)' ! 814: This is not a comparison operation but is listed here because it is ! 815: always used in conjunction with a comparison operation. To be ! 816: precise, COND is a comparison expression. This expression ! 817: represents a choice, according to COND, between the value ! 818: represented by THEN and the one represented by ELSE. ! 819: ! 820: On most machines, `if_then_else' expressions are valid only to ! 821: express conditional jumps. ! 822: ! 823: `(cond [TEST1 VALUE1 TEST2 VALUE2 ...] DEFAULT)' ! 824: Similar to `if_then_else', but more general. Each of TEST1, ! 825: TEST2, ... is performed in turn. The result of this expression is ! 826: the VALUE corresponding to the first non-zero test, or DEFAULT if ! 827: none of the tests are non-zero expressions. ! 828: ! 829: This is currently not valid for instruction patterns and is ! 830: supported only for insn attributes. *Note Insn Attributes::. ! 831: ! 832: ! 833: File: gcc.info, Node: Bit Fields, Next: Conversions, Prev: Comparisons, Up: RTL ! 834: ! 835: Bit Fields ! 836: ========== ! 837: ! 838: Special expression codes exist to represent bitfield instructions. ! 839: These types of expressions are lvalues in RTL; they may appear on the ! 840: left side of an assignment, indicating insertion of a value into the ! 841: specified bit field. ! 842: ! 843: `(sign_extract:M LOC SIZE POS)' ! 844: This represents a reference to a sign-extended bit field contained ! 845: or starting in LOC (a memory or register reference). The bit field ! 846: is SIZE bits wide and starts at bit POS. The compilation option ! 847: `BITS_BIG_ENDIAN' says which end of the memory unit POS counts ! 848: from. ! 849: ! 850: If LOC is in memory, its mode must be a single-byte integer mode. ! 851: If LOC is in a register, the mode to use is specified by the ! 852: operand of the `insv' or `extv' pattern (*note Standard Names::.) ! 853: and is usually a full-word integer mode. ! 854: ! 855: The mode of POS is machine-specific and is also specified in the ! 856: `insv' or `extv' pattern. ! 857: ! 858: The mode M is the same as the mode that would be used for LOC if ! 859: it were a register. ! 860: ! 861: `(zero_extract:M LOC SIZE POS)' ! 862: Like `sign_extract' but refers to an unsigned or zero-extended bit ! 863: field. The same sequence of bits are extracted, but they are ! 864: filled to an entire word with zeros instead of by sign-extension. ! 865: ! 866: ! 867: File: gcc.info, Node: Conversions, Next: RTL Declarations, Prev: Bit Fields, Up: RTL ! 868: ! 869: Conversions ! 870: =========== ! 871: ! 872: All conversions between machine modes must be represented by ! 873: explicit conversion operations. For example, an expression which is ! 874: the sum of a byte and a full word cannot be written as `(plus:SI ! 875: (reg:QI 34) (reg:SI 80))' because the `plus' operation requires two ! 876: operands of the same machine mode. Therefore, the byte-sized operand ! 877: is enclosed in a conversion operation, as in ! 878: ! 879: (plus:SI (sign_extend:SI (reg:QI 34)) (reg:SI 80)) ! 880: ! 881: The conversion operation is not a mere placeholder, because there ! 882: may be more than one way of converting from a given starting mode to ! 883: the desired final mode. The conversion operation code says how to do ! 884: it. ! 885: ! 886: For all conversion operations, X must not be `VOIDmode' because the ! 887: mode in which to do the conversion would not be known. The conversion ! 888: must either be done at compile-time or X must be placed into a register. ! 889: ! 890: `(sign_extend:M X)' ! 891: Represents the result of sign-extending the value X to machine ! 892: mode M. M must be a fixed-point mode and X a fixed-point value of ! 893: a mode narrower than M. ! 894: ! 895: `(zero_extend:M X)' ! 896: Represents the result of zero-extending the value X to machine ! 897: mode M. M must be a fixed-point mode and X a fixed-point value of ! 898: a mode narrower than M. ! 899: ! 900: `(float_extend:M X)' ! 901: Represents the result of extending the value X to machine mode M. ! 902: m must be a floating point mode and X a floating point value of a ! 903: mode narrower than M. ! 904: ! 905: `(truncate:M X)' ! 906: Represents the result of truncating the value X to machine mode M. ! 907: M must be a fixed-point mode and X a fixed-point value of a mode ! 908: wider than M. ! 909: ! 910: `(float_truncate:M X)' ! 911: Represents the result of truncating the value X to machine mode M. ! 912: M must be a floating point mode and X a floating point value of a ! 913: mode wider than M. ! 914: ! 915: `(float:M X)' ! 916: Represents the result of converting fixed point value X, regarded ! 917: as signed, to floating point mode M. ! 918: ! 919: `(unsigned_float:M X)' ! 920: Represents the result of converting fixed point value X, regarded ! 921: as unsigned, to floating point mode M. ! 922: ! 923: `(fix:M X)' ! 924: When M is a fixed point mode, represents the result of converting ! 925: floating point value X to mode M, regarded as signed. How ! 926: rounding is done is not specified, so this operation may be used ! 927: validly in compiling C code only for integer-valued operands. ! 928: ! 929: `(unsigned_fix:M X)' ! 930: Represents the result of converting floating point value X to ! 931: fixed point mode M, regarded as unsigned. How rounding is done is ! 932: not specified. ! 933: ! 934: `(fix:M X)' ! 935: When M is a floating point mode, represents the result of ! 936: converting floating point value X (valid for mode M) to an ! 937: integer, still represented in floating point mode M, by rounding ! 938: towards zero. ! 939: ! 940: ! 941: File: gcc.info, Node: RTL Declarations, Next: Side Effects, Prev: Conversions, Up: RTL ! 942: ! 943: Declarations ! 944: ============ ! 945: ! 946: Declaration expression codes do not represent arithmetic operations ! 947: but rather state assertions about their operands. ! 948: ! 949: `(strict_low_part (subreg:M (reg:N R) 0))' ! 950: This expression code is used in only one context: as the ! 951: destination operand of a `set' expression. In addition, the ! 952: operand of this expression must be a non-paradoxical `subreg' ! 953: expression. 1.1.1.4 root 954: 1.1.1.5 ! root 955: The presence of `strict_low_part' says that the part of the ! 956: register which is meaningful in mode N, but is not part of mode M, ! 957: is not to be altered. Normally, an assignment to such a subreg is ! 958: allowed to have undefined effects on the rest of the register when ! 959: M is less than a word. 1.1.1.2 root 960:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.