x64: port fcmp to ISLE (#3967)
* x64: port scalar `fcmp` to ISLE Implement the CLIF lowering for the `fcmp` to ISLE. This adds a new type-matcher, `ty_scalar_float`, for detecting uses of `F32` and `F64`. * isle: rename `vec128` to `ty_vec12` This refactoring changes the name of the `vec128` matcher function to follow the `ty_*` convention of the other type matchers. It also makes the helper an inline function call. * x64: port vector `fcmp` to ISLE
This commit is contained in:
@@ -145,22 +145,22 @@
|
||||
|
||||
;;;; Rules for `uadd_sat` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule (lower (has_type (vec128 ty) (uadd_sat x y)))
|
||||
(rule (lower (has_type (ty_vec128 ty) (uadd_sat x y)))
|
||||
(uqadd x y (vector_size ty)))
|
||||
|
||||
;;;; Rules for `sadd_sat` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule (lower (has_type (vec128 ty) (sadd_sat x y)))
|
||||
(rule (lower (has_type (ty_vec128 ty) (sadd_sat x y)))
|
||||
(sqadd x y (vector_size ty)))
|
||||
|
||||
;;;; Rules for `usub_sat` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule (lower (has_type (vec128 ty) (usub_sat x y)))
|
||||
(rule (lower (has_type (ty_vec128 ty) (usub_sat x y)))
|
||||
(uqsub x y (vector_size ty)))
|
||||
|
||||
;;;; Rules for `ssub_sat` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule (lower (has_type (vec128 ty) (ssub_sat x y)))
|
||||
(rule (lower (has_type (ty_vec128 ty) (ssub_sat x y)))
|
||||
(sqsub x y (vector_size ty)))
|
||||
|
||||
;;;; Rules for `ineg` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@@ -170,7 +170,7 @@
|
||||
(sub ty (zero_reg) x))
|
||||
|
||||
;; vectors.
|
||||
(rule (lower (has_type (vec128 ty) (ineg x)))
|
||||
(rule (lower (has_type (ty_vec128 ty) (ineg x)))
|
||||
(neg x (vector_size ty)))
|
||||
|
||||
;;;; Rules for `imul` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@@ -208,7 +208,7 @@
|
||||
(value_regs dst_lo dst_hi)))
|
||||
|
||||
;; Case for i8x16, i16x8, and i32x4.
|
||||
(rule (lower (has_type (vec128 ty @ (not_i64x2)) (imul x y)))
|
||||
(rule (lower (has_type (ty_vec128 ty @ (not_i64x2)) (imul x y)))
|
||||
(mul x y (vector_size ty)))
|
||||
|
||||
;; Special lowering for i64x2.
|
||||
@@ -575,7 +575,7 @@
|
||||
(value_regs new_lo new_hi)))
|
||||
|
||||
;; Implementation of `bnot` for vector types.
|
||||
(rule (lower (has_type (vec128 ty) (bnot x)))
|
||||
(rule (lower (has_type (ty_vec128 ty) (bnot x)))
|
||||
(not x (vector_size ty)))
|
||||
|
||||
;;;; Rules for `band` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@@ -588,7 +588,7 @@
|
||||
|
||||
(rule (lower (has_type $I128 (band x y))) (i128_alu_bitop (ALUOp.And) $I64 x y))
|
||||
|
||||
(rule (lower (has_type (vec128 ty) (band x y)))
|
||||
(rule (lower (has_type (ty_vec128 ty) (band x y)))
|
||||
(and_vec x y (vector_size ty)))
|
||||
|
||||
;;;; Rules for `bor` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@@ -601,7 +601,7 @@
|
||||
|
||||
(rule (lower (has_type $I128 (bor x y))) (i128_alu_bitop (ALUOp.Orr) $I64 x y))
|
||||
|
||||
(rule (lower (has_type (vec128 ty) (bor x y)))
|
||||
(rule (lower (has_type (ty_vec128 ty) (bor x y)))
|
||||
(orr_vec x y (vector_size ty)))
|
||||
|
||||
;;;; Rules for `bxor` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@@ -614,7 +614,7 @@
|
||||
|
||||
(rule (lower (has_type $I128 (bxor x y))) (i128_alu_bitop (ALUOp.Eor) $I64 x y))
|
||||
|
||||
(rule (lower (has_type (vec128 ty) (bxor x y)))
|
||||
(rule (lower (has_type (ty_vec128 ty) (bxor x y)))
|
||||
(eor_vec x y (vector_size ty)))
|
||||
|
||||
;;;; Rules for `band_not` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@@ -627,7 +627,7 @@
|
||||
|
||||
(rule (lower (has_type $I128 (band_not x y))) (i128_alu_bitop (ALUOp.AndNot) $I64 x y))
|
||||
|
||||
(rule (lower (has_type (vec128 ty) (band_not x y)))
|
||||
(rule (lower (has_type (ty_vec128 ty) (band_not x y)))
|
||||
(bic_vec x y (vector_size ty)))
|
||||
|
||||
;;;; Rules for `bor_not` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@@ -691,7 +691,7 @@
|
||||
(csel (Cond.Ne) lo_lshift maybe_hi)))))
|
||||
|
||||
;; Shift for vector types.
|
||||
(rule (lower (has_type (vec128 ty) (ishl x y)))
|
||||
(rule (lower (has_type (ty_vec128 ty) (ishl x y)))
|
||||
(let ((size VectorSize (vector_size ty))
|
||||
(shift Reg (vec_dup y size)))
|
||||
(sshl x shift size)))
|
||||
@@ -749,7 +749,7 @@
|
||||
(lower_ushr128 x (value_regs_get y 0)))
|
||||
|
||||
;; Vector shifts.
|
||||
(rule (lower (has_type (vec128 ty) (ushr x y)))
|
||||
(rule (lower (has_type (ty_vec128 ty) (ushr x y)))
|
||||
(let ((size VectorSize (vector_size ty))
|
||||
(shift Reg (vec_dup (sub $I32 (zero_reg) y) size)))
|
||||
(ushl x shift size)))
|
||||
@@ -769,7 +769,7 @@
|
||||
(src_hi Reg (value_regs_get src 1))
|
||||
(lo_rshift Reg (lsr $I64 src_lo amt))
|
||||
(hi_rshift Reg (lsr $I64 src_hi amt))
|
||||
|
||||
|
||||
(inv_amt Reg (orr_not $I32 (zero_reg) amt))
|
||||
(hi_lshift Reg (lsl $I64 (lsl_imm $I64 src_hi (imm_shift_from_u8 1))
|
||||
inv_amt))
|
||||
@@ -798,7 +798,7 @@
|
||||
;; Vector shifts.
|
||||
;;
|
||||
;; Note that right shifts are implemented with a negative left shift.
|
||||
(rule (lower (has_type (vec128 ty) (sshr x y)))
|
||||
(rule (lower (has_type (ty_vec128 ty) (sshr x y)))
|
||||
(let ((size VectorSize (vector_size ty))
|
||||
(shift Reg (vec_dup (sub $I32 (zero_reg) y) size)))
|
||||
(sshl x shift size)))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
src/clif.isle 9ea75a6f790b5c03
|
||||
src/prelude.isle b2bc986bcbbbb77
|
||||
src/prelude.isle 74d9514ac948e163
|
||||
src/isa/aarch64/inst.isle 19ccefb6a496d392
|
||||
src/isa/aarch64/lower.isle 90ead921762336d2
|
||||
src/isa/aarch64/lower.isle d88b62dd6b40622
|
||||
|
||||
@@ -56,7 +56,8 @@ pub trait Context {
|
||||
fn ty_8_or_16(&mut self, arg0: Type) -> Option<Type>;
|
||||
fn ty_int_bool_64(&mut self, arg0: Type) -> Option<Type>;
|
||||
fn ty_int_bool_128(&mut self, arg0: Type) -> Option<Type>;
|
||||
fn vec128(&mut self, arg0: Type) -> Option<Type>;
|
||||
fn ty_scalar_float(&mut self, arg0: Type) -> Option<Type>;
|
||||
fn ty_vec128(&mut self, arg0: Type) -> Option<Type>;
|
||||
fn not_i64x2(&mut self, arg0: Type) -> Option<()>;
|
||||
fn value_list_slice(&mut self, arg0: ValueList) -> ValueSlice;
|
||||
fn value_slice_empty(&mut self, arg0: ValueSlice) -> Option<()>;
|
||||
@@ -129,13 +130,13 @@ pub trait Context {
|
||||
fn rotr_opposite_amount(&mut self, arg0: Type, arg1: ImmShift) -> ImmShift;
|
||||
}
|
||||
|
||||
/// Internal type SideEffectNoResult: defined at src/prelude.isle line 393.
|
||||
/// Internal type SideEffectNoResult: defined at src/prelude.isle line 397.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum SideEffectNoResult {
|
||||
Inst { inst: MInst },
|
||||
}
|
||||
|
||||
/// Internal type ProducesFlags: defined at src/prelude.isle line 415.
|
||||
/// Internal type ProducesFlags: defined at src/prelude.isle line 419.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum ProducesFlags {
|
||||
ProducesFlagsSideEffect { inst: MInst },
|
||||
@@ -143,7 +144,7 @@ pub enum ProducesFlags {
|
||||
ProducesFlagsReturnsResultWithConsumer { inst: MInst, result: Reg },
|
||||
}
|
||||
|
||||
/// Internal type ConsumesFlags: defined at src/prelude.isle line 426.
|
||||
/// Internal type ConsumesFlags: defined at src/prelude.isle line 430.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum ConsumesFlags {
|
||||
ConsumesFlagsReturnsResultWithProducer {
|
||||
@@ -1085,7 +1086,7 @@ pub fn constructor_side_effect<C: Context>(
|
||||
inst: ref pattern1_0,
|
||||
} = pattern0_0
|
||||
{
|
||||
// Rule at src/prelude.isle line 398.
|
||||
// Rule at src/prelude.isle line 402.
|
||||
let expr0_0 = C::emit(ctx, pattern1_0);
|
||||
let expr1_0 = C::output_none(ctx);
|
||||
return Some(expr1_0);
|
||||
@@ -1103,7 +1104,7 @@ pub fn constructor_safepoint<C: Context>(
|
||||
inst: ref pattern1_0,
|
||||
} = pattern0_0
|
||||
{
|
||||
// Rule at src/prelude.isle line 404.
|
||||
// Rule at src/prelude.isle line 408.
|
||||
let expr0_0 = C::emit_safepoint(ctx, pattern1_0);
|
||||
let expr1_0 = C::output_none(ctx);
|
||||
return Some(expr1_0);
|
||||
@@ -1122,7 +1123,7 @@ pub fn constructor_produces_flags_get_reg<C: Context>(
|
||||
result: pattern1_1,
|
||||
} = pattern0_0
|
||||
{
|
||||
// Rule at src/prelude.isle line 442.
|
||||
// Rule at src/prelude.isle line 446.
|
||||
return Some(pattern1_1);
|
||||
}
|
||||
return None;
|
||||
@@ -1139,7 +1140,7 @@ pub fn constructor_produces_flags_ignore<C: Context>(
|
||||
inst: ref pattern1_0,
|
||||
result: pattern1_1,
|
||||
} => {
|
||||
// Rule at src/prelude.isle line 447.
|
||||
// Rule at src/prelude.isle line 451.
|
||||
let expr0_0 = ProducesFlags::ProducesFlagsSideEffect {
|
||||
inst: pattern1_0.clone(),
|
||||
};
|
||||
@@ -1149,7 +1150,7 @@ pub fn constructor_produces_flags_ignore<C: Context>(
|
||||
inst: ref pattern1_0,
|
||||
result: pattern1_1,
|
||||
} => {
|
||||
// Rule at src/prelude.isle line 449.
|
||||
// Rule at src/prelude.isle line 453.
|
||||
let expr0_0 = ProducesFlags::ProducesFlagsSideEffect {
|
||||
inst: pattern1_0.clone(),
|
||||
};
|
||||
@@ -1178,7 +1179,7 @@ pub fn constructor_consumes_flags_concat<C: Context>(
|
||||
result: pattern3_1,
|
||||
} = pattern2_0
|
||||
{
|
||||
// Rule at src/prelude.isle line 456.
|
||||
// Rule at src/prelude.isle line 460.
|
||||
let expr0_0 = C::value_regs(ctx, pattern1_1, pattern3_1);
|
||||
let expr1_0 = ConsumesFlags::ConsumesFlagsTwiceReturnsValueRegs {
|
||||
inst1: pattern1_0.clone(),
|
||||
@@ -1208,7 +1209,7 @@ pub fn constructor_with_flags<C: Context>(
|
||||
inst: ref pattern3_0,
|
||||
result: pattern3_1,
|
||||
} => {
|
||||
// Rule at src/prelude.isle line 481.
|
||||
// Rule at src/prelude.isle line 485.
|
||||
let expr0_0 = C::emit(ctx, pattern1_0);
|
||||
let expr1_0 = C::emit(ctx, pattern3_0);
|
||||
let expr2_0 = C::value_reg(ctx, pattern3_1);
|
||||
@@ -1219,7 +1220,7 @@ pub fn constructor_with_flags<C: Context>(
|
||||
inst2: ref pattern3_1,
|
||||
result: pattern3_2,
|
||||
} => {
|
||||
// Rule at src/prelude.isle line 487.
|
||||
// Rule at src/prelude.isle line 491.
|
||||
let expr0_0 = C::emit(ctx, pattern1_0);
|
||||
let expr1_0 = C::emit(ctx, pattern3_0);
|
||||
let expr2_0 = C::emit(ctx, pattern3_1);
|
||||
@@ -1232,7 +1233,7 @@ pub fn constructor_with_flags<C: Context>(
|
||||
inst4: ref pattern3_3,
|
||||
result: pattern3_4,
|
||||
} => {
|
||||
// Rule at src/prelude.isle line 499.
|
||||
// Rule at src/prelude.isle line 503.
|
||||
let expr0_0 = C::emit(ctx, pattern1_0);
|
||||
let expr1_0 = C::emit(ctx, pattern3_0);
|
||||
let expr2_0 = C::emit(ctx, pattern3_1);
|
||||
@@ -1253,7 +1254,7 @@ pub fn constructor_with_flags<C: Context>(
|
||||
result: pattern3_1,
|
||||
} = pattern2_0
|
||||
{
|
||||
// Rule at src/prelude.isle line 475.
|
||||
// Rule at src/prelude.isle line 479.
|
||||
let expr0_0 = C::emit(ctx, pattern1_0);
|
||||
let expr1_0 = C::emit(ctx, pattern3_0);
|
||||
let expr2_0 = C::value_regs(ctx, pattern1_1, pattern3_1);
|
||||
@@ -1273,7 +1274,7 @@ pub fn constructor_with_flags_reg<C: Context>(
|
||||
) -> Option<Reg> {
|
||||
let pattern0_0 = arg0;
|
||||
let pattern1_0 = arg1;
|
||||
// Rule at src/prelude.isle line 516.
|
||||
// Rule at src/prelude.isle line 520.
|
||||
let expr0_0 = constructor_with_flags(ctx, pattern0_0, pattern1_0)?;
|
||||
let expr1_0: usize = 0;
|
||||
let expr2_0 = C::value_regs_get(ctx, expr0_0, expr1_0);
|
||||
@@ -6477,7 +6478,7 @@ pub fn constructor_lower<C: Context>(ctx: &mut C, arg0: Inst) -> Option<InstOutp
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
if let Some(pattern3_0) = C::vec128(ctx, pattern2_0) {
|
||||
if let Some(pattern3_0) = C::ty_vec128(ctx, pattern2_0) {
|
||||
let pattern4_0 = C::inst_data(ctx, pattern0_0);
|
||||
match &pattern4_0 {
|
||||
&InstructionData::Binary {
|
||||
|
||||
Reference in New Issue
Block a user