Fix sign-extension in stage1 compiler
This commit is contained in:
parent
0a481fe5d2
commit
208c8f58b2
2 changed files with 5 additions and 4 deletions
|
|
@ -427,13 +427,14 @@ pub fn C_integral(t: Type, u: u64, sign_extend: bool) -> ValueRef {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn C_big_integral(t: Type, u: u128) -> ValueRef {
|
||||
pub fn C_big_integral(t: Type, u: u128, sign_extend: bool) -> ValueRef {
|
||||
if ::std::mem::size_of::<u128>() == 16 {
|
||||
unsafe {
|
||||
llvm::LLVMConstIntOfArbitraryPrecision(t.to_ref(), 2, &u as *const u128 as *const u64)
|
||||
}
|
||||
} else {
|
||||
C_integral(t, u as u64, false)
|
||||
// SNAP: remove after snapshot
|
||||
C_integral(t, u as u64, sign_extend)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ impl<'tcx> Const<'tcx> {
|
|||
ConstVal::Integral(I16(v)) => C_integral(Type::i16(ccx), v as u64, true),
|
||||
ConstVal::Integral(I32(v)) => C_integral(Type::i32(ccx), v as u64, true),
|
||||
ConstVal::Integral(I64(v)) => C_integral(Type::i64(ccx), v as u64, true),
|
||||
ConstVal::Integral(I128(v)) => C_big_integral(Type::i128(ccx), v as u128),
|
||||
ConstVal::Integral(I128(v)) => C_big_integral(Type::i128(ccx), v as u128, true),
|
||||
ConstVal::Integral(Isize(v)) => {
|
||||
let i = v.as_i64(ccx.tcx().sess.target.int_type);
|
||||
C_integral(Type::int(ccx), i as u64, true)
|
||||
|
|
@ -85,7 +85,7 @@ impl<'tcx> Const<'tcx> {
|
|||
ConstVal::Integral(U16(v)) => C_integral(Type::i16(ccx), v as u64, false),
|
||||
ConstVal::Integral(U32(v)) => C_integral(Type::i32(ccx), v as u64, false),
|
||||
ConstVal::Integral(U64(v)) => C_integral(Type::i64(ccx), v, false),
|
||||
ConstVal::Integral(U128(v)) => C_big_integral(Type::i128(ccx), v),
|
||||
ConstVal::Integral(U128(v)) => C_big_integral(Type::i128(ccx), v, false),
|
||||
ConstVal::Integral(Usize(v)) => {
|
||||
let u = v.as_u64(ccx.tcx().sess.target.uint_type);
|
||||
C_integral(Type::int(ccx), u, false)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue