mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-06 13:07:59 +00:00
switch to read_cycle_counter_frequency from arm64_read_cycle_counter_freq, trap on invalid arch
This commit is contained in:
@@ -2809,16 +2809,20 @@ gb_internal lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValu
|
||||
}
|
||||
return res;
|
||||
}
|
||||
case BuiltinProc_arm64_read_cycle_counter_frequency:
|
||||
case BuiltinProc_read_cycle_counter_frequency:
|
||||
{
|
||||
lbValue res = {};
|
||||
res.type = tv.type;
|
||||
|
||||
LLVMTypeRef func_type = LLVMFunctionType(LLVMInt64TypeInContext(p->module->ctx), nullptr, 0, false);
|
||||
bool has_side_effects = false;
|
||||
LLVMValueRef the_asm = llvm_get_inline_asm(func_type, str_lit("mrs $0, cntfrq_el0"), str_lit("=r"), has_side_effects);
|
||||
GB_ASSERT(the_asm != nullptr);
|
||||
res.value = LLVMBuildCall2(p->builder, func_type, the_asm, nullptr, 0, "");
|
||||
if (build_context.metrics.arch == TargetArch_arm64) {
|
||||
LLVMTypeRef func_type = LLVMFunctionType(LLVMInt64TypeInContext(p->module->ctx), nullptr, 0, false);
|
||||
bool has_side_effects = false;
|
||||
LLVMValueRef the_asm = llvm_get_inline_asm(func_type, str_lit("mrs $0, cntfrq_el0"), str_lit("=r"), has_side_effects);
|
||||
GB_ASSERT(the_asm != nullptr);
|
||||
res.value = LLVMBuildCall2(p->builder, func_type, the_asm, nullptr, 0, "");
|
||||
} else {
|
||||
GB_PANIC("Unsupported architecture: %.*s", LIT(target_arch_names[build_context.metrics.arch]));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user