diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-02-03 15:14:18 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-02-03 15:14:18 -0500 |
| commit | 5a86c0499694d4dafa3af97c6b26860714bc8983 (patch) | |
| tree | 36c7b589fa136e75ae8f104009f360fc2ee25431 /src/codegen.cpp | |
| parent | 8c9016b6d1a62da847faf95b6124515cdcd9fe0b (diff) | |
| download | zig-5a86c0499694d4dafa3af97c6b26860714bc8983.tar.gz zig-5a86c0499694d4dafa3af97c6b26860714bc8983.zip | |
add volatileStore() builtin function
See #238
We can revisit how volatile will work later - for now
here's a builtin function to do it.
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
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) { |
