aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_proc.cpp
diff options
context:
space:
mode:
authorColin Davidson <colrdavidson@gmail.com>2025-07-29 12:21:46 -0700
committerColin Davidson <colrdavidson@gmail.com>2025-07-29 12:21:46 -0700
commit9a2e6fff481968f201e6bf6a601ab7a4e3fbef45 (patch)
tree00af92c561ffd9c6ea5548b6e117ca03cd48ac49 /src/llvm_backend_proc.cpp
parentc1b3d035e4be4bdbebb397035a95e6dbc60f1bd6 (diff)
switch to read_cycle_counter_frequency from arm64_read_cycle_counter_freq, trap on invalid arch
Diffstat (limited to 'src/llvm_backend_proc.cpp')
-rw-r--r--src/llvm_backend_proc.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp
index 3f5819b43..5e38e6bdc 100644
--- a/src/llvm_backend_proc.cpp
+++ b/src/llvm_backend_proc.cpp
@@ -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;
}