diff options
| author | Dan Gohman <dan433584@gmail.com> | 2016-03-21 19:54:41 +0000 |
|---|---|---|
| committer | Dan Gohman <dan433584@gmail.com> | 2016-03-21 19:54:41 +0000 |
| commit | c8d7f14506afc62f69a802dd56fa95006ae2472b (patch) | |
| tree | f53ae6979655778c5601e5b253c8d67c4761b913 /llvm | |
| parent | 2e5c526bb11b281c86564b3172729ed6aa0d6ed8 (diff) | |
| download | bcm5719-llvm-c8d7f14506afc62f69a802dd56fa95006ae2472b.tar.gz bcm5719-llvm-c8d7f14506afc62f69a802dd56fa95006ae2472b.zip | |
[WebAssembly] Implement the eqz instructions.
llvm-svn: 263976
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyInstrInteger.td | 7 | ||||
| -rw-r--r-- | llvm/test/CodeGen/WebAssembly/i32.ll | 11 | ||||
| -rw-r--r-- | llvm/test/CodeGen/WebAssembly/i64.ll | 11 |
3 files changed, 29 insertions, 0 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrInteger.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrInteger.td index b23e825dbf9..f5404ec8c8a 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrInteger.td +++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrInteger.td @@ -54,6 +54,13 @@ defm CLZ : UnaryInt<ctlz, "clz ">; defm CTZ : UnaryInt<cttz, "ctz ">; defm POPCNT : UnaryInt<ctpop, "popcnt">; +def EQZ_I32 : I<(outs I32:$dst), (ins I32:$src), + [(set I32:$dst, (setcc I32:$src, 0, SETEQ))], + "i32.eqz \t$dst, $src">; +def EQZ_I64 : I<(outs I32:$dst), (ins I64:$src), + [(set I32:$dst, (setcc I64:$src, 0, SETEQ))], + "i64.eqz \t$dst, $src">; + } // Defs = [ARGUMENTS] // Expand the "don't care" operations to supported operations. diff --git a/llvm/test/CodeGen/WebAssembly/i32.ll b/llvm/test/CodeGen/WebAssembly/i32.ll index 10d97ad9e6d..d241b80ed3f 100644 --- a/llvm/test/CodeGen/WebAssembly/i32.ll +++ b/llvm/test/CodeGen/WebAssembly/i32.ll @@ -188,3 +188,14 @@ define i32 @popcnt32(i32 %x) { %a = call i32 @llvm.ctpop.i32(i32 %x) ret i32 %a } + +; CHECK-LABEL: eqz32: +; CHECK-NEXT: .param i32{{$}} +; CHECK-NEXT: .result i32{{$}} +; CHECK-NEXT: i32.eqz $push0=, $0{{$}} +; CHECK-NEXT: return $pop0{{$}} +define i32 @eqz32(i32 %x) { + %a = icmp eq i32 %x, 0 + %b = zext i1 %a to i32 + ret i32 %b +} diff --git a/llvm/test/CodeGen/WebAssembly/i64.ll b/llvm/test/CodeGen/WebAssembly/i64.ll index 6dd46a91fad..c2a1bb6b970 100644 --- a/llvm/test/CodeGen/WebAssembly/i64.ll +++ b/llvm/test/CodeGen/WebAssembly/i64.ll @@ -188,3 +188,14 @@ define i64 @popcnt64(i64 %x) { %a = call i64 @llvm.ctpop.i64(i64 %x) ret i64 %a } + +; CHECK-LABEL: eqz64: +; CHECK-NEXT: .param i64{{$}} +; CHECK-NEXT: .result i32{{$}} +; CHECK-NEXT: i64.eqz $push0=, $0{{$}} +; CHECK-NEXT: return $pop0{{$}} +define i32 @eqz64(i64 %x) { + %a = icmp eq i64 %x, 0 + %b = zext i1 %a to i32 + ret i32 %b +} |

