[llvm] r342689 - [WebAssembly] Add V128 value type to binary format
Thomas Lively via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 20 15:04:44 PDT 2018
Author: tlively
Date: Thu Sep 20 15:04:44 2018
New Revision: 342689
URL: http://llvm.org/viewvc/llvm-project?rev=342689&view=rev
Log:
[WebAssembly] Add V128 value type to binary format
Summary: Adds the necessary support to lib/ObjectYAML and fixes SIMD
calls to allow the tests to work. Also removes some dead code that
would otherwise have to have been updated.
Reviewers: aheejin, dschuff, sbc100
Subscribers: jgravelle-google, sunfish, llvm-commits
Differential Revision: https://reviews.llvm.org/D52105
Added:
llvm/trunk/test/MC/WebAssembly/types.ll
Modified:
llvm/trunk/include/llvm/BinaryFormat/Wasm.h
llvm/trunk/lib/ObjectYAML/WasmYAML.cpp
llvm/trunk/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
llvm/trunk/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.h
llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp
llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrCall.td
llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
llvm/trunk/test/CodeGen/WebAssembly/call.ll
Modified: llvm/trunk/include/llvm/BinaryFormat/Wasm.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BinaryFormat/Wasm.h?rev=342689&r1=342688&r2=342689&view=diff
==============================================================================
--- llvm/trunk/include/llvm/BinaryFormat/Wasm.h (original)
+++ llvm/trunk/include/llvm/BinaryFormat/Wasm.h Thu Sep 20 15:04:44 2018
@@ -191,6 +191,7 @@ enum : unsigned {
WASM_TYPE_I64 = 0x7E,
WASM_TYPE_F32 = 0x7D,
WASM_TYPE_F64 = 0x7C,
+ WASM_TYPE_V128 = 0x7B,
WASM_TYPE_ANYFUNC = 0x70,
WASM_TYPE_EXCEPT_REF = 0x68,
WASM_TYPE_FUNC = 0x60,
@@ -225,6 +226,7 @@ enum class ValType {
I64 = WASM_TYPE_I64,
F32 = WASM_TYPE_F32,
F64 = WASM_TYPE_F64,
+ V128 = WASM_TYPE_V128,
EXCEPT_REF = WASM_TYPE_EXCEPT_REF,
};
Modified: llvm/trunk/lib/ObjectYAML/WasmYAML.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ObjectYAML/WasmYAML.cpp?rev=342689&r1=342688&r2=342689&view=diff
==============================================================================
--- llvm/trunk/lib/ObjectYAML/WasmYAML.cpp (original)
+++ llvm/trunk/lib/ObjectYAML/WasmYAML.cpp Thu Sep 20 15:04:44 2018
@@ -452,6 +452,7 @@ void ScalarEnumerationTraits<WasmYAML::V
ECase(I64);
ECase(F32);
ECase(F64);
+ ECase(V128);
ECase(ANYFUNC);
ECase(FUNC);
ECase(NORESULT);
Modified: llvm/trunk/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp?rev=342689&r1=342688&r2=342689&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp Thu Sep 20 15:04:44 2018
@@ -258,19 +258,3 @@ const char *llvm::WebAssembly::TypeToStr
llvm_unreachable("unsupported type");
}
}
-
-const char *llvm::WebAssembly::TypeToString(wasm::ValType Type) {
- switch (Type) {
- case wasm::ValType::I32:
- return "i32";
- case wasm::ValType::I64:
- return "i64";
- case wasm::ValType::F32:
- return "f32";
- case wasm::ValType::F64:
- return "f64";
- case wasm::ValType::EXCEPT_REF:
- return "except_ref";
- }
- llvm_unreachable("unsupported type");
-}
Modified: llvm/trunk/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.h?rev=342689&r1=342688&r2=342689&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.h (original)
+++ llvm/trunk/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.h Thu Sep 20 15:04:44 2018
@@ -51,7 +51,6 @@ public:
namespace WebAssembly {
const char *TypeToString(MVT Ty);
-const char *TypeToString(wasm::ValType Type);
} // end namespace WebAssembly
Modified: llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp?rev=342689&r1=342688&r2=342689&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp Thu Sep 20 15:04:44 2018
@@ -133,6 +133,13 @@ wasm::ValType WebAssembly::toValType(con
return wasm::ValType::F32;
case MVT::f64:
return wasm::ValType::F64;
+ case MVT::v16i8:
+ case MVT::v8i16:
+ case MVT::v4i32:
+ case MVT::v2i64:
+ case MVT::v4f32:
+ case MVT::v2f64:
+ return wasm::ValType::V128;
case MVT::ExceptRef:
return wasm::ValType::EXCEPT_REF;
default:
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrCall.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrCall.td?rev=342689&r1=342688&r2=342689&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrCall.td (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrCall.td Thu Sep 20 15:04:44 2018
@@ -89,12 +89,12 @@ let Uses = [SP32, SP64], isCall = 1 in {
defm "" : CALL<F32, "f32.">;
defm "" : CALL<F64, "f64.">;
defm "" : CALL<EXCEPT_REF, "except_ref.">;
- defm "" : SIMD_CALL<v16i8, "i8x16.">;
- defm "" : SIMD_CALL<v8i16, "i16x8.">;
- defm "" : SIMD_CALL<v4i32, "i32x4.">;
- defm "" : SIMD_CALL<v2i64, "i64x2.">;
- defm "" : SIMD_CALL<v4f32, "f32x4.">;
- defm "" : SIMD_CALL<v2f64, "f64x2.">;
+ defm "" : SIMD_CALL<v16i8, "v128.">;
+ defm "" : SIMD_CALL<v8i16, "v128.">;
+ defm "" : SIMD_CALL<v4i32, "v128.">;
+ defm "" : SIMD_CALL<v2i64, "v128.">;
+ defm "" : SIMD_CALL<v4f32, "v128.">;
+ defm "" : SIMD_CALL<v2f64, "v128.">;
defm CALL_VOID : I<(outs), (ins function32_op:$callee, variable_ops),
(outs), (ins function32_op:$callee),
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp?rev=342689&r1=342688&r2=342689&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp Thu Sep 20 15:04:44 2018
@@ -149,6 +149,8 @@ static wasm::ValType getType(const Targe
return wasm::ValType::F32;
if (RC == &WebAssembly::F64RegClass)
return wasm::ValType::F64;
+ if (RC == &WebAssembly::V128RegClass)
+ return wasm::ValType::V128;
llvm_unreachable("Unexpected register class");
}
Modified: llvm/trunk/test/CodeGen/WebAssembly/call.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/call.ll?rev=342689&r1=342688&r2=342689&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/call.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/call.ll Thu Sep 20 15:04:44 2018
@@ -1,5 +1,5 @@
-; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -wasm-temporary-workarounds=false | FileCheck %s
-; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -fast-isel -fast-isel-abort=1 -wasm-temporary-workarounds=false | FileCheck %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -wasm-temporary-workarounds=false -mattr=+sign-ext,+simd128 | FileCheck %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -fast-isel -fast-isel-abort=1 -wasm-temporary-workarounds=false -mattr=+sign-ext,+simd128 | FileCheck %s
; Test that basic call operations assemble as expected.
@@ -12,6 +12,7 @@ declare i32 @i32_binary(i32, i32)
declare i64 @i64_nullary()
declare float @float_nullary()
declare double @double_nullary()
+declare <16 x i8> @v128_nullary()
declare void @void_nullary()
; CHECK-LABEL: call_i32_nullary:
@@ -50,6 +51,15 @@ define double @call_double_nullary() {
ret double %r
}
+; CHECK-LABEL: call_v128_nullary:
+; CHECK-NEXT: .result v128{{$}}
+; CHECK-NEXT: {{^}} v128.call $push[[NUM:[0-9]+]]=, v128_nullary at FUNCTION{{$}}
+; CHECK-NEXT: return $pop[[NUM]]{{$}}
+define <16 x i8> @call_v128_nullary() {
+ %r = call <16 x i8> @v128_nullary()
+ ret <16 x i8> %r
+}
+
; CHECK-LABEL: call_void_nullary:
; CHECK-NEXT: {{^}} call void_nullary at FUNCTION{{$}}
; CHECK-NEXT: return{{$}}
@@ -102,6 +112,17 @@ define i32 @call_indirect_i32(i32 ()* %c
ret i32 %t
}
+; CHECK-LABEL: call_indirect_v128:
+; CHECK-NEXT: .param i32{{$}}
+; CHECK-NEXT: .result v128{{$}}
+; CHECK-NEXT: get_local $push[[L0:[0-9]+]]=, 0{{$}}
+; CHECK-NEXT: {{^}} v128.call_indirect $push[[NUM:[0-9]+]]=, $pop[[L0]]{{$}}
+; CHECK-NEXT: return $pop[[NUM]]{{$}}
+define <16 x i8> @call_indirect_v128(<16 x i8> ()* %callee) {
+ %t = call <16 x i8> %callee()
+ ret <16 x i8> %t
+}
+
; CHECK-LABEL: call_indirect_arg:
; CHECK-NEXT: .param i32, i32{{$}}
; CHECK-NEXT: get_local $push[[L0:[0-9]+]]=, 1{{$}}
Added: llvm/trunk/test/MC/WebAssembly/types.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/types.ll?rev=342689&view=auto
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/types.ll (added)
+++ llvm/trunk/test/MC/WebAssembly/types.ll Thu Sep 20 15:04:44 2018
@@ -0,0 +1,52 @@
+; RUN: llc -wasm-enable-unimplemented-simd -mattr=+sign-ext,+simd128 -filetype=obj %s -o - | obj2yaml | FileCheck %s
+
+target triple = "wasm32-unknown-unknown"
+
+declare i32 @i32()
+declare i64 @i64()
+declare float @f32()
+declare double @f64()
+declare <16 x i8> @v16i8()
+declare <8 x i16> @v8i16()
+declare <4 x i32> @v4i32()
+declare <2 x i64> @v2i64()
+declare <4 x float> @v4f32()
+declare <2 x double> @v2f64()
+
+define void @f1() {
+entry:
+ %tmp1 = call i32 @i32()
+ %tmp2 = call i64 @i64()
+ %tmp3 = call float @f32()
+ %tmp4 = call double @f64()
+ %tmp5 = call <16 x i8> @v16i8()
+ %tmp6 = call <8 x i16> @v8i16()
+ %tmp7 = call <4 x i32> @v4i32()
+ %tmp8 = call <2 x i64> @v2i64()
+ %tmp9 = call <4 x float> @v4f32()
+ %tmp10 = call <2 x double> @v2f64()
+ ret void
+}
+
+; CHECK-LABEL: - Type: TYPE
+; CHECK-NEXT: Signatures:
+; CHECK-NEXT: - Index: 0
+; CHECK-NEXT: ReturnType: NORESULT
+; CHECK-NEXT: ParamTypes:
+; CHECK-NEXT: - Index: 1
+; CHECK-NEXT: ReturnType: I32
+; CHECK-NEXT: ParamTypes:
+; CHECK-NEXT: - Index: 2
+; CHECK-NEXT: ReturnType: I64
+; CHECK-NEXT: ParamTypes:
+; CHECK-NEXT: - Index: 3
+; CHECK-NEXT: ReturnType: F32
+; CHECK-NEXT: ParamTypes:
+; CHECK-NEXT: - Index: 4
+; CHECK-NEXT: ReturnType: F64
+; CHECK-NEXT: ParamTypes:
+; CHECK-NEXT: - Index: 5
+; CHECK-NEXT: ReturnType: V128
+; CHECK-NEXT: ParamTypes:
+; should be no additional types
+; CHECK-NOT: ReturnType
More information about the llvm-commits
mailing list