[WebAssembly] Add type prefixes to call instructions

Add return type information to call and call_indirect instructions. This
allows them to be disambiguated without knowledge of the callee.

Differential Revision: http://reviews.llvm.org/D15484


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255565 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2015-12-14 22:56:51 +00:00
parent 4fe3f079fb
commit ae06f491f7
7 changed files with 28 additions and 28 deletions

View File

@ -25,19 +25,19 @@ def ADJCALLSTACKUP : I<(outs), (ins i32imm:$amt),
[(WebAssemblycallseq_end timm:$amt, undef)]>; [(WebAssemblycallseq_end timm:$amt, undef)]>;
} // isCodeGenOnly = 1 } // isCodeGenOnly = 1
multiclass CALL<WebAssemblyRegClass vt> { multiclass CALL<WebAssemblyRegClass vt, string prefix> {
def CALL_#vt : I<(outs vt:$dst), (ins i32imm:$callee, variable_ops), def CALL_#vt : I<(outs vt:$dst), (ins i32imm:$callee, variable_ops),
[(set vt:$dst, (WebAssemblycall1 (i32 imm:$callee)))], [(set vt:$dst, (WebAssemblycall1 (i32 imm:$callee)))],
"call \t$dst, $callee">; !strconcat(prefix, "call\t$dst, $callee")>;
def CALL_INDIRECT_#vt : I<(outs vt:$dst), (ins I32:$callee, variable_ops), def CALL_INDIRECT_#vt : I<(outs vt:$dst), (ins I32:$callee, variable_ops),
[(set vt:$dst, (WebAssemblycall1 I32:$callee))], [(set vt:$dst, (WebAssemblycall1 I32:$callee))],
"call_indirect\t$dst, $callee">; !strconcat(prefix, "call_indirect\t$dst, $callee")>;
} }
let Uses = [SP32, SP64], isCall = 1 in { let Uses = [SP32, SP64], isCall = 1 in {
defm : CALL<I32>; defm : CALL<I32, "i32.">;
defm : CALL<I64>; defm : CALL<I64, "i64.">;
defm : CALL<F32>; defm : CALL<F32, "f32.">;
defm : CALL<F64>; defm : CALL<F64, "f64.">;
def CALL_VOID : I<(outs), (ins i32imm:$callee, variable_ops), def CALL_VOID : I<(outs), (ins i32imm:$callee, variable_ops),
[(WebAssemblycall0 (i32 imm:$callee))], [(WebAssemblycall0 (i32 imm:$callee))],

View File

@ -15,7 +15,7 @@ declare void @void_nullary()
; CHECK-LABEL: call_i32_nullary: ; CHECK-LABEL: call_i32_nullary:
; CHECK-NEXT: .result i32{{$}} ; CHECK-NEXT: .result i32{{$}}
; CHECK-NEXT: call $push[[NUM:[0-9]+]]=, i32_nullary{{$}} ; CHECK-NEXT: {{^}} i32.call $push[[NUM:[0-9]+]]=, i32_nullary{{$}}
; CHECK-NEXT: return $pop[[NUM]]{{$}} ; CHECK-NEXT: return $pop[[NUM]]{{$}}
define i32 @call_i32_nullary() { define i32 @call_i32_nullary() {
%r = call i32 @i32_nullary() %r = call i32 @i32_nullary()
@ -24,7 +24,7 @@ define i32 @call_i32_nullary() {
; CHECK-LABEL: call_i64_nullary: ; CHECK-LABEL: call_i64_nullary:
; CHECK-NEXT: .result i64{{$}} ; CHECK-NEXT: .result i64{{$}}
; CHECK-NEXT: call $push[[NUM:[0-9]+]]=, i64_nullary{{$}} ; CHECK-NEXT: {{^}} i64.call $push[[NUM:[0-9]+]]=, i64_nullary{{$}}
; CHECK-NEXT: return $pop[[NUM]]{{$}} ; CHECK-NEXT: return $pop[[NUM]]{{$}}
define i64 @call_i64_nullary() { define i64 @call_i64_nullary() {
%r = call i64 @i64_nullary() %r = call i64 @i64_nullary()
@ -33,7 +33,7 @@ define i64 @call_i64_nullary() {
; CHECK-LABEL: call_float_nullary: ; CHECK-LABEL: call_float_nullary:
; CHECK-NEXT: .result f32{{$}} ; CHECK-NEXT: .result f32{{$}}
; CHECK-NEXT: call $push[[NUM:[0-9]+]]=, float_nullary{{$}} ; CHECK-NEXT: {{^}} f32.call $push[[NUM:[0-9]+]]=, float_nullary{{$}}
; CHECK-NEXT: return $pop[[NUM]]{{$}} ; CHECK-NEXT: return $pop[[NUM]]{{$}}
define float @call_float_nullary() { define float @call_float_nullary() {
%r = call float @float_nullary() %r = call float @float_nullary()
@ -42,7 +42,7 @@ define float @call_float_nullary() {
; CHECK-LABEL: call_double_nullary: ; CHECK-LABEL: call_double_nullary:
; CHECK-NEXT: .result f64{{$}} ; CHECK-NEXT: .result f64{{$}}
; CHECK-NEXT: call $push[[NUM:[0-9]+]]=, double_nullary{{$}} ; CHECK-NEXT: {{^}} f64.call $push[[NUM:[0-9]+]]=, double_nullary{{$}}
; CHECK-NEXT: return $pop[[NUM]]{{$}} ; CHECK-NEXT: return $pop[[NUM]]{{$}}
define double @call_double_nullary() { define double @call_double_nullary() {
%r = call double @double_nullary() %r = call double @double_nullary()
@ -50,7 +50,7 @@ define double @call_double_nullary() {
} }
; CHECK-LABEL: call_void_nullary: ; CHECK-LABEL: call_void_nullary:
; CHECK-NEXT: call void_nullary{{$}} ; CHECK-NEXT: {{^}} call void_nullary{{$}}
; CHECK-NEXT: return{{$}} ; CHECK-NEXT: return{{$}}
define void @call_void_nullary() { define void @call_void_nullary() {
call void @void_nullary() call void @void_nullary()
@ -60,7 +60,7 @@ define void @call_void_nullary() {
; CHECK-LABEL: call_i32_unary: ; CHECK-LABEL: call_i32_unary:
; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i32{{$}}
; CHECK-NEXT: .result i32{{$}} ; CHECK-NEXT: .result i32{{$}}
; CHECK-NEXT: call $push[[NUM:[0-9]+]]=, i32_unary, $0{{$}} ; CHECK-NEXT: {{^}} i32.call $push[[NUM:[0-9]+]]=, i32_unary, $0{{$}}
; CHECK-NEXT: return $pop[[NUM]]{{$}} ; CHECK-NEXT: return $pop[[NUM]]{{$}}
define i32 @call_i32_unary(i32 %a) { define i32 @call_i32_unary(i32 %a) {
%r = call i32 @i32_unary(i32 %a) %r = call i32 @i32_unary(i32 %a)
@ -70,7 +70,7 @@ define i32 @call_i32_unary(i32 %a) {
; CHECK-LABEL: call_i32_binary: ; CHECK-LABEL: call_i32_binary:
; CHECK-NEXT: .param i32, i32{{$}} ; CHECK-NEXT: .param i32, i32{{$}}
; CHECK-NEXT: .result i32{{$}} ; CHECK-NEXT: .result i32{{$}}
; CHECK-NEXT: call $push[[NUM:[0-9]+]]=, i32_binary, $0, $1{{$}} ; CHECK-NEXT: {{^}} i32.call $push[[NUM:[0-9]+]]=, i32_binary, $0, $1{{$}}
; CHECK-NEXT: return $pop[[NUM]]{{$}} ; CHECK-NEXT: return $pop[[NUM]]{{$}}
define i32 @call_i32_binary(i32 %a, i32 %b) { define i32 @call_i32_binary(i32 %a, i32 %b) {
%r = call i32 @i32_binary(i32 %a, i32 %b) %r = call i32 @i32_binary(i32 %a, i32 %b)
@ -79,7 +79,7 @@ define i32 @call_i32_binary(i32 %a, i32 %b) {
; CHECK-LABEL: call_indirect_void: ; CHECK-LABEL: call_indirect_void:
; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i32{{$}}
; CHECK-NEXT: call_indirect $0{{$}} ; CHECK-NEXT: {{^}} call_indirect $0{{$}}
; CHECK-NEXT: return{{$}} ; CHECK-NEXT: return{{$}}
define void @call_indirect_void(void ()* %callee) { define void @call_indirect_void(void ()* %callee) {
call void %callee() call void %callee()
@ -89,7 +89,7 @@ define void @call_indirect_void(void ()* %callee) {
; CHECK-LABEL: call_indirect_i32: ; CHECK-LABEL: call_indirect_i32:
; CHECK-NEXT: .param i32{{$}} ; CHECK-NEXT: .param i32{{$}}
; CHECK-NEXT: .result i32{{$}} ; CHECK-NEXT: .result i32{{$}}
; CHECK-NEXT: call_indirect $push[[NUM:[0-9]+]]=, $0{{$}} ; CHECK-NEXT: {{^}} i32.call_indirect $push[[NUM:[0-9]+]]=, $0{{$}}
; CHECK-NEXT: return $pop[[NUM]]{{$}} ; CHECK-NEXT: return $pop[[NUM]]{{$}}
define i32 @call_indirect_i32(i32 ()* %callee) { define i32 @call_indirect_i32(i32 ()* %callee) {
%t = call i32 %callee() %t = call i32 %callee()
@ -97,7 +97,7 @@ define i32 @call_indirect_i32(i32 ()* %callee) {
} }
; CHECK-LABEL: tail_call_void_nullary: ; CHECK-LABEL: tail_call_void_nullary:
; CHECK-NEXT: call void_nullary{{$}} ; CHECK-NEXT: {{^}} call void_nullary{{$}}
; CHECK-NEXT: return{{$}} ; CHECK-NEXT: return{{$}}
define void @tail_call_void_nullary() { define void @tail_call_void_nullary() {
tail call void @void_nullary() tail call void @void_nullary()
@ -105,7 +105,7 @@ define void @tail_call_void_nullary() {
} }
; CHECK-LABEL: fastcc_tail_call_void_nullary: ; CHECK-LABEL: fastcc_tail_call_void_nullary:
; CHECK-NEXT: call void_nullary{{$}} ; CHECK-NEXT: {{^}} call void_nullary{{$}}
; CHECK-NEXT: return{{$}} ; CHECK-NEXT: return{{$}}
define void @fastcc_tail_call_void_nullary() { define void @fastcc_tail_call_void_nullary() {
tail call fastcc void @void_nullary() tail call fastcc void @void_nullary()
@ -113,7 +113,7 @@ define void @fastcc_tail_call_void_nullary() {
} }
; CHECK-LABEL: coldcc_tail_call_void_nullary: ; CHECK-LABEL: coldcc_tail_call_void_nullary:
; CHECK-NEXT: call void_nullary ; CHECK-NEXT: {{^}} call void_nullary
; CHECK-NEXT: return{{$}} ; CHECK-NEXT: return{{$}}
define void @coldcc_tail_call_void_nullary() { define void @coldcc_tail_call_void_nullary() {
tail call coldcc void @void_nullary() tail call coldcc void @void_nullary()

View File

@ -146,7 +146,7 @@ define float @fmax32(float %x) {
} }
; CHECK-LABEL: fma32: ; CHECK-LABEL: fma32:
; CHECK: call $push0=, fmaf, $0, $1, $2{{$}} ; CHECK: {{^}} f32.call $push0=, fmaf, $0, $1, $2{{$}}
; CHECK-NEXT: return $pop0{{$}} ; CHECK-NEXT: return $pop0{{$}}
define float @fma32(float %a, float %b, float %c) { define float @fma32(float %a, float %b, float %c) {
%d = call float @llvm.fma.f32(float %a, float %b, float %c) %d = call float @llvm.fma.f32(float %a, float %b, float %c)

View File

@ -146,7 +146,7 @@ define double @fmax64(double %x) {
} }
; CHECK-LABEL: fma64: ; CHECK-LABEL: fma64:
; CHECK: call $push0=, fma, $0, $1, $2{{$}} ; CHECK: {{^}} f64.call $push0=, fma, $0, $1, $2{{$}}
; CHECK-NEXT: return $pop0{{$}} ; CHECK-NEXT: return $pop0{{$}}
define double @fma64(double %a, double %b, double %c) { define double @fma64(double %a, double %b, double %c) {
%d = call double @llvm.fma.f64(double %a, double %b, double %c) %d = call double @llvm.fma.f64(double %a, double %b, double %c)

View File

@ -8,7 +8,7 @@ target triple = "wasm32-unknown-unknown"
; CHECK-LABEL: frem32: ; CHECK-LABEL: frem32:
; CHECK-NEXT: .param f32, f32{{$}} ; CHECK-NEXT: .param f32, f32{{$}}
; CHECK-NEXT: .result f32{{$}} ; CHECK-NEXT: .result f32{{$}}
; CHECK-NEXT: call $push0=, fmodf, $0, $1{{$}} ; CHECK-NEXT: {{^}} f32.call $push0=, fmodf, $0, $1{{$}}
; CHECK-NEXT: return $pop0{{$}} ; CHECK-NEXT: return $pop0{{$}}
define float @frem32(float %x, float %y) { define float @frem32(float %x, float %y) {
%a = frem float %x, %y %a = frem float %x, %y
@ -18,7 +18,7 @@ define float @frem32(float %x, float %y) {
; CHECK-LABEL: frem64: ; CHECK-LABEL: frem64:
; CHECK-NEXT: .param f64, f64{{$}} ; CHECK-NEXT: .param f64, f64{{$}}
; CHECK-NEXT: .result f64{{$}} ; CHECK-NEXT: .result f64{{$}}
; CHECK-NEXT: call $push0=, fmod, $0, $1{{$}} ; CHECK-NEXT: {{^}} f64.call $push0=, fmod, $0, $1{{$}}
; CHECK-NEXT: return $pop0{{$}} ; CHECK-NEXT: return $pop0{{$}}
define double @frem64(double %x, double %y) { define double @frem64(double %x, double %y) {
%a = frem double %x, %y %a = frem double %x, %y

View File

@ -8,8 +8,8 @@ target triple = "wasm32-unknown-unknown"
; CHECK-LABEL: _Z3foov: ; CHECK-LABEL: _Z3foov:
; CHECK-NEXT: .result i32{{$}} ; CHECK-NEXT: .result i32{{$}}
; CHECK-NEXT: i32.const $push0=, 1{{$}} ; CHECK-NEXT: i32.const $push0=, 1{{$}}
; CHECK-NEXT: call $push1=, _Znwm, $pop0{{$}} ; CHECK-NEXT: {{^}} i32.call $push1=, _Znwm, $pop0{{$}}
; CHECK-NEXT: call $push2=, _ZN5AppleC1Ev, $pop1{{$}} ; CHECK-NEXT: {{^}} i32.call $push2=, _ZN5AppleC1Ev, $pop1{{$}}
; CHECK-NEXT: return $pop2{{$}} ; CHECK-NEXT: return $pop2{{$}}
%class.Apple = type { i8 } %class.Apple = type { i8 }
declare noalias i8* @_Znwm(i32) declare noalias i8* @_Znwm(i32)
@ -25,7 +25,7 @@ entry:
; CHECK-LABEL: _Z3barPvS_l: ; CHECK-LABEL: _Z3barPvS_l:
; CHECK-NEXT: .param i32, i32, i32{{$}} ; CHECK-NEXT: .param i32, i32, i32{{$}}
; CHECK-NEXT: .result i32{{$}} ; CHECK-NEXT: .result i32{{$}}
; CHECK-NEXT: call $push0=, memcpy, $0, $1, $2{{$}} ; CHECK-NEXT: {{^}} i32.call $push0=, memcpy, $0, $1, $2{{$}}
; CHECK-NEXT: return $pop0{{$}} ; CHECK-NEXT: return $pop0{{$}}
declare i8* @memcpy(i8* returned, i8*, i32) declare i8* @memcpy(i8* returned, i8*, i32)
define i8* @_Z3barPvS_l(i8* %p, i8* %s, i32 %n) { define i8* @_Z3barPvS_l(i8* %p, i8* %s, i32 %n) {
@ -38,7 +38,7 @@ entry:
; CHECK-LABEL: test_constant_arg: ; CHECK-LABEL: test_constant_arg:
; CHECK-NEXT: i32.const $push0=, global{{$}} ; CHECK-NEXT: i32.const $push0=, global{{$}}
; CHECK-NEXT: call $discard=, returns_arg, $pop0{{$}} ; CHECK-NEXT: {{^}} i32.call $discard=, returns_arg, $pop0{{$}}
; CHECK-NEXT: return{{$}} ; CHECK-NEXT: return{{$}}
@global = external global i32 @global = external global i32
@addr = global i32* @global @addr = global i32* @global

View File

@ -22,7 +22,7 @@ define i32 @unused_second(i32 %x, i32 %y) {
} }
; CHECK-LABEL: call_something: ; CHECK-LABEL: call_something:
; CHECK-NEXT: call $discard=, return_something{{$}} ; CHECK-NEXT: {{^}} i32.call $discard=, return_something{{$}}
; CHECK-NEXT: return{{$}} ; CHECK-NEXT: return{{$}}
declare i32 @return_something() declare i32 @return_something()
define void @call_something() { define void @call_something() {