static SmallString<32> Name(const WebAssemblyInstrInfo *TII,
const MachineInstr *MI) {
std::string N(StringRef(TII->getName(MI->getOpcode())).lower());
- std::string::size_type End = N.find('_');
+ std::string::size_type End = N.rfind('_');
End = std::string::npos == End ? N.length() : End;
return SmallString<32>(&N[0], &N[End]);
}
* load_global: load the value of a given global variable
* store_global: store a given value to a given global variable
*/
+
+def page_size_I32 : I<(outs Int32:$dst), (ins),
+ [(set Int32:$dst, (int_wasm_page_size))]>,
+ Requires<[HasAddr32]>;
+def page_size_I64 : I<(outs Int64:$dst), (ins),
+ [(set Int64:$dst, (int_wasm_page_size))]>,
+ Requires<[HasAddr64]>;
--- /dev/null
+; RUN: llc < %s -asm-verbose=false | FileCheck %s
+
+; Test that basic memory operations assemble as expected with 32-bit addresses.
+
+target datalayout = "e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+declare i32 @llvm.wasm.page.size.i32() nounwind readnone
+
+; CHECK-LABEL: page_size:
+; CHECK-NEXT: (setlocal @0 (page_size))
+; CHECK-NEXT: (return @0)
+define i32 @page_size() {
+ %a = call i32 @llvm.wasm.page.size.i32()
+ ret i32 %a
+}
--- /dev/null
+; RUN: llc < %s -asm-verbose=false | FileCheck %s
+
+; Test that basic memory operations assemble as expected with 64-bit addresses.
+
+target datalayout = "e-p:64:64-i64:64-n32:64-S128"
+target triple = "wasm64-unknown-unknown"
+
+declare i64 @llvm.wasm.page.size.i64() nounwind readnone
+
+; CHECK-LABEL: page_size:
+; CHECK-NEXT: (setlocal @0 (page_size))
+; CHECK-NEXT: (return @0)
+define i64 @page_size() {
+ %a = call i64 @llvm.wasm.page.size.i64()
+ ret i64 %a
+}