From 1848e0df05a14679d49e5b87988fa6c7b609739b Mon Sep 17 00:00:00 2001 From: Colin Davidson Date: Mon, 28 Jul 2025 15:10:42 -0700 Subject: use the correct frequency for the arm tsc timer --- src/llvm_backend_proc.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/llvm_backend_proc.cpp') diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp index ffa434278..3f5819b43 100644 --- a/src/llvm_backend_proc.cpp +++ b/src/llvm_backend_proc.cpp @@ -2809,6 +2809,19 @@ gb_internal lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValu } return res; } + case BuiltinProc_arm64_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, ""); + + return res; + } case BuiltinProc_count_trailing_zeros: return lb_emit_count_trailing_zeros(p, lb_build_expr(p, ce->args[0]), tv.type); -- cgit v1.2.3