Skip to content

Commit 1a8282a

Browse files
committed
Auto merge of #46486 - scottmcm:i128-target-option, r=nagisa
Add an i128_lowering flag in TargetOptions Not actually enabled by default anywhere yet. r? @nagisa cc #45676 @est31
2 parents c16f480 + 1bc402f commit 1a8282a

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

src/librustc/session/config.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1176,9 +1176,10 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
11761176
saturating_float_casts: bool = (false, parse_bool, [TRACKED],
11771177
"make float->int casts UB-free: numbers outside the integer type's range are clipped to \
11781178
the max/min integer respectively, and NaN is mapped to 0"),
1179-
lower_128bit_ops: bool = (false, parse_bool, [TRACKED],
1179+
lower_128bit_ops: Option<bool> = (None, parse_opt_bool, [TRACKED],
11801180
"rewrite operators on i128 and u128 into lang item calls (typically provided \
1181-
by compiler-builtins) so translation doesn't need to support them"),
1181+
by compiler-builtins) so translation doesn't need to support them,
1182+
overriding the default for the current target"),
11821183
}
11831184

11841185
pub fn default_lib_output() -> CrateType {

src/librustc_back/target/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,10 @@ pub struct TargetOptions {
453453
/// Whether library functions call lowering/optimization is disabled in LLVM
454454
/// for this target unconditionally.
455455
pub no_builtins: bool,
456+
457+
/// Whether to lower 128-bit operations to compiler_builtins calls. Use if
458+
/// your backend only supports 64-bit and smaller math.
459+
pub i128_lowering: bool,
456460
}
457461

458462
impl Default for TargetOptions {
@@ -521,6 +525,7 @@ impl Default for TargetOptions {
521525
requires_lto: false,
522526
singlethread: false,
523527
no_builtins: false,
528+
i128_lowering: false,
524529
}
525530
}
526531
}

src/librustc_mir/transform/lower_128bit.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ impl MirPass for Lower128Bit {
2525
tcx: TyCtxt<'a, 'tcx, 'tcx>,
2626
_src: MirSource,
2727
mir: &mut Mir<'tcx>) {
28-
if !tcx.sess.opts.debugging_opts.lower_128bit_ops {
28+
let debugging_override = tcx.sess.opts.debugging_opts.lower_128bit_ops;
29+
let target_default = tcx.sess.host.options.i128_lowering;
30+
if !debugging_override.unwrap_or(target_default) {
2931
return
3032
}
3133

src/test/mir-opt/lower_128bit_debug_test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// ignore-asmjs
1414
// ignore-emscripten
1515

16-
// compile-flags: -Z lower_128bit_ops -C debug_assertions=yes
16+
// compile-flags: -Z lower_128bit_ops=yes -C debug_assertions=yes
1717

1818
#![feature(i128_type)]
1919

src/test/mir-opt/lower_128bit_test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// ignore-asmjs
1414
// ignore-emscripten
1515

16-
// compile-flags: -Z lower_128bit_ops -C debug_assertions=no
16+
// compile-flags: -Z lower_128bit_ops=yes -C debug_assertions=no
1717

1818
#![feature(i128_type)]
1919

0 commit comments

Comments
 (0)