• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt | FileCheck %s
2
3; Test that basic immediates assemble as expected.
4
5target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
6target triple = "wasm32-unknown-unknown"
7
8; CHECK-LABEL: zero_i32:
9; CHECK-NEXT: .result i32{{$}}
10; CHECK-NEXT: i32.const $push[[NUM:[0-9]+]]=, 0{{$}}
11; CHECK-NEXT: return $pop[[NUM]]{{$}}
12define i32 @zero_i32() {
13  ret i32 0
14}
15
16; CHECK-LABEL: one_i32:
17; CHECK-NEXT: .result i32{{$}}
18; CHECK-NEXT: i32.const $push[[NUM:[0-9]+]]=, 1{{$}}
19; CHECK-NEXT: return $pop[[NUM]]{{$}}
20define i32 @one_i32() {
21  ret i32 1
22}
23
24; CHECK-LABEL: max_i32:
25; CHECK-NEXT: .result i32{{$}}
26; CHECK-NEXT: i32.const $push[[NUM:[0-9]+]]=, 2147483647{{$}}
27; CHECK-NEXT: return $pop[[NUM]]{{$}}
28define i32 @max_i32() {
29  ret i32 2147483647
30}
31
32; CHECK-LABEL: min_i32:
33; CHECK-NEXT: .result i32{{$}}
34; CHECK-NEXT: i32.const $push[[NUM:[0-9]+]]=, -2147483648{{$}}
35; CHECK-NEXT: return $pop[[NUM]]{{$}}
36define i32 @min_i32() {
37  ret i32 -2147483648
38}
39
40; CHECK-LABEL: zero_i64:
41; CHECK-NEXT: .result i64{{$}}
42; CHECK-NEXT: i64.const $push[[NUM:[0-9]+]]=, 0{{$}}
43; CHECK-NEXT: return $pop[[NUM]]{{$}}
44define i64 @zero_i64() {
45  ret i64 0
46}
47
48; CHECK-LABEL: one_i64:
49; CHECK-NEXT: .result i64{{$}}
50; CHECK-NEXT: i64.const $push[[NUM:[0-9]+]]=, 1{{$}}
51; CHECK-NEXT: return $pop[[NUM]]{{$}}
52define i64 @one_i64() {
53  ret i64 1
54}
55
56; CHECK-LABEL: max_i64:
57; CHECK-NEXT: .result i64{{$}}
58; CHECK-NEXT: i64.const $push[[NUM:[0-9]+]]=, 9223372036854775807{{$}}
59; CHECK-NEXT: return $pop[[NUM]]{{$}}
60define i64 @max_i64() {
61  ret i64 9223372036854775807
62}
63
64; CHECK-LABEL: min_i64:
65; CHECK-NEXT: .result i64{{$}}
66; CHECK-NEXT: i64.const $push[[NUM:[0-9]+]]=, -9223372036854775808{{$}}
67; CHECK-NEXT: return $pop[[NUM]]{{$}}
68define i64 @min_i64() {
69  ret i64 -9223372036854775808
70}
71
72; CHECK-LABEL: negzero_f32:
73; CHECK-NEXT: .result f32{{$}}
74; CHECK-NEXT: f32.const $push[[NUM:[0-9]+]]=, -0x0p0{{$}}
75; CHECK-NEXT: return $pop[[NUM]]{{$}}
76define float @negzero_f32() {
77  ret float -0.0
78}
79
80; CHECK-LABEL: zero_f32:
81; CHECK-NEXT: .result f32{{$}}
82; CHECK-NEXT: f32.const $push[[NUM:[0-9]+]]=, 0x0p0{{$}}
83; CHECK-NEXT: return $pop[[NUM]]{{$}}
84define float @zero_f32() {
85  ret float 0.0
86}
87
88; CHECK-LABEL: one_f32:
89; CHECK-NEXT: .result f32{{$}}
90; CHECK-NEXT: f32.const $push[[NUM:[0-9]+]]=, 0x1p0{{$}}
91; CHECK-NEXT: return $pop[[NUM]]{{$}}
92define float @one_f32() {
93  ret float 1.0
94}
95
96; CHECK-LABEL: two_f32:
97; CHECK-NEXT: .result f32{{$}}
98; CHECK-NEXT: f32.const $push[[NUM:[0-9]+]]=, 0x1p1{{$}}
99; CHECK-NEXT: return $pop[[NUM]]{{$}}
100define float @two_f32() {
101  ret float 2.0
102}
103
104; CHECK-LABEL: nan_f32:
105; CHECK-NEXT: .result f32{{$}}
106; CHECK-NEXT: f32.const $push[[NUM:[0-9]+]]=, nan{{$}}
107; CHECK-NEXT: return $pop[[NUM]]{{$}}
108define float @nan_f32() {
109  ret float 0x7FF8000000000000
110}
111
112; CHECK-LABEL: negnan_f32:
113; CHECK-NEXT: .result f32{{$}}
114; CHECK-NEXT: f32.const $push[[NUM:[0-9]+]]=, -nan{{$}}
115; CHECK-NEXT: return $pop[[NUM]]{{$}}
116define float @negnan_f32() {
117  ret float 0xFFF8000000000000
118}
119
120; CHECK-LABEL: inf_f32:
121; CHECK-NEXT: .result f32{{$}}
122; CHECK-NEXT: f32.const $push[[NUM:[0-9]+]]=, infinity{{$}}
123; CHECK-NEXT: return $pop[[NUM]]{{$}}
124define float @inf_f32() {
125  ret float 0x7FF0000000000000
126}
127
128; CHECK-LABEL: neginf_f32:
129; CHECK-NEXT: .result f32{{$}}
130; CHECK-NEXT: f32.const $push[[NUM:[0-9]+]]=, -infinity{{$}}
131; CHECK-NEXT: return $pop[[NUM]]{{$}}
132define float @neginf_f32() {
133  ret float 0xFFF0000000000000
134}
135
136; CHECK-LABEL: custom_nan_f32:
137; CHECK-NEXT: .result f32{{$}}
138; CHECK-NEXT: f32.const $push[[NUM:[0-9]+]]=, -nan:0x6bcdef{{$}}
139; CHECK-NEXT: return $pop[[NUM]]{{$}}
140define float @custom_nan_f32() {
141  ret float 0xFFFD79BDE0000000
142}
143
144; TODO: LLVM's MC layer stores f32 operands as host doubles, requiring a
145; conversion, so the bits of the NaN are not fully preserved.
146
147; CHECK-LABEL: custom_nans_f32:
148; CHECK-NEXT: .result f32{{$}}
149; CHECK-NEXT: f32.const $push[[NUM:[0-9]+]]=, -nan:0x6bcdef{{$}}
150; CHECK-NEXT: return $pop[[NUM]]{{$}}
151define float @custom_nans_f32() {
152  ret float 0xFFF579BDE0000000
153}
154
155; CHECK-LABEL: negzero_f64:
156; CHECK-NEXT: .result f64{{$}}
157; CHECK-NEXT: f64.const $push[[NUM:[0-9]+]]=, -0x0p0{{$}}
158; CHECK-NEXT: return $pop[[NUM]]{{$}}
159define double @negzero_f64() {
160  ret double -0.0
161}
162
163; CHECK-LABEL: zero_f64:
164; CHECK-NEXT: .result f64{{$}}
165; CHECK-NEXT: f64.const $push[[NUM:[0-9]+]]=, 0x0p0{{$}}
166; CHECK-NEXT: return $pop[[NUM]]{{$}}
167define double @zero_f64() {
168  ret double 0.0
169}
170
171; CHECK-LABEL: one_f64:
172; CHECK-NEXT: .result f64{{$}}
173; CHECK-NEXT: f64.const $push[[NUM:[0-9]+]]=, 0x1p0{{$}}
174; CHECK-NEXT: return $pop[[NUM]]{{$}}
175define double @one_f64() {
176  ret double 1.0
177}
178
179; CHECK-LABEL: two_f64:
180; CHECK-NEXT: .result f64{{$}}
181; CHECK-NEXT: f64.const $push[[NUM:[0-9]+]]=, 0x1p1{{$}}
182; CHECK-NEXT: return $pop[[NUM]]{{$}}
183define double @two_f64() {
184  ret double 2.0
185}
186
187; CHECK-LABEL: nan_f64:
188; CHECK-NEXT: .result f64{{$}}
189; CHECK-NEXT: f64.const $push[[NUM:[0-9]+]]=, nan{{$}}
190; CHECK-NEXT: return $pop[[NUM]]{{$}}
191define double @nan_f64() {
192  ret double 0x7FF8000000000000
193}
194
195; CHECK-LABEL: negnan_f64:
196; CHECK-NEXT: .result f64{{$}}
197; CHECK-NEXT: f64.const $push[[NUM:[0-9]+]]=, -nan{{$}}
198; CHECK-NEXT: return $pop[[NUM]]{{$}}
199define double @negnan_f64() {
200  ret double 0xFFF8000000000000
201}
202
203; CHECK-LABEL: inf_f64:
204; CHECK-NEXT: .result f64{{$}}
205; CHECK-NEXT: f64.const $push[[NUM:[0-9]+]]=, infinity{{$}}
206; CHECK-NEXT: return $pop[[NUM]]{{$}}
207define double @inf_f64() {
208  ret double 0x7FF0000000000000
209}
210
211; CHECK-LABEL: neginf_f64:
212; CHECK-NEXT: .result f64{{$}}
213; CHECK-NEXT: f64.const $push[[NUM:[0-9]+]]=, -infinity{{$}}
214; CHECK-NEXT: return $pop[[NUM]]{{$}}
215define double @neginf_f64() {
216  ret double 0xFFF0000000000000
217}
218
219; CHECK-LABEL: custom_nan_f64:
220; CHECK-NEXT: .result f64{{$}}
221; CHECK-NEXT: f64.const $push[[NUM:[0-9]+]]=, -nan:0xabcdef0123456{{$}}
222; CHECK-NEXT: return $pop[[NUM]]{{$}}
223define double @custom_nan_f64() {
224  ret double 0xFFFABCDEF0123456
225}
226
227; CHECK-LABEL: custom_nans_f64:
228; CHECK-NEXT: .result f64{{$}}
229; CHECK-NEXT: f64.const $push[[NUM:[0-9]+]]=, -nan:0x2bcdef0123456{{$}}
230; CHECK-NEXT: return $pop[[NUM]]{{$}}
231define double @custom_nans_f64() {
232  ret double 0xFFF2BCDEF0123456
233}
234