diff options
| author | cardboardguru76 <stevew@tellybug.com> | 2025-07-30 00:28:31 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-30 00:28:31 +0100 |
| commit | 44f039a92f79b1af5df9ada793834db43a0faea9 (patch) | |
| tree | 55ce6d242b65d9973b14655d6ce5db28b723da89 /src/llvm_backend_proc.cpp | |
| parent | 9c5e577792eff2cd9c95b590526c17a4e8762d5a (diff) | |
| parent | 861fa4ab68d07bc8f3827ca29946c79c7b3f744e (diff) | |
Merge branch 'odin-lang:master' into darwin-foundation-support-for-handmade-hero-port
Diffstat (limited to 'src/llvm_backend_proc.cpp')
| -rw-r--r-- | src/llvm_backend_proc.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp index 5c38367f1..e63c92f6f 100644 --- a/src/llvm_backend_proc.cpp +++ b/src/llvm_backend_proc.cpp @@ -2811,6 +2811,21 @@ gb_internal lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValu } return res; } + case BuiltinProc_read_cycle_counter_frequency: + { + lbValue res = {}; + res.type = tv.type; + + 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, ""); + } + + return res; + } case BuiltinProc_count_trailing_zeros: return lb_emit_count_trailing_zeros(p, lb_build_expr(p, ce->args[0]), tv.type); |