• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -mattr=avr6,sram < %s -march=avr | FileCheck %s
2
3define void @store8(i8* %x, i8 %y) {
4; CHECK-LABEL: store8:
5; CHECK: st {{[XYZ]}}, r22
6  store i8 %y, i8* %x
7  ret void
8}
9
10define void @store16(i16* %x, i16 %y) {
11; CHECK-LABEL: store16:
12; CHECK: st {{[YZ]}}, r22
13; CHECK: std {{[YZ]}}+1, r23
14  store i16 %y, i16* %x
15  ret void
16}
17
18define void @store8disp(i8* %x, i8 %y) {
19; CHECK-LABEL: store8disp:
20; CHECK: std {{[YZ]}}+63, r22
21  %arrayidx = getelementptr inbounds i8, i8* %x, i16 63
22  store i8 %y, i8* %arrayidx
23  ret void
24}
25
26define void @store8nodisp(i8* %x, i8 %y) {
27; CHECK-LABEL: store8nodisp:
28; CHECK: movw r26, r24
29; CHECK: subi r26, 192
30; CHECK: sbci r27, 255
31; CHECK: st {{[XYZ]}}, r22
32  %arrayidx = getelementptr inbounds i8, i8* %x, i16 64
33  store i8 %y, i8* %arrayidx
34  ret void
35}
36
37define void @store16disp(i16* %x, i16 %y) {
38; CHECK-LABEL: store16disp:
39; CHECK: std {{[YZ]}}+62, r22
40; CHECK: std {{[YZ]}}+63, r23
41  %arrayidx = getelementptr inbounds i16, i16* %x, i16 31
42  store i16 %y, i16* %arrayidx
43  ret void
44}
45
46define void @store16nodisp(i16* %x, i16 %y) {
47; CHECK-LABEL: store16nodisp:
48; CHECK: subi r24, 192
49; CHECK: sbci r25, 255
50; CHECK: movw r30, r24
51; CHECK: st {{[YZ]}}, r22
52; CHECK: std {{[YZ]}}+1, r23
53  %arrayidx = getelementptr inbounds i16, i16* %x, i16 32
54  store i16 %y, i16* %arrayidx
55  ret void
56}
57
58define void @store8postinc(i8* %x, i8 %y) {
59; CHECK-LABEL: store8postinc:
60; CHECK: st {{[XYZ]}}+, {{.*}}
61entry:
62  %tobool3 = icmp eq i8 %y, 0
63  br i1 %tobool3, label %while.end, label %while.body
64while.body:                                       ; preds = %entry, %while.body
65  %dec5.in = phi i8 [ %dec5, %while.body ], [ %y, %entry ]
66  %x.addr.04 = phi i8* [ %incdec.ptr, %while.body ], [ %x, %entry ]
67  %dec5 = add i8 %dec5.in, -1
68  %incdec.ptr = getelementptr inbounds i8, i8* %x.addr.04, i16 1
69  store i8 %dec5, i8* %x.addr.04
70  %tobool = icmp eq i8 %dec5, 0
71  br i1 %tobool, label %while.end, label %while.body
72while.end:                                        ; preds = %while.body, %entry
73  ret void
74}
75
76define void @store16postinc(i16* %x, i16 %y) {
77; CHECK-LABEL: store16postinc:
78; CHECK: st {{[XYZ]}}+, {{.*}}
79; CHECK: st {{[XYZ]}}+, {{.*}}
80entry:
81  %tobool3 = icmp eq i16 %y, 0
82  br i1 %tobool3, label %while.end, label %while.body
83while.body:                                       ; preds = %entry, %while.body
84  %dec5.in = phi i16 [ %dec5, %while.body ], [ %y, %entry ]
85  %x.addr.04 = phi i16* [ %incdec.ptr, %while.body ], [ %x, %entry ]
86  %dec5 = add nsw i16 %dec5.in, -1
87  %incdec.ptr = getelementptr inbounds i16, i16* %x.addr.04, i16 1
88  store i16 %dec5, i16* %x.addr.04
89  %tobool = icmp eq i16 %dec5, 0
90  br i1 %tobool, label %while.end, label %while.body
91while.end:                                        ; preds = %while.body, %entry
92  ret void
93}
94
95define void @store8predec(i8* %x, i8 %y) {
96; CHECK-LABEL: store8predec:
97; CHECK: st -{{[XYZ]}}, {{.*}}
98entry:
99  %tobool3 = icmp eq i8 %y, 0
100  br i1 %tobool3, label %while.end, label %while.body
101while.body:                                       ; preds = %entry, %while.body
102  %dec5.in = phi i8 [ %dec5, %while.body ], [ %y, %entry ]
103  %x.addr.04 = phi i8* [ %incdec.ptr, %while.body ], [ %x, %entry ]
104  %dec5 = add i8 %dec5.in, -1
105  %incdec.ptr = getelementptr inbounds i8, i8* %x.addr.04, i16 -1
106  store i8 %dec5, i8* %incdec.ptr
107  %tobool = icmp eq i8 %dec5, 0
108  br i1 %tobool, label %while.end, label %while.body
109while.end:                                        ; preds = %while.body, %entry
110  ret void
111}
112
113define void @store16predec(i16* %x, i16 %y) {
114; CHECK-LABEL: store16predec:
115; CHECK: st -{{[XYZ]}}, {{.*}}
116; CHECK: st -{{[XYZ]}}, {{.*}}
117entry:
118  %tobool3 = icmp eq i16 %y, 0
119  br i1 %tobool3, label %while.end, label %while.body
120while.body:                                       ; preds = %entry, %while.body
121  %dec5.in = phi i16 [ %dec5, %while.body ], [ %y, %entry ]
122  %x.addr.04 = phi i16* [ %incdec.ptr, %while.body ], [ %x, %entry ]
123  %dec5 = add nsw i16 %dec5.in, -1
124  %incdec.ptr = getelementptr inbounds i16, i16* %x.addr.04, i16 -1
125  store i16 %dec5, i16* %incdec.ptr
126  %tobool = icmp eq i16 %dec5, 0
127  br i1 %tobool, label %while.end, label %while.body
128while.end:                                        ; preds = %while.body, %entry
129  ret void
130}
131