Skip to content

Commit 55b6d11

Browse files
authored
Unrolled build for rust-lang#125148
Rollup merge of rust-lang#125148 - RalfJung:codegen-sh, r=scottmcm codegen: tweak/extend shift comments r? `@scottmcm`
2 parents a59072e + 17bd43c commit 55b6d11

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

compiler/rustc_codegen_ssa/src/base.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,13 @@ pub fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
294294
}
295295
}
296296

297-
/// Returns `rhs` sufficiently masked, truncated, and/or extended so that
298-
/// it can be used to shift `lhs`.
297+
/// Returns `rhs` sufficiently masked, truncated, and/or extended so that it can be used to shift
298+
/// `lhs`: it has the same size as `lhs`, and the value, when interpreted unsigned (no matter its
299+
/// type), will not exceed the size of `lhs`.
299300
///
300-
/// Shifts in MIR are all allowed to have mismatched LHS & RHS types.
301+
/// Shifts in MIR are all allowed to have mismatched LHS & RHS types, and signed RHS.
301302
/// The shift methods in `BuilderMethods`, however, are fully homogeneous
302-
/// (both parameters and the return type are all the same type).
303+
/// (both parameters and the return type are all the same size) and assume an unsigned RHS.
303304
///
304305
/// If `is_unchecked` is false, this masks the RHS to ensure it stays in-bounds,
305306
/// as the `BuilderMethods` shifts are UB for out-of-bounds shift amounts.

compiler/rustc_codegen_ssa/src/traits/builder.rs

+8
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,16 @@ pub trait BuilderMethods<'a, 'tcx>:
110110
fn frem(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
111111
fn frem_fast(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
112112
fn frem_algebraic(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
113+
/// Generate a left-shift. Both operands must have the same size. The right operand must be
114+
/// interpreted as unsigned and can be assumed to be less than the size of the left operand.
113115
fn shl(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
116+
/// Generate a logical right-shift. Both operands must have the same size. The right operand
117+
/// must be interpreted as unsigned and can be assumed to be less than the size of the left
118+
/// operand.
114119
fn lshr(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
120+
/// Generate an arithmetic right-shift. Both operands must have the same size. The right operand
121+
/// must be interpreted as unsigned and can be assumed to be less than the size of the left
122+
/// operand.
115123
fn ashr(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
116124
fn unchecked_sadd(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
117125
fn unchecked_uadd(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;

0 commit comments

Comments
 (0)