INT NEQ for i1 and i8 integer types

This commit is contained in:
Chad Stearns 2020-05-01 17:29:43 -04:00
parent 4b5f7bfded
commit d1b00633be
3 changed files with 28 additions and 0 deletions

View file

@ -1255,6 +1255,18 @@ fn call_with_args<'a, 'ctx, 'env>(
BasicValueEnum::IntValue(int_val) BasicValueEnum::IntValue(int_val)
} }
Symbol::INT_NEQ_I1 => {
debug_assert!(args.len() == 2);
let int_val = env.builder.build_int_compare(
IntPredicate::NE,
args[0].0.into_int_value(),
args[1].0.into_int_value(),
"cmp_i1",
);
BasicValueEnum::IntValue(int_val)
}
Symbol::INT_EQ_I8 => { Symbol::INT_EQ_I8 => {
debug_assert!(args.len() == 2); debug_assert!(args.len() == 2);
@ -1267,6 +1279,18 @@ fn call_with_args<'a, 'ctx, 'env>(
BasicValueEnum::IntValue(int_val) BasicValueEnum::IntValue(int_val)
} }
Symbol::INT_NEQ_I8 => {
debug_assert!(args.len() == 2);
let int_val = env.builder.build_int_compare(
IntPredicate::NE,
args[0].0.into_int_value(),
args[1].0.into_int_value(),
"cmp_i8",
);
BasicValueEnum::IntValue(int_val)
}
Symbol::NUM_TO_FLOAT => { Symbol::NUM_TO_FLOAT => {
// TODO specialize this to be not just for i64! // TODO specialize this to be not just for i64!
let builtin_fn_name = "i64_to_f64_"; let builtin_fn_name = "i64_to_f64_";

View file

@ -607,6 +607,8 @@ define_builtins! {
17 INT_DIV_ARG_NUMERATOR: "div#numerator" // The first argument to `//`, the numerator 17 INT_DIV_ARG_NUMERATOR: "div#numerator" // The first argument to `//`, the numerator
18 INT_DIV_ARG_DENOMINATOR: "div#denominator" // The first argument to `//`, the denominator 18 INT_DIV_ARG_DENOMINATOR: "div#denominator" // The first argument to `//`, the denominator
19 INT_NEQ_I64: "#neqi64" 19 INT_NEQ_I64: "#neqi64"
20 INT_NEQ_I1: "#neqi1"
21 INT_NEQ_I8: "#neqi8"
} }
3 FLOAT: "Float" => { 3 FLOAT: "Float" => {
0 FLOAT_FLOAT: "Float" imported // the Float.Float type alias 0 FLOAT_FLOAT: "Float" imported // the Float.Float type alias

View file

@ -552,6 +552,8 @@ fn from_can<'a>(
) { ) {
Ok(Layout::Builtin(builtin)) => match builtin { Ok(Layout::Builtin(builtin)) => match builtin {
Builtin::Int64 => Symbol::INT_NEQ_I64, Builtin::Int64 => Symbol::INT_NEQ_I64,
Builtin::Bool => Symbol::INT_NEQ_I1,
Builtin::Byte => Symbol::INT_NEQ_I8,
_ => { _ => {
panic!("Not-Equality not implemented for {:?}", builtin) panic!("Not-Equality not implemented for {:?}", builtin)
} }