aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/c.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/codegen/c.zig')
-rw-r--r--src/codegen/c.zig13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index 3f3147ca80..77e571bc21 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -1278,6 +1278,7 @@ fn genBody(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail, OutO
.error_name => try airErrorName(f, inst),
.splat => try airSplat(f, inst),
.vector_init => try airVectorInit(f, inst),
+ .prefetch => try airPrefetch(f, inst),
.int_to_float,
.float_to_int,
@@ -3089,6 +3090,18 @@ fn airVectorInit(f: *Function, inst: Air.Inst.Index) !CValue {
return f.fail("TODO: C backend: implement airVectorInit", .{});
}
+fn airPrefetch(f: *Function, inst: Air.Inst.Index) !CValue {
+ const prefetch = f.air.instructions.items(.data)[inst].prefetch;
+ const ptr = try f.resolveInst(prefetch.ptr);
+ const writer = f.object.writer();
+ try writer.writeAll("zig_prefetch(");
+ try f.writeCValue(writer, ptr);
+ try writer.print(", {d}, {d});\n", .{
+ @enumToInt(prefetch.rw), prefetch.locality,
+ });
+ return CValue.none;
+}
+
fn toMemoryOrder(order: std.builtin.AtomicOrder) [:0]const u8 {
return switch (order) {
.Unordered => "memory_order_relaxed",