Copyright (C) 2000-2012 |
GNU Info (gcc-300.info)Storage LayoutStorage Layout ============== Note that the definitions of the macros in this table which are sizes or alignments measured in bits do not need to be constant. They can be C expressions that refer to static variables, such as the `target_flags'. Note: Run-time Target. `BITS_BIG_ENDIAN' Define this macro to have the value 1 if the most significant bit in a byte has the lowest number; otherwise define it to have the value zero. This means that bit-field instructions count from the most significant bit. If the machine has no bit-field instructions, then this must still be defined, but it doesn't matter which value it is defined to. This macro need not be a constant. This macro does not affect the way structure fields are packed into bytes or words; that is controlled by `BYTES_BIG_ENDIAN'. `BYTES_BIG_ENDIAN' Define this macro to have the value 1 if the most significant byte in a word has the lowest number. This macro need not be a constant. `WORDS_BIG_ENDIAN' Define this macro to have the value 1 if, in a multiword object, the most significant word has the lowest number. This applies to both memory locations and registers; GCC fundamentally assumes that the order of words in memory is the same as the order in registers. This macro need not be a constant. `LIBGCC2_WORDS_BIG_ENDIAN' Define this macro if `WORDS_BIG_ENDIAN' is not constant. This must be a constant value with the same meaning as `WORDS_BIG_ENDIAN', which will be used only when compiling `libgcc2.c'. Typically the value will be set based on preprocessor defines. `FLOAT_WORDS_BIG_ENDIAN' Define this macro to have the value 1 if `DFmode', `XFmode' or `TFmode' floating point numbers are stored in memory with the word containing the sign bit at the lowest address; otherwise define it to have the value 0. This macro need not be a constant. You need not define this macro if the ordering is the same as for multi-word integers. `BITS_PER_UNIT' Define this macro to be the number of bits in an addressable storage unit (byte); normally 8. `BITS_PER_WORD' Number of bits in a word; normally 32. `MAX_BITS_PER_WORD' Maximum number of bits in a word. If this is undefined, the default is `BITS_PER_WORD'. Otherwise, it is the constant value that is the largest value that `BITS_PER_WORD' can have at run-time. `UNITS_PER_WORD' Number of storage units in a word; normally 4. `MIN_UNITS_PER_WORD' Minimum number of units in a word. If this is undefined, the default is `UNITS_PER_WORD'. Otherwise, it is the constant value that is the smallest value that `UNITS_PER_WORD' can have at run-time. `POINTER_SIZE' Width of a pointer, in bits. You must specify a value no wider than the width of `Pmode'. If it is not equal to the width of `Pmode', you must define `POINTERS_EXTEND_UNSIGNED'. `POINTERS_EXTEND_UNSIGNED' A C expression whose value is nonzero if pointers that need to be extended from being `POINTER_SIZE' bits wide to `Pmode' are to be zero-extended and zero if they are to be sign-extended. You need not define this macro if the `POINTER_SIZE' is equal to the width of `Pmode'. `PROMOTE_MODE (M, UNSIGNEDP, TYPE)' A macro to update M and UNSIGNEDP when an object whose type is TYPE and which has the specified mode and signedness is to be stored in a register. This macro is only called when TYPE is a scalar type. On most RISC machines, which only have operations that operate on a full register, define this macro to set M to `word_mode' if M is an integer mode narrower than `BITS_PER_WORD'. In most cases, only integer modes should be widened because wider-precision floating-point operations are usually more expensive than their narrower counterparts. For most machines, the macro definition does not change UNSIGNEDP. However, some machines, have instructions that preferentially handle either signed or unsigned quantities of certain modes. For example, on the DEC Alpha, 32-bit loads from memory and 32-bit add instructions sign-extend the result to 64 bits. On such machines, set UNSIGNEDP according to which kind of extension is more efficient. Do not define this macro if it would never modify M. `PROMOTE_FUNCTION_ARGS' Define this macro if the promotion described by `PROMOTE_MODE' should also be done for outgoing function arguments. `PROMOTE_FUNCTION_RETURN' Define this macro if the promotion described by `PROMOTE_MODE' should also be done for the return value of functions. If this macro is defined, `FUNCTION_VALUE' must perform the same promotions done by `PROMOTE_MODE'. `PROMOTE_FOR_CALL_ONLY' Define this macro if the promotion described by `PROMOTE_MODE' should _only_ be performed for outgoing function arguments or function return values, as specified by `PROMOTE_FUNCTION_ARGS' and `PROMOTE_FUNCTION_RETURN', respectively. `PARM_BOUNDARY' Normal alignment required for function parameters on the stack, in bits. All stack parameters receive at least this much alignment regardless of data type. On most machines, this is the same as the size of an integer. `STACK_BOUNDARY' Define this macro if there is a guaranteed alignment for the stack pointer on this machine. The definition is a C expression for the desired alignment (measured in bits). This value is used as a default if `PREFERRED_STACK_BOUNDARY' is not defined. `PREFERRED_STACK_BOUNDARY' Define this macro if you wish to preserve a certain alignment for the stack pointer. The definition is a C expression for the desired alignment (measured in bits). If `STACK_BOUNDARY' is also defined, this macro must evaluate to a value equal to or larger than `STACK_BOUNDARY'. `FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN' A C expression that evaluates true if `PREFERRED_STACK_BOUNDARY' is not guaranteed by the runtime and we should emit code to align the stack at the beginning of `main'. If `PUSH_ROUNDING' is not defined, the stack will always be aligned to the specified boundary. If `PUSH_ROUNDING' is defined and specifies a less strict alignment than `PREFERRED_STACK_BOUNDARY', the stack may be momentarily unaligned while pushing arguments. `FUNCTION_BOUNDARY' Alignment required for a function entry point, in bits. `BIGGEST_ALIGNMENT' Biggest alignment that any data type can require on this machine, in bits. `MINIMUM_ATOMIC_ALIGNMENT' If defined, the smallest alignment, in bits, that can be given to an object that can be referenced in one operation, without disturbing any nearby object. Normally, this is `BITS_PER_UNIT', but may be larger on machines that don't have byte or half-word store operations. `BIGGEST_FIELD_ALIGNMENT' Biggest alignment that any structure or union field can require on this machine, in bits. If defined, this overrides `BIGGEST_ALIGNMENT' for structure and union fields only, unless the field alignment has been set by the `__attribute__ ((aligned (N)))' construct. `ADJUST_FIELD_ALIGN (FIELD, COMPUTED)' An expression for the alignment of a structure field FIELD if the alignment computed in the usual way is COMPUTED. GCC uses this value instead of the value in `BIGGEST_ALIGNMENT' or `BIGGEST_FIELD_ALIGNMENT', if defined, for structure fields only. `MAX_OFILE_ALIGNMENT' Biggest alignment supported by the object file format of this machine. Use this macro to limit the alignment which can be specified using the `__attribute__ ((aligned (N)))' construct. If not defined, the default value is `BIGGEST_ALIGNMENT'. `DATA_ALIGNMENT (TYPE, BASIC-ALIGN)' If defined, a C expression to compute the alignment for a variable in the static store. TYPE is the data type, and BASIC-ALIGN is the alignment that the object would ordinarily have. The value of this macro is used instead of that alignment to align the object. If this macro is not defined, then BASIC-ALIGN is used. One use of this macro is to increase alignment of medium-size data to make it all fit in fewer cache lines. Another is to cause character arrays to be word-aligned so that `strcpy' calls that copy constants to character arrays can be done inline. `CONSTANT_ALIGNMENT (CONSTANT, BASIC-ALIGN)' If defined, a C expression to compute the alignment given to a constant that is being placed in memory. CONSTANT is the constant and BASIC-ALIGN is the alignment that the object would ordinarily have. The value of this macro is used instead of that alignment to align the object. If this macro is not defined, then BASIC-ALIGN is used. The typical use of this macro is to increase alignment for string constants to be word aligned so that `strcpy' calls that copy constants can be done inline. `LOCAL_ALIGNMENT (TYPE, BASIC-ALIGN)' If defined, a C expression to compute the alignment for a variable in the local store. TYPE is the data type, and BASIC-ALIGN is the alignment that the object would ordinarily have. The value of this macro is used instead of that alignment to align the object. If this macro is not defined, then BASIC-ALIGN is used. One use of this macro is to increase alignment of medium-size data to make it all fit in fewer cache lines. `EMPTY_FIELD_BOUNDARY' Alignment in bits to be given to a structure bit-field that follows an empty field such as `int : 0;'. Note that `PCC_BITFIELD_TYPE_MATTERS' also affects the alignment that results from an empty field. `STRUCTURE_SIZE_BOUNDARY' Number of bits which any structure or union's size must be a multiple of. Each structure or union's size is rounded up to a multiple of this. If you do not define this macro, the default is the same as `BITS_PER_UNIT'. `STRICT_ALIGNMENT' Define this macro to be the value 1 if instructions will fail to work if given data not on the nominal alignment. If instructions will merely go slower in that case, define this macro as 0. `PCC_BITFIELD_TYPE_MATTERS' Define this if you wish to imitate the way many other C compilers handle alignment of bit-fields and the structures that contain them. The behavior is that the type written for a bit-field (`int', `short', or other integer type) imposes an alignment for the entire structure, as if the structure really did contain an ordinary field of that type. In addition, the bit-field is placed within the structure so that it would fit within such a field, not crossing a boundary for it. Thus, on most machines, a bit-field whose type is written as `int' would not cross a four-byte boundary, and would force four-byte alignment for the whole structure. (The alignment used may not be four bytes; it is controlled by the other alignment parameters.) If the macro is defined, its definition should be a C expression; a nonzero value for the expression enables this behavior. Note that if this macro is not defined, or its value is zero, some bit-fields may cross more than one alignment boundary. The compiler can support such references if there are `insv', `extv', and `extzv' insns that can directly reference memory. The other known way of making bit-fields work is to define `STRUCTURE_SIZE_BOUNDARY' as large as `BIGGEST_ALIGNMENT'. Then every structure can be accessed with fullwords. Unless the machine has bit-field instructions or you define `STRUCTURE_SIZE_BOUNDARY' that way, you must define `PCC_BITFIELD_TYPE_MATTERS' to have a nonzero value. If your aim is to make GCC use the same conventions for laying out bit-fields as are used by another compiler, here is how to investigate what the other compiler does. Compile and run this program: struct foo1 { char x; char :0; char y; }; struct foo2 { char x; int :0; char y; }; main () { printf ("Size of foo1 is %d\n", sizeof (struct foo1)); printf ("Size of foo2 is %d\n", sizeof (struct foo2)); exit (0); } If this prints 2 and 5, then the compiler's behavior is what you would get from `PCC_BITFIELD_TYPE_MATTERS'. `BITFIELD_NBYTES_LIMITED' Like PCC_BITFIELD_TYPE_MATTERS except that its effect is limited to aligning a bit-field within the structure. `STRUCT_FORCE_BLK (FIELD)' Return 1 if a structure containing FIELD should be accessed using `BLKMODE'. Normally, this is not needed. See the file `c4x.h' for an example of how to use this macro to prevent a structure having a floating point field from being accessed in an integer mode. `ROUND_TYPE_SIZE (TYPE, COMPUTED, SPECIFIED)' Define this macro as an expression for the overall size of a type (given by TYPE as a tree node) when the size computed in the usual way is COMPUTED and the alignment is SPECIFIED. The default is to round COMPUTED up to a multiple of SPECIFIED. `ROUND_TYPE_SIZE_UNIT (TYPE, COMPUTED, SPECIFIED)' Similar to `ROUND_TYPE_SIZE', but sizes and alignments are specified in units (bytes). If you define `ROUND_TYPE_SIZE', you must also define this macro and they must be defined consistently with each other. `ROUND_TYPE_ALIGN (TYPE, COMPUTED, SPECIFIED)' Define this macro as an expression for the alignment of a type (given by TYPE as a tree node) if the alignment computed in the usual way is COMPUTED and the alignment explicitly specified was SPECIFIED. The default is to use SPECIFIED if it is larger; otherwise, use the smaller of COMPUTED and `BIGGEST_ALIGNMENT' `MAX_FIXED_MODE_SIZE' An integer expression for the size in bits of the largest integer machine mode that should actually be used. All integer machine modes of this size or smaller can be used for structures and unions with the appropriate sizes. If this macro is undefined, `GET_MODE_BITSIZE (DImode)' is assumed. `VECTOR_MODE_SUPPORTED_P(MODE)' Define this macro to be nonzero if the port is prepared to handle insns involving vector mode MODE. At the very least, it must have move patterns for this mode. `STACK_SAVEAREA_MODE (SAVE_LEVEL)' If defined, an expression of type `enum machine_mode' that specifies the mode of the save area operand of a `save_stack_LEVEL' named pattern (Note: Standard Names). SAVE_LEVEL is one of `SAVE_BLOCK', `SAVE_FUNCTION', or `SAVE_NONLOCAL' and selects which of the three named patterns is having its mode specified. You need not define this macro if it always returns `Pmode'. You would most commonly define this macro if the `save_stack_LEVEL' patterns need to support both a 32- and a 64-bit mode. `STACK_SIZE_MODE' If defined, an expression of type `enum machine_mode' that specifies the mode of the size increment operand of an `allocate_stack' named pattern (Note: Standard Names). You need not define this macro if it always returns `word_mode'. You would most commonly define this macro if the `allocate_stack' pattern needs to support both a 32- and a 64-bit mode. `CHECK_FLOAT_VALUE (MODE, VALUE, OVERFLOW)' A C statement to validate the value VALUE (of type `double') for mode MODE. This means that you check whether VALUE fits within the possible range of values for mode MODE on this target machine. The mode MODE is always a mode of class `MODE_FLOAT'. OVERFLOW is nonzero if the value is already known to be out of range. If VALUE is not valid or if OVERFLOW is nonzero, you should set OVERFLOW to 1 and then assign some valid value to VALUE. Allowing an invalid value to go through the compiler can produce incorrect assembler code which may even cause Unix assemblers to crash. This macro need not be defined if there is no work for it to do. `TARGET_FLOAT_FORMAT' A code distinguishing the floating point format of the target machine. There are five defined values: `IEEE_FLOAT_FORMAT' This code indicates IEEE floating point. It is the default; there is no need to define this macro when the format is IEEE. `VAX_FLOAT_FORMAT' This code indicates the peculiar format used on the Vax. `IBM_FLOAT_FORMAT' This code indicates the format used on the IBM System/370. `C4X_FLOAT_FORMAT' This code indicates the format used on the TMS320C3x/C4x. `UNKNOWN_FLOAT_FORMAT' This code indicates any other format. The value of this macro is compared with `HOST_FLOAT_FORMAT' (Note: Config) to determine whether the target machine has the same format as the host machine. If any other formats are actually in use on supported machines, new codes should be defined for them. The ordering of the component words of floating point values stored in memory is controlled by `FLOAT_WORDS_BIG_ENDIAN' for the target machine and `HOST_FLOAT_WORDS_BIG_ENDIAN' for the host. `DEFAULT_VTABLE_THUNKS' GCC supports two ways of implementing C++ vtables: traditional or with so-called "thunks". The flag `-fvtable-thunk' chooses between them. Define this macro to be a C expression for the default value of that flag. If `DEFAULT_VTABLE_THUNKS' is 0, GCC uses the traditional implementation by default. The "thunk" implementation is more efficient (especially if you have provided an implementation of `ASM_OUTPUT_MI_THUNK', see Note: Function Entry), but is not binary compatible with code compiled using the traditional implementation. If you are writing a new port, define `DEFAULT_VTABLE_THUNKS' to 1. If you do not define this macro, the default for `-fvtable-thunk' is 0. |