Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit86f2fa3

Browse files
Rollup merge of#125148 - RalfJung:codegen-sh, r=scottmcm
codegen: tweak/extend shift commentsr? `@scottmcm`
2 parents6dddc88 +17bd43c commit86f2fa3

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

‎compiler/rustc_codegen_ssa/src/base.rs‎

Lines changed: 5 additions & 4 deletions
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 sametype).
303+
/// (both parameters and the return type are all the samesize) 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‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,16 @@ pub trait BuilderMethods<'a, 'tcx>:
110110
fnfrem(&mutself,lhs:Self::Value,rhs:Self::Value) ->Self::Value;
111111
fnfrem_fast(&mutself,lhs:Self::Value,rhs:Self::Value) ->Self::Value;
112112
fnfrem_algebraic(&mutself,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
fnshl(&mutself,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
fnlshr(&mutself,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
fnashr(&mutself,lhs:Self::Value,rhs:Self::Value) ->Self::Value;
116124
fnunchecked_sadd(&mutself,lhs:Self::Value,rhs:Self::Value) ->Self::Value;
117125
fnunchecked_uadd(&mutself,lhs:Self::Value,rhs:Self::Value) ->Self::Value;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp