-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[WebAssembly] Implement all f16x8 binary instructions. #93360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,33 +16,34 @@ | |
multiclass ABSTRACT_SIMD_I<dag oops_r, dag iops_r, dag oops_s, dag iops_s, | ||
list<dag> pattern_r, string asmstr_r, | ||
string asmstr_s, bits<32> simdop, | ||
Predicate simd_level> { | ||
list<Predicate> reqs> { | ||
defm "" : I<oops_r, iops_r, oops_s, iops_s, pattern_r, asmstr_r, asmstr_s, | ||
!if(!ge(simdop, 0x100), | ||
!or(0xfd0000, !and(0xffff, simdop)), | ||
!or(0xfd00, !and(0xff, simdop)))>, | ||
Requires<[simd_level]>; | ||
Requires<reqs>; | ||
} | ||
|
||
multiclass SIMD_I<dag oops_r, dag iops_r, dag oops_s, dag iops_s, | ||
list<dag> pattern_r, string asmstr_r = "", | ||
string asmstr_s = "", bits<32> simdop = -1> { | ||
string asmstr_s = "", bits<32> simdop = -1, | ||
list<Predicate> reqs = []> { | ||
defm "" : ABSTRACT_SIMD_I<oops_r, iops_r, oops_s, iops_s, pattern_r, asmstr_r, | ||
asmstr_s, simdop, HasSIMD128>; | ||
asmstr_s, simdop, !listconcat([HasSIMD128], reqs)>; | ||
} | ||
|
||
multiclass RELAXED_I<dag oops_r, dag iops_r, dag oops_s, dag iops_s, | ||
list<dag> pattern_r, string asmstr_r = "", | ||
string asmstr_s = "", bits<32> simdop = -1> { | ||
defm "" : ABSTRACT_SIMD_I<oops_r, iops_r, oops_s, iops_s, pattern_r, asmstr_r, | ||
asmstr_s, simdop, HasRelaxedSIMD>; | ||
asmstr_s, simdop, [HasRelaxedSIMD]>; | ||
} | ||
|
||
multiclass HALF_PRECISION_I<dag oops_r, dag iops_r, dag oops_s, dag iops_s, | ||
list<dag> pattern_r, string asmstr_r = "", | ||
string asmstr_s = "", bits<32> simdop = -1> { | ||
defm "" : ABSTRACT_SIMD_I<oops_r, iops_r, oops_s, iops_s, pattern_r, asmstr_r, | ||
asmstr_s, simdop, HasHalfPrecision>; | ||
asmstr_s, simdop, [HasHalfPrecision]>; | ||
} | ||
|
||
|
||
|
@@ -152,6 +153,18 @@ def F64x2 : Vec { | |
let prefix = "f64x2"; | ||
} | ||
|
||
def F16x8 : Vec { | ||
let vt = v8f16; | ||
let int_vt = v8i16; | ||
let lane_vt = f32; | ||
let lane_rc = F32; | ||
let lane_bits = 16; | ||
let lane_idx = LaneIdx8; | ||
let lane_load = int_wasm_loadf16_f32; | ||
let splat = PatFrag<(ops node:$x), (v8f16 (splat_vector (f16 $x)))>; | ||
let prefix = "f16x8"; | ||
} | ||
|
||
defvar AllVecs = [I8x16, I16x8, I32x4, I64x2, F32x4, F64x2]; | ||
defvar IntVecs = [I8x16, I16x8, I32x4, I64x2]; | ||
|
||
|
@@ -781,13 +794,14 @@ def : Pat<(v2i64 (nodes[0] (v2f64 V128:$lhs), (v2f64 V128:$rhs))), | |
// Bitwise operations | ||
//===----------------------------------------------------------------------===// | ||
|
||
multiclass SIMDBinary<Vec vec, SDPatternOperator node, string name, bits<32> simdop> { | ||
multiclass SIMDBinary<Vec vec, SDPatternOperator node, string name, | ||
bits<32> simdop, list<Predicate> reqs = []> { | ||
defm _#vec : SIMD_I<(outs V128:$dst), (ins V128:$lhs, V128:$rhs), | ||
(outs), (ins), | ||
[(set (vec.vt V128:$dst), | ||
(node (vec.vt V128:$lhs), (vec.vt V128:$rhs)))], | ||
vec.prefix#"."#name#"\t$dst, $lhs, $rhs", | ||
vec.prefix#"."#name, simdop>; | ||
vec.prefix#"."#name, simdop, reqs>; | ||
} | ||
|
||
multiclass SIMDBitwise<SDPatternOperator node, string name, bits<32> simdop, | ||
|
@@ -1199,6 +1213,7 @@ def : Pat<(v2f64 (froundeven (v2f64 V128:$src))), (NEAREST_F64x2 V128:$src)>; | |
multiclass SIMDBinaryFP<SDPatternOperator node, string name, bits<32> baseInst> { | ||
defm "" : SIMDBinary<F32x4, node, name, baseInst>; | ||
defm "" : SIMDBinary<F64x2, node, name, !add(baseInst, 12)>; | ||
defm "" : SIMDBinary<F16x8, node, name, !add(baseInst, 80), [HasHalfPrecision]>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand why it's added, and I wish we can multi-inherit from I'm not strongly opinionated about it and it's basically just a matter of preference, but how about adding a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ended up adding |
||
} | ||
|
||
// Addition: add | ||
|
@@ -1242,7 +1257,7 @@ defm PMAX : SIMDBinaryFP<pmax, "pmax", 235>; | |
// Also match the pmin/pmax cases where the operands are int vectors (but the | ||
// comparison is still a floating point comparison). This can happen when using | ||
// the wasm_simd128.h intrinsics because v128_t is an integer vector. | ||
foreach vec = [F32x4, F64x2] in { | ||
foreach vec = [F32x4, F64x2, F16x8] in { | ||
defvar pmin = !cast<NI>("PMIN_"#vec); | ||
defvar pmax = !cast<NI>("PMAX_"#vec); | ||
def : Pat<(vec.int_vt (vselect | ||
|
@@ -1266,6 +1281,10 @@ def : Pat<(v2f64 (int_wasm_pmin (v2f64 V128:$lhs), (v2f64 V128:$rhs))), | |
(PMIN_F64x2 V128:$lhs, V128:$rhs)>; | ||
def : Pat<(v2f64 (int_wasm_pmax (v2f64 V128:$lhs), (v2f64 V128:$rhs))), | ||
(PMAX_F64x2 V128:$lhs, V128:$rhs)>; | ||
def : Pat<(v8f16 (int_wasm_pmin (v8f16 V128:$lhs), (v8f16 V128:$rhs))), | ||
(PMIN_F16x8 V128:$lhs, V128:$rhs)>; | ||
def : Pat<(v8f16 (int_wasm_pmax (v8f16 V128:$lhs), (v8f16 V128:$rhs))), | ||
(PMAX_F16x8 V128:$lhs, V128:$rhs)>; | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Conversions | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that we can't add
F16x8
here, it's not "all vectors" anymore... Should we rename it to something? If so, to what?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope to include F16x8 here when we better support it and the regular patterns work for it. I've added a comment for now, but can change the name if wanted.