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