diff options
| author | bors <bors@rust-lang.org> | 2024-05-27 13:22:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-05-27 13:22:55 +0000 |
| commit | f6e4703e91eedcc5e33ad2cf3f6c0d034782f245 (patch) | |
| tree | 9fe749bc3c6f1791aeb8ad41b7deeaa9d17ca9bd /compiler/rustc_codegen_ssa/src | |
| parent | a59072ec4fb6824213df5e9de8cae4812fd4fe97 (diff) | |
| parent | 7083131c92dd4dcbfc23216cd7eb8d7fac93fcaf (diff) | |
| download | rust-f6e4703e91eedcc5e33ad2cf3f6c0d034782f245.tar.gz rust-f6e4703e91eedcc5e33ad2cf3f6c0d034782f245.zip | |
Auto merge of #125611 - GuillaumeGomez:rollup-dfavpgg, r=GuillaumeGomez
Rollup of 7 pull requests Successful merges: - #124870 (Update Result docs to the new guarantees) - #125148 (codegen: tweak/extend shift comments) - #125522 (Add "better" edition handling on lint-docs tool) - #125530 (cleanup dependence of `ExtCtxt` in transcribe when macro expansion) - #125535 (clean-up: remove deprecated field `dist.missing-tools`) - #125597 (Uplift `EarlyBinder` into `rustc_type_ir`) - #125607 (Migrate `run-make/compile-stdin` to `rmake.rs`) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/base.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/traits/builder.rs | 8 |
2 files changed, 13 insertions, 4 deletions
diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index 5d7eb052561..f372d3a0522 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -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. diff --git a/compiler/rustc_codegen_ssa/src/traits/builder.rs b/compiler/rustc_codegen_ssa/src/traits/builder.rs index 9fd6eb8edab..2f0daefa46a 100644 --- a/compiler/rustc_codegen_ssa/src/traits/builder.rs +++ b/compiler/rustc_codegen_ssa/src/traits/builder.rs @@ -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; |
