From: Anton Korobeynikov Date: Fri, 25 Jan 2019 08:51:53 +0000 (+0000) Subject: [MSP430] Ajust f32/f64 alignment according to MSP430 EABI X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eba0c57f16ada7fd52d840bd51e0be3a7e19f8a5;p=clang [MSP430] Ajust f32/f64 alignment according to MSP430 EABI Patch by Kristina Bessonova! Differential Revision: https://reviews.llvm.org/D57015 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@352177 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Targets/MSP430.h b/lib/Basic/Targets/MSP430.h index 185a537638..620f12d2b8 100644 --- a/lib/Basic/Targets/MSP430.h +++ b/lib/Basic/Targets/MSP430.h @@ -33,6 +33,10 @@ public: LongWidth = 32; LongLongWidth = 64; LongAlign = LongLongAlign = 16; + FloatWidth = 32; + FloatAlign = 16; + DoubleWidth = LongDoubleWidth = 64; + DoubleAlign = LongDoubleAlign = 16; PointerWidth = 16; PointerAlign = 16; SuitableAlign = 16; @@ -51,6 +55,8 @@ public: return None; } + bool allowsLargerPreferedTypeAlignment() const override { return false; } + bool hasFeature(StringRef Feature) const override { return Feature == "msp430"; } diff --git a/test/CodeGen/msp430-align.c b/test/CodeGen/msp430-align.c new file mode 100644 index 0000000000..72de87b3bb --- /dev/null +++ b/test/CodeGen/msp430-align.c @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -triple msp430-elf -emit-llvm %s -o - | FileCheck %s + +// MSP430 target prefers chars to be aligned to 8 bit and other types to 16 bit. + +// CHECK: @c ={{.*}}global i8 1, align 1 +// CHECK: @s ={{.*}}global i16 266, align 2 +// CHECK: @i ={{.*}}global i16 266, align 2 +// CHECK: @l ={{.*}}global i32 16909060, align 2 +// CHECK: @ll ={{.*}}global i64 283686952306183, align 2 +// CHECK: @f ={{.*}}global float 1.000000e+00, align 2 +// CHECK: @d ={{.*}}global double 1.000000e+00, align 2 +// CHECK: @ld ={{.*}}global double 1.000000e+00, align 2 +// CHECK: @p ={{.*}}global i8* @c, align 2 + +char c = 1; +short s = 266; +int i = 266; +long l = 16909060; +long long ll = 283686952306183; +float f = 1.0f; +double d = 1.0; +long double ld = 1.0; +char *p = &c; diff --git a/test/Preprocessor/init.c b/test/Preprocessor/init.c index fc8692b522..366dc96aa5 100644 --- a/test/Preprocessor/init.c +++ b/test/Preprocessor/init.c @@ -5158,7 +5158,7 @@ // MSP430:#define __SIZE_MAX__ 65535U // MSP430:#define __SIZE_TYPE__ unsigned int // MSP430:#define __SIZE_WIDTH__ 16 -// MSP430-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U +// MSP430-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 2U // MSP430:#define __UINT16_C_SUFFIX__ U // MSP430:#define __UINT16_MAX__ 65535U // MSP430:#define __UINT16_TYPE__ unsigned short