diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index 45484027edc..532216ba851 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -14,7 +14,7 @@ alloc_system = { path = "./alloc_system" } [patch.crates-io] rustc-std-workspace-core = { path = "./sysroot_src/src/tools/rustc-std-workspace-core" } rustc-std-workspace-alloc = { path = "./rustc-std-workspace-alloc" } -compiler_builtins = { path = "./compiler_builtins" } +#compiler_builtins = { path = "./compiler_builtins" } [profile.release] debug = true diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 23a92c73780..d435e347005 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -118,5 +118,5 @@ fn take_f32(_f: f32) {} fn take_unique(_u: Unique<()>) {} fn main() { - assert_eq!((1u128 + 2) as u16, 3); + } diff --git a/example/std_example.rs b/example/std_example.rs index 98d9ed17b03..ae77616a83d 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -3,32 +3,7 @@ use std::io::Write; fn main() { - let _ = ::std::iter::repeat('a' as u8).take(10).collect::>(); - let stderr = ::std::io::stderr(); - let mut stderr = stderr.lock(); - - writeln!(stderr, "some {} text", "").unwrap(); - - let _ = std::process::Command::new("true").env("c", "d").spawn(); - - println!("cargo:rustc-link-lib=z"); - - static ONCE: std::sync::Once = std::sync::ONCE_INIT; - ONCE.call_once(|| {}); - - LoopState::Continue(()) == LoopState::Break(()); - - // Make sure ByValPair values with differently sized components are correctly passed - map(None::<(u8, Box)>); - - println!("{}", 2.3f32.exp()); - println!("{}", 2.3f32.exp2()); - println!("{}", 2.3f32.abs()); - println!("{}", 2.3f32.sqrt()); - println!("{}", 2.3f32.floor()); - println!("{}", 2.3f32.ceil()); - println!("{}", 2.3f32.min(1.0)); - println!("{}", 2.3f32.max(1.0)); + assert_eq!((1u128 + 2) as u16, 3); } #[derive(PartialEq)] diff --git a/src/base.rs b/src/base.rs index f8bd5672346..7163c0949f7 100644 --- a/src/base.rs +++ b/src/base.rs @@ -11,83 +11,6 @@ pub fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( let mir = tcx.instance_mir(instance.def); - // Check fn sig for u128 and i128 and replace those functions with a trap. - { - // FIXME implement u128 and i128 support - - // Check sig for u128 and i128 - let fn_sig = tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &instance.fn_sig(tcx)); - - struct UI128Visitor<'tcx>(TyCtxt<'tcx>, bool); - - impl<'tcx> rustc::ty::fold::TypeVisitor<'tcx> for UI128Visitor<'tcx> { - fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { - if t.sty == self.0.types.u128.sty || t.sty == self.0.types.i128.sty { - self.1 = true; - return false; // stop visiting - } - - t.super_visit_with(self) - } - } - - let mut visitor = UI128Visitor(tcx, false); - fn_sig.visit_with(&mut visitor); - - //If found replace function with a trap. - if visitor.1 { - tcx.sess.warn("u128 and i128 are not yet supported. \ - Functions using these as args will be replaced with a trap."); - - // Declare function with fake signature - let sig = Signature { - params: vec![AbiParam::new(types::INVALID)], - returns: vec![], - call_conv: CallConv::Fast, - }; - let name = tcx.symbol_name(instance).as_str(); - let func_id = cx.module.declare_function(&*name, linkage, &sig).unwrap(); - - // Create trapping function - let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig); - let mut func_ctx = FunctionBuilderContext::new(); - let mut bcx = FunctionBuilder::new(&mut func, &mut func_ctx); - let start_ebb = bcx.create_ebb(); - bcx.append_ebb_params_for_function_params(start_ebb); - bcx.switch_to_block(start_ebb); - - let mut fx = FunctionCx { - tcx, - module: cx.module, - pointer_type: pointer_ty(tcx), - - instance, - mir, - - bcx, - ebb_map: HashMap::new(), - local_map: HashMap::new(), - - clif_comments: crate::pretty_clif::CommentWriter::new(tcx, instance), - constants: &mut cx.ccx, - caches: &mut cx.caches, - source_info_set: indexmap::IndexSet::new(), - }; - - crate::trap::trap_unreachable(&mut fx, "[unimplemented] Called function with u128 or i128 as argument."); - fx.bcx.seal_all_blocks(); - fx.bcx.finalize(); - - // Define function - cx.caches.context.func = func; - cx.module - .define_function(func_id, &mut cx.caches.context) - .unwrap(); - cx.caches.context.clear(); - return; - } - } - // Declare function let (name, sig) = get_function_name_and_sig(tcx, instance, false); let func_id = cx.module.declare_function(&name, linkage, &sig).unwrap(); @@ -391,7 +314,7 @@ fn trans_stmt<'a, 'tcx: 'a>( let rhs = trans_operand(fx, rhs); let res = match ty.sty { - ty::Bool => trans_bool_binop(fx, *bin_op, lhs, rhs, lval.layout().ty), + ty::Bool => trans_bool_binop(fx, *bin_op, lhs, rhs), ty::Uint(_) => { trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, false) } @@ -666,7 +589,7 @@ fn trans_stmt<'a, 'tcx: 'a>( clobbers, // Vec volatile, // bool alignstack, // bool - dialect, // syntax::ast::AsmDialect + dialect: _, // syntax::ast::AsmDialect asm_str_style: _, ctxt: _, } = asm; @@ -705,6 +628,9 @@ fn trans_stmt<'a, 'tcx: 'a>( crate::trap::trap_unimplemented(fx, "_xgetbv arch intrinsic is not supported"); } + _ if fx.tcx.symbol_name(fx.instance).as_str() == "__rust_probestack" => { + crate::trap::trap_unimplemented(fx, "__rust_probestack is not supported"); + } _ => unimpl!("Inline assembly is not supported"), } } @@ -856,10 +782,9 @@ fn trans_bool_binop<'a, 'tcx: 'a>( bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, - ty: Ty<'tcx>, ) -> CValue<'tcx> { let res = binop_match! { - fx, bin_op, false, lhs, rhs, ty, "bool"; + fx, bin_op, false, lhs, rhs, fx.tcx.types.bool, "bool"; Add (_) bug; Sub (_) bug; Mul (_) bug; @@ -900,7 +825,7 @@ pub fn trans_int_binop<'a, 'tcx: 'a>( ); } - if out_ty == fx.tcx.types.u128 || out_ty == fx.tcx.types.i128 { + if lhs.layout().ty == fx.tcx.types.u128 || lhs.layout().ty == fx.tcx.types.i128 { return match (bin_op, signed) { _ => { let layout = fx.layout_of(out_ty); diff --git a/src/common.rs b/src/common.rs index 810744527f9..57794a66b9c 100644 --- a/src/common.rs +++ b/src/common.rs @@ -82,6 +82,15 @@ pub fn clif_intcast<'a, 'tcx: 'a>( if from == to { return val; } + if to == types::I128 { + let wider = if signed { + fx.bcx.ins().sextend(types::I64, val) + } else { + fx.bcx.ins().uextend(types::I64, val) + }; + let zero = fx.bcx.ins().iconst(types::I64, 0); + return fx.bcx.ins().iconcat(wider, zero); + } if to.wider_or_equal(from) { if signed { fx.bcx.ins().sextend(to, val) @@ -89,7 +98,7 @@ pub fn clif_intcast<'a, 'tcx: 'a>( fx.bcx.ins().uextend(to, val) } } else if from == types::I128 { - let (lsb, msb) = fx.bcx.ins().isplit(val); + let (lsb, _msb) = fx.bcx.ins().isplit(val); fx.bcx.ins().ireduce(to, lsb) } else { fx.bcx.ins().ireduce(to, val)