1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00

[WebAssembly] CodeGen support for __builtin_wasm_page_size()

llvm-svn: 245872
This commit is contained in:
Dan Gohman 2015-08-24 21:03:24 +00:00
parent 7c54263be5
commit 7bd84e30f7
4 changed files with 40 additions and 1 deletions

View File

@ -79,7 +79,7 @@ private:
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]);
}

View File

@ -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]>;

View File

@ -0,0 +1,16 @@
; 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
}

View File

@ -0,0 +1,16 @@
; 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
}