diff --git a/cranelift/codegen/meta/src/cdsl/ast.rs b/cranelift/codegen/meta/src/cdsl/ast.rs index 46214e2abf..37892fc896 100644 --- a/cranelift/codegen/meta/src/cdsl/ast.rs +++ b/cranelift/codegen/meta/src/cdsl/ast.rs @@ -1,5 +1,5 @@ use crate::cdsl::formats::FormatRegistry; -use crate::cdsl::inst::{ApplyTarget, Instruction, InstructionPredicate}; +use crate::cdsl::inst::{InstSpec, Instruction, InstructionPredicate}; use crate::cdsl::operands::{OperandKind, OperandKindFields}; use crate::cdsl::types::ValueType; use crate::cdsl::typevar::{TypeSetBuilder, TypeVar}; @@ -375,10 +375,10 @@ pub struct Apply { } impl Apply { - pub fn new(target: ApplyTarget, args: Vec) -> Self { + pub fn new(target: InstSpec, args: Vec) -> Self { let (inst, value_types) = match target.into() { - ApplyTarget::Inst(inst) => (inst, Vec::new()), - ApplyTarget::Bound(bound_inst) => (bound_inst.inst, bound_inst.value_types), + InstSpec::Inst(inst) => (inst, Vec::new()), + InstSpec::Bound(bound_inst) => (bound_inst.inst, bound_inst.value_types), }; // Basic check on number of arguments. @@ -520,7 +520,7 @@ impl Apply { pub enum DummyExpr { Var(DummyVar), Literal(Literal), - Apply(ApplyTarget, Vec), + Apply(InstSpec, Vec), } #[derive(Clone)] @@ -553,7 +553,7 @@ pub struct ExprBuilder { } impl ExprBuilder { - pub fn apply(inst: ApplyTarget, args: Vec) -> Self { + pub fn apply(inst: InstSpec, args: Vec) -> Self { let expr = DummyExpr::Apply(inst, args); Self { expr } } diff --git a/cranelift/codegen/meta/src/cdsl/inst.rs b/cranelift/codegen/meta/src/cdsl/inst.rs index 6b9bfe60a1..2dcd3e4d9a 100644 --- a/cranelift/codegen/meta/src/cdsl/inst.rs +++ b/cranelift/codegen/meta/src/cdsl/inst.rs @@ -599,38 +599,39 @@ impl InstructionPredicate { } } -pub enum ApplyTarget { +/// An instruction specification, containing an instruction that has bound types or not. +pub enum InstSpec { Inst(Instruction), Bound(BoundInstruction), } -impl ApplyTarget { +impl InstSpec { pub fn inst(&self) -> &Instruction { match &self { - ApplyTarget::Inst(inst) => inst, - ApplyTarget::Bound(bound_inst) => &bound_inst.inst, + InstSpec::Inst(inst) => inst, + InstSpec::Bound(bound_inst) => &bound_inst.inst, } } } -impl Into for &Instruction { - fn into(self) -> ApplyTarget { - ApplyTarget::Inst(self.clone()) +impl Into for &Instruction { + fn into(self) -> InstSpec { + InstSpec::Inst(self.clone()) } } -impl Into for BoundInstruction { - fn into(self) -> ApplyTarget { - ApplyTarget::Bound(self) +impl Into for BoundInstruction { + fn into(self) -> InstSpec { + InstSpec::Bound(self) } } -pub fn bind(target: impl Into, lane_type: impl Into) -> BoundInstruction { +pub fn bind(target: impl Into, lane_type: impl Into) -> BoundInstruction { let value_type = ValueType::from(lane_type.into()); let (inst, value_types) = match target.into() { - ApplyTarget::Inst(inst) => (inst, vec![value_type]), - ApplyTarget::Bound(bound_inst) => { + InstSpec::Inst(inst) => (inst, vec![value_type]), + InstSpec::Bound(bound_inst) => { let mut new_value_types = bound_inst.value_types; new_value_types.push(value_type); (bound_inst.inst, new_value_types)