gccint: Machine Modes
1
1 14.6 Machine Modes
1 ==================
1
1 A machine mode describes a size of data object and the representation
1 used for it. In the C code, machine modes are represented by an
1 enumeration type, 'machine_mode', defined in 'machmode.def'. Each RTL
1 expression has room for a machine mode and so do certain kinds of tree
1 expressions (declarations and types, to be precise).
1
1 In debugging dumps and machine descriptions, the machine mode of an RTL
1 expression is written after the expression code with a colon to separate
1 them. The letters 'mode' which appear at the end of each machine mode
1 name are omitted. For example, '(reg:SI 38)' is a 'reg' expression with
1 machine mode 'SImode'. If the mode is 'VOIDmode', it is not written at
1 all.
1
1 Here is a table of machine modes. The term "byte" below refers to an
1 object of 'BITS_PER_UNIT' bits (⇒Storage Layout).
1
1 'BImode'
1 "Bit" mode represents a single bit, for predicate registers.
1
1 'QImode'
1 "Quarter-Integer" mode represents a single byte treated as an
1 integer.
1
1 'HImode'
1 "Half-Integer" mode represents a two-byte integer.
1
1 'PSImode'
1 "Partial Single Integer" mode represents an integer which occupies
1 four bytes but which doesn't really use all four. On some
1 machines, this is the right mode to use for pointers.
1
1 'SImode'
1 "Single Integer" mode represents a four-byte integer.
1
1 'PDImode'
1 "Partial Double Integer" mode represents an integer which occupies
1 eight bytes but which doesn't really use all eight. On some
1 machines, this is the right mode to use for certain pointers.
1
1 'DImode'
1 "Double Integer" mode represents an eight-byte integer.
1
1 'TImode'
1 "Tetra Integer" (?) mode represents a sixteen-byte integer.
1
1 'OImode'
1 "Octa Integer" (?) mode represents a thirty-two-byte integer.
1
1 'XImode'
1 "Hexadeca Integer" (?) mode represents a sixty-four-byte integer.
1
1 'QFmode'
1 "Quarter-Floating" mode represents a quarter-precision (single
1 byte) floating point number.
1
1 'HFmode'
1 "Half-Floating" mode represents a half-precision (two byte)
1 floating point number.
1
1 'TQFmode'
1 "Three-Quarter-Floating" (?) mode represents a
1 three-quarter-precision (three byte) floating point number.
1
1 'SFmode'
1 "Single Floating" mode represents a four byte floating point
1 number. In the common case, of a processor with IEEE arithmetic
1 and 8-bit bytes, this is a single-precision IEEE floating point
1 number; it can also be used for double-precision (on processors
1 with 16-bit bytes) and single-precision VAX and IBM types.
1
1 'DFmode'
1 "Double Floating" mode represents an eight byte floating point
1 number. In the common case, of a processor with IEEE arithmetic
1 and 8-bit bytes, this is a double-precision IEEE floating point
1 number.
1
1 'XFmode'
1 "Extended Floating" mode represents an IEEE extended floating point
1 number. This mode only has 80 meaningful bits (ten bytes). Some
1 processors require such numbers to be padded to twelve bytes,
1 others to sixteen; this mode is used for either.
1
1 'SDmode'
1 "Single Decimal Floating" mode represents a four byte decimal
1 floating point number (as distinct from conventional binary
1 floating point).
1
1 'DDmode'
1 "Double Decimal Floating" mode represents an eight byte decimal
1 floating point number.
1
1 'TDmode'
1 "Tetra Decimal Floating" mode represents a sixteen byte decimal
1 floating point number all 128 of whose bits are meaningful.
1
1 'TFmode'
1 "Tetra Floating" mode represents a sixteen byte floating point
1 number all 128 of whose bits are meaningful. One common use is the
1 IEEE quad-precision format.
1
1 'QQmode'
1 "Quarter-Fractional" mode represents a single byte treated as a
1 signed fractional number. The default format is "s.7".
1
1 'HQmode'
1 "Half-Fractional" mode represents a two-byte signed fractional
1 number. The default format is "s.15".
1
1 'SQmode'
1 "Single Fractional" mode represents a four-byte signed fractional
1 number. The default format is "s.31".
1
1 'DQmode'
1 "Double Fractional" mode represents an eight-byte signed fractional
1 number. The default format is "s.63".
1
1 'TQmode'
1 "Tetra Fractional" mode represents a sixteen-byte signed fractional
1 number. The default format is "s.127".
1
1 'UQQmode'
1 "Unsigned Quarter-Fractional" mode represents a single byte treated
1 as an unsigned fractional number. The default format is ".8".
1
1 'UHQmode'
1 "Unsigned Half-Fractional" mode represents a two-byte unsigned
1 fractional number. The default format is ".16".
1
1 'USQmode'
1 "Unsigned Single Fractional" mode represents a four-byte unsigned
1 fractional number. The default format is ".32".
1
1 'UDQmode'
1 "Unsigned Double Fractional" mode represents an eight-byte unsigned
1 fractional number. The default format is ".64".
1
1 'UTQmode'
1 "Unsigned Tetra Fractional" mode represents a sixteen-byte unsigned
1 fractional number. The default format is ".128".
1
1 'HAmode'
1 "Half-Accumulator" mode represents a two-byte signed accumulator.
1 The default format is "s8.7".
1
1 'SAmode'
1 "Single Accumulator" mode represents a four-byte signed
1 accumulator. The default format is "s16.15".
1
1 'DAmode'
1 "Double Accumulator" mode represents an eight-byte signed
1 accumulator. The default format is "s32.31".
1
1 'TAmode'
1 "Tetra Accumulator" mode represents a sixteen-byte signed
1 accumulator. The default format is "s64.63".
1
1 'UHAmode'
1 "Unsigned Half-Accumulator" mode represents a two-byte unsigned
1 accumulator. The default format is "8.8".
1
1 'USAmode'
1 "Unsigned Single Accumulator" mode represents a four-byte unsigned
1 accumulator. The default format is "16.16".
1
1 'UDAmode'
1 "Unsigned Double Accumulator" mode represents an eight-byte
1 unsigned accumulator. The default format is "32.32".
1
1 'UTAmode'
1 "Unsigned Tetra Accumulator" mode represents a sixteen-byte
1 unsigned accumulator. The default format is "64.64".
1
1 'CCmode'
1 "Condition Code" mode represents the value of a condition code,
1 which is a machine-specific set of bits used to represent the
1 result of a comparison operation. Other machine-specific modes may
1 also be used for the condition code. These modes are not used on
1 machines that use 'cc0' (⇒Condition Code).
1
1 'BLKmode'
1 "Block" mode represents values that are aggregates to which none of
1 the other modes apply. In RTL, only memory references can have
1 this mode, and only if they appear in string-move or vector
1 instructions. On machines which have no such instructions,
1 'BLKmode' will not appear in RTL.
1
1 'VOIDmode'
1 Void mode means the absence of a mode or an unspecified mode. For
1 example, RTL expressions of code 'const_int' have mode 'VOIDmode'
1 because they can be taken to have whatever mode the context
1 requires. In debugging dumps of RTL, 'VOIDmode' is expressed by
1 the absence of any mode.
1
1 'QCmode, HCmode, SCmode, DCmode, XCmode, TCmode'
1 These modes stand for a complex number represented as a pair of
1 floating point values. The floating point values are in 'QFmode',
1 'HFmode', 'SFmode', 'DFmode', 'XFmode', and 'TFmode', respectively.
1
1 'CQImode, CHImode, CSImode, CDImode, CTImode, COImode, CPSImode'
1 These modes stand for a complex number represented as a pair of
1 integer values. The integer values are in 'QImode', 'HImode',
1 'SImode', 'DImode', 'TImode', 'OImode', and 'PSImode',
1 respectively.
1
1 'BND32mode BND64mode'
1 These modes stand for bounds for pointer of 32 and 64 bit size
1 respectively. Mode size is double pointer mode size.
1
1 The machine description defines 'Pmode' as a C macro which expands into
1 the machine mode used for addresses. Normally this is the mode whose
1 size is 'BITS_PER_WORD', 'SImode' on 32-bit machines.
1
1 The only modes which a machine description must support are 'QImode',
1 and the modes corresponding to 'BITS_PER_WORD', 'FLOAT_TYPE_SIZE' and
1 'DOUBLE_TYPE_SIZE'. The compiler will attempt to use 'DImode' for
1 8-byte structures and unions, but this can be prevented by overriding
1 the definition of 'MAX_FIXED_MODE_SIZE'. Alternatively, you can have
1 the compiler use 'TImode' for 16-byte structures and unions. Likewise,
1 you can arrange for the C type 'short int' to avoid using 'HImode'.
1
1 Very few explicit references to machine modes remain in the compiler
1 and these few references will soon be removed. Instead, the machine
1 modes are divided into mode classes. These are represented by the
1 enumeration type 'enum mode_class' defined in 'machmode.h'. The
1 possible mode classes are:
1
1 'MODE_INT'
1 Integer modes. By default these are 'BImode', 'QImode', 'HImode',
1 'SImode', 'DImode', 'TImode', and 'OImode'.
1
1 'MODE_PARTIAL_INT'
1 The "partial integer" modes, 'PQImode', 'PHImode', 'PSImode' and
1 'PDImode'.
1
1 'MODE_FLOAT'
1 Floating point modes. By default these are 'QFmode', 'HFmode',
1 'TQFmode', 'SFmode', 'DFmode', 'XFmode' and 'TFmode'.
1
1 'MODE_DECIMAL_FLOAT'
1 Decimal floating point modes. By default these are 'SDmode',
1 'DDmode' and 'TDmode'.
1
1 'MODE_FRACT'
1 Signed fractional modes. By default these are 'QQmode', 'HQmode',
1 'SQmode', 'DQmode' and 'TQmode'.
1
1 'MODE_UFRACT'
1 Unsigned fractional modes. By default these are 'UQQmode',
1 'UHQmode', 'USQmode', 'UDQmode' and 'UTQmode'.
1
1 'MODE_ACCUM'
1 Signed accumulator modes. By default these are 'HAmode', 'SAmode',
1 'DAmode' and 'TAmode'.
1
1 'MODE_UACCUM'
1 Unsigned accumulator modes. By default these are 'UHAmode',
1 'USAmode', 'UDAmode' and 'UTAmode'.
1
1 'MODE_COMPLEX_INT'
1 Complex integer modes. (These are not currently implemented).
1
1 'MODE_COMPLEX_FLOAT'
1 Complex floating point modes. By default these are 'QCmode',
1 'HCmode', 'SCmode', 'DCmode', 'XCmode', and 'TCmode'.
1
1 'MODE_FUNCTION'
1 Algol or Pascal function variables including a static chain.
1 (These are not currently implemented).
1
1 'MODE_CC'
1 Modes representing condition code values. These are 'CCmode' plus
11 any 'CC_MODE' modes listed in the 'MACHINE-modes.def'. ⇒Jump
Patterns, also see ⇒Condition Code.
1
1 'MODE_POINTER_BOUNDS'
1 Pointer bounds modes. Used to represent values of pointer bounds
1 type. Operations in these modes may be executed as NOPs depending
1 on hardware features and environment setup.
1
1 'MODE_RANDOM'
1 This is a catchall mode class for modes which don't fit into the
1 above classes. Currently 'VOIDmode' and 'BLKmode' are in
1 'MODE_RANDOM'.
1
1 'machmode.h' also defines various wrapper classes that combine a
1 'machine_mode' with a static assertion that a particular condition
1 holds. The classes are:
1
1 'scalar_int_mode'
1 A mode that has class 'MODE_INT' or 'MODE_PARTIAL_INT'.
1
1 'scalar_float_mode'
1 A mode that has class 'MODE_FLOAT' or 'MODE_DECIMAL_FLOAT'.
1
1 'scalar_mode'
1 A mode that holds a single numerical value. In practice this means
1 that the mode is a 'scalar_int_mode', is a 'scalar_float_mode', or
1 has class 'MODE_FRACT', 'MODE_UFRACT', 'MODE_ACCUM', 'MODE_UACCUM'
1 or 'MODE_POINTER_BOUNDS'.
1
1 'complex_mode'
1 A mode that has class 'MODE_COMPLEX_INT' or 'MODE_COMPLEX_FLOAT'.
1
1 'fixed_size_mode'
1 A mode whose size is known at compile time.
1
1 Named modes use the most constrained of the available wrapper classes,
1 if one exists, otherwise they use 'machine_mode'. For example, 'QImode'
1 is a 'scalar_int_mode', 'SFmode' is a 'scalar_float_mode' and 'BLKmode'
1 is a plain 'machine_mode'. It is possible to refer to any mode as a raw
1 'machine_mode' by adding the 'E_' prefix, where 'E' stands for
1 "enumeration". For example, the raw 'machine_mode' names of the modes
1 just mentioned are 'E_QImode', 'E_SFmode' and 'E_BLKmode' respectively.
1
1 The wrapper classes implicitly convert to 'machine_mode' and to any
1 wrapper class that represents a more general condition; for example
1 'scalar_int_mode' and 'scalar_float_mode' both convert to 'scalar_mode'
1 and all three convert to 'fixed_size_mode'. The classes act like
1 'machine_mode's that accept only certain named modes.
1
1 'machmode.h' also defines a template class 'opt_mode<T>' that holds a
1 'T' or nothing, where 'T' can be either 'machine_mode' or one of the
1 wrapper classes above. The main operations on an 'opt_mode<T>' X are as
1 follows:
1
1 'X.exists ()'
1 Return true if X holds a mode rather than nothing.
1
1 'X.exists (&Y)'
1 Return true if X holds a mode rather than nothing, storing the mode
1 in Y if so. Y must be assignment-compatible with T.
1
1 'X.require ()'
1 Assert that X holds a mode rather than nothing and return that
1 mode.
1
1 'X = Y'
1 Set X to Y, where Y is a T or implicitly converts to a T.
1
1 The default constructor sets an 'opt_mode<T>' to nothing. There is
1 also a constructor that takes an initial value of type T.
1
1 It is possible to use the 'is-a.h' accessors on a 'machine_mode' or
1 machine mode wrapper X:
1
1 'is_a <T> (X)'
1 Return true if X meets the conditions for wrapper class T.
1
1 'is_a <T> (X, &Y)'
1 Return true if X meets the conditions for wrapper class T, storing
1 it in Y if so. Y must be assignment-compatible with T.
1
1 'as_a <T> (X)'
1 Assert that X meets the conditions for wrapper class T and return
1 it as a T.
1
1 'dyn_cast <T> (X)'
1 Return an 'opt_mode<T>' that holds X if X meets the conditions for
1 wrapper class T and that holds nothing otherwise.
1
1 The purpose of these wrapper classes is to give stronger static type
1 checking. For example, if a function takes a 'scalar_int_mode', a
1 caller that has a general 'machine_mode' must either check or assert
1 that the code is indeed a scalar integer first, using one of the
1 functions above.
1
1 The wrapper classes are normal C++ classes, with user-defined
1 constructors. Sometimes it is useful to have a POD version of the same
1 type, particularly if the type appears in a 'union'. The template class
1 'pod_mode<T>' provides a POD version of wrapper class T. It is
1 assignment-compatible with T and implicitly converts to both
1 'machine_mode' and T.
1
1 Here are some C macros that relate to machine modes:
1
1 'GET_MODE (X)'
1 Returns the machine mode of the RTX X.
1
1 'PUT_MODE (X, NEWMODE)'
1 Alters the machine mode of the RTX X to be NEWMODE.
1
1 'NUM_MACHINE_MODES'
1 Stands for the number of machine modes available on the target
1 machine. This is one greater than the largest numeric value of any
1 machine mode.
1
1 'GET_MODE_NAME (M)'
1 Returns the name of mode M as a string.
1
1 'GET_MODE_CLASS (M)'
1 Returns the mode class of mode M.
1
1 'GET_MODE_WIDER_MODE (M)'
1 Returns the next wider natural mode. For example, the expression
1 'GET_MODE_WIDER_MODE (QImode)' returns 'HImode'.
1
1 'GET_MODE_SIZE (M)'
1 Returns the size in bytes of a datum of mode M.
1
1 'GET_MODE_BITSIZE (M)'
1 Returns the size in bits of a datum of mode M.
1
1 'GET_MODE_IBIT (M)'
1 Returns the number of integral bits of a datum of fixed-point mode
1 M.
1
1 'GET_MODE_FBIT (M)'
1 Returns the number of fractional bits of a datum of fixed-point
1 mode M.
1
1 'GET_MODE_MASK (M)'
1 Returns a bitmask containing 1 for all bits in a word that fit
1 within mode M. This macro can only be used for modes whose bitsize
1 is less than or equal to 'HOST_BITS_PER_INT'.
1
1 'GET_MODE_ALIGNMENT (M)'
1 Return the required alignment, in bits, for an object of mode M.
1
1 'GET_MODE_UNIT_SIZE (M)'
1 Returns the size in bytes of the subunits of a datum of mode M.
1 This is the same as 'GET_MODE_SIZE' except in the case of complex
1 modes. For them, the unit size is the size of the real or
1 imaginary part.
1
1 'GET_MODE_NUNITS (M)'
1 Returns the number of units contained in a mode, i.e.,
1 'GET_MODE_SIZE' divided by 'GET_MODE_UNIT_SIZE'.
1
1 'GET_CLASS_NARROWEST_MODE (C)'
1 Returns the narrowest mode in mode class C.
1
1 The following 3 variables are defined on every target. They can be
1 used to allocate buffers that are guaranteed to be large enough to hold
1 any value that can be represented on the target. The first two can be
1 overridden by defining them in the target's mode.def file, however, the
1 value must be a constant that can determined very early in the
1 compilation process. The third symbol cannot be overridden.
1
1 'BITS_PER_UNIT'
1 The number of bits in an addressable storage unit (byte). If you
1 do not define this, the default is 8.
1
1 'MAX_BITSIZE_MODE_ANY_INT'
1 The maximum bitsize of any mode that is used in integer math. This
1 should be overridden by the target if it uses large integers as
1 containers for larger vectors but otherwise never uses the contents
1 to compute integer values.
1
1 'MAX_BITSIZE_MODE_ANY_MODE'
1 The bitsize of the largest mode on the target. The default value
1 is the largest mode size given in the mode definition file, which
1 is always correct for targets whose modes have a fixed size.
1 Targets that might increase the size of a mode beyond this default
1 should define 'MAX_BITSIZE_MODE_ANY_MODE' to the actual upper limit
1 in 'MACHINE-modes.def'.
1
1 The global variables 'byte_mode' and 'word_mode' contain modes whose
1 classes are 'MODE_INT' and whose bitsizes are either 'BITS_PER_UNIT' or
1 'BITS_PER_WORD', respectively. On 32-bit machines, these are 'QImode'
1 and 'SImode', respectively.
1