llvm.org GIT mirror llvm / d433cde
WebAssembly: fix load/store syntax Summary: The syntax has changed a bit recently. Reviewers: binji Subscribers: llvm-commits, jfb, sunfish, dschuff Differential Revision: http://reviews.llvm.org/D13821 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250535 91177308-0d34-0410-b5e6-96231b3b80d8 JF Bastien 4 years ago
7 changed file(s) with 81 addition(s) and 81 deletion(s). Raw diff Collapse all Expand all
2222 // types when loading, and truncate when storing.
2323
2424 // Basic load.
25 def LOAD_I32_ : I<(outs I32:$dst), (ins I32:$addr),
26 [(set I32:$dst, (load I32:$addr))]>;
27 def LOAD_I64_ : I<(outs I64:$dst), (ins I32:$addr),
28 [(set I64:$dst, (load I32:$addr))]>;
29 def LOAD_F32_ : I<(outs F32:$dst), (ins I32:$addr),
30 [(set F32:$dst, (load I32:$addr))]>;
31 def LOAD_F64_ : I<(outs F64:$dst), (ins I32:$addr),
32 [(set F64:$dst, (load I32:$addr))]>;
25 def LOAD_I32 : I<(outs I32:$dst), (ins I32:$addr),
26 [(set I32:$dst, (load I32:$addr))]>;
27 def LOAD_I64 : I<(outs I64:$dst), (ins I32:$addr),
28 [(set I64:$dst, (load I32:$addr))]>;
29 def LOAD_F32 : I<(outs F32:$dst), (ins I32:$addr),
30 [(set F32:$dst, (load I32:$addr))]>;
31 def LOAD_F64 : I<(outs F64:$dst), (ins I32:$addr),
32 [(set F64:$dst, (load I32:$addr))]>;
3333
3434 // Extending load.
35 def LOAD_S_i8_I32_ : I<(outs I32:$dst), (ins I32:$addr),
36 [(set I32:$dst, (sextloadi8 I32:$addr))]>;
37 def LOAD_U_i8_I32_ : I<(outs I32:$dst), (ins I32:$addr),
38 [(set I32:$dst, (zextloadi8 I32:$addr))]>;
39 def LOAD_S_i16_I32_ : I<(outs I32:$dst), (ins I32:$addr),
40 [(set I32:$dst, (sextloadi16 I32:$addr))]>;
41 def LOAD_U_i16_I32_ : I<(outs I32:$dst), (ins I32:$addr),
42 [(set I32:$dst, (zextloadi16 I32:$addr))]>;
43 def LOAD_S_i8_I64_ : I<(outs I64:$dst), (ins I32:$addr),
44 [(set I64:$dst, (sextloadi8 I32:$addr))]>;
45 def LOAD_U_i8_I64_ : I<(outs I64:$dst), (ins I32:$addr),
46 [(set I64:$dst, (zextloadi8 I32:$addr))]>;
47 def LOAD_S_i16_I64_ : I<(outs I64:$dst), (ins I32:$addr),
48 [(set I64:$dst, (sextloadi16 I32:$addr))]>;
49 def LOAD_U_i16_I64_ : I<(outs I64:$dst), (ins I32:$addr),
50 [(set I64:$dst, (zextloadi16 I32:$addr))]>;
51 def LOAD_S_I32_I64_ : I<(outs I64:$dst), (ins I32:$addr),
52 [(set I64:$dst, (sextloadi32 I32:$addr))]>;
53 def LOAD_U_I32_I64_ : I<(outs I64:$dst), (ins I32:$addr),
54 [(set I64:$dst, (zextloadi32 I32:$addr))]>;
35 def LOAD8_S_I32 : I<(outs I32:$dst), (ins I32:$addr),
36 [(set I32:$dst, (sextloadi8 I32:$addr))]>;
37 def LOAD8_U_I32 : I<(outs I32:$dst), (ins I32:$addr),
38 [(set I32:$dst, (zextloadi8 I32:$addr))]>;
39 def LOAD16_S_I32 : I<(outs I32:$dst), (ins I32:$addr),
40 [(set I32:$dst, (sextloadi16 I32:$addr))]>;
41 def LOAD16_U_I32 : I<(outs I32:$dst), (ins I32:$addr),
42 [(set I32:$dst, (zextloadi16 I32:$addr))]>;
43 def LOAD8_S_I64 : I<(outs I64:$dst), (ins I32:$addr),
44 [(set I64:$dst, (sextloadi8 I32:$addr))]>;
45 def LOAD8_U_I64 : I<(outs I64:$dst), (ins I32:$addr),
46 [(set I64:$dst, (zextloadi8 I32:$addr))]>;
47 def LOAD16_S_I64 : I<(outs I64:$dst), (ins I32:$addr),
48 [(set I64:$dst, (sextloadi16 I32:$addr))]>;
49 def LOAD16_U_I64 : I<(outs I64:$dst), (ins I32:$addr),
50 [(set I64:$dst, (zextloadi16 I32:$addr))]>;
51 def LOAD32_S_I64 : I<(outs I64:$dst), (ins I32:$addr),
52 [(set I64:$dst, (sextloadi32 I32:$addr))]>;
53 def LOAD32_U_I64 : I<(outs I64:$dst), (ins I32:$addr),
54 [(set I64:$dst, (zextloadi32 I32:$addr))]>;
5555
5656 // "Don't care" extending load become zero-extending load.
57 def : Pat<(i32 (extloadi8 I32:$addr)), (LOAD_U_i8_I32_ $addr)>;
58 def : Pat<(i32 (extloadi16 I32:$addr)), (LOAD_U_i16_I32_ $addr)>;
59 def : Pat<(i64 (extloadi8 I32:$addr)), (LOAD_U_i8_I64_ $addr)>;
60 def : Pat<(i64 (extloadi16 I32:$addr)), (LOAD_U_i16_I64_ $addr)>;
61 def : Pat<(i64 (extloadi32 I32:$addr)), (LOAD_U_I32_I64_ $addr)>;
57 def : Pat<(i32 (extloadi8 I32:$addr)), (LOAD8_U_I32 $addr)>;
58 def : Pat<(i32 (extloadi16 I32:$addr)), (LOAD16_U_I32 $addr)>;
59 def : Pat<(i64 (extloadi8 I32:$addr)), (LOAD8_U_I64 $addr)>;
60 def : Pat<(i64 (extloadi16 I32:$addr)), (LOAD16_U_I64 $addr)>;
61 def : Pat<(i64 (extloadi32 I32:$addr)), (LOAD32_U_I64 $addr)>;
6262
6363 // Basic store.
6464 // Note: WebAssembly inverts SelectionDAG's usual operand order.
65 def STORE_I32_ : I<(outs), (ins I32:$addr, I32:$val),
66 [(store i32:$val, I32:$addr)]>;
67 def STORE_I64_ : I<(outs), (ins I32:$addr, I64:$val),
68 [(store i64:$val, I32:$addr)]>;
69 def STORE_F32_ : I<(outs), (ins I32:$addr, F32:$val),
70 [(store f32:$val, I32:$addr)]>;
71 def STORE_F64_ : I<(outs), (ins I32:$addr, F64:$val),
72 [(store f64:$val, I32:$addr)]>;
65 def STORE_I32 : I<(outs), (ins I32:$addr, I32:$val),
66 [(store i32:$val, I32:$addr)]>;
67 def STORE_I64 : I<(outs), (ins I32:$addr, I64:$val),
68 [(store i64:$val, I32:$addr)]>;
69 def STORE_F32 : I<(outs), (ins I32:$addr, F32:$val),
70 [(store f32:$val, I32:$addr)]>;
71 def STORE_F64 : I<(outs), (ins I32:$addr, F64:$val),
72 [(store f64:$val, I32:$addr)]>;
7373
7474 // Truncating store.
75 def STORE_i8_I32 : I<(outs), (ins I32:$addr, I32:$val),
76 [(truncstorei8 I32:$val, I32:$addr)]>;
77 def STORE_i16_I32 : I<(outs), (ins I32:$addr, I32:$val),
78 [(truncstorei16 I32:$val, I32:$addr)]>;
79 def STORE_i8_I64 : I<(outs), (ins I32:$addr, I64:$val),
80 [(truncstorei8 I64:$val, I32:$addr)]>;
81 def STORE_i16_I64 : I<(outs), (ins I32:$addr, I64:$val),
82 [(truncstorei16 I64:$val, I32:$addr)]>;
83 def STORE_I32_I64 : I<(outs), (ins I32:$addr, I64:$val),
84 [(truncstorei32 I64:$val, I32:$addr)]>;
75 def STORE8_I32 : I<(outs), (ins I32:$addr, I32:$val),
76 [(truncstorei8 I32:$val, I32:$addr)]>;
77 def STORE16_I32 : I<(outs), (ins I32:$addr, I32:$val),
78 [(truncstorei16 I32:$val, I32:$addr)]>;
79 def STORE8_I64 : I<(outs), (ins I32:$addr, I64:$val),
80 [(truncstorei8 I64:$val, I32:$addr)]>;
81 def STORE16_I64 : I<(outs), (ins I32:$addr, I64:$val),
82 [(truncstorei16 I64:$val, I32:$addr)]>;
83 def STORE32_I64 : I<(outs), (ins I32:$addr, I64:$val),
84 [(truncstorei32 I64:$val, I32:$addr)]>;
8585
8686 // Page size.
8787 def page_size_I32 : I<(outs I32:$dst), (ins),
185185 ; CHECK-LABEL: minimal_loop:
186186 ; CHECK-NOT: br
187187 ; CHECK: BB7_1:
188 ; CHECK: store_i32 (get_local 1), (get_local 3){{$}}
188 ; CHECK: i32.store (get_local 1), (get_local 3){{$}}
189189 ; CHECK: br $BB7_1{{$}}
190190 define i32 @minimal_loop(i32* %p) {
191191 entry:
55 target triple = "wasm32-unknown-unknown"
66
77 ; CHECK-LABEL: sext_i8_i32:
8 ; CHECK: load_s_i8_i32 (get_local 1){{$}}
8 ; CHECK: i32.load8_s (get_local 1){{$}}
99 ; CHECK-NEXT: set_local 2, pop{{$}}
1010 define i32 @sext_i8_i32(i8 *%p) {
1111 %v = load i8, i8* %p
1414 }
1515
1616 ; CHECK-LABEL: zext_i8_i32:
17 ; CHECK: load_u_i8_i32 (get_local 1){{$}}
17 ; CHECK: i32.load8_u (get_local 1){{$}}
1818 ; CHECK-NEXT: set_local 2, pop{{$}}
1919 define i32 @zext_i8_i32(i8 *%p) {
2020 %v = load i8, i8* %p
2323 }
2424
2525 ; CHECK-LABEL: sext_i16_i32:
26 ; CHECK: load_s_i16_i32 (get_local 1){{$}}
26 ; CHECK: i32.load16_s (get_local 1){{$}}
2727 ; CHECK-NEXT: set_local 2, pop{{$}}
2828 define i32 @sext_i16_i32(i16 *%p) {
2929 %v = load i16, i16* %p
3232 }
3333
3434 ; CHECK-LABEL: zext_i16_i32:
35 ; CHECK: load_u_i16_i32 (get_local 1){{$}}
35 ; CHECK: i32.load16_u (get_local 1){{$}}
3636 ; CHECK-NEXT: set_local 2, pop{{$}}
3737 define i32 @zext_i16_i32(i16 *%p) {
3838 %v = load i16, i16* %p
4141 }
4242
4343 ; CHECK-LABEL: sext_i8_i64:
44 ; CHECK: load_s_i8_i64 (get_local 1){{$}}
44 ; CHECK: i64.load8_s (get_local 1){{$}}
4545 ; CHECK-NEXT: set_local 2, pop{{$}}
4646 define i64 @sext_i8_i64(i8 *%p) {
4747 %v = load i8, i8* %p
5050 }
5151
5252 ; CHECK-LABEL: zext_i8_i64:
53 ; CHECK: load_u_i8_i64 (get_local 1){{$}}
53 ; CHECK: i64.load8_u (get_local 1){{$}}
5454 ; CHECK-NEXT: set_local 2, pop{{$}}
5555 define i64 @zext_i8_i64(i8 *%p) {
5656 %v = load i8, i8* %p
5959 }
6060
6161 ; CHECK-LABEL: sext_i16_i64:
62 ; CHECK: load_s_i16_i64 (get_local 1){{$}}
62 ; CHECK: i64.load16_s (get_local 1){{$}}
6363 ; CHECK-NEXT: set_local 2, pop{{$}}
6464 define i64 @sext_i16_i64(i16 *%p) {
6565 %v = load i16, i16* %p
6868 }
6969
7070 ; CHECK-LABEL: zext_i16_i64:
71 ; CHECK: load_u_i16_i64 (get_local 1){{$}}
71 ; CHECK: i64.load16_u (get_local 1){{$}}
7272 ; CHECK-NEXT: set_local 2, pop{{$}}
7373 define i64 @zext_i16_i64(i16 *%p) {
7474 %v = load i16, i16* %p
7777 }
7878
7979 ; CHECK-LABEL: sext_i32_i64:
80 ; CHECK: load_s_i32_i64 (get_local 1){{$}}
80 ; CHECK: i64.load32_s (get_local 1){{$}}
8181 ; CHECK-NEXT: set_local 2, pop{{$}}
8282 define i64 @sext_i32_i64(i32 *%p) {
8383 %v = load i32, i32* %p
8686 }
8787
8888 ; CHECK-LABEL: zext_i32_i64:
89 ; CHECK: load_u_i32_i64 (get_local 1){{$}}
89 ; CHECK: i64.load32_u (get_local 1){{$}}
9090 ; CHECK: set_local 2, pop{{$}}
9191 define i64 @zext_i32_i64(i32 *%p) {
9292 %v = load i32, i32* %p
55 target triple = "wasm32-unknown-unknown"
66
77 ; CHECK-LABEL: load_u_i1_i32:
8 ; CHECK: load_u_i8_i32 (get_local 1){{$}}
8 ; CHECK: i32.load8_u (get_local 1){{$}}
99 ; CHECK-NEXT: set_local 2, pop{{$}}
1010 ; CHECK-NEXT: return (get_local 2){{$}}
1111 define i32 @load_u_i1_i32(i1* %p) {
1515 }
1616
1717 ; CHECK-LABEL: load_s_i1_i32:
18 ; CHECK: load_u_i8_i32 (get_local 1){{$}}
18 ; CHECK: i32.load8_u (get_local 1){{$}}
1919 ; CHECK-NEXT: set_local 2, pop{{$}}
2020 ; CHECK-NEXT: i32.const 31{{$}}
2121 ; CHECK-NEXT: set_local 3, pop{{$}}
3131 }
3232
3333 ; CHECK-LABEL: load_u_i1_i64:
34 ; CHECK: load_u_i8_i64 (get_local 1){{$}}
34 ; CHECK: i64.load8_u (get_local 1){{$}}
3535 ; CHECK-NEXT: set_local 2, pop{{$}}
3636 ; CHECK-NEXT: return (get_local 2){{$}}
3737 define i64 @load_u_i1_i64(i1* %p) {
4141 }
4242
4343 ; CHECK-LABEL: load_s_i1_i64:
44 ; CHECK: load_u_i8_i64 (get_local 1){{$}}
44 ; CHECK: i64.load8_u (get_local 1){{$}}
4545 ; CHECK-NEXT: set_local 2, pop{{$}}
4646 ; CHECK-NEXT: i64.const 63{{$}}
4747 ; CHECK-NEXT: set_local 3, pop{{$}}
6161 ; CHECK-NEXT: set_local 4, pop{{$}}
6262 ; CHECK-NEXT: and (get_local 3), (get_local 4){{$}}
6363 ; CHECK-NEXT: set_local 5, pop{{$}}
64 ; CHECK-NEXT: store_i8 (get_local 2), (get_local 5){{$}}
64 ; CHECK-NEXT: i32.store8 (get_local 2), (get_local 5){{$}}
6565 define void @store_i32_i1(i1* %p, i32 %v) {
6666 %t = trunc i32 %v to i1
6767 store i1 %t, i1* %p
7373 ; CHECK-NEXT: set_local 4, pop{{$}}
7474 ; CHECK-NEXT: and (get_local 3), (get_local 4){{$}}
7575 ; CHECK-NEXT: set_local 5, pop{{$}}
76 ; CHECK-NEXT: store_i8 (get_local 2), (get_local 5){{$}}
76 ; CHECK-NEXT: i64.store8 (get_local 2), (get_local 5){{$}}
7777 define void @store_i64_i1(i1* %p, i64 %v) {
7878 %t = trunc i64 %v to i1
7979 store i1 %t, i1* %p
1010 ; CHECK-NEXT: .local i32, i32{{$}}
1111 ; CHECK-NEXT: get_local 0{{$}}
1212 ; CHECK-NEXT: set_local 1, pop{{$}}
13 ; CHECK-NEXT: load_i32 (get_local 1){{$}}
13 ; CHECK-NEXT: i32.load (get_local 1){{$}}
1414 ; CHECK-NEXT: set_local 2, pop{{$}}
1515 ; CHECK-NEXT: return (get_local 2){{$}}
1616 define i32 @ldi32(i32 *%p) {
2424 ; CHECK-NEXT: .local i32, i64{{$}}
2525 ; CHECK-NEXT: get_local 0{{$}}
2626 ; CHECK-NEXT: set_local 1, pop{{$}}
27 ; CHECK-NEXT: load_i64 (get_local 1){{$}}
27 ; CHECK-NEXT: i64.load (get_local 1){{$}}
2828 ; CHECK-NEXT: set_local 2, pop{{$}}
2929 ; CHECK-NEXT: return (get_local 2){{$}}
3030 define i64 @ldi64(i64 *%p) {
3838 ; CHECK-NEXT: .local i32, f32{{$}}
3939 ; CHECK-NEXT: get_local 0{{$}}
4040 ; CHECK-NEXT: set_local 1, pop{{$}}
41 ; CHECK-NEXT: load_f32 (get_local 1){{$}}
41 ; CHECK-NEXT: f32.load (get_local 1){{$}}
4242 ; CHECK-NEXT: set_local 2, pop{{$}}
4343 ; CHECK-NEXT: return (get_local 2){{$}}
4444 define float @ldf32(float *%p) {
5252 ; CHECK-NEXT: .local i32, f64{{$}}
5353 ; CHECK-NEXT: get_local 0{{$}}
5454 ; CHECK-NEXT: set_local 1, pop{{$}}
55 ; CHECK-NEXT: load_f64 (get_local 1){{$}}
55 ; CHECK-NEXT: f64.load (get_local 1){{$}}
5656 ; CHECK-NEXT: set_local 2, pop{{$}}
5757 ; CHECK-NEXT: return (get_local 2){{$}}
5858 define double @ldf64(double *%p) {
55 target triple = "wasm32-unknown-unknown"
66
77 ; CHECK-LABEL: trunc_i8_i32:
8 ; CHECK: store_i8 (get_local 3), (get_local 2){{$}}
8 ; CHECK: i32.store8 (get_local 3), (get_local 2){{$}}
99 define void @trunc_i8_i32(i8 *%p, i32 %v) {
1010 %t = trunc i32 %v to i8
1111 store i8 %t, i8* %p
1313 }
1414
1515 ; CHECK-LABEL: trunc_i16_i32:
16 ; CHECK: store_i16 (get_local 3), (get_local 2){{$}}
16 ; CHECK: i32.store16 (get_local 3), (get_local 2){{$}}
1717 define void @trunc_i16_i32(i16 *%p, i32 %v) {
1818 %t = trunc i32 %v to i16
1919 store i16 %t, i16* %p
2121 }
2222
2323 ; CHECK-LABEL: trunc_i8_i64:
24 ; CHECK: store_i8 (get_local 3), (get_local 2){{$}}
24 ; CHECK: i64.store8 (get_local 3), (get_local 2){{$}}
2525 define void @trunc_i8_i64(i8 *%p, i64 %v) {
2626 %t = trunc i64 %v to i8
2727 store i8 %t, i8* %p
2929 }
3030
3131 ; CHECK-LABEL: trunc_i16_i64:
32 ; CHECK: store_i16 (get_local 3), (get_local 2){{$}}
32 ; CHECK: i64.store16 (get_local 3), (get_local 2){{$}}
3333 define void @trunc_i16_i64(i16 *%p, i64 %v) {
3434 %t = trunc i64 %v to i16
3535 store i16 %t, i16* %p
3737 }
3838
3939 ; CHECK-LABEL: trunc_i32_i64:
40 ; CHECK: store_i32 (get_local 3), (get_local 2){{$}}
40 ; CHECK: i64.store32 (get_local 3), (get_local 2){{$}}
4141 define void @trunc_i32_i64(i32 *%p, i64 %v) {
4242 %t = trunc i64 %v to i32
4343 store i32 %t, i32* %p
1212 ; CHECK-NEXT: set_local 2, pop{{$}}
1313 ; CHECK-NEXT: get_local 0{{$}}
1414 ; CHECK-NEXT: set_local 3, pop{{$}}
15 ; CHECK-NEXT: store_i32 (get_local 3), (get_local 2){{$}}
15 ; CHECK-NEXT: i32.store (get_local 3), (get_local 2){{$}}
1616 ; CHECK-NEXT: return{{$}}
1717 define void @sti32(i32 *%p, i32 %v) {
1818 store i32 %v, i32* %p
2727 ; CHECK-NEXT: set_local 2, pop{{$}}
2828 ; CHECK-NEXT: get_local 0{{$}}
2929 ; CHECK-NEXT: set_local 3, pop{{$}}
30 ; CHECK-NEXT: store_i64 (get_local 3), (get_local 2){{$}}
30 ; CHECK-NEXT: i64.store (get_local 3), (get_local 2){{$}}
3131 ; CHECK-NEXT: return{{$}}
3232 define void @sti64(i64 *%p, i64 %v) {
3333 store i64 %v, i64* %p
4242 ; CHECK-NEXT: set_local 2, pop{{$}}
4343 ; CHECK-NEXT: get_local 0{{$}}
4444 ; CHECK-NEXT: set_local 3, pop{{$}}
45 ; CHECK-NEXT: store_f32 (get_local 3), (get_local 2){{$}}
45 ; CHECK-NEXT: f32.store (get_local 3), (get_local 2){{$}}
4646 ; CHECK-NEXT: return{{$}}
4747 define void @stf32(float *%p, float %v) {
4848 store float %v, float* %p
5757 ; CHECK-NEXT: set_local 2, pop{{$}}
5858 ; CHECK-NEXT: get_local 0{{$}}
5959 ; CHECK-NEXT: set_local 3, pop{{$}}
60 ; CHECK-NEXT: store_f64 (get_local 3), (get_local 2){{$}}
60 ; CHECK-NEXT: f64.store (get_local 3), (get_local 2){{$}}
6161 ; CHECK-NEXT: return{{$}}
6262 define void @stf64(double *%p, double %v) {
6363 store double %v, double* %p