Skip to content

Commit

Permalink
Unrolled build for rust-lang#125148
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#125148 - RalfJung:codegen-sh, r=scottmcm

codegen: tweak/extend shift comments

r? `@scottmcm`
  • Loading branch information
rust-timer committed May 27, 2024
2 parents a59072e + 17bd43c commit 55b6d11
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 5 additions & 4 deletions compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,13 @@ pub fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
}
}

/// Returns `rhs` sufficiently masked, truncated, and/or extended so that
/// it can be used to shift `lhs`.
/// Returns `rhs` sufficiently masked, truncated, and/or extended so that it can be used to shift
/// `lhs`: it has the same size as `lhs`, and the value, when interpreted unsigned (no matter its
/// type), will not exceed the size of `lhs`.
///
/// Shifts in MIR are all allowed to have mismatched LHS & RHS types.
/// Shifts in MIR are all allowed to have mismatched LHS & RHS types, and signed RHS.
/// The shift methods in `BuilderMethods`, however, are fully homogeneous
/// (both parameters and the return type are all the same type).
/// (both parameters and the return type are all the same size) and assume an unsigned RHS.
///
/// If `is_unchecked` is false, this masks the RHS to ensure it stays in-bounds,
/// as the `BuilderMethods` shifts are UB for out-of-bounds shift amounts.
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_codegen_ssa/src/traits/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,16 @@ pub trait BuilderMethods<'a, 'tcx>:
fn frem(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
fn frem_fast(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
fn frem_algebraic(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
/// Generate a left-shift. Both operands must have the same size. The right operand must be
/// interpreted as unsigned and can be assumed to be less than the size of the left operand.
fn shl(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
/// Generate a logical right-shift. Both operands must have the same size. The right operand
/// must be interpreted as unsigned and can be assumed to be less than the size of the left
/// operand.
fn lshr(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
/// Generate an arithmetic right-shift. Both operands must have the same size. The right operand
/// must be interpreted as unsigned and can be assumed to be less than the size of the left
/// operand.
fn ashr(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
fn unchecked_sadd(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
fn unchecked_uadd(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
Expand Down

0 comments on commit 55b6d11

Please sign in to comment.