From 5222cb601b9a04df93cc3603ede80cc0e3dc9940 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Wed, 15 Aug 2018 18:15:18 +0000 Subject: [PATCH] [WebAssembly][NFC] Standardize SIMD multiclass format Summary: This CL changes the ExtractLane ISEL multiclass to more closely mirror the structure of the splat and replace_lane multiclasses. Reviewers: aheejin, dschuff Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D50794 llvm-svn: 339801 --- .../lib/Target/WebAssembly/WebAssemblyInstrSIMD.td | 66 ++++++++++------------ 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td index aec83cb..2a45051 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td +++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td @@ -18,14 +18,15 @@ foreach SIZE = [2, 4, 8, 16, 32] in def LaneIdx#SIZE : ImmLeaf; // lane extraction -multiclass ExtractLane simdop, - SDNode extract = vector_extract> { - defm "" : SIMD_I<(outs reg_t:$dst), (ins V128:$vec, I32:$idx), - (outs), (ins I32:$idx), - [(set reg_t:$dst, - (extract (vec_t V128:$vec), (i32 imm_t:$idx)))], - name#"\t$dst, $vec, $idx", name#"\t$idx", simdop>; +multiclass ExtractLane simdop, + string suffix = "", SDNode extract = vector_extract> { + defm EXTRACT_LANE_#vec_t#suffix : + SIMD_I<(outs reg_t:$dst), (ins V128:$vec, I32:$idx), + (outs), (ins I32:$idx), + [(set reg_t:$dst, (extract (vec_t V128:$vec), (i32 imm_t:$idx)))], + vec#".extract_lane"#suffix#"\t$dst, $vec, $idx", + vec#".extract_lane"#suffix#"\t$idx", simdop>; } multiclass ExtractPat { def _s : PatFrag<(ops node:$vec, node:$idx), @@ -48,43 +49,36 @@ multiclass ExtractPat { defm extract_i8x16 : ExtractPat; defm extract_i16x8 : ExtractPat; multiclass ExtractLaneExtended baseInst> { - defm _I8x16 : ExtractLane("extract_i8x16"#sign)>; - defm _I16x8 : ExtractLane("extract_i16x8"#sign)>; + defm "" : ExtractLane("extract_i8x16"#sign)>; + defm "" : ExtractLane("extract_i16x8"#sign)>; } let Defs = [ARGUMENTS] in { -defm EXTRACT_LANE_S : ExtractLaneExtended<"_s", 9>; -defm EXTRACT_LANE_U : ExtractLaneExtended<"_u", 10>; -defm EXTRACT_LANE_I32x4 : - ExtractLane; -defm EXTRACT_LANE_I64x2 : - ExtractLane; -defm EXTRACT_LANE_F32x4 : - ExtractLane; -defm EXTRACT_LANE_F64x2 : - ExtractLane; +defm "" : ExtractLaneExtended<"_s", 9>; +defm "" : ExtractLaneExtended<"_u", 10>; +defm "" : ExtractLane; +defm "" : ExtractLane; +defm "" : ExtractLane; +defm "" : ExtractLane; } // Defs = [ARGUMENTS] // follow convention of making implicit expansions unsigned def : Pat<(i32 (vector_extract (v16i8 V128:$vec), (i32 LaneIdx16:$idx))), - (EXTRACT_LANE_U_I8x16 V128:$vec, (i32 LaneIdx16:$idx))>; + (EXTRACT_LANE_v16i8_u V128:$vec, (i32 LaneIdx16:$idx))>; def : Pat<(i32 (vector_extract (v8i16 V128:$vec), (i32 LaneIdx8:$idx))), - (EXTRACT_LANE_U_I16x8 V128:$vec, (i32 LaneIdx8:$idx))>; + (EXTRACT_LANE_v8i16_u V128:$vec, (i32 LaneIdx8:$idx))>; // lane replacement multiclass ReplaceLane simdop> { - defm REPLACE_LANE_#vec_t : SIMD_I<(outs V128:$dst), - (ins V128:$vec, I32:$idx, reg_t:$x), - (outs), (ins I32:$idx), - [(set V128:$dst, (vector_insert - (vec_t V128:$vec), - (lane_t reg_t:$x), - (i32 imm_t:$idx)))], - vec#".replace_lane\t$dst, $vec, $idx, $x", - vec#".replace_lane\t$idx", simdop>; + defm REPLACE_LANE_#vec_t : + SIMD_I<(outs V128:$dst), (ins V128:$vec, I32:$idx, reg_t:$x), + (outs), (ins I32:$idx), + [(set V128:$dst, (vector_insert + (vec_t V128:$vec), (lane_t reg_t:$x), (i32 imm_t:$idx)))], + vec#".replace_lane\t$dst, $vec, $idx, $x", + vec#".replace_lane\t$idx", simdop>; } let Defs = [ARGUMENTS] in { defm "" : ReplaceLane; @@ -107,11 +101,11 @@ def splat16 : PatFrag<(ops node:$x), (build_vector node:$x, node:$x, node:$x, node:$x, node:$x, node:$x, node:$x, node:$x, node:$x, node:$x, node:$x, node:$x)>; -multiclass Splat simdop> { defm SPLAT_#vec_t : SIMD_I<(outs V128:$dst), (ins reg_t:$x), (outs), (ins), [(set (vec_t V128:$dst), (splat_pat reg_t:$x))], - name#".splat\t$dst, $x", name#".splat", simdop>; + vec#".splat\t$dst, $x", vec#".splat", simdop>; } let Defs = [ARGUMENTS] in { defm "" : Splat; -- 2.7.4