[WebAssembly] CodeGen support for __builtin_wasm_page_size()

llvm-svn: 245872
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
index 4216fb6..6f98b4f 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -79,7 +79,7 @@
 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]);
 }
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td
index 5ab40e8..8457dc8 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td
@@ -44,3 +44,10 @@
  * 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]>;