llvm.org GIT mirror llvm / ae31b98
[WebAssembly] Update wasm builtin functions to match spec changes. The page_size operator has been removed from the spec, and the resize_memory operator has been changed to grow_memory. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252202 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 4 years ago
4 changed file(s) with 18 addition(s) and 51 deletion(s). Raw diff Collapse all Expand all
1313
1414 let TargetPrefix = "wasm" in { // All intrinsics start with "llvm.wasm.".
1515
16 def int_wasm_page_size : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
1716 def int_wasm_memory_size : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
18 def int_wasm_resize_memory : Intrinsic<[], [llvm_anyint_ty], []>;
17 def int_wasm_grow_memory : Intrinsic<[], [llvm_anyint_ty], []>;
1918
2019 }
8383 def STORE32_I64 : I<(outs), (ins I32:$addr, I64:$val),
8484 [(truncstorei32 I64:$val, I32:$addr)]>;
8585
86 // Page size.
87 def page_size_I32 : I<(outs I32:$dst), (ins),
88 [(set I32:$dst, (int_wasm_page_size))]>,
89 Requires<[HasAddr32]>;
90 def page_size_I64 : I<(outs I64:$dst), (ins),
91 [(set I64:$dst, (int_wasm_page_size))]>,
92 Requires<[HasAddr64]>;
93
9486 // Memory size.
9587 def memory_size_I32 : I<(outs I32:$dst), (ins),
9688 [(set I32:$dst, (int_wasm_memory_size))]>,
9991 [(set I64:$dst, (int_wasm_memory_size))]>,
10092 Requires<[HasAddr64]>;
10193
102 // Resize memory.
103 def resize_memory_I32 : I<(outs), (ins I32:$delta),
104 [(int_wasm_resize_memory I32:$delta)]>,
105 Requires<[HasAddr32]>;
106 def resize_memory_I64 : I<(outs), (ins I64:$delta),
107 [(int_wasm_resize_memory I64:$delta)]>,
108 Requires<[HasAddr64]>;
94 // Grow memory.
95 def grow_memory_I32 : I<(outs), (ins I32:$delta),
96 [(int_wasm_grow_memory I32:$delta)]>,
97 Requires<[HasAddr32]>;
98 def grow_memory_I64 : I<(outs), (ins I64:$delta),
99 [(int_wasm_grow_memory I64:$delta)]>,
100 Requires<[HasAddr64]>;
44 target datalayout = "e-p:32:32-i64:64-n32:64-S128"
55 target triple = "wasm32-unknown-unknown"
66
7 declare i32 @llvm.wasm.page.size.i32() nounwind readnone
87 declare i32 @llvm.wasm.memory.size.i32() nounwind readnone
9 declare void @llvm.wasm.resize.memory.i32(i32) nounwind
10
11 ; CHECK-LABEL: page_size:
12 ; CHECK-NEXT: .result i32{{$}}
13 ; CHECK-NEXT: .local i32{{$}}
14 ; CHECK-NEXT: page_size
15 ; CHECK-NEXT: set_local 0, pop{{$}}
16 ; CHECK-NEXT: return (get_local 0){{$}}
17 define i32 @page_size() {
18 %a = call i32 @llvm.wasm.page.size.i32()
19 ret i32 %a
20 }
8 declare void @llvm.wasm.grow.memory.i32(i32) nounwind
219
2210 ; CHECK-LABEL: memory_size:
2311 ; CHECK-NEXT: .result i32{{$}}
3018 ret i32 %a
3119 }
3220
33 ; CHECK-LABEL: resize_memory:
21 ; CHECK-LABEL: grow_memory:
3422 ; CHECK-NEXT: .param i32
3523 ; CHECK-NEXT: .local i32{{$}}
36 ; CHECK: resize_memory (get_local 1)
24 ; CHECK: grow_memory (get_local 1)
3725 ; CHECK-NEXT: return
38 define void @resize_memory(i32 %n) {
39 call void @llvm.wasm.resize.memory.i32(i32 %n)
26 define void @grow_memory(i32 %n) {
27 call void @llvm.wasm.grow.memory.i32(i32 %n)
4028 ret void
4129 }
44 target datalayout = "e-p:64:64-i64:64-n32:64-S128"
55 target triple = "wasm64-unknown-unknown"
66
7 declare i64 @llvm.wasm.page.size.i64() nounwind readnone
87 declare i64 @llvm.wasm.memory.size.i64() nounwind readnone
9 declare void @llvm.wasm.resize.memory.i64(i64) nounwind
10
11 ; CHECK-LABEL: page_size:
12 ; CHECK-NEXT: .result i64{{$}}
13 ; CHECK-NEXT: .local i64{{$}}
14 ; CHECK-NEXT: page_size
15 ; CHECK-NEXT: set_local 0, pop{{$}}
16 ; CHECK-NEXT: return (get_local 0){{$}}
17 define i64 @page_size() {
18 %a = call i64 @llvm.wasm.page.size.i64()
19 ret i64 %a
20 }
8 declare void @llvm.wasm.grow.memory.i64(i64) nounwind
219
2210 ; CHECK-LABEL: memory_size:
2311 ; CHECK-NEXT: .result i64{{$}}
3018 ret i64 %a
3119 }
3220
33 ; CHECK-LABEL: resize_memory:
21 ; CHECK-LABEL: grow_memory:
3422 ; CHECK-NEXT: .param i64
3523 ; CHECK-NEXT: .local i64{{$}}
36 ; CHECK: resize_memory (get_local 1)
24 ; CHECK: grow_memory (get_local 1)
3725 ; CHECK-NEXT: return
38 define void @resize_memory(i64 %n) {
39 call void @llvm.wasm.resize.memory.i64(i64 %n)
26 define void @grow_memory(i64 %n) {
27 call void @llvm.wasm.grow.memory.i64(i64 %n)
4028 ret void
4129 }