Skip to content

Commit

Permalink
rustc_abi: remove Primitive::{is_float,is_int}
Browse files Browse the repository at this point in the history
there were fixmes for this already

i am about to remove is_ptr (since callers need to properly distinguish
between pointers in different address spaces), so might as well do this
at the same time
  • Loading branch information
erikdesjardins committed Jan 23, 2023
1 parent a5fa99e commit 96f8f99
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
12 changes: 0 additions & 12 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,18 +887,6 @@ impl Primitive {
}
}

// FIXME(eddyb) remove, it's trivial thanks to `matches!`.
#[inline]
pub fn is_float(self) -> bool {
matches!(self, F32 | F64)
}

// FIXME(eddyb) remove, it's completely unused.
#[inline]
pub fn is_int(self) -> bool {
matches!(self, Int(..))
}

#[inline]
pub fn is_ptr(self) -> bool {
matches!(self, Pointer)
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_target/src/abi/call/sparc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ where
{
let dl = cx.data_layout();

if !scalar.primitive().is_float() {
if !matches!(scalar.primitive(), abi::F32 | abi::F64) {
return data;
}

Expand Down Expand Up @@ -87,7 +87,7 @@ where
_ => {}
}

if (offset.bytes() % 4) != 0 && scalar2.primitive().is_float() {
if (offset.bytes() % 4) != 0 && matches!(scalar2.primitive(), abi::F32 | abi::F64) {
offset += Size::from_bytes(4 - (offset.bytes() % 4));
}
data = arg_scalar(cx, scalar2, offset, data);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
C: HasDataLayout,
{
match self.abi {
Abi::Scalar(scalar) => scalar.primitive().is_float(),
Abi::Scalar(scalar) => matches!(scalar.primitive(), F32 | F64),
Abi::Aggregate { .. } => {
if self.fields.count() == 1 && self.fields.offset(0).bytes() == 0 {
self.field(cx, 0).is_single_fp_element(cx)
Expand Down

0 comments on commit 96f8f99

Please sign in to comment.