Merge pull request #371 from maxaudron/master
add 32 bit shift instructions
This commit is contained in:
commit
cf75c5dc21
3 changed files with 34 additions and 0 deletions
|
|
@ -188,6 +188,7 @@ macro_rules! int_impl {
|
|||
};
|
||||
}
|
||||
|
||||
int_impl!(i16, u16, 16);
|
||||
int_impl!(i32, u32, 32);
|
||||
int_impl!(i64, u64, 64);
|
||||
int_impl!(i128, u128, 128);
|
||||
|
|
@ -229,6 +230,8 @@ macro_rules! large_int {
|
|||
};
|
||||
}
|
||||
|
||||
large_int!(u32, u16, u16, 16);
|
||||
large_int!(i32, u16, i16, 16);
|
||||
large_int!(u64, u32, u32, 32);
|
||||
large_int!(i64, u32, i32, 32);
|
||||
large_int!(u128, u64, u64, 64);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ trait Ashl: Int + LargeInt {
|
|||
}
|
||||
}
|
||||
|
||||
impl Ashl for u32 {}
|
||||
impl Ashl for u64 {}
|
||||
impl Ashl for u128 {}
|
||||
|
||||
|
|
@ -47,6 +48,7 @@ trait Ashr: Int + LargeInt {
|
|||
}
|
||||
}
|
||||
|
||||
impl Ashr for i32 {}
|
||||
impl Ashr for i64 {}
|
||||
impl Ashr for i128 {}
|
||||
|
||||
|
|
@ -70,10 +72,16 @@ trait Lshr: Int + LargeInt {
|
|||
}
|
||||
}
|
||||
|
||||
impl Lshr for u32 {}
|
||||
impl Lshr for u64 {}
|
||||
impl Lshr for u128 {}
|
||||
|
||||
intrinsics! {
|
||||
#[maybe_use_optimized_c_shim]
|
||||
pub extern "C" fn __ashlsi3(a: u32, b: u32) -> u32 {
|
||||
a.ashl(b)
|
||||
}
|
||||
|
||||
#[maybe_use_optimized_c_shim]
|
||||
#[arm_aeabi_alias = __aeabi_llsl]
|
||||
pub extern "C" fn __ashldi3(a: u64, b: u32) -> u64 {
|
||||
|
|
@ -84,6 +92,11 @@ intrinsics! {
|
|||
a.ashl(b)
|
||||
}
|
||||
|
||||
#[maybe_use_optimized_c_shim]
|
||||
pub extern "C" fn __ashrsi3(a: i32, b: u32) -> i32 {
|
||||
a.ashr(b)
|
||||
}
|
||||
|
||||
#[maybe_use_optimized_c_shim]
|
||||
#[arm_aeabi_alias = __aeabi_lasr]
|
||||
pub extern "C" fn __ashrdi3(a: i64, b: u32) -> i64 {
|
||||
|
|
@ -94,6 +107,11 @@ intrinsics! {
|
|||
a.ashr(b)
|
||||
}
|
||||
|
||||
#[maybe_use_optimized_c_shim]
|
||||
pub extern "C" fn __lshrsi3(a: u32, b: u32) -> u32 {
|
||||
a.lshr(b)
|
||||
}
|
||||
|
||||
#[maybe_use_optimized_c_shim]
|
||||
#[arm_aeabi_alias = __aeabi_llsr]
|
||||
pub extern "C" fn __lshrdi3(a: u64, b: u32) -> u64 {
|
||||
|
|
|
|||
|
|
@ -857,6 +857,10 @@ fn main() {
|
|||
);
|
||||
|
||||
// int/shift.rs
|
||||
gen(
|
||||
|(a, b): (MyU32, MyU32)| Some(a.0 << (b.0 % 32)),
|
||||
"builtins::int::shift::__ashlsi3(a, b % 32)",
|
||||
);
|
||||
gen(
|
||||
|(a, b): (MyU64, MyU32)| Some(a.0 << (b.0 % 64)),
|
||||
"builtins::int::shift::__ashldi3(a, b % 64)",
|
||||
|
|
@ -865,6 +869,10 @@ fn main() {
|
|||
|(a, b): (MyU128, MyU32)| Some(a.0 << (b.0 % 128)),
|
||||
"builtins::int::shift::__ashlti3(a, b % 128)",
|
||||
);
|
||||
gen(
|
||||
|(a, b): (MyI32, MyU32)| Some(a.0 >> (b.0 % 32)),
|
||||
"builtins::int::shift::__ashrsi3(a, b % 32)",
|
||||
);
|
||||
gen(
|
||||
|(a, b): (MyI64, MyU32)| Some(a.0 >> (b.0 % 64)),
|
||||
"builtins::int::shift::__ashrdi3(a, b % 64)",
|
||||
|
|
@ -873,6 +881,10 @@ fn main() {
|
|||
|(a, b): (MyI128, MyU32)| Some(a.0 >> (b.0 % 128)),
|
||||
"builtins::int::shift::__ashrti3(a, b % 128)",
|
||||
);
|
||||
gen(
|
||||
|(a, b): (MyU32, MyU32)| Some(a.0 >> (b.0 % 32)),
|
||||
"builtins::int::shift::__lshrsi3(a, b % 32)",
|
||||
);
|
||||
gen(
|
||||
|(a, b): (MyU64, MyU32)| Some(a.0 >> (b.0 % 64)),
|
||||
"builtins::int::shift::__lshrdi3(a, b % 64)",
|
||||
|
|
@ -1285,6 +1297,7 @@ my_integer! {
|
|||
struct MyI32(i32);
|
||||
struct MyI64(i64);
|
||||
struct MyI128(i128);
|
||||
struct MyU16(u16);
|
||||
struct MyU32(u32);
|
||||
struct MyU64(u64);
|
||||
struct MyU128(u128);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue