r352177 - [MSP430] Ajust f32/f64 alignment according to MSP430 EABI

Anton Korobeynikov via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 25 00:51:53 PST 2019


Author: asl
Date: Fri Jan 25 00:51:53 2019
New Revision: 352177

URL: http://llvm.org/viewvc/llvm-project?rev=352177&view=rev
Log:
[MSP430] Ajust f32/f64 alignment according to MSP430 EABI

Patch by Kristina Bessonova!

Differential Revision: https://reviews.llvm.org/D57015

Added:
    cfe/trunk/test/CodeGen/msp430-align.c
Modified:
    cfe/trunk/lib/Basic/Targets/MSP430.h
    cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets/MSP430.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/MSP430.h?rev=352177&r1=352176&r2=352177&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/MSP430.h (original)
+++ cfe/trunk/lib/Basic/Targets/MSP430.h Fri Jan 25 00:51:53 2019
@@ -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";
   }

Added: cfe/trunk/test/CodeGen/msp430-align.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/msp430-align.c?rev=352177&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/msp430-align.c (added)
+++ cfe/trunk/test/CodeGen/msp430-align.c Fri Jan 25 00:51:53 2019
@@ -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;

Modified: cfe/trunk/test/Preprocessor/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=352177&r1=352176&r2=352177&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Fri Jan 25 00:51:53 2019
@@ -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




More information about the cfe-commits mailing list