[PATCH] D57015: [MSP430] Ajust f32/f64 alignment according to MSP430 EABI

Anton Korobeynikov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 25 00:52:08 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rC352177: [MSP430] Ajust f32/f64 alignment according to MSP430 EABI (authored by asl, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57015?vs=182784&id=183492#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57015/new/

https://reviews.llvm.org/D57015

Files:
  lib/Basic/Targets/MSP430.h
  test/CodeGen/msp430-align.c
  test/Preprocessor/init.c


Index: test/CodeGen/msp430-align.c
===================================================================
--- test/CodeGen/msp430-align.c
+++ 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;
Index: test/Preprocessor/init.c
===================================================================
--- test/Preprocessor/init.c
+++ 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
Index: lib/Basic/Targets/MSP430.h
===================================================================
--- lib/Basic/Targets/MSP430.h
+++ lib/Basic/Targets/MSP430.h
@@ -33,6 +33,10 @@
     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 @@
     return None;
   }
 
+  bool allowsLargerPreferedTypeAlignment() const override { return false; }
+
   bool hasFeature(StringRef Feature) const override {
     return Feature == "msp430";
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57015.183492.patch
Type: text/x-patch
Size: 2200 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190125/799ddbee/attachment.bin>


More information about the cfe-commits mailing list