mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
Merge branch 'main' into int_overflow
This commit is contained in:
commit
7055253564
82 changed files with 1326 additions and 1036 deletions
|
@ -8,19 +8,18 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
morphic_lib = { path = "../../vendor/morphic_lib" }
|
||||
roc_alias_analysis = { path = "../alias_analysis" }
|
||||
roc_bitcode_bc = { path = "../builtins/bitcode/bc" }
|
||||
roc_builtins = { path = "../builtins" }
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_debug_flags = { path = "../debug_flags" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_mono = { path = "../mono" }
|
||||
roc_region = { path = "../region" }
|
||||
roc_std = { path = "../../roc_std" }
|
||||
roc_target = { path = "../roc_target" }
|
||||
|
||||
morphic_lib.workspace = true
|
||||
roc_alias_analysis.workspace = true
|
||||
roc_bitcode_bc.workspace = true
|
||||
roc_builtins.workspace = true
|
||||
roc_collections.workspace = true
|
||||
roc_debug_flags.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_mono.workspace = true
|
||||
roc_region.workspace = true
|
||||
roc_std.workspace = true
|
||||
roc_target.workspace = true
|
||||
bumpalo.workspace = true
|
||||
inkwell.workspace = true
|
||||
target-lexicon.workspace = true
|
||||
|
|
|
@ -12,8 +12,8 @@ use crate::llvm::refcounting::{
|
|||
use inkwell::attributes::{Attribute, AttributeLoc};
|
||||
use inkwell::types::{BasicType, BasicTypeEnum, StructType};
|
||||
use inkwell::values::{
|
||||
BasicValueEnum, CallSiteValue, FunctionValue, InstructionValue, IntValue, PointerValue,
|
||||
StructValue,
|
||||
BasicValue, BasicValueEnum, CallSiteValue, FunctionValue, InstructionValue, IntValue,
|
||||
PointerValue, StructValue,
|
||||
};
|
||||
use inkwell::AddressSpace;
|
||||
use roc_error_macros::internal_error;
|
||||
|
@ -47,6 +47,28 @@ pub fn call_bitcode_fn<'ctx>(
|
|||
.build_bitcast(ret, env.context.i128_type(), "return_i128")
|
||||
.unwrap();
|
||||
}
|
||||
} else if env.target == roc_target::Target::MacArm64 {
|
||||
// Essentially the same happens on macos arm64, but with array type [2xi64].
|
||||
let i64_type = env.context.i64_type();
|
||||
let arr_type = i64_type.array_type(2);
|
||||
if ret.get_type() == arr_type.into() {
|
||||
let alloca = env
|
||||
.builder
|
||||
.build_array_alloca(i64_type, i64_type.const_int(2, false), "dec_alloca")
|
||||
.unwrap_or_else(|err| internal_error!("failed to build array alloca: {err}"));
|
||||
let instruction = alloca.as_instruction_value().unwrap_or_else(|| {
|
||||
internal_error!("failed to convert pointer to instruction value ({alloca:?})");
|
||||
});
|
||||
instruction.set_alignment(16).unwrap_or_else(|err| {
|
||||
internal_error!(
|
||||
"failed to set 16-byte alignment on instruction ({instruction:?}): {err}"
|
||||
);
|
||||
});
|
||||
env.builder.new_build_store(alloca, ret);
|
||||
return env
|
||||
.builder
|
||||
.new_build_load(env.context.i128_type(), alloca, "return_i128");
|
||||
}
|
||||
}
|
||||
|
||||
ret
|
||||
|
|
|
@ -1784,7 +1784,7 @@ fn build_float_binop<'ctx>(
|
|||
};
|
||||
|
||||
match op {
|
||||
NumAdd => bd.new_build_float_add(lhs, rhs, "add_float").into(),
|
||||
NumAdd | NumAddSaturated => bd.new_build_float_add(lhs, rhs, "add_float").into(),
|
||||
NumAddChecked => {
|
||||
let context = env.context;
|
||||
|
||||
|
@ -1811,7 +1811,7 @@ fn build_float_binop<'ctx>(
|
|||
struct_value.into()
|
||||
}
|
||||
NumAddWrap => unreachable!("wrapping addition is not defined on floats"),
|
||||
NumSub => bd.new_build_float_sub(lhs, rhs, "sub_float").into(),
|
||||
NumSub | NumSubSaturated => bd.new_build_float_sub(lhs, rhs, "sub_float").into(),
|
||||
NumSubChecked => {
|
||||
let context = env.context;
|
||||
|
||||
|
@ -1838,8 +1838,7 @@ fn build_float_binop<'ctx>(
|
|||
struct_value.into()
|
||||
}
|
||||
NumSubWrap => unreachable!("wrapping subtraction is not defined on floats"),
|
||||
NumMul => bd.new_build_float_mul(lhs, rhs, "mul_float").into(),
|
||||
NumMulSaturated => bd.new_build_float_mul(lhs, rhs, "mul_float").into(),
|
||||
NumMul | NumMulSaturated => bd.new_build_float_mul(lhs, rhs, "mul_float").into(),
|
||||
NumMulChecked => {
|
||||
let context = env.context;
|
||||
|
||||
|
@ -1881,7 +1880,7 @@ fn build_float_binop<'ctx>(
|
|||
&bitcode::NUM_POW[float_width],
|
||||
),
|
||||
_ => {
|
||||
unreachable!("Unrecognized int binary operation: {:?}", op);
|
||||
unreachable!("Unrecognized float binary operation: {:?}", op);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2312,6 +2311,9 @@ fn build_dec_binop<'a, 'ctx>(
|
|||
rhs,
|
||||
"Decimal multiplication overflowed",
|
||||
),
|
||||
NumAddSaturated => dec_binary_op(env, bitcode::DEC_ADD_SATURATED, lhs, rhs),
|
||||
NumSubSaturated => dec_binary_op(env, bitcode::DEC_SUB_SATURATED, lhs, rhs),
|
||||
NumMulSaturated => dec_binary_op(env, bitcode::DEC_MUL_SATURATED, lhs, rhs),
|
||||
NumDivFrac => dec_binop_with_unchecked(env, bitcode::DEC_DIV, lhs, rhs),
|
||||
|
||||
NumLt => call_bitcode_fn(env, &[lhs, rhs], &bitcode::NUM_LESS_THAN[IntWidth::I128]),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue