diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h @@ -325,30 +325,10 @@ case WebAssembly::ATOMIC_WAIT_I64: case WebAssembly::ATOMIC_WAIT_I64_S: return 3; - case WebAssembly::LOAD_v16i8: - case WebAssembly::LOAD_v16i8_S: - case WebAssembly::LOAD_v8i16: - case WebAssembly::LOAD_v8i16_S: - case WebAssembly::LOAD_v4i32: - case WebAssembly::LOAD_v4i32_S: - case WebAssembly::LOAD_v2i64: - case WebAssembly::LOAD_v2i64_S: - case WebAssembly::LOAD_v4f32: - case WebAssembly::LOAD_v4f32_S: - case WebAssembly::LOAD_v2f64: - case WebAssembly::LOAD_v2f64_S: - case WebAssembly::STORE_v16i8: - case WebAssembly::STORE_v16i8_S: - case WebAssembly::STORE_v8i16: - case WebAssembly::STORE_v8i16_S: - case WebAssembly::STORE_v4i32: - case WebAssembly::STORE_v4i32_S: - case WebAssembly::STORE_v2i64: - case WebAssembly::STORE_v2i64_S: - case WebAssembly::STORE_v4f32: - case WebAssembly::STORE_v4f32_S: - case WebAssembly::STORE_v2f64: - case WebAssembly::STORE_v2f64_S: + case WebAssembly::LOAD_V128: + case WebAssembly::LOAD_V128_S: + case WebAssembly::STORE_V128: + case WebAssembly::STORE_V128_S: return 4; default: return -1; diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrAtomics.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrAtomics.td --- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrAtomics.td +++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrAtomics.td @@ -71,12 +71,6 @@ def : NotifyPatImmOff; def : NotifyPatImmOff; -def NotifyPatGlobalAddr : - Pat<(i32 (int_wasm_atomic_notify (regPlusGA I32:$addr, - (WebAssemblywrapper tglobaladdr:$off)), - I32:$count)), - (ATOMIC_NOTIFY 0, tglobaladdr:$off, I32:$addr, I32:$count)>; - // Select notifys with just a constant offset. def NotifyPatOffsetOnly : Pat<(i32 (int_wasm_atomic_notify imm:$off, I32:$count)), @@ -105,13 +99,6 @@ def : WaitPatImmOff; def : WaitPatImmOff; -class WaitPatGlobalAddr : - Pat<(i32 (kind (regPlusGA I32:$addr, (WebAssemblywrapper tglobaladdr:$off)), - ty:$exp, I64:$timeout)), - (inst 0, tglobaladdr:$off, I32:$addr, ty:$exp, I64:$timeout)>; -def : WaitPatGlobalAddr; -def : WaitPatGlobalAddr; - // Select wait_i32, ATOMIC_WAIT_I32s with just a constant offset. class WaitPatOffsetOnly : Pat<(i32 (kind imm:$off, ty:$exp, I64:$timeout)), @@ -164,9 +151,6 @@ def : LoadPatImmOff; def : LoadPatImmOff; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; - // Select loads with just a constant offset. def : LoadPatOffsetOnly; def : LoadPatOffsetOnly; @@ -257,16 +241,6 @@ def : LoadPatImmOff; // No 32->64 patterns, just use i32.atomic.load and i64.extend_s/i64 -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; - // Extending loads with just a constant offset def : LoadPatOffsetOnly; def : LoadPatOffsetOnly; @@ -326,13 +300,6 @@ def : AStorePatImmOff; def : AStorePatImmOff; -class AStorePatGlobalAddr : - Pat<(kind (regPlusGA I32:$addr, (WebAssemblywrapper tglobaladdr:$off)), - ty:$val), - (inst 0, tglobaladdr:$off, I32:$addr, ty:$val)>; -def : AStorePatGlobalAddr; -def : AStorePatGlobalAddr; - // Select stores with just a constant offset. class AStorePatOffsetOnly : Pat<(kind imm:$off, ty:$val), (inst 0, imm:$off, (CONST_I32 0), ty:$val)>; @@ -387,12 +354,6 @@ def : AStorePatImmOff; def : AStorePatImmOff; -def : AStorePatGlobalAddr; -def : AStorePatGlobalAddr; -def : AStorePatGlobalAddr; -def : AStorePatGlobalAddr; -def : AStorePatGlobalAddr; - // Truncating stores with just a constant offset def : AStorePatOffsetOnly; def : AStorePatOffsetOnly; @@ -513,11 +474,6 @@ Pat<(ty (kind (operand I32:$addr, imm:$off), ty:$val)), (inst 0, imm:$off, I32:$addr, ty:$val)>; -class BinRMWPatGlobalAddr : - Pat<(ty (kind (regPlusGA I32:$addr, (WebAssemblywrapper tglobaladdr:$off)), - ty:$val)), - (inst 0, tglobaladdr:$off, I32:$addr, ty:$val)>; - // Select binary RMWs with just a constant offset. class BinRMWPatOffsetOnly : Pat<(ty (kind imm:$off, ty:$val)), @@ -538,9 +494,6 @@ def : BinRMWPatImmOff; def : BinRMWPatImmOff; - def : BinRMWPatGlobalAddr; - def : BinRMWPatGlobalAddr; - def : BinRMWPatOffsetOnly; def : BinRMWPatOffsetOnly; @@ -635,17 +588,6 @@ def : BinRMWPatImmOff, or_is_add, inst8_64>; def : BinRMWPatImmOff, or_is_add, inst16_64>; - def : BinRMWPatGlobalAddr, inst8_32>; - def : BinRMWPatGlobalAddr, inst16_32>; - def : BinRMWPatGlobalAddr, inst8_64>; - def : BinRMWPatGlobalAddr, inst16_64>; - def : BinRMWPatGlobalAddr, inst32_64>; - - def : BinRMWPatGlobalAddr, inst8_32>; - def : BinRMWPatGlobalAddr, inst16_32>; - def : BinRMWPatGlobalAddr, inst8_64>; - def : BinRMWPatGlobalAddr, inst16_64>; - // Truncating-extending binary RMWs with just a constant offset def : BinRMWPatOffsetOnly, inst8_32>; def : BinRMWPatOffsetOnly, inst16_32>; @@ -745,11 +687,6 @@ Pat<(ty (kind (operand I32:$addr, imm:$off), ty:$exp, ty:$new)), (inst 0, imm:$off, I32:$addr, ty:$exp, ty:$new)>; -class TerRMWPatGlobalAddr : - Pat<(ty (kind (regPlusGA I32:$addr, (WebAssemblywrapper tglobaladdr:$off)), - ty:$exp, ty:$new)), - (inst 0, tglobaladdr:$off, I32:$addr, ty:$exp, ty:$new)>; - // Select ternary RMWs with just a constant offset. class TerRMWPatOffsetOnly : Pat<(ty (kind imm:$off, ty:$exp, ty:$new)), @@ -770,9 +707,6 @@ def : TerRMWPatImmOff; def : TerRMWPatImmOff; - def : TerRMWPatGlobalAddr; - def : TerRMWPatGlobalAddr; - def : TerRMWPatOffsetOnly; def : TerRMWPatOffsetOnly; @@ -859,17 +793,6 @@ def : TerRMWPatImmOff, or_is_add, inst8_64>; def : TerRMWPatImmOff, or_is_add, inst16_64>; - def : TerRMWPatGlobalAddr, inst8_32>; - def : TerRMWPatGlobalAddr, inst16_32>; - def : TerRMWPatGlobalAddr, inst8_64>; - def : TerRMWPatGlobalAddr, inst16_64>; - def : TerRMWPatGlobalAddr, inst32_64>; - - def : TerRMWPatGlobalAddr, inst8_32>; - def : TerRMWPatGlobalAddr, inst16_32>; - def : TerRMWPatGlobalAddr, inst8_64>; - def : TerRMWPatGlobalAddr, inst16_64>; - // Truncating-extending ternary RMWs with just a constant offset def : TerRMWPatOffsetOnly, inst8_32>; def : TerRMWPatOffsetOnly, inst16_32>; diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td --- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td +++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td @@ -37,16 +37,6 @@ return (~Known0.Zero & ~Known1.Zero) == 0; }]>; -// GlobalAddresses are conceptually unsigned values, so we can also fold them -// into immediate values as long as the add is 'nuw'. -// TODO: We'd like to also match GA offsets but there are cases where the -// register can have a negative value. Find out what more we can do. -def regPlusGA : PatFrag<(ops node:$addr, node:$off), - (add node:$addr, node:$off), - [{ - return N->getFlags().hasNoUnsignedWrap(); -}]>; - // We don't need a regPlusES because external symbols never have constant // offsets folded into them, so we can just use add. @@ -93,15 +83,6 @@ def : LoadPatImmOff; def : LoadPatImmOff; -class LoadPatGlobalAddr : - Pat<(ty (kind (regPlusGA I32:$addr, (WebAssemblywrapper tglobaladdr:$off)))), - (inst 0, tglobaladdr:$off, I32:$addr)>, Requires<[IsNotPIC]>; - -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; - // Select loads with just a constant offset. class LoadPatOffsetOnly : Pat<(ty (kind imm:$off)), (inst 0, imm:$off, (CONST_I32 0))>; @@ -167,18 +148,6 @@ def : LoadPatImmOff; def : LoadPatImmOff; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; - -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; - // Select extending loads with just a constant offset. def : LoadPatOffsetOnly; def : LoadPatOffsetOnly; @@ -224,11 +193,6 @@ def : LoadPatImmOff; def : LoadPatImmOff; def : LoadPatImmOff; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; -def : LoadPatGlobalAddr; // Select "don't care" extending loads with just a constant offset. def : LoadPatOffsetOnly; @@ -282,15 +246,6 @@ def : StorePatImmOff; def : StorePatImmOff; -class StorePatGlobalAddr : - Pat<(kind ty:$val, - (regPlusGA I32:$addr, (WebAssemblywrapper tglobaladdr:$off))), - (inst 0, tglobaladdr:$off, I32:$addr, ty:$val)>, Requires<[IsNotPIC]>; -def : StorePatGlobalAddr; -def : StorePatGlobalAddr; -def : StorePatGlobalAddr; -def : StorePatGlobalAddr; - // Select stores with just a constant offset. class StorePatOffsetOnly : Pat<(kind ty:$val, imm:$off), (inst 0, imm:$off, (CONST_I32 0), ty:$val)>; @@ -333,12 +288,6 @@ def : StorePatImmOff; def : StorePatImmOff; -def : StorePatGlobalAddr; -def : StorePatGlobalAddr; -def : StorePatGlobalAddr; -def : StorePatGlobalAddr; -def : StorePatGlobalAddr; - // Select truncating stores with just a constant offset. def : StorePatOffsetOnly; def : StorePatOffsetOnly; diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td --- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td +++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td @@ -40,47 +40,37 @@ //===----------------------------------------------------------------------===// // Load: v128.load -multiclass SIMDLoad { - let mayLoad = 1, UseNamedOperandTable = 1 in - defm LOAD_#vec_t : - SIMD_I<(outs V128:$dst), (ins P2Align:$p2align, offset32_op:$off, I32:$addr), - (outs), (ins P2Align:$p2align, offset32_op:$off), [], - "v128.load\t$dst, ${off}(${addr})$p2align", - "v128.load\t$off$p2align", 0>; -} - -foreach vec_t = [v16i8, v8i16, v4i32, v2i64, v4f32, v2f64] in { -defm "" : SIMDLoad; +let mayLoad = 1, UseNamedOperandTable = 1 in +defm LOAD_V128 : + SIMD_I<(outs V128:$dst), (ins P2Align:$p2align, offset32_op:$off, I32:$addr), + (outs), (ins P2Align:$p2align, offset32_op:$off), [], + "v128.load\t$dst, ${off}(${addr})$p2align", + "v128.load\t$off$p2align", 0>; // Def load and store patterns from WebAssemblyInstrMemory.td for vector types -def : LoadPatNoOffset("LOAD_"#vec_t)>; -def : LoadPatImmOff("LOAD_"#vec_t)>; -def : LoadPatImmOff("LOAD_"#vec_t)>; -def : LoadPatGlobalAddr("LOAD_"#vec_t)>; -def : LoadPatOffsetOnly("LOAD_"#vec_t)>; -def : LoadPatGlobalAddrOffOnly("LOAD_"#vec_t)>; +foreach vec_t = [v16i8, v8i16, v4i32, v2i64, v4f32, v2f64] in { +def : LoadPatNoOffset; +def : LoadPatImmOff; +def : LoadPatImmOff; +def : LoadPatOffsetOnly; +def : LoadPatGlobalAddrOffOnly; } // Store: v128.store -multiclass SIMDStore { - let mayStore = 1, UseNamedOperandTable = 1 in - defm STORE_#vec_t : - SIMD_I<(outs), (ins P2Align:$p2align, offset32_op:$off, I32:$addr, V128:$vec), - (outs), (ins P2Align:$p2align, offset32_op:$off), [], - "v128.store\t${off}(${addr})$p2align, $vec", - "v128.store\t$off$p2align", 1>; -} +let mayStore = 1, UseNamedOperandTable = 1 in +defm STORE_V128 : + SIMD_I<(outs), (ins P2Align:$p2align, offset32_op:$off, I32:$addr, V128:$vec), + (outs), (ins P2Align:$p2align, offset32_op:$off), [], + "v128.store\t${off}(${addr})$p2align, $vec", + "v128.store\t$off$p2align", 1>; foreach vec_t = [v16i8, v8i16, v4i32, v2i64, v4f32, v2f64] in { -defm "" : SIMDStore; - // Def load and store patterns from WebAssemblyInstrMemory.td for vector types -def : StorePatNoOffset("STORE_"#vec_t)>; -def : StorePatImmOff("STORE_"#vec_t)>; -def : StorePatImmOff("STORE_"#vec_t)>; -def : StorePatGlobalAddr("STORE_"#vec_t)>; -def : StorePatOffsetOnly("STORE_"#vec_t)>; -def : StorePatGlobalAddrOffOnly("STORE_"#vec_t)>; +def : StorePatNoOffset; +def : StorePatImmOff; +def : StorePatImmOff; +def : StorePatOffsetOnly; +def : StorePatGlobalAddrOffOnly; } //===----------------------------------------------------------------------===// @@ -90,7 +80,7 @@ // Constant: v128.const multiclass ConstVec { let isMoveImm = 1, isReMaterializable = 1, - Predicates = [HasSIMD128, HasUnimplementedSIMD128] in + Predicates = [HasUnimplementedSIMD128] in defm CONST_V128_#vec_t : SIMD_I<(outs V128:$dst), ops, (outs), ops, [(set V128:$dst, (vec_t pat))], "v128.const\t$dst, "#args, @@ -286,7 +276,7 @@ } defm "" : ExtractLaneExtended<"_s", 5>; -let Predicates = [HasSIMD128, HasUnimplementedSIMD128] in +let Predicates = [HasUnimplementedSIMD128] in defm "" : ExtractLaneExtended<"_u", 6>; defm "" : ExtractLane; defm "" : ExtractLane; @@ -655,7 +645,7 @@ defm NEG : SIMDUnaryFP; // Square root: sqrt -let Predicates = [HasSIMD128, HasUnimplementedSIMD128] in +let Predicates = [HasUnimplementedSIMD128] in defm SQRT : SIMDUnaryFP; //===----------------------------------------------------------------------===// @@ -679,7 +669,7 @@ defm MUL : SIMDBinaryFP; // Division: div -let Predicates = [HasSIMD128, HasUnimplementedSIMD128] in +let Predicates = [HasUnimplementedSIMD128] in defm DIV : SIMDBinaryFP; // NaN-propagating minimum: min @@ -772,6 +762,7 @@ //===----------------------------------------------------------------------===// // Quasi-Fused Multiply- Add and Subtract (QFMA/QFMS) //===----------------------------------------------------------------------===// + multiclass SIMDQFM baseInst> { defm QFMA_#vec_t : SIMD_I<(outs V128:$dst), (ins V128:$a, V128:$b, V128:$c),