llvm.org GIT mirror llvm / 66f026b
[MSP430] Fix data layout string. Summary: Without this patch some types have incorrect size and/or alignment according to the MSP430 EABI. Reviewers: asl, awygle Reviewed By: asl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D34561 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306159 91177308-0d34-0410-b5e6-96231b3b80d8 Vadzim Dambrouski 3 years ago
3 changed file(s) with 64 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
3131 return *RM;
3232 }
3333
34 static std::string computeDataLayout(const Triple &TT, StringRef CPU,
35 const TargetOptions &Options) {
36 return "e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16";
37 }
38
3439 MSP430TargetMachine::MSP430TargetMachine(const Target &T, const Triple &TT,
3540 StringRef CPU, StringRef FS,
3641 const TargetOptions &Options,
3742 Optional RM,
3843 CodeModel::Model CM,
3944 CodeGenOpt::Level OL)
40 : LLVMTargetMachine(T, "e-m:e-p:16:16-i32:16:32-a:16-n8:16", TT, CPU, FS,
45 : LLVMTargetMachine(T, computeDataLayout(TT, CPU, Options), TT, CPU, FS,
4146 Options, getEffectiveRelocModel(RM), CM, OL),
4247 TLOF(make_unique()),
43 // FIXME: Check DataLayout string.
4448 Subtarget(TT, CPU, FS, *this) {
4549 initAsmInfo();
4650 }
6363 %0 = load i16, i16* %retval ; [#uses=1]
6464 ret i16 %0
6565 ; CHECK-LABEL: mov2:
66 ; CHECK: mov.w 0(r1), 4(r1)
6667 ; CHECK: mov.w 2(r1), 6(r1)
67 ; CHECK: mov.w 0(r1), 4(r1)
6868 }
0 ; RUN: llc < %s | FileCheck %s
1
2 target triple = "msp430"
3
4 %struct.X = type { i8 }
5
6 ; CHECK-LABEL: @foo
7 ; CHECK: sub.w #4, r1
8 ; CHECK: mov.b #1, 3(r1)
9 define void @foo() {
10 %1 = alloca %struct.X
11 %2 = alloca %struct.X
12 %3 = alloca %struct.X
13 %4 = getelementptr inbounds %struct.X, %struct.X* %1, i32 0, i32 0
14 store i8 1, i8* %4
15 %5 = getelementptr inbounds %struct.X, %struct.X* %2, i32 0, i32 0
16 store i8 1, i8* %5
17 %6 = getelementptr inbounds %struct.X, %struct.X* %3, i32 0, i32 0
18 store i8 1, i8* %6
19 ret void
20 }
21
22 ; CHECK-LABEL: @bar
23 ; CHECK: sub.w #4, r1
24 ; CHECK: mov.b #1, 3(r1)
25 define void @bar() {
26 %1 = alloca [3 x %struct.X]
27 %2 = getelementptr inbounds [3 x %struct.X], [3 x %struct.X]* %1, i16 0, i16 0
28 %3 = getelementptr inbounds %struct.X, %struct.X* %2, i32 0, i32 0
29 store i8 1, i8* %3
30 %4 = getelementptr inbounds [3 x %struct.X], [3 x %struct.X]* %1, i16 0, i16 1
31 %5 = getelementptr inbounds %struct.X, %struct.X* %4, i32 0, i32 0
32 store i8 1, i8* %5
33 %6 = getelementptr inbounds [3 x %struct.X], [3 x %struct.X]* %1, i16 0, i16 2
34 %7 = getelementptr inbounds %struct.X, %struct.X* %6, i32 0, i32 0
35 store i8 1, i8* %7
36 ret void
37 }
38
39 %struct.Y = type { i8, i16 }
40
41 ; CHECK-LABEL: @baz
42 ; CHECK: sub.w #8, r1
43 ; CHECK: mov.w #2, 6(r1)
44 define void @baz() {
45 %1 = alloca %struct.Y, align 2
46 %2 = alloca %struct.Y, align 2
47 %3 = getelementptr inbounds %struct.Y, %struct.Y* %1, i32 0, i32 0
48 store i8 1, i8* %3, align 2
49 %4 = getelementptr inbounds %struct.Y, %struct.Y* %1, i32 0, i32 1
50 store i16 2, i16* %4, align 2
51 %5 = getelementptr inbounds %struct.Y, %struct.Y* %2, i32 0, i32 0
52 store i8 1, i8* %5, align 2
53 %6 = getelementptr inbounds %struct.Y, %struct.Y* %2, i32 0, i32 1
54 store i16 2, i16* %6, align 2
55 ret void
56 }