cmpxchg
Function parameters
Parameters
- gz:*GenZir
- scope:*Scope
- node:Ast.Node.Index
- params:[]const Ast.Node.Index
- small:u16
Functions in this namespace
Functions
Source
Implementation
fn cmpxchg(
gz: *GenZir,
scope: *Scope,
ri: ResultInfo,
node: Ast.Node.Index,
params: []const Ast.Node.Index,
small: u16,
) InnerError!Zir.Inst.Ref {
const int_type = try typeExpr(gz, scope, params[0]);
const atomic_order_type = try gz.addBuiltinValue(node, .atomic_order);
const result = try gz.addExtendedPayloadSmall(.cmpxchg, small, Zir.Inst.Cmpxchg{
// zig fmt: off
.node = gz.nodeIndexToRelative(node),
.ptr = try expr(gz, scope, .{ .rl = .none }, params[1]),
.expected_value = try expr(gz, scope, .{ .rl = .{ .ty = int_type } }, params[2]),
.new_value = try expr(gz, scope, .{ .rl = .{ .coerced_ty = int_type } }, params[3]),
.success_order = try expr(gz, scope, .{ .rl = .{ .coerced_ty = atomic_order_type } }, params[4]),
.failure_order = try expr(gz, scope, .{ .rl = .{ .coerced_ty = atomic_order_type } }, params[5]),
// zig fmt: on
});
return rvalue(gz, ri, result, node);
}