Avoid heavy repetition in llvm/ffi.rs.

Through judicious use of `use` and `Self`.
This commit is contained in:
Nicholas Nethercote 2024-09-18 14:07:12 +10:00
parent 3b071692cb
commit c5af8b2722

View File

@ -220,17 +220,18 @@ pub enum IntPredicate {
impl IntPredicate { impl IntPredicate {
pub fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self { pub fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self {
use rustc_codegen_ssa::common::IntPredicate as Common;
match intpre { match intpre {
rustc_codegen_ssa::common::IntPredicate::IntEQ => IntPredicate::IntEQ, Common::IntEQ => Self::IntEQ,
rustc_codegen_ssa::common::IntPredicate::IntNE => IntPredicate::IntNE, Common::IntNE => Self::IntNE,
rustc_codegen_ssa::common::IntPredicate::IntUGT => IntPredicate::IntUGT, Common::IntUGT => Self::IntUGT,
rustc_codegen_ssa::common::IntPredicate::IntUGE => IntPredicate::IntUGE, Common::IntUGE => Self::IntUGE,
rustc_codegen_ssa::common::IntPredicate::IntULT => IntPredicate::IntULT, Common::IntULT => Self::IntULT,
rustc_codegen_ssa::common::IntPredicate::IntULE => IntPredicate::IntULE, Common::IntULE => Self::IntULE,
rustc_codegen_ssa::common::IntPredicate::IntSGT => IntPredicate::IntSGT, Common::IntSGT => Self::IntSGT,
rustc_codegen_ssa::common::IntPredicate::IntSGE => IntPredicate::IntSGE, Common::IntSGE => Self::IntSGE,
rustc_codegen_ssa::common::IntPredicate::IntSLT => IntPredicate::IntSLT, Common::IntSLT => Self::IntSLT,
rustc_codegen_ssa::common::IntPredicate::IntSLE => IntPredicate::IntSLE, Common::IntSLE => Self::IntSLE,
} }
} }
} }
@ -259,27 +260,24 @@ pub enum RealPredicate {
impl RealPredicate { impl RealPredicate {
pub fn from_generic(realp: rustc_codegen_ssa::common::RealPredicate) -> Self { pub fn from_generic(realp: rustc_codegen_ssa::common::RealPredicate) -> Self {
use rustc_codegen_ssa::common::RealPredicate as Common;
match realp { match realp {
rustc_codegen_ssa::common::RealPredicate::RealPredicateFalse => { Common::RealPredicateFalse => Self::RealPredicateFalse,
RealPredicate::RealPredicateFalse Common::RealOEQ => Self::RealOEQ,
} Common::RealOGT => Self::RealOGT,
rustc_codegen_ssa::common::RealPredicate::RealOEQ => RealPredicate::RealOEQ, Common::RealOGE => Self::RealOGE,
rustc_codegen_ssa::common::RealPredicate::RealOGT => RealPredicate::RealOGT, Common::RealOLT => Self::RealOLT,
rustc_codegen_ssa::common::RealPredicate::RealOGE => RealPredicate::RealOGE, Common::RealOLE => Self::RealOLE,
rustc_codegen_ssa::common::RealPredicate::RealOLT => RealPredicate::RealOLT, Common::RealONE => Self::RealONE,
rustc_codegen_ssa::common::RealPredicate::RealOLE => RealPredicate::RealOLE, Common::RealORD => Self::RealORD,
rustc_codegen_ssa::common::RealPredicate::RealONE => RealPredicate::RealONE, Common::RealUNO => Self::RealUNO,
rustc_codegen_ssa::common::RealPredicate::RealORD => RealPredicate::RealORD, Common::RealUEQ => Self::RealUEQ,
rustc_codegen_ssa::common::RealPredicate::RealUNO => RealPredicate::RealUNO, Common::RealUGT => Self::RealUGT,
rustc_codegen_ssa::common::RealPredicate::RealUEQ => RealPredicate::RealUEQ, Common::RealUGE => Self::RealUGE,
rustc_codegen_ssa::common::RealPredicate::RealUGT => RealPredicate::RealUGT, Common::RealULT => Self::RealULT,
rustc_codegen_ssa::common::RealPredicate::RealUGE => RealPredicate::RealUGE, Common::RealULE => Self::RealULE,
rustc_codegen_ssa::common::RealPredicate::RealULT => RealPredicate::RealULT, Common::RealUNE => Self::RealUNE,
rustc_codegen_ssa::common::RealPredicate::RealULE => RealPredicate::RealULE, Common::RealPredicateTrue => Self::RealPredicateTrue,
rustc_codegen_ssa::common::RealPredicate::RealUNE => RealPredicate::RealUNE,
rustc_codegen_ssa::common::RealPredicate::RealPredicateTrue => {
RealPredicate::RealPredicateTrue
}
} }
} }
} }
@ -311,26 +309,27 @@ pub enum TypeKind {
impl TypeKind { impl TypeKind {
pub fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind { pub fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind {
use rustc_codegen_ssa::common::TypeKind as Common;
match self { match self {
TypeKind::Void => rustc_codegen_ssa::common::TypeKind::Void, Self::Void => Common::Void,
TypeKind::Half => rustc_codegen_ssa::common::TypeKind::Half, Self::Half => Common::Half,
TypeKind::Float => rustc_codegen_ssa::common::TypeKind::Float, Self::Float => Common::Float,
TypeKind::Double => rustc_codegen_ssa::common::TypeKind::Double, Self::Double => Common::Double,
TypeKind::X86_FP80 => rustc_codegen_ssa::common::TypeKind::X86_FP80, Self::X86_FP80 => Common::X86_FP80,
TypeKind::FP128 => rustc_codegen_ssa::common::TypeKind::FP128, Self::FP128 => Common::FP128,
TypeKind::PPC_FP128 => rustc_codegen_ssa::common::TypeKind::PPC_FP128, Self::PPC_FP128 => Common::PPC_FP128,
TypeKind::Label => rustc_codegen_ssa::common::TypeKind::Label, Self::Label => Common::Label,
TypeKind::Integer => rustc_codegen_ssa::common::TypeKind::Integer, Self::Integer => Common::Integer,
TypeKind::Function => rustc_codegen_ssa::common::TypeKind::Function, Self::Function => Common::Function,
TypeKind::Struct => rustc_codegen_ssa::common::TypeKind::Struct, Self::Struct => Common::Struct,
TypeKind::Array => rustc_codegen_ssa::common::TypeKind::Array, Self::Array => Common::Array,
TypeKind::Pointer => rustc_codegen_ssa::common::TypeKind::Pointer, Self::Pointer => Common::Pointer,
TypeKind::Vector => rustc_codegen_ssa::common::TypeKind::Vector, Self::Vector => Common::Vector,
TypeKind::Metadata => rustc_codegen_ssa::common::TypeKind::Metadata, Self::Metadata => Common::Metadata,
TypeKind::Token => rustc_codegen_ssa::common::TypeKind::Token, Self::Token => Common::Token,
TypeKind::ScalableVector => rustc_codegen_ssa::common::TypeKind::ScalableVector, Self::ScalableVector => Common::ScalableVector,
TypeKind::BFloat => rustc_codegen_ssa::common::TypeKind::BFloat, Self::BFloat => Common::BFloat,
TypeKind::X86_AMX => rustc_codegen_ssa::common::TypeKind::X86_AMX, Self::X86_AMX => Common::X86_AMX,
} }
} }
} }
@ -354,18 +353,19 @@ pub enum AtomicRmwBinOp {
impl AtomicRmwBinOp { impl AtomicRmwBinOp {
pub fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self { pub fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self {
use rustc_codegen_ssa::common::AtomicRmwBinOp as Common;
match op { match op {
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg, Common::AtomicXchg => Self::AtomicXchg,
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd, Common::AtomicAdd => Self::AtomicAdd,
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub, Common::AtomicSub => Self::AtomicSub,
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd, Common::AtomicAnd => Self::AtomicAnd,
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand, Common::AtomicNand => Self::AtomicNand,
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr, Common::AtomicOr => Self::AtomicOr,
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor, Common::AtomicXor => Self::AtomicXor,
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax, Common::AtomicMax => Self::AtomicMax,
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin, Common::AtomicMin => Self::AtomicMin,
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax, Common::AtomicUMax => Self::AtomicUMax,
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin, Common::AtomicUMin => Self::AtomicUMin,
} }
} }
} }
@ -387,17 +387,14 @@ pub enum AtomicOrdering {
impl AtomicOrdering { impl AtomicOrdering {
pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self { pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
use rustc_codegen_ssa::common::AtomicOrdering as Common;
match ao { match ao {
rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered, Common::Unordered => Self::Unordered,
rustc_codegen_ssa::common::AtomicOrdering::Relaxed => AtomicOrdering::Monotonic, Common::Relaxed => Self::Monotonic,
rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire, Common::Acquire => Self::Acquire,
rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release, Common::Release => Self::Release,
rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease => { Common::AcquireRelease => Self::AcquireRelease,
AtomicOrdering::AcquireRelease Common::SequentiallyConsistent => Self::SequentiallyConsistent,
}
rustc_codegen_ssa::common::AtomicOrdering::SequentiallyConsistent => {
AtomicOrdering::SequentiallyConsistent
}
} }
} }
} }