Skip to content

Commit

Permalink
Remove support for -Zlower-128bit-ops
Browse files Browse the repository at this point in the history
It is broken and unused
  • Loading branch information
bjorn3 committed Jul 19, 2019
1 parent f9477a7 commit 3427a14
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 325 deletions.
28 changes: 0 additions & 28 deletions src/librustc/middle/lang_items.rs
Expand Up @@ -367,34 +367,6 @@ language_item_table! {

DebugTraitLangItem, "debug_trait", debug_trait, Target::Trait;

// A lang item for each of the 128-bit operators we can optionally lower.
I128AddFnLangItem, "i128_add", i128_add_fn, Target::Fn;
U128AddFnLangItem, "u128_add", u128_add_fn, Target::Fn;
I128SubFnLangItem, "i128_sub", i128_sub_fn, Target::Fn;
U128SubFnLangItem, "u128_sub", u128_sub_fn, Target::Fn;
I128MulFnLangItem, "i128_mul", i128_mul_fn, Target::Fn;
U128MulFnLangItem, "u128_mul", u128_mul_fn, Target::Fn;
I128DivFnLangItem, "i128_div", i128_div_fn, Target::Fn;
U128DivFnLangItem, "u128_div", u128_div_fn, Target::Fn;
I128RemFnLangItem, "i128_rem", i128_rem_fn, Target::Fn;
U128RemFnLangItem, "u128_rem", u128_rem_fn, Target::Fn;
I128ShlFnLangItem, "i128_shl", i128_shl_fn, Target::Fn;
U128ShlFnLangItem, "u128_shl", u128_shl_fn, Target::Fn;
I128ShrFnLangItem, "i128_shr", i128_shr_fn, Target::Fn;
U128ShrFnLangItem, "u128_shr", u128_shr_fn, Target::Fn;
// And overflow versions for the operators that are checkable.
// While MIR calls these Checked*, they return (T,bool), not Option<T>.
I128AddoFnLangItem, "i128_addo", i128_addo_fn, Target::Fn;
U128AddoFnLangItem, "u128_addo", u128_addo_fn, Target::Fn;
I128SuboFnLangItem, "i128_subo", i128_subo_fn, Target::Fn;
U128SuboFnLangItem, "u128_subo", u128_subo_fn, Target::Fn;
I128MuloFnLangItem, "i128_mulo", i128_mulo_fn, Target::Fn;
U128MuloFnLangItem, "u128_mulo", u128_mulo_fn, Target::Fn;
I128ShloFnLangItem, "i128_shlo", i128_shlo_fn, Target::Fn;
U128ShloFnLangItem, "u128_shlo", u128_shlo_fn, Target::Fn;
I128ShroFnLangItem, "i128_shro", i128_shro_fn, Target::Fn;
U128ShroFnLangItem, "u128_shro", u128_shro_fn, Target::Fn;

// Align offset for stride != 1, must not panic.
AlignOffsetLangItem, "align_offset", align_offset_fn, Target::Fn;

Expand Down
4 changes: 0 additions & 4 deletions src/librustc/session/config.rs
Expand Up @@ -1406,10 +1406,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
saturating_float_casts: bool = (false, parse_bool, [TRACKED],
"make float->int casts UB-free: numbers outside the integer type's range are clipped to \
the max/min integer respectively, and NaN is mapped to 0"),
lower_128bit_ops: Option<bool> = (None, parse_opt_bool, [TRACKED],
"rewrite operators on i128 and u128 into lang item calls (typically provided \
by compiler-builtins) so codegen doesn't need to support them,
overriding the default for the current target"),
human_readable_cgu_names: bool = (false, parse_bool, [TRACKED],
"generate human-readable, predictable names for codegen units"),
dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED],
Expand Down
36 changes: 1 addition & 35 deletions src/librustc/ty/context.rs
Expand Up @@ -21,7 +21,7 @@ use crate::middle::cstore::EncodedMetadata;
use crate::middle::lang_items;
use crate::middle::resolve_lifetime::{self, ObjectLifetimeDefault};
use crate::middle::stability;
use crate::mir::{self, Body, interpret, ProjectionKind};
use crate::mir::{Body, interpret, ProjectionKind};
use crate::mir::interpret::{ConstValue, Allocation, Scalar};
use crate::ty::subst::{Kind, InternalSubsts, SubstsRef, Subst};
use crate::ty::ReprOptions;
Expand Down Expand Up @@ -1297,40 +1297,6 @@ impl<'tcx> TyCtxt<'tcx> {
self.get_lang_items(LOCAL_CRATE)
}

/// Due to missing llvm support for lowering 128 bit math to software emulation
/// (on some targets), the lowering can be done in MIR.
///
/// This function only exists until said support is implemented.
pub fn is_binop_lang_item(&self, def_id: DefId) -> Option<(mir::BinOp, bool)> {
let items = self.lang_items();
let def_id = Some(def_id);
if items.i128_add_fn() == def_id { Some((mir::BinOp::Add, false)) }
else if items.u128_add_fn() == def_id { Some((mir::BinOp::Add, false)) }
else if items.i128_sub_fn() == def_id { Some((mir::BinOp::Sub, false)) }
else if items.u128_sub_fn() == def_id { Some((mir::BinOp::Sub, false)) }
else if items.i128_mul_fn() == def_id { Some((mir::BinOp::Mul, false)) }
else if items.u128_mul_fn() == def_id { Some((mir::BinOp::Mul, false)) }
else if items.i128_div_fn() == def_id { Some((mir::BinOp::Div, false)) }
else if items.u128_div_fn() == def_id { Some((mir::BinOp::Div, false)) }
else if items.i128_rem_fn() == def_id { Some((mir::BinOp::Rem, false)) }
else if items.u128_rem_fn() == def_id { Some((mir::BinOp::Rem, false)) }
else if items.i128_shl_fn() == def_id { Some((mir::BinOp::Shl, false)) }
else if items.u128_shl_fn() == def_id { Some((mir::BinOp::Shl, false)) }
else if items.i128_shr_fn() == def_id { Some((mir::BinOp::Shr, false)) }
else if items.u128_shr_fn() == def_id { Some((mir::BinOp::Shr, false)) }
else if items.i128_addo_fn() == def_id { Some((mir::BinOp::Add, true)) }
else if items.u128_addo_fn() == def_id { Some((mir::BinOp::Add, true)) }
else if items.i128_subo_fn() == def_id { Some((mir::BinOp::Sub, true)) }
else if items.u128_subo_fn() == def_id { Some((mir::BinOp::Sub, true)) }
else if items.i128_mulo_fn() == def_id { Some((mir::BinOp::Mul, true)) }
else if items.u128_mulo_fn() == def_id { Some((mir::BinOp::Mul, true)) }
else if items.i128_shlo_fn() == def_id { Some((mir::BinOp::Shl, true)) }
else if items.u128_shlo_fn() == def_id { Some((mir::BinOp::Shl, true)) }
else if items.i128_shro_fn() == def_id { Some((mir::BinOp::Shr, true)) }
else if items.u128_shro_fn() == def_id { Some((mir::BinOp::Shr, true)) }
else { None }
}

pub fn stability(self) -> &'tcx stability::Index<'tcx> {
self.stability_index(LOCAL_CRATE)
}
Expand Down
15 changes: 2 additions & 13 deletions src/librustc_mir/interpret/intrinsics.rs
Expand Up @@ -230,21 +230,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
&mut self,
instance: ty::Instance<'tcx>,
args: &[OpTy<'tcx, M::PointerTag>],
dest: Option<PlaceTy<'tcx, M::PointerTag>>,
_dest: Option<PlaceTy<'tcx, M::PointerTag>>,
) -> InterpResult<'tcx, bool> {
let def_id = instance.def_id();
// Some fn calls are actually BinOp intrinsics
if let Some((op, oflo)) = self.tcx.is_binop_lang_item(def_id) {
let dest = dest.expect("128 lowerings can't diverge");
let l = self.read_immediate(args[0])?;
let r = self.read_immediate(args[1])?;
if oflo {
self.binop_with_overflow(op, l, r, dest)?;
} else {
self.binop_ignore_overflow(op, l, r, dest)?;
}
return Ok(true);
} else if Some(def_id) == self.tcx.lang_items().panic_fn() {
if Some(def_id) == self.tcx.lang_items().panic_fn() {
assert!(args.len() == 1);
// &(&'static str, &'static str, u32, u32)
let place = self.deref_operand(args[0])?;
Expand Down
7 changes: 0 additions & 7 deletions src/librustc_mir/transform/inline.rs
Expand Up @@ -232,13 +232,6 @@ impl Inliner<'tcx> {
return false;
}

// Do not inline {u,i}128 lang items, codegen const eval depends
// on detecting calls to these lang items and intercepting them
if tcx.is_binop_lang_item(callsite.callee).is_some() {
debug!(" not inlining 128bit integer lang item");
return false;
}

let codegen_fn_attrs = tcx.codegen_fn_attrs(callsite.callee);

let hinted = match codegen_fn_attrs.inline {
Expand Down
230 changes: 0 additions & 230 deletions src/librustc_mir/transform/lower_128bit.rs

This file was deleted.

3 changes: 0 additions & 3 deletions src/librustc_mir/transform/mod.rs
Expand Up @@ -34,7 +34,6 @@ pub mod copy_prop;
pub mod const_prop;
pub mod generator;
pub mod inline;
pub mod lower_128bit;
pub mod uniform_array_move_out;

pub(crate) fn provide(providers: &mut Providers<'_>) {
Expand Down Expand Up @@ -272,8 +271,6 @@ fn optimized_mir(tcx: TyCtxt<'_>, def_id: DefId) -> &Body<'_> {
// From here on out, regions are gone.
&erase_regions::EraseRegions,

&lower_128bit::Lower128Bit,


// Optimizations begin.
&uniform_array_move_out::RestoreSubsliceArrayMoveOut,
Expand Down

0 comments on commit 3427a14

Please sign in to comment.