blob: 4b3c8fb7931529288ca64b8460dea442994751cd [file] [log] [blame]
Daniel Sanders8008de52015-10-15 14:34:23 +00001; RUN: llc -march=mipsel -mattr=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16_h
2; RUN: llc -march=mipsel -mattr=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16_b
Reed Kotler3589dd72012-10-28 06:02:37 +00003
4@.str = private unnamed_addr constant [9 x i8] c"%hd %c \0A\00", align 1
5@sp = common global i16* null, align 4
6@cp = common global i8* null, align 4
7
8define void @p1(i16 signext %s, i8 signext %c) nounwind {
9entry:
10 %conv = sext i16 %s to i32
11 %conv1 = sext i8 %c to i32
David Blaikie23af6482015-04-16 23:24:18 +000012 %call = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i32 %conv, i32 %conv1) nounwind
Reed Kotler3589dd72012-10-28 06:02:37 +000013 ret void
14}
15
16declare i32 @printf(i8* nocapture, ...) nounwind
17
18define void @p2() nounwind {
19entry:
David Blaikiea79ac142015-02-27 21:17:42 +000020 %0 = load i16*, i16** @sp, align 4
21 %1 = load i16, i16* %0, align 2
22 %2 = load i8*, i8** @cp, align 4
23 %3 = load i8, i8* %2, align 1
Reed Kotler3589dd72012-10-28 06:02:37 +000024 %conv.i = sext i16 %1 to i32
25 %conv1.i = sext i8 %3 to i32
David Blaikie23af6482015-04-16 23:24:18 +000026 %call.i = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i32 %conv.i, i32 %conv1.i) nounwind
David Blaikiea79ac142015-02-27 21:17:42 +000027 %4 = load i16*, i16** @sp, align 4
Reed Kotler3589dd72012-10-28 06:02:37 +000028 store i16 32, i16* %4, align 2
David Blaikiea79ac142015-02-27 21:17:42 +000029 %5 = load i8*, i8** @cp, align 4
Reed Kotler3589dd72012-10-28 06:02:37 +000030 store i8 97, i8* %5, align 1
31 ret void
32}
33
34define void @test() nounwind {
35entry:
36 %s = alloca i16, align 4
37 %c = alloca i8, align 4
38 store i16 16, i16* %s, align 4
39 store i8 99, i8* %c, align 4
40 store i16* %s, i16** @sp, align 4
41 store i8* %c, i8** @cp, align 4
David Blaikie23af6482015-04-16 23:24:18 +000042 %call.i.i = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i32 16, i32 99) nounwind
David Blaikiea79ac142015-02-27 21:17:42 +000043 %0 = load i16*, i16** @sp, align 4
Reed Kotler3589dd72012-10-28 06:02:37 +000044 store i16 32, i16* %0, align 2
David Blaikiea79ac142015-02-27 21:17:42 +000045 %1 = load i8*, i8** @cp, align 4
Reed Kotler3589dd72012-10-28 06:02:37 +000046 store i8 97, i8* %1, align 1
David Blaikiea79ac142015-02-27 21:17:42 +000047 %2 = load i16, i16* %s, align 4
48 %3 = load i8, i8* %c, align 4
Reed Kotler3589dd72012-10-28 06:02:37 +000049 %conv.i = sext i16 %2 to i32
50 %conv1.i = sext i8 %3 to i32
David Blaikie23af6482015-04-16 23:24:18 +000051 %call.i = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i32 %conv.i, i32 %conv1.i) nounwind
Reed Kotler3589dd72012-10-28 06:02:37 +000052 ret void
Stephen Lind24ab202013-07-14 06:24:09 +000053; 16_b-LABEL: test:
54; 16_h-LABEL: test:
Reed Kotler3589dd72012-10-28 06:02:37 +000055; 16_b: sb ${{[0-9]+}}, [[offset1:[0-9]+]](${{[0-9]+}})
56; 16_b: lb ${{[0-9]+}}, [[offset1]](${{[0-9]+}})
57; 16_h: sh ${{[0-9]+}}, [[offset2:[0-9]+]](${{[0-9]+}})
58; 16_h: lh ${{[0-9]+}}, [[offset2]](${{[0-9]+}})
59}
60
61define i32 @main() nounwind {
62entry:
63 %s.i = alloca i16, align 4
64 %c.i = alloca i8, align 4
65 %0 = bitcast i16* %s.i to i8*
66 call void @llvm.lifetime.start(i64 -1, i8* %0) nounwind
67 call void @llvm.lifetime.start(i64 -1, i8* %c.i) nounwind
68 store i16 16, i16* %s.i, align 4
69 store i8 99, i8* %c.i, align 4
70 store i16* %s.i, i16** @sp, align 4
71 store i8* %c.i, i8** @cp, align 4
David Blaikie23af6482015-04-16 23:24:18 +000072 %call.i.i.i = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i32 16, i32 99) nounwind
David Blaikiea79ac142015-02-27 21:17:42 +000073 %1 = load i16*, i16** @sp, align 4
Reed Kotler3589dd72012-10-28 06:02:37 +000074 store i16 32, i16* %1, align 2
David Blaikiea79ac142015-02-27 21:17:42 +000075 %2 = load i8*, i8** @cp, align 4
Reed Kotler3589dd72012-10-28 06:02:37 +000076 store i8 97, i8* %2, align 1
David Blaikiea79ac142015-02-27 21:17:42 +000077 %3 = load i16, i16* %s.i, align 4
78 %4 = load i8, i8* %c.i, align 4
Reed Kotler3589dd72012-10-28 06:02:37 +000079 %conv.i.i = sext i16 %3 to i32
80 %conv1.i.i = sext i8 %4 to i32
David Blaikie23af6482015-04-16 23:24:18 +000081 %call.i.i = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i32 %conv.i.i, i32 %conv1.i.i) nounwind
Reed Kotler3589dd72012-10-28 06:02:37 +000082 call void @llvm.lifetime.end(i64 -1, i8* %0) nounwind
83 call void @llvm.lifetime.end(i64 -1, i8* %c.i) nounwind
84 ret i32 0
85}
86
87declare void @llvm.lifetime.start(i64, i8* nocapture) nounwind
88
89declare void @llvm.lifetime.end(i64, i8* nocapture) nounwind
90