diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-11-13 03:06:55 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-13 03:06:55 +0000 |
| commit | 8bae70454dabe77dfe7e5344e59ca2180d63af51 (patch) | |
| tree | bfb8f584993bf720414f5ab493b42aadd3c24e72 /src/codegen.cpp | |
| parent | 32b37e695aa0581b863a395e0a28b7b4aa76c07d (diff) | |
| parent | 41914321b4593e3ed246cadda705e1076ab670d7 (diff) | |
| download | zig-8bae70454dabe77dfe7e5344e59ca2180d63af51.tar.gz zig-8bae70454dabe77dfe7e5344e59ca2180d63af51.zip | |
Merge pull request #3675 from Vexu/atomic-store
Add @atomicStore builtin
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 387c6120c2..a0666a3522 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -5655,6 +5655,17 @@ static LLVMValueRef ir_render_atomic_load(CodeGen *g, IrExecutable *executable, return load_inst; } +static LLVMValueRef ir_render_atomic_store(CodeGen *g, IrExecutable *executable, + IrInstructionAtomicStore *instruction) +{ + LLVMAtomicOrdering ordering = to_LLVMAtomicOrdering(instruction->resolved_ordering); + LLVMValueRef ptr = ir_llvm_value(g, instruction->ptr); + LLVMValueRef value = ir_llvm_value(g, instruction->value); + LLVMValueRef store_inst = gen_store(g, value, ptr, instruction->ptr->value.type); + LLVMSetOrdering(store_inst, ordering); + return nullptr; +} + static LLVMValueRef ir_render_float_op(CodeGen *g, IrExecutable *executable, IrInstructionFloatOp *instruction) { LLVMValueRef op = ir_llvm_value(g, instruction->op1); assert(instruction->base.value.type->id == ZigTypeIdFloat); @@ -6258,6 +6269,8 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable, return ir_render_atomic_rmw(g, executable, (IrInstructionAtomicRmw *)instruction); case IrInstructionIdAtomicLoad: return ir_render_atomic_load(g, executable, (IrInstructionAtomicLoad *)instruction); + case IrInstructionIdAtomicStore: + return ir_render_atomic_store(g, executable, (IrInstructionAtomicStore *)instruction); case IrInstructionIdSaveErrRetAddr: return ir_render_save_err_ret_addr(g, executable, (IrInstructionSaveErrRetAddr *)instruction); case IrInstructionIdFloatOp: @@ -8074,6 +8087,7 @@ static void define_builtin_fns(CodeGen *g) { create_builtin_fn(g, BuiltinFnIdErrorReturnTrace, "errorReturnTrace", 0); create_builtin_fn(g, BuiltinFnIdAtomicRmw, "atomicRmw", 5); create_builtin_fn(g, BuiltinFnIdAtomicLoad, "atomicLoad", 3); + create_builtin_fn(g, BuiltinFnIdAtomicStore, "atomicStore", 4); create_builtin_fn(g, BuiltinFnIdErrSetCast, "errSetCast", 2); create_builtin_fn(g, BuiltinFnIdToBytes, "sliceToBytes", 1); create_builtin_fn(g, BuiltinFnIdFromBytes, "bytesToSlice", 2); |
