mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-21 03:53:04 +02:00
21c5b7a6bb
Summary: Follow the same syntax as for the spec repo. Both have evolved slightly independently and need to converge again. This, along with wasmate changes, allows me to do the following: echo "int add(int a, int b) { return a + b; }" > add.c ./out/bin/clang -O2 -S --target=wasm32-unknown-unknown add.c -o add.wack ./experimental/prototype-wasmate/wasmate.py add.wack > add.wast ./sexpr-wasm-prototype/out/sexpr-wasm add.wast -o add.wasm ./sexpr-wasm-prototype/third_party/v8-native-prototype/v8/v8/out/Release/d8 -e "print(WASM.instantiateModule(readbuffer('add.wasm'), {print:print}).add(42, 1337));" As you'd expect, the d8 shell prints out the right value. Reviewers: sunfish Subscribers: jfb, llvm-commits, dschuff Differential Revision: http://reviews.llvm.org/D13712 llvm-svn: 250480
43 lines
1.2 KiB
LLVM
43 lines
1.2 KiB
LLVM
; 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
|
|
declare i64 @llvm.wasm.memory.size.i64() nounwind readnone
|
|
declare void @llvm.wasm.resize.memory.i64(i64) nounwind
|
|
|
|
; CHECK-LABEL: page_size:
|
|
; CHECK-NEXT: .result i64{{$}}
|
|
; CHECK-NEXT: .local i64{{$}}
|
|
; CHECK-NEXT: page_size
|
|
; CHECK-NEXT: set_local 0, pop{{$}}
|
|
; CHECK-NEXT: return (get_local 0){{$}}
|
|
define i64 @page_size() {
|
|
%a = call i64 @llvm.wasm.page.size.i64()
|
|
ret i64 %a
|
|
}
|
|
|
|
; CHECK-LABEL: memory_size:
|
|
; CHECK-NEXT: .result i64{{$}}
|
|
; CHECK-NEXT: .local i64{{$}}
|
|
; CHECK-NEXT: memory_size
|
|
; CHECK-NEXT: set_local 0, pop{{$}}
|
|
; CHECK-NEXT: return (get_local 0){{$}}
|
|
define i64 @memory_size() {
|
|
%a = call i64 @llvm.wasm.memory.size.i64()
|
|
ret i64 %a
|
|
}
|
|
|
|
; CHECK-LABEL: resize_memory:
|
|
; CHECK-NEXT: .param i64
|
|
; CHECK-NEXT: .local i64{{$}}
|
|
; CHECK: resize_memory (get_local 1)
|
|
; CHECK-NEXT: return
|
|
define void @resize_memory(i64 %n) {
|
|
call void @llvm.wasm.resize.memory.i64(i64 %n)
|
|
ret void
|
|
}
|