mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
gen_dev-x86_64 extend Num.neg to all Signed and Unsigned int sizes
This commit is contained in:
parent
f1a1f57adf
commit
72863daa7e
2 changed files with 13 additions and 12 deletions
|
@ -1786,7 +1786,7 @@ impl<
|
|||
|
||||
fn build_num_neg(&mut self, dst: &Symbol, src: &Symbol, layout: &InLayout<'a>) {
|
||||
match self.layout_interner.get_repr(*layout) {
|
||||
LayoutRepr::Builtin(Builtin::Int(IntWidth::I64 | IntWidth::U64)) => {
|
||||
LayoutRepr::Builtin(Builtin::Int(quadword_and_smaller!())) => {
|
||||
let dst_reg = self.storage_manager.claim_general_reg(&mut self.buf, dst);
|
||||
let src_reg = self.storage_manager.load_to_general_reg(&mut self.buf, src);
|
||||
ASM::neg_reg64_reg64(&mut self.buf, dst_reg, src_reg);
|
||||
|
|
|
@ -1605,20 +1605,21 @@ fn tail_call_elimination() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "gen-dev")]
|
||||
fn int_negate_dev() {
|
||||
// TODO
|
||||
// dev backend yet to have `Num.maxI64` or `Num.minI64`.
|
||||
// add the "gen-dev" feature to the test below after implementing them both.
|
||||
assert_evals_to!("Num.neg 123", -123, i64);
|
||||
assert_evals_to!("Num.neg -123", 123, i64);
|
||||
assert_evals_to!("Num.neg 0", 0, i64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn int_negate() {
|
||||
assert_evals_to!("Num.neg 123i8", -123, i8);
|
||||
assert_evals_to!("Num.neg Num.maxI8", -i8::MAX, i8);
|
||||
assert_evals_to!("Num.neg (Num.minI8 + 1)", i8::MAX, i8);
|
||||
|
||||
assert_evals_to!("Num.neg 123i16", -123, i16);
|
||||
assert_evals_to!("Num.neg Num.maxI16", -i16::MAX, i16);
|
||||
assert_evals_to!("Num.neg (Num.minI16 + 1)", i16::MAX, i16);
|
||||
|
||||
assert_evals_to!("Num.neg 123i32", -123, i32);
|
||||
assert_evals_to!("Num.neg Num.maxI32", -i32::MAX, i32);
|
||||
assert_evals_to!("Num.neg (Num.minI32 + 1)", i32::MAX, i32);
|
||||
|
||||
assert_evals_to!("Num.neg 123", -123, i64);
|
||||
assert_evals_to!("Num.neg Num.maxI64", -i64::MAX, i64);
|
||||
assert_evals_to!("Num.neg (Num.minI64 + 1)", i64::MAX, i64);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue