authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-02-23 20:11:38-05:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-02-23 20:30:59-05:00
log3a1cb62317073b8e599e604b74edf9d10f16d4a2
tree13ff2b2970f3f39807fc7f49650d28954b54f964
parent8ccdc74949e361b211dade90184ecb160c9340d8

CBE: delete stage1 hacks


1 files changed, 106 insertions(+), 106 deletions(-)

src/codegen/c.zig+106-106
......@@ -309,7 +309,7 @@ pub const Function = struct {
309309 const val = f.air.value(inst).?;
310310 const ty = f.air.typeOf(inst);
311311
312 const result = if (lowersToArray(ty, f.object.dg.module.getTarget())) result: {
312 const result: CValue = if (lowersToArray(ty, f.object.dg.module.getTarget())) result: {
313313 const writer = f.object.code_header.writer();
314314 const alignment = 0;
315315 const decl_c_value = try f.allocLocalValue(ty, alignment);
......@@ -321,7 +321,7 @@ pub const Function = struct {
321321 try f.object.dg.renderValue(writer, ty, val, .StaticInitializer);
322322 try writer.writeAll(";\n ");
323323 break :result decl_c_value;
324 } else CValue{ .constant = inst };
324 } else .{ .constant = inst };
325325
326326 gop.value_ptr.* = result;
327327 return result;
......@@ -346,7 +346,7 @@ pub const Function = struct {
346346 .alignment = alignment,
347347 .loop_depth = @intCast(LoopDepth, f.free_locals_stack.items.len - 1),
348348 });
349 return CValue{ .new_local = @intCast(LocalIndex, f.locals.items.len - 1) };
349 return .{ .new_local = @intCast(LocalIndex, f.locals.items.len - 1) };
350350 }
351351
352352 fn allocLocal(f: *Function, inst: Air.Inst.Index, ty: Type) !CValue {
......@@ -363,7 +363,7 @@ pub const Function = struct {
363363 if (local.alignment >= alignment) {
364364 local.loop_depth = @intCast(LoopDepth, f.free_locals_stack.items.len - 1);
365365 _ = locals_list.swapRemove(i);
366 return CValue{ .new_local = local_index };
366 return .{ .new_local = local_index };
367367 }
368368 }
369369 }
......@@ -545,7 +545,7 @@ pub const DeclGen = struct {
545545
546546 // Render an undefined pointer if we have a pointer to a zero-bit or comptime type.
547547 if (ty.isPtrAtRuntime() and !decl.ty.isFnOrHasRuntimeBits()) {
548 return dg.writeCValue(writer, CValue{ .undef = ty });
548 return dg.writeCValue(writer, .{ .undef = ty });
549549 }
550550
551551 // Chase function values in order to be able to reference the original function.
......@@ -2649,7 +2649,7 @@ pub fn genDecl(o: *Object) !void {
26492649 defer tracy.end();
26502650
26512651 const decl = o.dg.decl.?;
2652 const decl_c_value: CValue = .{ .decl = o.dg.decl_index.unwrap().? };
2652 const decl_c_value = .{ .decl = o.dg.decl_index.unwrap().? };
26532653 const tv: TypedValue = .{ .ty = decl.ty, .val = decl.val };
26542654
26552655 if (!tv.ty.isFnOrHasRuntimeBitsIgnoreComptime()) return;
......@@ -3011,7 +3011,7 @@ fn airSliceField(f: *Function, inst: Air.Inst.Index, is_ptr: bool, field_name: [
30113011
30123012 if (f.liveness.isUnused(inst)) {
30133013 try reap(f, inst, &.{ty_op.operand});
3014 return CValue.none;
3014 return .none;
30153015 }
30163016
30173017 const inst_ty = f.air.typeOfIndex(inst);
......@@ -3037,7 +3037,7 @@ fn airPtrElemVal(f: *Function, inst: Air.Inst.Index) !CValue {
30373037 !inst_ty.hasRuntimeBitsIgnoreComptime())
30383038 {
30393039 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
3040 return CValue.none;
3040 return .none;
30413041 }
30423042
30433043 const ptr = try f.resolveInst(bin_op.lhs);
......@@ -3076,7 +3076,7 @@ fn airPtrElemPtr(f: *Function, inst: Air.Inst.Index) !CValue {
30763076
30773077 if (f.liveness.isUnused(inst)) {
30783078 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
3079 return CValue.none;
3079 return .none;
30803080 }
30813081
30823082 const inst_ty = f.air.typeOfIndex(inst);
......@@ -3117,7 +3117,7 @@ fn airSliceElemVal(f: *Function, inst: Air.Inst.Index) !CValue {
31173117 !inst_ty.hasRuntimeBitsIgnoreComptime())
31183118 {
31193119 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
3120 return CValue.none;
3120 return .none;
31213121 }
31223122
31233123 const slice = try f.resolveInst(bin_op.lhs);
......@@ -3156,7 +3156,7 @@ fn airSliceElemPtr(f: *Function, inst: Air.Inst.Index) !CValue {
31563156
31573157 if (f.liveness.isUnused(inst)) {
31583158 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
3159 return CValue.none;
3159 return .none;
31603160 }
31613161
31623162 const slice_ty = f.air.typeOf(bin_op.lhs);
......@@ -3186,7 +3186,7 @@ fn airArrayElemVal(f: *Function, inst: Air.Inst.Index) !CValue {
31863186 const inst_ty = f.air.typeOfIndex(inst);
31873187 if (f.liveness.isUnused(inst) or !inst_ty.hasRuntimeBitsIgnoreComptime()) {
31883188 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
3189 return CValue.none;
3189 return .none;
31903190 }
31913191
31923192 const array = try f.resolveInst(bin_op.lhs);
......@@ -3224,7 +3224,7 @@ fn airAlloc(f: *Function, inst: Air.Inst.Index) !CValue {
32243224
32253225 const elem_type = inst_ty.elemType();
32263226 if (!elem_type.isFnOrHasRuntimeBitsIgnoreComptime()) {
3227 return CValue{ .undef = inst_ty };
3227 return .{ .undef = inst_ty };
32283228 }
32293229
32303230 const target = f.object.dg.module.getTarget();
......@@ -3236,7 +3236,7 @@ fn airAlloc(f: *Function, inst: Air.Inst.Index) !CValue {
32363236 log.debug("%{d}: allocated unfreeable t{d}", .{ inst, local.new_local });
32373237 const gpa = f.object.dg.module.gpa;
32383238 try f.allocs.put(gpa, local.new_local, false);
3239 return CValue{ .local_ref = local.new_local };
3239 return .{ .local_ref = local.new_local };
32403240}
32413241
32423242fn airRetPtr(f: *Function, inst: Air.Inst.Index) !CValue {
......@@ -3244,7 +3244,7 @@ fn airRetPtr(f: *Function, inst: Air.Inst.Index) !CValue {
32443244
32453245 const elem_ty = inst_ty.elemType();
32463246 if (!elem_ty.isFnOrHasRuntimeBitsIgnoreComptime()) {
3247 return CValue{ .undef = inst_ty };
3247 return .{ .undef = inst_ty };
32483248 }
32493249
32503250 const target = f.object.dg.module.getTarget();
......@@ -3256,7 +3256,7 @@ fn airRetPtr(f: *Function, inst: Air.Inst.Index) !CValue {
32563256 log.debug("%{d}: allocated unfreeable t{d}", .{ inst, local.new_local });
32573257 const gpa = f.object.dg.module.gpa;
32583258 try f.allocs.put(gpa, local.new_local, false);
3259 return CValue{ .local_ref = local.new_local };
3259 return .{ .local_ref = local.new_local };
32603260}
32613261
32623262fn airArg(f: *Function, inst: Air.Inst.Index) !CValue {
......@@ -3280,7 +3280,7 @@ fn airLoad(f: *Function, inst: Air.Inst.Index) !CValue {
32803280 (!ptr_info.@"volatile" and f.liveness.isUnused(inst)))
32813281 {
32823282 try reap(f, inst, &.{ty_op.operand});
3283 return CValue.none;
3283 return .none;
32843284 }
32853285
32863286 const operand = try f.resolveInst(ty_op.operand);
......@@ -3414,7 +3414,7 @@ fn airRet(f: *Function, inst: Air.Inst.Index, is_ptr: bool) !CValue {
34143414 // Not even allowed to return void in a naked function.
34153415 if (!is_naked) try writer.writeAll("return;\n");
34163416 }
3417 return CValue.none;
3417 return .none;
34183418}
34193419
34203420fn airIntCast(f: *Function, inst: Air.Inst.Index) !CValue {
......@@ -3422,7 +3422,7 @@ fn airIntCast(f: *Function, inst: Air.Inst.Index) !CValue {
34223422
34233423 if (f.liveness.isUnused(inst)) {
34243424 try reap(f, inst, &.{ty_op.operand});
3425 return CValue.none;
3425 return .none;
34263426 }
34273427
34283428 const operand = try f.resolveInst(ty_op.operand);
......@@ -3443,7 +3443,7 @@ fn airTrunc(f: *Function, inst: Air.Inst.Index) !CValue {
34433443 const ty_op = f.air.instructions.items(.data)[inst].ty_op;
34443444 if (f.liveness.isUnused(inst)) {
34453445 try reap(f, inst, &.{ty_op.operand});
3446 return CValue.none;
3446 return .none;
34473447 }
34483448
34493449 const operand = try f.resolveInst(ty_op.operand);
......@@ -3532,7 +3532,7 @@ fn airBoolToInt(f: *Function, inst: Air.Inst.Index) !CValue {
35323532 const un_op = f.air.instructions.items(.data)[inst].un_op;
35333533 if (f.liveness.isUnused(inst)) {
35343534 try reap(f, inst, &.{un_op});
3535 return CValue.none;
3535 return .none;
35363536 }
35373537 const operand = try f.resolveInst(un_op);
35383538 try reap(f, inst, &.{un_op});
......@@ -3555,7 +3555,7 @@ fn storeUndefined(f: *Function, lhs_child_ty: Type, dest_ptr: CValue) !CValue {
35553555 try f.renderType(writer, lhs_child_ty);
35563556 try writer.writeAll("));\n");
35573557 }
3558 return CValue.none;
3558 return .none;
35593559}
35603560
35613561fn airStore(f: *Function, inst: Air.Inst.Index) !CValue {
......@@ -3564,7 +3564,7 @@ fn airStore(f: *Function, inst: Air.Inst.Index) !CValue {
35643564 const ptr_info = f.air.typeOf(bin_op.lhs).ptrInfo().data;
35653565 if (!ptr_info.pointee_type.hasRuntimeBitsIgnoreComptime()) {
35663566 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
3567 return CValue.none;
3567 return .none;
35683568 }
35693569
35703570 const ptr_val = try f.resolveInst(bin_op.lhs);
......@@ -3690,7 +3690,7 @@ fn airStore(f: *Function, inst: Air.Inst.Index) !CValue {
36903690 try f.writeCValue(writer, src_val, .Other);
36913691 }
36923692 try writer.writeAll(";\n");
3693 return CValue.none;
3693 return .none;
36943694}
36953695
36963696fn airOverflow(f: *Function, inst: Air.Inst.Index, operation: []const u8, info: BuiltinInfo) !CValue {
......@@ -3699,7 +3699,7 @@ fn airOverflow(f: *Function, inst: Air.Inst.Index, operation: []const u8, info:
36993699
37003700 if (f.liveness.isUnused(inst)) {
37013701 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
3702 return CValue.none;
3702 return .none;
37033703 }
37043704
37053705 const lhs = try f.resolveInst(bin_op.lhs);
......@@ -3755,7 +3755,7 @@ fn airNot(f: *Function, inst: Air.Inst.Index) !CValue {
37553755
37563756 if (f.liveness.isUnused(inst)) {
37573757 try reap(f, inst, &.{ty_op.operand});
3758 return CValue.none;
3758 return .none;
37593759 }
37603760
37613761 const op = try f.resolveInst(ty_op.operand);
......@@ -3790,7 +3790,7 @@ fn airBinOp(
37903790
37913791 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
37923792
3793 if (f.liveness.isUnused(inst)) return CValue.none;
3793 if (f.liveness.isUnused(inst)) return .none;
37943794
37953795 const inst_ty = f.air.typeOfIndex(inst);
37963796
......@@ -3813,7 +3813,7 @@ fn airCmpOp(f: *Function, inst: Air.Inst.Index, operator: []const u8, operation:
38133813
38143814 if (f.liveness.isUnused(inst)) {
38153815 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
3816 return CValue.none;
3816 return .none;
38173817 }
38183818
38193819 const operand_ty = f.air.typeOf(bin_op.lhs);
......@@ -3853,7 +3853,7 @@ fn airEquality(
38533853
38543854 if (f.liveness.isUnused(inst)) {
38553855 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
3856 return CValue.none;
3856 return .none;
38573857 }
38583858
38593859 const operand_ty = f.air.typeOf(bin_op.lhs);
......@@ -3909,7 +3909,7 @@ fn airCmpLtErrorsLen(f: *Function, inst: Air.Inst.Index) !CValue {
39093909
39103910 if (f.liveness.isUnused(inst)) {
39113911 try reap(f, inst, &.{un_op});
3912 return CValue.none;
3912 return .none;
39133913 }
39143914
39153915 const inst_ty = f.air.typeOfIndex(inst);
......@@ -3930,7 +3930,7 @@ fn airPtrAddSub(f: *Function, inst: Air.Inst.Index, operator: u8) !CValue {
39303930 const bin_op = f.air.extraData(Air.Bin, ty_pl.payload).data;
39313931 if (f.liveness.isUnused(inst)) {
39323932 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
3933 return CValue.none;
3933 return .none;
39343934 }
39353935
39363936 const lhs = try f.resolveInst(bin_op.lhs);
......@@ -3971,7 +3971,7 @@ fn airMinMax(f: *Function, inst: Air.Inst.Index, operator: u8, operation: []cons
39713971
39723972 if (f.liveness.isUnused(inst)) {
39733973 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
3974 return CValue.none;
3974 return .none;
39753975 }
39763976
39773977 const inst_ty = f.air.typeOfIndex(inst);
......@@ -4010,7 +4010,7 @@ fn airSlice(f: *Function, inst: Air.Inst.Index) !CValue {
40104010
40114011 if (f.liveness.isUnused(inst)) {
40124012 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
4013 return CValue.none;
4013 return .none;
40144014 }
40154015
40164016 const ptr = try f.resolveInst(bin_op.lhs);
......@@ -4097,7 +4097,7 @@ fn airCall(
40974097 var lowered_ret_buf: LowerFnRetTyBuffer = undefined;
40984098 const lowered_ret_ty = lowerFnRetTy(ret_ty, &lowered_ret_buf, target);
40994099
4100 const result_local: CValue = if (modifier == .always_tail) r: {
4100 const result_local = if (modifier == .always_tail) r: {
41014101 try writer.writeAll("zig_always_tail return ");
41024102 break :r .none;
41034103 } else if (!lowered_ret_ty.hasRuntimeBitsIgnoreComptime())
......@@ -4187,7 +4187,7 @@ fn airDbgStmt(f: *Function, inst: Air.Inst.Index) !CValue {
41874187 // Perhaps an additional compilation option is in order?
41884188 //try writer.print("#line {d}\n", .{dbg_stmt.line + 1});
41894189 try writer.print("/* file:{d}:{d} */\n", .{ dbg_stmt.line + 1, dbg_stmt.column + 1 });
4190 return CValue.none;
4190 return .none;
41914191}
41924192
41934193fn airDbgInline(f: *Function, inst: Air.Inst.Index) !CValue {
......@@ -4196,7 +4196,7 @@ fn airDbgInline(f: *Function, inst: Air.Inst.Index) !CValue {
41964196 const function = f.air.values[ty_pl.payload].castTag(.function).?.data;
41974197 const mod = f.object.dg.module;
41984198 try writer.print("/* dbg func:{s} */\n", .{mod.declPtr(function.owner_decl).name});
4199 return CValue.none;
4199 return .none;
42004200}
42014201
42024202fn airDbgVar(f: *Function, inst: Air.Inst.Index) !CValue {
......@@ -4208,7 +4208,7 @@ fn airDbgVar(f: *Function, inst: Air.Inst.Index) !CValue {
42084208 try reap(f, inst, &.{pl_op.operand});
42094209 const writer = f.object.writer();
42104210 try writer.print("/* var:{s} */\n", .{name});
4211 return CValue.none;
4211 return .none;
42124212}
42134213
42144214fn airBlock(f: *Function, inst: Air.Inst.Index) !CValue {
......@@ -4224,7 +4224,7 @@ fn airBlock(f: *Function, inst: Air.Inst.Index) !CValue {
42244224 const result = if (inst_ty.tag() != .void and !f.liveness.isUnused(inst))
42254225 try f.allocLocal(inst, inst_ty)
42264226 else
4227 CValue{ .none = {} };
4227 .none;
42284228
42294229 try f.blocks.putNoClobber(f.object.dg.gpa, inst, .{
42304230 .block_id = block_id,
......@@ -4294,7 +4294,7 @@ fn lowerTry(
42944294
42954295 if (!payload_has_bits) {
42964296 if (!operand_is_ptr) {
4297 return CValue.none;
4297 return .none;
42984298 } else {
42994299 return err_union;
43004300 }
......@@ -4303,7 +4303,7 @@ fn lowerTry(
43034303 try reap(f, inst, &.{operand});
43044304
43054305 if (f.liveness.isUnused(inst)) {
4306 return CValue.none;
4306 return .none;
43074307 }
43084308
43094309 const target = f.object.dg.module.getTarget();
......@@ -4359,7 +4359,7 @@ fn airBr(f: *Function, inst: Air.Inst.Index) !CValue {
43594359 }
43604360
43614361 try writer.print("goto zig_block_{d};\n", .{block.block_id});
4362 return CValue.none;
4362 return .none;
43634363}
43644364
43654365fn airBitcast(f: *Function, inst: Air.Inst.Index) !CValue {
......@@ -4369,7 +4369,7 @@ fn airBitcast(f: *Function, inst: Air.Inst.Index) !CValue {
43694369 // https://github.com/ziglang/zig/issues/13410
43704370 if (f.liveness.isUnused(inst) or !dest_ty.hasRuntimeBits()) {
43714371 try reap(f, inst, &.{ty_op.operand});
4372 return CValue.none;
4372 return .none;
43734373 }
43744374
43754375 const operand = try f.resolveInst(ty_op.operand);
......@@ -4441,11 +4441,11 @@ fn airBitcast(f: *Function, inst: Air.Inst.Index) !CValue {
44414441
44424442fn airBreakpoint(writer: anytype) !CValue {
44434443 try writer.writeAll("zig_breakpoint();\n");
4444 return CValue.none;
4444 return .none;
44454445}
44464446
44474447fn airRetAddr(f: *Function, inst: Air.Inst.Index) !CValue {
4448 if (f.liveness.isUnused(inst)) return CValue.none;
4448 if (f.liveness.isUnused(inst)) return .none;
44494449 const writer = f.object.writer();
44504450 const local = try f.allocLocal(inst, Type.usize);
44514451 try f.writeCValue(writer, local, .Other);
......@@ -4456,7 +4456,7 @@ fn airRetAddr(f: *Function, inst: Air.Inst.Index) !CValue {
44564456}
44574457
44584458fn airFrameAddress(f: *Function, inst: Air.Inst.Index) !CValue {
4459 if (f.liveness.isUnused(inst)) return CValue.none;
4459 if (f.liveness.isUnused(inst)) return .none;
44604460 const writer = f.object.writer();
44614461 const local = try f.allocLocal(inst, Type.usize);
44624462 try f.writeCValue(writer, local, .Other);
......@@ -4474,7 +4474,7 @@ fn airFence(f: *Function, inst: Air.Inst.Index) !CValue {
44744474 try writeMemoryOrder(writer, atomic_order);
44754475 try writer.writeAll(");\n");
44764476
4477 return CValue.none;
4477 return .none;
44784478}
44794479
44804480fn airUnreach(f: *Function) !CValue {
......@@ -4482,7 +4482,7 @@ fn airUnreach(f: *Function) !CValue {
44824482 if (f.object.dg.decl) |decl| if (decl.ty.fnCallingConvention() == .Naked) return .none;
44834483
44844484 try f.object.writer().writeAll("zig_unreachable();\n");
4485 return CValue.none;
4485 return .none;
44864486}
44874487
44884488fn airLoop(f: *Function, inst: Air.Inst.Index) !CValue {
......@@ -4514,7 +4514,7 @@ fn airLoop(f: *Function, inst: Air.Inst.Index) !CValue {
45144514 deinitFreeLocalsMap(gpa, new_free_locals);
45154515 new_free_locals.* = old_free_locals.move();
45164516
4517 return CValue.none;
4517 return .none;
45184518}
45194519
45204520fn airCondBr(f: *Function, inst: Air.Inst.Index) !CValue {
......@@ -4579,7 +4579,7 @@ fn airCondBr(f: *Function, inst: Air.Inst.Index) !CValue {
45794579
45804580 try f.object.indent_writer.insertNewline();
45814581
4582 return CValue.none;
4582 return .none;
45834583}
45844584
45854585fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue {
......@@ -4691,7 +4691,7 @@ fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue {
46914691
46924692 f.object.indent_writer.popIndent();
46934693 try writer.writeAll("}\n");
4694 return CValue.none;
4694 return .none;
46954695}
46964696
46974697fn asmInputNeedsLocal(constraint: []const u8, value: CValue) bool {
......@@ -4713,8 +4713,8 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
47134713 const inputs = @ptrCast([]const Air.Inst.Ref, f.air.extra[extra_i..][0..extra.data.inputs_len]);
47144714 extra_i += inputs.len;
47154715
4716 const result: CValue = r: {
4717 if (!is_volatile and f.liveness.isUnused(inst)) break :r CValue.none;
4716 const result = r: {
4717 if (!is_volatile and f.liveness.isUnused(inst)) break :r .none;
47184718
47194719 const writer = f.object.writer();
47204720 const inst_ty = f.air.typeOfIndex(inst);
......@@ -4899,7 +4899,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
48994899 const input_val = try f.resolveInst(input);
49004900 try writer.print("{s}(", .{fmtStringLiteral(if (is_reg) "r" else constraint, null)});
49014901 try f.writeCValue(writer, if (asmInputNeedsLocal(constraint, input_val)) local: {
4902 const input_local = CValue{ .local = locals_index };
4902 const input_local = .{ .local = locals_index };
49034903 locals_index += 1;
49044904 break :local input_local;
49054905 } else input_val, .Other);
......@@ -4932,7 +4932,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
49324932 const is_reg = constraint[1] == '{';
49334933 if (is_reg) {
49344934 try f.writeCValueDeref(writer, if (output == .none)
4935 CValue{ .local_ref = local.new_local }
4935 .{ .local_ref = local.new_local }
49364936 else
49374937 try f.resolveInst(output));
49384938 try writer.writeAll(" = ");
......@@ -4967,7 +4967,7 @@ fn airIsNull(
49674967
49684968 if (f.liveness.isUnused(inst)) {
49694969 try reap(f, inst, &.{un_op});
4970 return CValue.none;
4970 return .none;
49714971 }
49724972
49734973 const writer = f.object.writer();
......@@ -5017,7 +5017,7 @@ fn airOptionalPayload(f: *Function, inst: Air.Inst.Index) !CValue {
50175017
50185018 if (f.liveness.isUnused(inst)) {
50195019 try reap(f, inst, &.{ty_op.operand});
5020 return CValue.none;
5020 return .none;
50215021 }
50225022
50235023 const operand = try f.resolveInst(ty_op.operand);
......@@ -5028,7 +5028,7 @@ fn airOptionalPayload(f: *Function, inst: Air.Inst.Index) !CValue {
50285028 const payload_ty = opt_ty.optionalChild(&buf);
50295029
50305030 if (!payload_ty.hasRuntimeBitsIgnoreComptime()) {
5031 return CValue.none;
5031 return .none;
50325032 }
50335033
50345034 const inst_ty = f.air.typeOfIndex(inst);
......@@ -5069,7 +5069,7 @@ fn airOptionalPayloadPtr(f: *Function, inst: Air.Inst.Index) !CValue {
50695069
50705070 if (f.liveness.isUnused(inst)) {
50715071 try reap(f, inst, &.{ty_op.operand});
5072 return CValue.none;
5072 return .none;
50735073 }
50745074
50755075 const writer = f.object.writer();
......@@ -5080,7 +5080,7 @@ fn airOptionalPayloadPtr(f: *Function, inst: Air.Inst.Index) !CValue {
50805080 const inst_ty = f.air.typeOfIndex(inst);
50815081
50825082 if (!inst_ty.childType().hasRuntimeBitsIgnoreComptime()) {
5083 return CValue{ .undef = inst_ty };
5083 return .{ .undef = inst_ty };
50845084 }
50855085
50865086 const local = try f.allocLocal(inst, inst_ty);
......@@ -5112,7 +5112,7 @@ fn airOptionalPayloadPtrSet(f: *Function, inst: Air.Inst.Index) !CValue {
51125112
51135113 if (opt_ty.optionalReprIsPayload()) {
51145114 if (f.liveness.isUnused(inst)) {
5115 return CValue.none;
5115 return .none;
51165116 }
51175117 const local = try f.allocLocal(inst, inst_ty);
51185118 // The payload and the optional are the same value.
......@@ -5129,7 +5129,7 @@ fn airOptionalPayloadPtrSet(f: *Function, inst: Air.Inst.Index) !CValue {
51295129 try writer.writeAll(";\n");
51305130
51315131 if (f.liveness.isUnused(inst)) {
5132 return CValue.none;
5132 return .none;
51335133 }
51345134
51355135 const local = try f.allocLocal(inst, inst_ty);
......@@ -5232,7 +5232,7 @@ fn airFieldParentPtr(f: *Function, inst: Air.Inst.Index) !CValue {
52325232
52335233 if (f.liveness.isUnused(inst)) {
52345234 try reap(f, inst, &.{extra.field_ptr});
5235 return CValue.none;
5235 return .none;
52365236 }
52375237
52385238 const target = f.object.dg.module.getTarget();
......@@ -5355,13 +5355,13 @@ fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue {
53555355
53565356 if (f.liveness.isUnused(inst)) {
53575357 try reap(f, inst, &.{extra.struct_operand});
5358 return CValue.none;
5358 return .none;
53595359 }
53605360
53615361 const inst_ty = f.air.typeOfIndex(inst);
53625362 if (!inst_ty.hasRuntimeBitsIgnoreComptime()) {
53635363 try reap(f, inst, &.{extra.struct_operand});
5364 return CValue.none;
5364 return .none;
53655365 }
53665366
53675367 const target = f.object.dg.module.getTarget();
......@@ -5512,7 +5512,7 @@ fn airUnwrapErrUnionErr(f: *Function, inst: Air.Inst.Index) !CValue {
55125512
55135513 if (f.liveness.isUnused(inst)) {
55145514 try reap(f, inst, &.{ty_op.operand});
5515 return CValue.none;
5515 return .none;
55165516 }
55175517
55185518 const inst_ty = f.air.typeOfIndex(inst);
......@@ -5549,7 +5549,7 @@ fn airUnwrapErrUnionPay(f: *Function, inst: Air.Inst.Index, is_ptr: bool) !CValu
55495549
55505550 if (f.liveness.isUnused(inst)) {
55515551 try reap(f, inst, &.{ty_op.operand});
5552 return CValue.none;
5552 return .none;
55535553 }
55545554
55555555 const inst_ty = f.air.typeOfIndex(inst);
......@@ -5560,7 +5560,7 @@ fn airUnwrapErrUnionPay(f: *Function, inst: Air.Inst.Index, is_ptr: bool) !CValu
55605560 const error_union_ty = if (operand_is_ptr) operand_ty.childType() else operand_ty;
55615561
55625562 if (!error_union_ty.errorUnionPayload().hasRuntimeBits()) {
5563 if (!is_ptr) return CValue.none;
5563 if (!is_ptr) return .none;
55645564
55655565 const w = f.object.writer();
55665566 const local = try f.allocLocal(inst, inst_ty);
......@@ -5591,7 +5591,7 @@ fn airWrapOptional(f: *Function, inst: Air.Inst.Index) !CValue {
55915591
55925592 if (f.liveness.isUnused(inst)) {
55935593 try reap(f, inst, &.{ty_op.operand});
5594 return CValue.none;
5594 return .none;
55955595 }
55965596
55975597 const inst_ty = f.air.typeOfIndex(inst);
......@@ -5637,7 +5637,7 @@ fn airWrapErrUnionErr(f: *Function, inst: Air.Inst.Index) !CValue {
56375637 const ty_op = f.air.instructions.items(.data)[inst].ty_op;
56385638 if (f.liveness.isUnused(inst)) {
56395639 try reap(f, inst, &.{ty_op.operand});
5640 return CValue.none;
5640 return .none;
56415641 }
56425642
56435643 const writer = f.object.writer();
......@@ -5691,7 +5691,7 @@ fn airErrUnionPayloadPtrSet(f: *Function, inst: Air.Inst.Index) !CValue {
56915691 try writer.writeAll(";\n");
56925692
56935693 // Then return the payload pointer (only if it is used)
5694 if (f.liveness.isUnused(inst)) return CValue.none;
5694 if (f.liveness.isUnused(inst)) return .none;
56955695
56965696 const local = try f.allocLocal(inst, f.air.typeOfIndex(inst));
56975697 try f.writeCValue(writer, local, .Other);
......@@ -5702,7 +5702,7 @@ fn airErrUnionPayloadPtrSet(f: *Function, inst: Air.Inst.Index) !CValue {
57025702}
57035703
57045704fn airErrReturnTrace(f: *Function, inst: Air.Inst.Index) !CValue {
5705 if (f.liveness.isUnused(inst)) return CValue.none;
5705 if (f.liveness.isUnused(inst)) return .none;
57065706 return f.fail("TODO: C backend: implement airErrReturnTrace", .{});
57075707}
57085708
......@@ -5720,7 +5720,7 @@ fn airWrapErrUnionPay(f: *Function, inst: Air.Inst.Index) !CValue {
57205720 const ty_op = f.air.instructions.items(.data)[inst].ty_op;
57215721 if (f.liveness.isUnused(inst)) {
57225722 try reap(f, inst, &.{ty_op.operand});
5723 return CValue.none;
5723 return .none;
57245724 }
57255725
57265726 const inst_ty = f.air.typeOfIndex(inst);
......@@ -5758,7 +5758,7 @@ fn airIsErr(f: *Function, inst: Air.Inst.Index, is_ptr: bool, operator: []const
57585758
57595759 if (f.liveness.isUnused(inst)) {
57605760 try reap(f, inst, &.{un_op});
5761 return CValue.none;
5761 return .none;
57625762 }
57635763
57645764 const writer = f.object.writer();
......@@ -5796,7 +5796,7 @@ fn airArrayToSlice(f: *Function, inst: Air.Inst.Index) !CValue {
57965796
57975797 if (f.liveness.isUnused(inst)) {
57985798 try reap(f, inst, &.{ty_op.operand});
5799 return CValue.none;
5799 return .none;
58005800 }
58015801
58025802 const operand = try f.resolveInst(ty_op.operand);
......@@ -5812,7 +5812,7 @@ fn airArrayToSlice(f: *Function, inst: Air.Inst.Index) !CValue {
58125812 // &(*(void *)p)[0], although LLVM does via GetElementPtr
58135813 if (operand == .undef) {
58145814 var buf: Type.SlicePtrFieldTypeBuffer = undefined;
5815 try f.writeCValue(writer, CValue{ .undef = inst_ty.slicePtrFieldType(&buf) }, .Initializer);
5815 try f.writeCValue(writer, .{ .undef = inst_ty.slicePtrFieldType(&buf) }, .Initializer);
58165816 } else if (array_ty.hasRuntimeBitsIgnoreComptime()) {
58175817 try writer.writeAll("&(");
58185818 try f.writeCValueDeref(writer, operand);
......@@ -5834,7 +5834,7 @@ fn airFloatCast(f: *Function, inst: Air.Inst.Index) !CValue {
58345834
58355835 if (f.liveness.isUnused(inst)) {
58365836 try reap(f, inst, &.{ty_op.operand});
5837 return CValue.none;
5837 return .none;
58385838 }
58395839
58405840 const inst_ty = f.air.typeOfIndex(inst);
......@@ -5882,7 +5882,7 @@ fn airPtrToInt(f: *Function, inst: Air.Inst.Index) !CValue {
58825882
58835883 if (f.liveness.isUnused(inst)) {
58845884 try reap(f, inst, &.{un_op});
5885 return CValue.none;
5885 return .none;
58865886 }
58875887
58885888 const operand = try f.resolveInst(un_op);
......@@ -5910,7 +5910,7 @@ fn airUnBuiltinCall(
59105910
59115911 if (f.liveness.isUnused(inst)) {
59125912 try reap(f, inst, &.{ty_op.operand});
5913 return CValue.none;
5913 return .none;
59145914 }
59155915
59165916 const operand = try f.resolveInst(ty_op.operand);
......@@ -5942,7 +5942,7 @@ fn airBinBuiltinCall(
59425942
59435943 if (f.liveness.isUnused(inst)) {
59445944 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
5945 return CValue.none;
5945 return .none;
59465946 }
59475947
59485948 const lhs = try f.resolveInst(bin_op.lhs);
......@@ -6065,7 +6065,7 @@ fn airCmpxchg(f: *Function, inst: Air.Inst.Index, flavor: [*:0]const u8) !CValue
60656065
60666066 if (f.liveness.isUnused(inst)) {
60676067 try freeLocal(f, inst, local.new_local, 0);
6068 return CValue.none;
6068 return .none;
60696069 }
60706070
60716071 return local;
......@@ -6108,7 +6108,7 @@ fn airAtomicRmw(f: *Function, inst: Air.Inst.Index) !CValue {
61086108
61096109 if (f.liveness.isUnused(inst)) {
61106110 try freeLocal(f, inst, local.new_local, 0);
6111 return CValue.none;
6111 return .none;
61126112 }
61136113
61146114 return local;
......@@ -6120,7 +6120,7 @@ fn airAtomicLoad(f: *Function, inst: Air.Inst.Index) !CValue {
61206120 try reap(f, inst, &.{atomic_load.ptr});
61216121 const ptr_ty = f.air.typeOf(atomic_load.ptr);
61226122 if (!ptr_ty.isVolatilePtr() and f.liveness.isUnused(inst)) {
6123 return CValue.none;
6123 return .none;
61246124 }
61256125
61266126 const inst_ty = f.air.typeOfIndex(inst);
......@@ -6163,7 +6163,7 @@ fn airAtomicStore(f: *Function, inst: Air.Inst.Index, order: [*:0]const u8) !CVa
61636163 try f.object.dg.renderTypeForBuiltinFnName(writer, ptr_ty.childType());
61646164 try writer.writeAll(");\n");
61656165
6166 return CValue.none;
6166 return .none;
61676167}
61686168
61696169fn airMemset(f: *Function, inst: Air.Inst.Index) !CValue {
......@@ -6206,7 +6206,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index) !CValue {
62066206 try reap(f, inst, &.{ pl_op.operand, extra.lhs, extra.rhs });
62076207 try freeLocal(f, inst, index.new_local, 0);
62086208
6209 return CValue.none;
6209 return .none;
62106210 }
62116211
62126212 try reap(f, inst, &.{ pl_op.operand, extra.lhs, extra.rhs });
......@@ -6218,7 +6218,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index) !CValue {
62186218 try f.writeCValue(writer, len, .FunctionArgument);
62196219 try writer.writeAll(");\n");
62206220
6221 return CValue.none;
6221 return .none;
62226222}
62236223
62246224fn airMemcpy(f: *Function, inst: Air.Inst.Index) !CValue {
......@@ -6238,7 +6238,7 @@ fn airMemcpy(f: *Function, inst: Air.Inst.Index) !CValue {
62386238 try f.writeCValue(writer, len, .FunctionArgument);
62396239 try writer.writeAll(");\n");
62406240
6241 return CValue.none;
6241 return .none;
62426242}
62436243
62446244fn airSetUnionTag(f: *Function, inst: Air.Inst.Index) !CValue {
......@@ -6251,7 +6251,7 @@ fn airSetUnionTag(f: *Function, inst: Air.Inst.Index) !CValue {
62516251 const union_ty = f.air.typeOf(bin_op.lhs).childType();
62526252 const target = f.object.dg.module.getTarget();
62536253 const layout = union_ty.unionGetLayout(target);
6254 if (layout.tag_size == 0) return CValue.none;
6254 if (layout.tag_size == 0) return .none;
62556255
62566256 try writer.writeByte('(');
62576257 try f.writeCValue(writer, union_ptr, .Other);
......@@ -6259,7 +6259,7 @@ fn airSetUnionTag(f: *Function, inst: Air.Inst.Index) !CValue {
62596259 try f.writeCValue(writer, new_tag, .Other);
62606260 try writer.writeAll(";\n");
62616261
6262 return CValue.none;
6262 return .none;
62636263}
62646264
62656265fn airGetUnionTag(f: *Function, inst: Air.Inst.Index) !CValue {
......@@ -6267,7 +6267,7 @@ fn airGetUnionTag(f: *Function, inst: Air.Inst.Index) !CValue {
62676267
62686268 if (f.liveness.isUnused(inst)) {
62696269 try reap(f, inst, &.{ty_op.operand});
6270 return CValue.none;
6270 return .none;
62716271 }
62726272
62736273 const operand = try f.resolveInst(ty_op.operand);
......@@ -6277,7 +6277,7 @@ fn airGetUnionTag(f: *Function, inst: Air.Inst.Index) !CValue {
62776277
62786278 const target = f.object.dg.module.getTarget();
62796279 const layout = un_ty.unionGetLayout(target);
6280 if (layout.tag_size == 0) return CValue.none;
6280 if (layout.tag_size == 0) return .none;
62816281
62826282 const inst_ty = f.air.typeOfIndex(inst);
62836283 const writer = f.object.writer();
......@@ -6295,7 +6295,7 @@ fn airTagName(f: *Function, inst: Air.Inst.Index) !CValue {
62956295
62966296 if (f.liveness.isUnused(inst)) {
62976297 try reap(f, inst, &.{un_op});
6298 return CValue.none;
6298 return .none;
62996299 }
63006300
63016301 const inst_ty = f.air.typeOfIndex(inst);
......@@ -6320,7 +6320,7 @@ fn airErrorName(f: *Function, inst: Air.Inst.Index) !CValue {
63206320
63216321 if (f.liveness.isUnused(inst)) {
63226322 try reap(f, inst, &.{un_op});
6323 return CValue.none;
6323 return .none;
63246324 }
63256325
63266326 const writer = f.object.writer();
......@@ -6340,7 +6340,7 @@ fn airSplat(f: *Function, inst: Air.Inst.Index) !CValue {
63406340 const ty_op = f.air.instructions.items(.data)[inst].ty_op;
63416341 if (f.liveness.isUnused(inst)) {
63426342 try reap(f, inst, &.{ty_op.operand});
6343 return CValue.none;
6343 return .none;
63446344 }
63456345
63466346 const inst_ty = f.air.typeOfIndex(inst);
......@@ -6356,13 +6356,13 @@ fn airSplat(f: *Function, inst: Air.Inst.Index) !CValue {
63566356}
63576357
63586358fn airSelect(f: *Function, inst: Air.Inst.Index) !CValue {
6359 if (f.liveness.isUnused(inst)) return CValue.none;
6359 if (f.liveness.isUnused(inst)) return .none;
63606360
63616361 return f.fail("TODO: C backend: implement airSelect", .{});
63626362}
63636363
63646364fn airShuffle(f: *Function, inst: Air.Inst.Index) !CValue {
6365 if (f.liveness.isUnused(inst)) return CValue.none;
6365 if (f.liveness.isUnused(inst)) return .none;
63666366
63676367 return f.fail("TODO: C backend: implement airShuffle", .{});
63686368}
......@@ -6372,7 +6372,7 @@ fn airReduce(f: *Function, inst: Air.Inst.Index) !CValue {
63726372
63736373 if (f.liveness.isUnused(inst)) {
63746374 try reap(f, inst, &.{reduce.operand});
6375 return CValue.none;
6375 return .none;
63766376 }
63776377
63786378 const target = f.object.dg.module.getTarget();
......@@ -6545,7 +6545,7 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue {
65456545 }
65466546 }
65476547
6548 if (f.liveness.isUnused(inst)) return CValue.none;
6548 if (f.liveness.isUnused(inst)) return .none;
65496549
65506550 const target = f.object.dg.module.getTarget();
65516551
......@@ -6590,7 +6590,7 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue {
65906590
65916591 const element_ty = f.air.typeOf(element);
65926592 try f.writeCValue(writer, switch (element_ty.zigTypeTag()) {
6593 .Array => CValue{ .undef = element_ty },
6593 .Array => .{ .undef = element_ty },
65946594 else => resolved_element,
65956595 }, .Initializer);
65966596 empty = false;
......@@ -6697,7 +6697,7 @@ fn airUnionInit(f: *Function, inst: Air.Inst.Index) !CValue {
66976697
66986698 if (f.liveness.isUnused(inst)) {
66996699 try reap(f, inst, &.{extra.init});
6700 return CValue.none;
6700 return .none;
67016701 }
67026702
67036703 const union_ty = f.air.typeOfIndex(inst);
......@@ -6756,7 +6756,7 @@ fn airPrefetch(f: *Function, inst: Air.Inst.Index) !CValue {
67566756 // The available prefetch intrinsics do not accept a cache argument; only
67576757 // address, rw, and locality. So unless the cache is data, we do not lower
67586758 // this instruction.
6759 .instruction => return CValue.none,
6759 .instruction => return .none,
67606760 }
67616761 const ptr = try f.resolveInst(prefetch.ptr);
67626762 try reap(f, inst, &.{prefetch.ptr});
......@@ -6766,11 +6766,11 @@ fn airPrefetch(f: *Function, inst: Air.Inst.Index) !CValue {
67666766 try writer.print(", {d}, {d});\n", .{
67676767 @enumToInt(prefetch.rw), prefetch.locality,
67686768 });
6769 return CValue.none;
6769 return .none;
67706770}
67716771
67726772fn airWasmMemorySize(f: *Function, inst: Air.Inst.Index) !CValue {
6773 if (f.liveness.isUnused(inst)) return CValue.none;
6773 if (f.liveness.isUnused(inst)) return .none;
67746774
67756775 const pl_op = f.air.instructions.items(.data)[inst].pl_op;
67766776
......@@ -6807,7 +6807,7 @@ fn airFloatNeg(f: *Function, inst: Air.Inst.Index) !CValue {
68076807 const un_op = f.air.instructions.items(.data)[inst].un_op;
68086808 if (f.liveness.isUnused(inst)) {
68096809 try reap(f, inst, &.{un_op});
6810 return CValue.none;
6810 return .none;
68116811 }
68126812
68136813 const operand = try f.resolveInst(un_op);
......@@ -6829,7 +6829,7 @@ fn airUnFloatOp(f: *Function, inst: Air.Inst.Index, operation: []const u8) !CVal
68296829 const un_op = f.air.instructions.items(.data)[inst].un_op;
68306830 if (f.liveness.isUnused(inst)) {
68316831 try reap(f, inst, &.{un_op});
6832 return CValue.none;
6832 return .none;
68336833 }
68346834 const operand = try f.resolveInst(un_op);
68356835 try reap(f, inst, &.{un_op});
......@@ -6851,7 +6851,7 @@ fn airBinFloatOp(f: *Function, inst: Air.Inst.Index, operation: []const u8) !CVa
68516851 const bin_op = f.air.instructions.items(.data)[inst].bin_op;
68526852 if (f.liveness.isUnused(inst)) {
68536853 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
6854 return CValue.none;
6854 return .none;
68556855 }
68566856 const lhs = try f.resolveInst(bin_op.lhs);
68576857 const rhs = try f.resolveInst(bin_op.rhs);
......@@ -6878,7 +6878,7 @@ fn airMulAdd(f: *Function, inst: Air.Inst.Index) !CValue {
68786878 const bin_op = f.air.extraData(Air.Bin, pl_op.payload).data;
68796879 if (f.liveness.isUnused(inst)) {
68806880 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs, pl_op.operand });
6881 return CValue.none;
6881 return .none;
68826882 }
68836883 const inst_ty = f.air.typeOfIndex(inst);
68846884 const mulend1 = try f.resolveInst(bin_op.lhs);