Skip to content

Commit e0c54c3

Browse files
committed
Rename transmute_immediatetransmute_scalar
1 parent 5292554 commit e0c54c3

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

compiler/rustc_codegen_ssa/src/mir/operand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_session::config::OptLevel;
1313
use tracing::{debug, instrument};
1414

1515
use super::place::{PlaceRef, PlaceValue};
16-
use super::rvalue::transmute_immediate;
16+
use super::rvalue::transmute_scalar;
1717
use super::{FunctionCx, LocalRef};
1818
use crate::common::IntPredicate;
1919
use crate::traits::*;
@@ -614,7 +614,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, Result<V, abi::Scalar>> {
614614

615615
let mut update = |tgt: &mut Result<V, abi::Scalar>, src, from_scalar| {
616616
let to_scalar = tgt.unwrap_err();
617-
let imm = transmute_immediate(bx, src, from_scalar, to_scalar);
617+
let imm = transmute_scalar(bx, src, from_scalar, to_scalar);
618618
*tgt = Ok(imm);
619619
};
620620

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,14 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
256256
OperandValue::Immediate(imm),
257257
abi::BackendRepr::Scalar(from_scalar),
258258
abi::BackendRepr::Scalar(to_scalar),
259-
) => OperandValue::Immediate(transmute_immediate(bx, imm, from_scalar, to_scalar)),
259+
) => OperandValue::Immediate(transmute_scalar(bx, imm, from_scalar, to_scalar)),
260260
(
261261
OperandValue::Pair(imm_a, imm_b),
262262
abi::BackendRepr::ScalarPair(in_a, in_b),
263263
abi::BackendRepr::ScalarPair(out_a, out_b),
264264
) => OperandValue::Pair(
265-
transmute_immediate(bx, imm_a, in_a, out_a),
266-
transmute_immediate(bx, imm_b, in_b, out_b),
265+
transmute_scalar(bx, imm_a, in_a, out_a),
266+
transmute_scalar(bx, imm_b, in_b, out_b),
267267
),
268268
_ => return None,
269269
})
@@ -1017,12 +1017,14 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10171017
}
10181018
}
10191019

1020-
/// Transmutes one of the immediates from an [`OperandValue::Immediate`]
1021-
/// or an [`OperandValue::Pair`] to an immediate of the target type.
1020+
/// Transmutes a single scalar value `imm` from `from_scalar` to `to_scalar`.
10221021
///
1023-
/// `to_backend_ty` must be the *non*-immediate backend type (so it will be
1024-
/// `i8`, not `i1`, for `bool`-like types.)
1025-
pub(super) fn transmute_immediate<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
1022+
/// This is expected to be in *immediate* form, as seen in [`OperandValue::Immediate`]
1023+
/// or [`OperandValue::Pair`] (so `i1` for bools, not `i8`, for example).
1024+
///
1025+
/// ICEs if the passed-in `imm` is not a value of the expected type for
1026+
/// `from_scalar`, such as if it's a vector or a pair.
1027+
pub(super) fn transmute_scalar<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
10261028
bx: &mut Bx,
10271029
mut imm: Bx::Value,
10281030
from_scalar: abi::Scalar,
@@ -1033,7 +1035,7 @@ pub(super) fn transmute_immediate<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
10331035
assert_ne!(
10341036
bx.cx().type_kind(imm_ty),
10351037
TypeKind::Vector,
1036-
"Vector type {imm_ty:?} not allowed in transmute_immediate {from_scalar:?} -> {to_scalar:?}"
1038+
"Vector type {imm_ty:?} not allowed in transmute_scalar {from_scalar:?} -> {to_scalar:?}"
10371039
);
10381040

10391041
// While optimizations will remove no-op transmutes, they might still be

0 commit comments

Comments
 (0)