diff options
| author | gingerBill <bill@gingerbill.org> | 2020-10-24 15:08:35 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-10-24 15:08:35 +0100 |
| commit | 5fa488f163fbaa049e213f4b1cabf885ab49816f (patch) | |
| tree | a869e1993615b467f7cbd4552d5da0c08358406f /src/llvm_backend.cpp | |
| parent | feeb342c009022b3de6f903ef1e3cc40b54951ca (diff) | |
Add intrinsics.cpu_relax for llvm-api
Diffstat (limited to 'src/llvm_backend.cpp')
| -rw-r--r-- | src/llvm_backend.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index 8052bf759..65586d3a6 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -7835,8 +7835,17 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, } case BuiltinProc_cpu_relax: - // TODO(bill): BuiltinProc_cpu_relax - // ir_write_str_lit(f, "call void asm sideeffect \"pause\", \"\"()"); + { + LLVMTypeRef func_type = LLVMFunctionType(LLVMVoidTypeInContext(p->module->ctx), nullptr, 0, false); + LLVMValueRef the_asm = LLVMGetInlineAsm(func_type, + "pause", 5, + "", 0, + /*HasSideEffects*/true, /*IsAlignStack*/false, + LLVMInlineAsmDialectATT + ); + GB_ASSERT(the_asm != nullptr); + LLVMBuildCall2(p->builder, func_type, the_asm, nullptr, 0, ""); + } return {}; case BuiltinProc_atomic_fence: |