mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-25 14:02:52 +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
54 lines
1.1 KiB
LLVM
54 lines
1.1 KiB
LLVM
; RUN: llc < %s -asm-verbose=false | FileCheck %s
|
|
|
|
; Test that phis are lowered.
|
|
|
|
target datalayout = "e-p:32:32-i64:64-n32:64-S128"
|
|
target triple = "wasm32-unknown-unknown"
|
|
|
|
; Basic phi triangle.
|
|
|
|
; CHECK-LABEL: test0:
|
|
; CHECK: get_local 0{{$}}
|
|
; CHECK: set_local [[REG:.*]], pop
|
|
; CHECK: sdiv (get_local [[REG]]), {{.*}}
|
|
; CHECK: set_local [[REG]], pop
|
|
; CHECK: return (get_local [[REG]])
|
|
define i32 @test0(i32 %p) {
|
|
entry:
|
|
%t = icmp slt i32 %p, 0
|
|
br i1 %t, label %true, label %done
|
|
true:
|
|
%a = sdiv i32 %p, 3
|
|
br label %done
|
|
done:
|
|
%s = phi i32 [ %a, %true ], [ %p, %entry ]
|
|
ret i32 %s
|
|
}
|
|
|
|
; Swap phis.
|
|
|
|
; CHECK-LABEL: test1:
|
|
; CHECK: BB1_1:
|
|
; CHECK: get_local [[REG1:.*]]
|
|
; CHECK: set_local [[REG0:.*]], pop
|
|
; CHECK: get_local [[REG2:.*]]
|
|
; CHECK: set_local [[REG1]], pop
|
|
; CHECK: [[REG0]]
|
|
; CHECK: set_local [[REG2]], pop
|
|
define i32 @test1(i32 %n) {
|
|
entry:
|
|
br label %loop
|
|
|
|
loop:
|
|
%a = phi i32 [ 0, %entry ], [ %b, %loop ]
|
|
%b = phi i32 [ 1, %entry ], [ %a, %loop ]
|
|
%i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
|
|
|
|
%i.next = add i32 %i, 1
|
|
%t = icmp slt i32 %i.next, %n
|
|
br i1 %t, label %loop, label %exit
|
|
|
|
exit:
|
|
ret i32 %a
|
|
}
|