mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-16 05:56:56 +00:00
Remove some unnecessary changes
This commit is contained in:
parent
5180becc7c
commit
7f5c2dab9d
@ -446,7 +446,6 @@ pub mod intrinsics {
|
||||
pub fn needs_drop<T>() -> bool;
|
||||
pub fn bitreverse<T>(x: T) -> T;
|
||||
pub fn bswap<T>(x: T) -> T;
|
||||
pub fn unchecked_div<T>(lhs: T, rhs: T) -> T;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,65 @@
|
||||
use std::io::Write;
|
||||
use std::intrinsics;
|
||||
|
||||
fn main() {
|
||||
let _ = ::std::iter::repeat('a' as u8).take(10).collect::<Vec<_>>();
|
||||
let stderr = ::std::io::stderr();
|
||||
let mut stderr = stderr.lock();
|
||||
|
||||
writeln!(stderr, "some {} text", "<unknown>").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<Instruction>)>);
|
||||
|
||||
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!(0b0000000000000000000000000010000010000000000000000000000000000000_0000000000100000000000000000000000001000000000000100000000000000u128.leading_zeros(), 26);
|
||||
assert_eq!(0b0000000000000000000000000010000000000000000000000000000000000000_0000000000000000000000000000000000001000000000000000000010000000u128.trailing_zeros(), 7);
|
||||
|
||||
checked_div_i128(0i128, 2i128);
|
||||
checked_div_u128(0u128, 2u128);
|
||||
assert_eq!(1u128 + 2, 3);
|
||||
|
||||
assert_eq!(0b100010000000000000000000000000000u128 >> 10, 0b10001000000000000000000u128);
|
||||
assert_eq!(0xFEDCBA987654321123456789ABCDEFu128 >> 64, 0xFEDCBA98765432u128);
|
||||
assert_eq!(0xFEDCBA987654321123456789ABCDEFu128 as i128 >> 64, 0xFEDCBA98765432i128);
|
||||
assert_eq!(353985398u128 * 932490u128, 330087843781020u128);
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
enum LoopState {
|
||||
Continue(()),
|
||||
Break(())
|
||||
}
|
||||
|
||||
pub enum Instruction {
|
||||
Increment,
|
||||
Loop,
|
||||
}
|
||||
|
||||
fn map(a: Option<(u8, Box<Instruction>)>) -> Option<Box<Instruction>> {
|
||||
match a {
|
||||
None => None,
|
||||
Some((_, instr)) => Some(instr),
|
||||
}
|
||||
}
|
||||
|
||||
fn checked_div_i128(lhs: i128, rhs: i128) -> Option<i128> {
|
||||
if rhs == 0 || (lhs == -170141183460469231731687303715884105728 && rhs == -1) {
|
||||
None
|
||||
@ -17,20 +76,3 @@ fn checked_div_u128(lhs: u128, rhs: u128) -> Option<u128> {
|
||||
rhs => Some(unsafe { intrinsics::unchecked_div(lhs, rhs) })
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
assert_eq!(0b0000000000000000000000000010000010000000000000000000000000000000_0000000000100000000000000000000000001000000000000100000000000000u128.leading_zeros(), 26);
|
||||
assert_eq!(0b0000000000000000000000000010000000000000000000000000000000000000_0000000000000000000000000000000000001000000000000000000010000000u128.trailing_zeros(), 7);
|
||||
|
||||
checked_div_i128(0i128, 2i128);
|
||||
checked_div_u128(0u128, 2u128);
|
||||
assert_eq!(1u128 + 2, 3);
|
||||
|
||||
// overflow panic
|
||||
// 0xFEDCBA987654321123456789ABCDEFu128 + 0xFEDCBA987654321123456789ABCDEFu128;
|
||||
|
||||
println!("{}", 0b100010000000000000000000000000000u128 >> 10);
|
||||
println!("{}", 0xFEDCBA987654321123456789ABCDEFu128 >> 64);
|
||||
println!("{} >> 64 == {}", 0xFEDCBA987654321123456789ABCDEFu128 as i128, 0xFEDCBA987654321123456789ABCDEFu128 as i128 >> 64);
|
||||
println!("{}", 353985398u128 * 932490u128);
|
||||
}
|
||||
|
@ -34,31 +34,6 @@ enum CValueInner {
|
||||
ByValPair(Value, Value),
|
||||
}
|
||||
|
||||
fn store_scalar<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>, value: Value, addr: Value, offset: i32) {
|
||||
if fx.bcx.func.dfg.value_type(value) == types::I128 {
|
||||
let (a, b) = fx.bcx.ins().isplit(value);
|
||||
fx.bcx.ins().store(MemFlags::new(), a, addr, offset);
|
||||
fx.bcx.ins().store(MemFlags::new(), b, addr, offset + 8);
|
||||
} else {
|
||||
fx.bcx.ins().store(MemFlags::new(), value, addr, offset);
|
||||
}
|
||||
}
|
||||
|
||||
fn load_scalar<'a, 'tcx: 'a>(
|
||||
fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
|
||||
clif_ty: Type,
|
||||
addr: Value,
|
||||
offset: i32,
|
||||
) -> Value {
|
||||
if clif_ty == types::I128 {
|
||||
let a = fx.bcx.ins().load(types::I64, MemFlags::new(), addr, offset);
|
||||
let b = fx.bcx.ins().load(types::I64, MemFlags::new(), addr, offset + 8);
|
||||
fx.bcx.ins().iconcat(a, b)
|
||||
} else {
|
||||
fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, offset)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> CValue<'tcx> {
|
||||
pub fn by_ref(value: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> {
|
||||
CValue(CValueInner::ByRef(value), layout)
|
||||
@ -104,7 +79,7 @@ impl<'tcx> CValue<'tcx> {
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let clif_ty = scalar_to_clif_type(fx.tcx, scalar);
|
||||
load_scalar(fx, clif_ty, addr, 0)
|
||||
fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, 0)
|
||||
}
|
||||
CValueInner::ByVal(value) => value,
|
||||
CValueInner::ByValPair(_, _) => bug!("Please use load_scalar_pair for ByValPair"),
|
||||
@ -126,10 +101,10 @@ impl<'tcx> CValue<'tcx> {
|
||||
let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar);
|
||||
let clif_ty1 = scalar_to_clif_type(fx.tcx, a_scalar.clone());
|
||||
let clif_ty2 = scalar_to_clif_type(fx.tcx, b_scalar.clone());
|
||||
let val1 = load_scalar(fx, clif_ty1, addr, 0);
|
||||
let val2 = load_scalar(
|
||||
fx,
|
||||
let val1 = fx.bcx.ins().load(clif_ty1, MemFlags::new(), addr, 0);
|
||||
let val2 = fx.bcx.ins().load(
|
||||
clif_ty2,
|
||||
MemFlags::new(),
|
||||
addr,
|
||||
b_offset,
|
||||
);
|
||||
@ -389,15 +364,15 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> {
|
||||
|
||||
match from.0 {
|
||||
CValueInner::ByVal(val) => {
|
||||
store_scalar(fx, val, addr, 0);
|
||||
fx.bcx.ins().store(MemFlags::new(), val, addr, 0);
|
||||
}
|
||||
CValueInner::ByValPair(value, extra) => {
|
||||
match dst_layout.abi {
|
||||
Abi::ScalarPair(ref a_scalar, ref b_scalar) => {
|
||||
let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar);
|
||||
store_scalar(fx, value, addr, 0);
|
||||
store_scalar(
|
||||
fx,
|
||||
fx.bcx.ins().store(MemFlags::new(), value, addr, 0);
|
||||
fx.bcx.ins().store(
|
||||
MemFlags::new(),
|
||||
extra,
|
||||
addr,
|
||||
b_offset,
|
||||
|
Loading…
Reference in New Issue
Block a user