diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2015-05-18 11:02:12 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-05-27 12:49:45 -0700 |
commit | 9720a2dc65303f54ff5ee8c04248eab4617a0afd (patch) | |
tree | ee32232ad8bb19c7d93a464d44c8a72d2d4470f9 | |
parent | ba8a6006daa105176baf87c0cb643867a79890b9 (diff) | |
download | gcc-9720a2dc65303f54ff5ee8c04248eab4617a0afd.tar.gz |
Align scalar types > 4 bytes to 4 bytes
Intel MCU psABI specifies scalar types > 4 bytes should be aligned to 4
bytes.
* config/i386/i386.c (iamcu_alignment): New function.
(ix86_data_alignment): Call iamcu_alignment if TARGET_IAMCU is
true.
(x86_field_alignment): Return iamcu_alignment if TARGET_IAMCU is
true.
-rw-r--r-- | gcc/config/i386/i386.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 394832966cd..9d712dd4b0a 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -26600,6 +26600,34 @@ ix86_constant_alignment (tree exp, int align) return align; } +/* Compute the alignment for a variable for Intel MCU psABI. TYPE is + the data type, and ALIGN is the alignment that the object would + ordinarily have. */ + +static int +iamcu_alignment (tree type, int align) +{ + enum machine_mode mode; + + if (align < 32 || TYPE_USER_ALIGN (type)) + return align; + + /* Intel MCU psABI specifies scalar types > 4 bytes aligned to 4 + bytes. */ + mode = TYPE_MODE (strip_array_types (type)); + switch (GET_MODE_CLASS (mode)) + { + case MODE_INT: + case MODE_COMPLEX_INT: + case MODE_COMPLEX_FLOAT: + case MODE_FLOAT: + case MODE_DECIMAL_FLOAT: + return 32; + default: + return align; + } +} + /* Compute the alignment for a static variable. TYPE is the data type, and ALIGN is the alignment that the object would ordinarily have. The value of this function is used @@ -26628,6 +26656,9 @@ ix86_data_alignment (tree type, int align, bool opt) if (max_align < BITS_PER_WORD) max_align = BITS_PER_WORD; + if (TARGET_IAMCU) + align = iamcu_alignment (type, align); + if (opt && AGGREGATE_TYPE_P (type) && TYPE_SIZE (type) @@ -38913,6 +38944,8 @@ x86_field_alignment (tree field, int computed) if (TARGET_64BIT || TARGET_ALIGN_DOUBLE) return computed; + if (TARGET_IAMCU) + return iamcu_alignment (type, computed); mode = TYPE_MODE (strip_array_types (type)); if (mode == DFmode || mode == DCmode || GET_MODE_CLASS (mode) == MODE_INT |