feat(arm32 cdecl): Added thumb as the triple for cortex-m7. Updated the calling convention for cortex-m7 arm32 micro processors as the soft float register was being used when calling across the C ABI boundary causing guff data to be passed.

This commit is contained in:
MauriceElliott
2026-06-24 21:07:48 +01:00
parent ab11e45a4a
commit a3fa3476c6
3 changed files with 27 additions and 10 deletions

View File

@@ -452,7 +452,9 @@ gb_internal lbProcedure *lb_create_dummy_procedure(lbModule *m, String link_name
Type *pt = p->type;
lbCallingConventionKind cc_kind = lbCallingConvention_C;
if (!is_arch_wasm()) {
if (is_cortex_m7()) {
cc_kind = lbCallingConvention_ARM_AAPCS_VFP;
} else if (!is_arch_wasm()) {
cc_kind = lb_calling_convention_map[pt->Proc.calling_convention];
}
LLVMSetFunctionCallConv(p->value, cc_kind);
@@ -994,6 +996,9 @@ gb_internal lbValue lb_emit_call_internal(lbProcedure *p, lbValue value, lbValue
LLVMValueRef ret = LLVMBuildCall2(p->builder, fnp, fn, args, arg_count, "");
auto llvm_cc = lb_calling_convention_map[proc_type->Proc.calling_convention];
if (is_cortex_m7()) {
llvm_cc = lbCallingConvention_ARM_AAPCS_VFP;
}
LLVMSetInstructionCallConv(ret, llvm_cc);
LLVMAttributeIndex param_offset = LLVMAttributeIndex_FirstArgIndex;