From 10ad208c62f3054c9f3739159d8ab006ef707683 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Sun, 29 Nov 2015 22:59:19 +0000 Subject: [PATCH] [WebAssembly] Set several MCInstrDesc flags. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254271 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/WebAssembly/WebAssemblyInstrConv.td | 3 +++ lib/Target/WebAssembly/WebAssemblyInstrFloat.td | 6 ++++++ lib/Target/WebAssembly/WebAssemblyInstrInfo.td | 2 ++ lib/Target/WebAssembly/WebAssemblyInstrInteger.td | 9 +++++++++ 4 files changed, 20 insertions(+) diff --git a/lib/Target/WebAssembly/WebAssemblyInstrConv.td b/lib/Target/WebAssembly/WebAssemblyInstrConv.td index a34916eb5a2..4926b8fd872 100644 --- a/lib/Target/WebAssembly/WebAssemblyInstrConv.td +++ b/lib/Target/WebAssembly/WebAssemblyInstrConv.td @@ -26,6 +26,8 @@ def I64_EXTEND_U_I32 : I<(outs I64:$dst), (ins I32:$src), [(set I64:$dst, (zext I32:$src))], "i64.extend_u/i32\t$dst, $src">; +// Conversion from floating point to integer traps on overflow and invalid. +let hasSideEffects = 1 in { def I32_TRUNC_S_F32 : I<(outs I32:$dst), (ins F32:$src), [(set I32:$dst, (fp_to_sint F32:$src))], "i32.trunc_s/f32\t$dst, $src">; @@ -50,6 +52,7 @@ def I64_TRUNC_S_F64 : I<(outs I64:$dst), (ins F64:$src), def I64_TRUNC_U_F64 : I<(outs I64:$dst), (ins F64:$src), [(set I64:$dst, (fp_to_uint F64:$src))], "i64.trunc_u/f64\t$dst, $src">; +} // hasSideEffects = 1 def F32_CONVERT_S_I32 : I<(outs F32:$dst), (ins I32:$src), [(set F32:$dst, (sint_to_fp I32:$src))], diff --git a/lib/Target/WebAssembly/WebAssemblyInstrFloat.td b/lib/Target/WebAssembly/WebAssemblyInstrFloat.td index 0d819581621..d966380e6b0 100644 --- a/lib/Target/WebAssembly/WebAssemblyInstrFloat.td +++ b/lib/Target/WebAssembly/WebAssemblyInstrFloat.td @@ -14,8 +14,10 @@ let Defs = [ARGUMENTS] in { +let isCommutable = 1 in defm ADD : BinaryFP; defm SUB : BinaryFP; +let isCommutable = 1 in defm MUL : BinaryFP; defm DIV : BinaryFP; defm SQRT : UnaryFP; @@ -24,8 +26,10 @@ defm ABS : UnaryFP; defm NEG : UnaryFP; defm COPYSIGN : BinaryFP; +let isCommutable = 1 in { defm MIN : BinaryFP; defm MAX : BinaryFP; +} // isCommutable = 1 defm CEIL : UnaryFP; defm FLOOR : UnaryFP; @@ -40,8 +44,10 @@ def : Pat<(frint f64:$src), (NEAREST_F64 f64:$src)>; let Defs = [ARGUMENTS] in { +let isCommutable = 1 in { defm EQ : ComparisonFP; defm NE : ComparisonFP; +} // isCommutable = 1 defm LT : ComparisonFP; defm LE : ComparisonFP; defm GT : ComparisonFP; diff --git a/lib/Target/WebAssembly/WebAssemblyInstrInfo.td b/lib/Target/WebAssembly/WebAssemblyInstrInfo.td index 52e0bd6e97f..caffac1bc52 100644 --- a/lib/Target/WebAssembly/WebAssemblyInstrInfo.td +++ b/lib/Target/WebAssembly/WebAssemblyInstrInfo.td @@ -115,6 +115,7 @@ defm : LOCAL; defm : LOCAL; defm : LOCAL; +let isMoveImm = 1 in { def CONST_I32 : I<(outs I32:$res), (ins i32imm:$imm), [(set I32:$res, imm:$imm)], "i32.const\t$res, $imm">; @@ -127,6 +128,7 @@ def CONST_F32 : I<(outs F32:$res), (ins f32imm:$imm), def CONST_F64 : I<(outs F64:$res), (ins f64imm:$imm), [(set F64:$res, fpimm:$imm)], "f64.const\t$res, $imm">; +} // isMoveImm = 1 } // Defs = [ARGUMENTS] diff --git a/lib/Target/WebAssembly/WebAssemblyInstrInteger.td b/lib/Target/WebAssembly/WebAssemblyInstrInteger.td index 3fa2f712034..09e5eafb85e 100644 --- a/lib/Target/WebAssembly/WebAssemblyInstrInteger.td +++ b/lib/Target/WebAssembly/WebAssemblyInstrInteger.td @@ -16,22 +16,31 @@ let Defs = [ARGUMENTS] in { // The spaces after the names are for aesthetic purposes only, to make // operands line up vertically after tab expansion. +let isCommutable = 1 in defm ADD : BinaryInt; defm SUB : BinaryInt; +let isCommutable = 1 in defm MUL : BinaryInt; +// Divide and remainder trap on a zero denominator. +let hasSideEffects = 1 in { defm DIV_S : BinaryInt; defm DIV_U : BinaryInt; defm REM_S : BinaryInt; defm REM_U : BinaryInt; +} // hasSideEffects = 1 +let isCommutable = 1 in { defm AND : BinaryInt; defm OR : BinaryInt; defm XOR : BinaryInt; +} // isCommutable = 1 defm SHL : BinaryInt; defm SHR_U : BinaryInt; defm SHR_S : BinaryInt; +let isCommutable = 1 in { defm EQ : ComparisonInt; defm NE : ComparisonInt; +} // isCommutable = 1 defm LT_S : ComparisonInt; defm LE_S : ComparisonInt; defm LT_U : ComparisonInt; -- 2.34.1