llvm.org GIT mirror llvm / 238f816
[WebAssembly] Update to the new names for the memory intrinsics. The WebAssembly committee has decided on the names `memory.size` and `memory.grow` for the memory intrinsics, so update the LLVM intrinsics to follow those names, keeping both sets of old names in place for compatibility. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333708 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 1 year, 10 months ago
3 changed file(s) with 41 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
1414 let TargetPrefix = "wasm" in { // All intrinsics start with "llvm.wasm.".
1515
1616 // Query the current memory size, and increase the current memory size.
17 // Note that mem.size is not IntrNoMem because it must be sequenced with
18 // respect to mem.grow calls.
19 // These are the new proposed names, which aren't yet official. Use at your own
20 // risk.
17 // Note that memory.size is not IntrNoMem because it must be sequenced with
18 // respect to memory.grow calls.
19 def int_wasm_memory_size : Intrinsic<[llvm_anyint_ty],
20 [llvm_i32_ty],
21 [IntrReadMem]>;
22 def int_wasm_memory_grow : Intrinsic<[llvm_anyint_ty],
23 [llvm_i32_ty, LLVMMatchType<0>],
24 []>;
25
26 // These are the old names.
2127 def int_wasm_mem_size : Intrinsic<[llvm_anyint_ty],
2228 [llvm_i32_ty],
2329 [IntrReadMem]>;
2531 [llvm_i32_ty, LLVMMatchType<0>],
2632 []>;
2733
28 // These are the existing names, which are currently official, but expected
29 // to be deprecated in the future. They also lack the immediate field.
34 // These are the old old names. They also lack the immediate field.
3035 def int_wasm_current_memory : Intrinsic<[llvm_anyint_ty], [], [IntrReadMem]>;
3136 def int_wasm_grow_memory : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>], []>;
3237
443443 let Defs = [ARGUMENTS] in {
444444
445445 // Current memory size.
446 def MEMORY_SIZE_I32 : I<(outs I32:$dst), (ins i32imm:$flags),
447 [(set I32:$dst, (int_wasm_memory_size (i32 imm:$flags)))],
448 "memory.size\t$dst, $flags", 0x3f>,
449 Requires<[HasAddr32]>;
446450 def MEM_SIZE_I32 : I<(outs I32:$dst), (ins i32imm:$flags),
447451 [(set I32:$dst, (int_wasm_mem_size (i32 imm:$flags)))],
448452 "mem.size\t$dst, $flags", 0x3f>,
453457 Requires<[HasAddr32]>;
454458
455459 // Grow memory.
460 def MEMORY_GROW_I32 : I<(outs I32:$dst), (ins i32imm:$flags, I32:$delta),
461 [(set I32:$dst,
462 (int_wasm_memory_grow (i32 imm:$flags), I32:$delta))],
463 "memory.grow\t$dst, $flags, $delta", 0x3f>,
464 Requires<[HasAddr32]>;
456465 def MEM_GROW_I32 : I<(outs I32:$dst), (ins i32imm:$flags, I32:$delta),
457466 [(set I32:$dst,
458467 (int_wasm_mem_grow (i32 imm:$flags), I32:$delta))],
44 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
55 target triple = "wasm32-unknown-unknown"
66
7 declare i32 @llvm.wasm.memory.size.i32(i32) nounwind readonly
8 declare i32 @llvm.wasm.memory.grow.i32(i32, i32) nounwind
79 declare i32 @llvm.wasm.mem.size.i32(i32) nounwind readonly
810 declare i32 @llvm.wasm.mem.grow.i32(i32, i32) nounwind
911 declare i32 @llvm.wasm.current.memory.i32() nounwind readonly
1012 declare i32 @llvm.wasm.grow.memory.i32(i32) nounwind
13
14 ; CHECK-LABEL: memory_size:
15 ; CHECK-NEXT: .result i32{{$}}
16 ; CHECK-NEXT: memory.size $push0=, 0{{$}}
17 ; CHECK-NEXT: return $pop0{{$}}
18 define i32 @memory_size() {
19 %a = call i32 @llvm.wasm.memory.size.i32(i32 0)
20 ret i32 %a
21 }
22
23 ; CHECK-LABEL: memory_grow:
24 ; CHECK-NEXT: .param i32{{$}}
25 ; CHECK-NEXT: .result i32{{$}}
26 ; CHECK: memory.grow $push0=, 0, $0{{$}}
27 ; CHECK-NEXT: return $pop0{{$}}
28 define i32 @memory_grow(i32 %n) {
29 %a = call i32 @llvm.wasm.memory.grow.i32(i32 0, i32 %n)
30 ret i32 %a
31 }
1132
1233 ; CHECK-LABEL: mem_size:
1334 ; CHECK-NEXT: .result i32{{$}}