From 5a86c0499694d4dafa3af97c6b26860714bc8983 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 3 Feb 2017 15:14:18 -0500 Subject: add volatileStore() builtin function See #238 We can revisit how volatile will work later - for now here's a builtin function to do it. --- src/codegen.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index 8ebee75ac0..44b10dfca6 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -1303,7 +1303,10 @@ static LLVMValueRef ir_render_store_ptr(CodeGen *g, IrExecutable *executable, Ir return gen_struct_memcpy(g, value, ptr, op1_type); } - LLVMBuildStore(g->builder, value, ptr); + LLVMValueRef llvm_instruction = LLVMBuildStore(g->builder, value, ptr); + + LLVMSetVolatile(llvm_instruction, instruction->is_volatile); + return nullptr; } @@ -3686,6 +3689,7 @@ static void define_builtin_fns(CodeGen *g) { create_builtin_fn(g, BuiltinFnIdAlloca, "alloca", 2); create_builtin_fn(g, BuiltinFnIdSetGlobalAlign, "setGlobalAlign", 2); create_builtin_fn(g, BuiltinFnIdSetGlobalSection, "setGlobalSection", 2); + create_builtin_fn(g, BuiltinFnIdVolatileStore, "volatileStore", 2); } static void init(CodeGen *g, Buf *source_path) { -- cgit v1.2.3