| ... | @@ -309,7 +309,7 @@ pub const Function = struct { | ... | @@ -309,7 +309,7 @@ pub const Function = struct { |
| 309 | const val = f.air.value(inst).?; | 309 | const val = f.air.value(inst).?; |
| 310 | const ty = f.air.typeOf(inst); | 310 | const ty = f.air.typeOf(inst); |
| 311 | | 311 | |
| 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: { |
| 313 | const writer = f.object.code_header.writer(); | 313 | const writer = f.object.code_header.writer(); |
| 314 | const alignment = 0; | 314 | const alignment = 0; |
| 315 | const decl_c_value = try f.allocLocalValue(ty, alignment); | 315 | const decl_c_value = try f.allocLocalValue(ty, alignment); |
| ... | @@ -321,7 +321,7 @@ pub const Function = struct { | ... | @@ -321,7 +321,7 @@ pub const Function = struct { |
| 321 | try f.object.dg.renderValue(writer, ty, val, .StaticInitializer); | 321 | try f.object.dg.renderValue(writer, ty, val, .StaticInitializer); |
| 322 | try writer.writeAll(";\n "); | 322 | try writer.writeAll(";\n "); |
| 323 | break :result decl_c_value; | 323 | break :result decl_c_value; |
| 324 | } else CValue{ .constant = inst }; | 324 | } else .{ .constant = inst }; |
| 325 | | 325 | |
| 326 | gop.value_ptr.* = result; | 326 | gop.value_ptr.* = result; |
| 327 | return result; | 327 | return result; |
| ... | @@ -346,7 +346,7 @@ pub const Function = struct { | ... | @@ -346,7 +346,7 @@ pub const Function = struct { |
| 346 | .alignment = alignment, | 346 | .alignment = alignment, |
| 347 | .loop_depth = @intCast(LoopDepth, f.free_locals_stack.items.len - 1), | 347 | .loop_depth = @intCast(LoopDepth, f.free_locals_stack.items.len - 1), |
| 348 | }); | 348 | }); |
| 349 | return CValue{ .new_local = @intCast(LocalIndex, f.locals.items.len - 1) }; | 349 | return .{ .new_local = @intCast(LocalIndex, f.locals.items.len - 1) }; |
| 350 | } | 350 | } |
| 351 | | 351 | |
| 352 | fn allocLocal(f: *Function, inst: Air.Inst.Index, ty: Type) !CValue { | 352 | fn allocLocal(f: *Function, inst: Air.Inst.Index, ty: Type) !CValue { |
| ... | @@ -363,7 +363,7 @@ pub const Function = struct { | ... | @@ -363,7 +363,7 @@ pub const Function = struct { |
| 363 | if (local.alignment >= alignment) { | 363 | if (local.alignment >= alignment) { |
| 364 | local.loop_depth = @intCast(LoopDepth, f.free_locals_stack.items.len - 1); | 364 | local.loop_depth = @intCast(LoopDepth, f.free_locals_stack.items.len - 1); |
| 365 | _ = locals_list.swapRemove(i); | 365 | _ = locals_list.swapRemove(i); |
| 366 | return CValue{ .new_local = local_index }; | 366 | return .{ .new_local = local_index }; |
| 367 | } | 367 | } |
| 368 | } | 368 | } |
| 369 | } | 369 | } |
| ... | @@ -545,7 +545,7 @@ pub const DeclGen = struct { | ... | @@ -545,7 +545,7 @@ pub const DeclGen = struct { |
| 545 | | 545 | |
| 546 | // Render an undefined pointer if we have a pointer to a zero-bit or comptime type. | 546 | // Render an undefined pointer if we have a pointer to a zero-bit or comptime type. |
| 547 | if (ty.isPtrAtRuntime() and !decl.ty.isFnOrHasRuntimeBits()) { | 547 | if (ty.isPtrAtRuntime() and !decl.ty.isFnOrHasRuntimeBits()) { |
| 548 | return dg.writeCValue(writer, CValue{ .undef = ty }); | 548 | return dg.writeCValue(writer, .{ .undef = ty }); |
| 549 | } | 549 | } |
| 550 | | 550 | |
| 551 | // Chase function values in order to be able to reference the original function. | 551 | // Chase function values in order to be able to reference the original function. |
| ... | @@ -2649,7 +2649,7 @@ pub fn genDecl(o: *Object) !void { | ... | @@ -2649,7 +2649,7 @@ pub fn genDecl(o: *Object) !void { |
| 2649 | defer tracy.end(); | 2649 | defer tracy.end(); |
| 2650 | | 2650 | |
| 2651 | const decl = o.dg.decl.?; | 2651 | 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().? }; |
| 2653 | const tv: TypedValue = .{ .ty = decl.ty, .val = decl.val }; | 2653 | const tv: TypedValue = .{ .ty = decl.ty, .val = decl.val }; |
| 2654 | | 2654 | |
| 2655 | if (!tv.ty.isFnOrHasRuntimeBitsIgnoreComptime()) return; | 2655 | if (!tv.ty.isFnOrHasRuntimeBitsIgnoreComptime()) return; |
| ... | @@ -3011,7 +3011,7 @@ fn airSliceField(f: *Function, inst: Air.Inst.Index, is_ptr: bool, field_name: [ | ... | @@ -3011,7 +3011,7 @@ fn airSliceField(f: *Function, inst: Air.Inst.Index, is_ptr: bool, field_name: [ |
| 3011 | | 3011 | |
| 3012 | if (f.liveness.isUnused(inst)) { | 3012 | if (f.liveness.isUnused(inst)) { |
| 3013 | try reap(f, inst, &.{ty_op.operand}); | 3013 | try reap(f, inst, &.{ty_op.operand}); |
| 3014 | return CValue.none; | 3014 | return .none; |
| 3015 | } | 3015 | } |
| 3016 | | 3016 | |
| 3017 | const inst_ty = f.air.typeOfIndex(inst); | 3017 | const inst_ty = f.air.typeOfIndex(inst); |
| ... | @@ -3037,7 +3037,7 @@ fn airPtrElemVal(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -3037,7 +3037,7 @@ fn airPtrElemVal(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3037 | !inst_ty.hasRuntimeBitsIgnoreComptime()) | 3037 | !inst_ty.hasRuntimeBitsIgnoreComptime()) |
| 3038 | { | 3038 | { |
| 3039 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); | 3039 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); |
| 3040 | return CValue.none; | 3040 | return .none; |
| 3041 | } | 3041 | } |
| 3042 | | 3042 | |
| 3043 | const ptr = try f.resolveInst(bin_op.lhs); | 3043 | const ptr = try f.resolveInst(bin_op.lhs); |
| ... | @@ -3076,7 +3076,7 @@ fn airPtrElemPtr(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -3076,7 +3076,7 @@ fn airPtrElemPtr(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3076 | | 3076 | |
| 3077 | if (f.liveness.isUnused(inst)) { | 3077 | if (f.liveness.isUnused(inst)) { |
| 3078 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); | 3078 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); |
| 3079 | return CValue.none; | 3079 | return .none; |
| 3080 | } | 3080 | } |
| 3081 | | 3081 | |
| 3082 | const inst_ty = f.air.typeOfIndex(inst); | 3082 | const inst_ty = f.air.typeOfIndex(inst); |
| ... | @@ -3117,7 +3117,7 @@ fn airSliceElemVal(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -3117,7 +3117,7 @@ fn airSliceElemVal(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3117 | !inst_ty.hasRuntimeBitsIgnoreComptime()) | 3117 | !inst_ty.hasRuntimeBitsIgnoreComptime()) |
| 3118 | { | 3118 | { |
| 3119 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); | 3119 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); |
| 3120 | return CValue.none; | 3120 | return .none; |
| 3121 | } | 3121 | } |
| 3122 | | 3122 | |
| 3123 | const slice = try f.resolveInst(bin_op.lhs); | 3123 | const slice = try f.resolveInst(bin_op.lhs); |
| ... | @@ -3156,7 +3156,7 @@ fn airSliceElemPtr(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -3156,7 +3156,7 @@ fn airSliceElemPtr(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3156 | | 3156 | |
| 3157 | if (f.liveness.isUnused(inst)) { | 3157 | if (f.liveness.isUnused(inst)) { |
| 3158 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); | 3158 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); |
| 3159 | return CValue.none; | 3159 | return .none; |
| 3160 | } | 3160 | } |
| 3161 | | 3161 | |
| 3162 | const slice_ty = f.air.typeOf(bin_op.lhs); | 3162 | const slice_ty = f.air.typeOf(bin_op.lhs); |
| ... | @@ -3186,7 +3186,7 @@ fn airArrayElemVal(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -3186,7 +3186,7 @@ fn airArrayElemVal(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3186 | const inst_ty = f.air.typeOfIndex(inst); | 3186 | const inst_ty = f.air.typeOfIndex(inst); |
| 3187 | if (f.liveness.isUnused(inst) or !inst_ty.hasRuntimeBitsIgnoreComptime()) { | 3187 | if (f.liveness.isUnused(inst) or !inst_ty.hasRuntimeBitsIgnoreComptime()) { |
| 3188 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); | 3188 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); |
| 3189 | return CValue.none; | 3189 | return .none; |
| 3190 | } | 3190 | } |
| 3191 | | 3191 | |
| 3192 | const array = try f.resolveInst(bin_op.lhs); | 3192 | const array = try f.resolveInst(bin_op.lhs); |
| ... | @@ -3224,7 +3224,7 @@ fn airAlloc(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -3224,7 +3224,7 @@ fn airAlloc(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3224 | | 3224 | |
| 3225 | const elem_type = inst_ty.elemType(); | 3225 | const elem_type = inst_ty.elemType(); |
| 3226 | if (!elem_type.isFnOrHasRuntimeBitsIgnoreComptime()) { | 3226 | if (!elem_type.isFnOrHasRuntimeBitsIgnoreComptime()) { |
| 3227 | return CValue{ .undef = inst_ty }; | 3227 | return .{ .undef = inst_ty }; |
| 3228 | } | 3228 | } |
| 3229 | | 3229 | |
| 3230 | const target = f.object.dg.module.getTarget(); | 3230 | const target = f.object.dg.module.getTarget(); |
| ... | @@ -3236,7 +3236,7 @@ fn airAlloc(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -3236,7 +3236,7 @@ fn airAlloc(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3236 | log.debug("%{d}: allocated unfreeable t{d}", .{ inst, local.new_local }); | 3236 | log.debug("%{d}: allocated unfreeable t{d}", .{ inst, local.new_local }); |
| 3237 | const gpa = f.object.dg.module.gpa; | 3237 | const gpa = f.object.dg.module.gpa; |
| 3238 | try f.allocs.put(gpa, local.new_local, false); | 3238 | try f.allocs.put(gpa, local.new_local, false); |
| 3239 | return CValue{ .local_ref = local.new_local }; | 3239 | return .{ .local_ref = local.new_local }; |
| 3240 | } | 3240 | } |
| 3241 | | 3241 | |
| 3242 | fn airRetPtr(f: *Function, inst: Air.Inst.Index) !CValue { | 3242 | fn airRetPtr(f: *Function, inst: Air.Inst.Index) !CValue { |
| ... | @@ -3244,7 +3244,7 @@ fn airRetPtr(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -3244,7 +3244,7 @@ fn airRetPtr(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3244 | | 3244 | |
| 3245 | const elem_ty = inst_ty.elemType(); | 3245 | const elem_ty = inst_ty.elemType(); |
| 3246 | if (!elem_ty.isFnOrHasRuntimeBitsIgnoreComptime()) { | 3246 | if (!elem_ty.isFnOrHasRuntimeBitsIgnoreComptime()) { |
| 3247 | return CValue{ .undef = inst_ty }; | 3247 | return .{ .undef = inst_ty }; |
| 3248 | } | 3248 | } |
| 3249 | | 3249 | |
| 3250 | const target = f.object.dg.module.getTarget(); | 3250 | const target = f.object.dg.module.getTarget(); |
| ... | @@ -3256,7 +3256,7 @@ fn airRetPtr(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -3256,7 +3256,7 @@ fn airRetPtr(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3256 | log.debug("%{d}: allocated unfreeable t{d}", .{ inst, local.new_local }); | 3256 | log.debug("%{d}: allocated unfreeable t{d}", .{ inst, local.new_local }); |
| 3257 | const gpa = f.object.dg.module.gpa; | 3257 | const gpa = f.object.dg.module.gpa; |
| 3258 | try f.allocs.put(gpa, local.new_local, false); | 3258 | try f.allocs.put(gpa, local.new_local, false); |
| 3259 | return CValue{ .local_ref = local.new_local }; | 3259 | return .{ .local_ref = local.new_local }; |
| 3260 | } | 3260 | } |
| 3261 | | 3261 | |
| 3262 | fn airArg(f: *Function, inst: Air.Inst.Index) !CValue { | 3262 | fn airArg(f: *Function, inst: Air.Inst.Index) !CValue { |
| ... | @@ -3280,7 +3280,7 @@ fn airLoad(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -3280,7 +3280,7 @@ fn airLoad(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3280 | (!ptr_info.@"volatile" and f.liveness.isUnused(inst))) | 3280 | (!ptr_info.@"volatile" and f.liveness.isUnused(inst))) |
| 3281 | { | 3281 | { |
| 3282 | try reap(f, inst, &.{ty_op.operand}); | 3282 | try reap(f, inst, &.{ty_op.operand}); |
| 3283 | return CValue.none; | 3283 | return .none; |
| 3284 | } | 3284 | } |
| 3285 | | 3285 | |
| 3286 | const operand = try f.resolveInst(ty_op.operand); | 3286 | const operand = try f.resolveInst(ty_op.operand); |
| ... | @@ -3414,7 +3414,7 @@ fn airRet(f: *Function, inst: Air.Inst.Index, is_ptr: bool) !CValue { | ... | @@ -3414,7 +3414,7 @@ fn airRet(f: *Function, inst: Air.Inst.Index, is_ptr: bool) !CValue { |
| 3414 | // Not even allowed to return void in a naked function. | 3414 | // Not even allowed to return void in a naked function. |
| 3415 | if (!is_naked) try writer.writeAll("return;\n"); | 3415 | if (!is_naked) try writer.writeAll("return;\n"); |
| 3416 | } | 3416 | } |
| 3417 | return CValue.none; | 3417 | return .none; |
| 3418 | } | 3418 | } |
| 3419 | | 3419 | |
| 3420 | fn airIntCast(f: *Function, inst: Air.Inst.Index) !CValue { | 3420 | fn airIntCast(f: *Function, inst: Air.Inst.Index) !CValue { |
| ... | @@ -3422,7 +3422,7 @@ fn airIntCast(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -3422,7 +3422,7 @@ fn airIntCast(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3422 | | 3422 | |
| 3423 | if (f.liveness.isUnused(inst)) { | 3423 | if (f.liveness.isUnused(inst)) { |
| 3424 | try reap(f, inst, &.{ty_op.operand}); | 3424 | try reap(f, inst, &.{ty_op.operand}); |
| 3425 | return CValue.none; | 3425 | return .none; |
| 3426 | } | 3426 | } |
| 3427 | | 3427 | |
| 3428 | const operand = try f.resolveInst(ty_op.operand); | 3428 | const operand = try f.resolveInst(ty_op.operand); |
| ... | @@ -3443,7 +3443,7 @@ fn airTrunc(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -3443,7 +3443,7 @@ fn airTrunc(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3443 | const ty_op = f.air.instructions.items(.data)[inst].ty_op; | 3443 | const ty_op = f.air.instructions.items(.data)[inst].ty_op; |
| 3444 | if (f.liveness.isUnused(inst)) { | 3444 | if (f.liveness.isUnused(inst)) { |
| 3445 | try reap(f, inst, &.{ty_op.operand}); | 3445 | try reap(f, inst, &.{ty_op.operand}); |
| 3446 | return CValue.none; | 3446 | return .none; |
| 3447 | } | 3447 | } |
| 3448 | | 3448 | |
| 3449 | const operand = try f.resolveInst(ty_op.operand); | 3449 | const operand = try f.resolveInst(ty_op.operand); |
| ... | @@ -3532,7 +3532,7 @@ fn airBoolToInt(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -3532,7 +3532,7 @@ fn airBoolToInt(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3532 | const un_op = f.air.instructions.items(.data)[inst].un_op; | 3532 | const un_op = f.air.instructions.items(.data)[inst].un_op; |
| 3533 | if (f.liveness.isUnused(inst)) { | 3533 | if (f.liveness.isUnused(inst)) { |
| 3534 | try reap(f, inst, &.{un_op}); | 3534 | try reap(f, inst, &.{un_op}); |
| 3535 | return CValue.none; | 3535 | return .none; |
| 3536 | } | 3536 | } |
| 3537 | const operand = try f.resolveInst(un_op); | 3537 | const operand = try f.resolveInst(un_op); |
| 3538 | try reap(f, inst, &.{un_op}); | 3538 | try reap(f, inst, &.{un_op}); |
| ... | @@ -3555,7 +3555,7 @@ fn storeUndefined(f: *Function, lhs_child_ty: Type, dest_ptr: CValue) !CValue { | ... | @@ -3555,7 +3555,7 @@ fn storeUndefined(f: *Function, lhs_child_ty: Type, dest_ptr: CValue) !CValue { |
| 3555 | try f.renderType(writer, lhs_child_ty); | 3555 | try f.renderType(writer, lhs_child_ty); |
| 3556 | try writer.writeAll("));\n"); | 3556 | try writer.writeAll("));\n"); |
| 3557 | } | 3557 | } |
| 3558 | return CValue.none; | 3558 | return .none; |
| 3559 | } | 3559 | } |
| 3560 | | 3560 | |
| 3561 | fn airStore(f: *Function, inst: Air.Inst.Index) !CValue { | 3561 | fn airStore(f: *Function, inst: Air.Inst.Index) !CValue { |
| ... | @@ -3564,7 +3564,7 @@ fn airStore(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -3564,7 +3564,7 @@ fn airStore(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3564 | const ptr_info = f.air.typeOf(bin_op.lhs).ptrInfo().data; | 3564 | const ptr_info = f.air.typeOf(bin_op.lhs).ptrInfo().data; |
| 3565 | if (!ptr_info.pointee_type.hasRuntimeBitsIgnoreComptime()) { | 3565 | if (!ptr_info.pointee_type.hasRuntimeBitsIgnoreComptime()) { |
| 3566 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); | 3566 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); |
| 3567 | return CValue.none; | 3567 | return .none; |
| 3568 | } | 3568 | } |
| 3569 | | 3569 | |
| 3570 | const ptr_val = try f.resolveInst(bin_op.lhs); | 3570 | const ptr_val = try f.resolveInst(bin_op.lhs); |
| ... | @@ -3690,7 +3690,7 @@ fn airStore(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -3690,7 +3690,7 @@ fn airStore(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3690 | try f.writeCValue(writer, src_val, .Other); | 3690 | try f.writeCValue(writer, src_val, .Other); |
| 3691 | } | 3691 | } |
| 3692 | try writer.writeAll(";\n"); | 3692 | try writer.writeAll(";\n"); |
| 3693 | return CValue.none; | 3693 | return .none; |
| 3694 | } | 3694 | } |
| 3695 | | 3695 | |
| 3696 | fn airOverflow(f: *Function, inst: Air.Inst.Index, operation: []const u8, info: BuiltinInfo) !CValue { | 3696 | fn 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: | ... | @@ -3699,7 +3699,7 @@ fn airOverflow(f: *Function, inst: Air.Inst.Index, operation: []const u8, info: |
| 3699 | | 3699 | |
| 3700 | if (f.liveness.isUnused(inst)) { | 3700 | if (f.liveness.isUnused(inst)) { |
| 3701 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); | 3701 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); |
| 3702 | return CValue.none; | 3702 | return .none; |
| 3703 | } | 3703 | } |
| 3704 | | 3704 | |
| 3705 | const lhs = try f.resolveInst(bin_op.lhs); | 3705 | const lhs = try f.resolveInst(bin_op.lhs); |
| ... | @@ -3755,7 +3755,7 @@ fn airNot(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -3755,7 +3755,7 @@ fn airNot(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3755 | | 3755 | |
| 3756 | if (f.liveness.isUnused(inst)) { | 3756 | if (f.liveness.isUnused(inst)) { |
| 3757 | try reap(f, inst, &.{ty_op.operand}); | 3757 | try reap(f, inst, &.{ty_op.operand}); |
| 3758 | return CValue.none; | 3758 | return .none; |
| 3759 | } | 3759 | } |
| 3760 | | 3760 | |
| 3761 | const op = try f.resolveInst(ty_op.operand); | 3761 | const op = try f.resolveInst(ty_op.operand); |
| ... | @@ -3790,7 +3790,7 @@ fn airBinOp( | ... | @@ -3790,7 +3790,7 @@ fn airBinOp( |
| 3790 | | 3790 | |
| 3791 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); | 3791 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); |
| 3792 | | 3792 | |
| 3793 | if (f.liveness.isUnused(inst)) return CValue.none; | 3793 | if (f.liveness.isUnused(inst)) return .none; |
| 3794 | | 3794 | |
| 3795 | const inst_ty = f.air.typeOfIndex(inst); | 3795 | const inst_ty = f.air.typeOfIndex(inst); |
| 3796 | | 3796 | |
| ... | @@ -3813,7 +3813,7 @@ fn airCmpOp(f: *Function, inst: Air.Inst.Index, operator: []const u8, operation: | ... | @@ -3813,7 +3813,7 @@ fn airCmpOp(f: *Function, inst: Air.Inst.Index, operator: []const u8, operation: |
| 3813 | | 3813 | |
| 3814 | if (f.liveness.isUnused(inst)) { | 3814 | if (f.liveness.isUnused(inst)) { |
| 3815 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); | 3815 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); |
| 3816 | return CValue.none; | 3816 | return .none; |
| 3817 | } | 3817 | } |
| 3818 | | 3818 | |
| 3819 | const operand_ty = f.air.typeOf(bin_op.lhs); | 3819 | const operand_ty = f.air.typeOf(bin_op.lhs); |
| ... | @@ -3853,7 +3853,7 @@ fn airEquality( | ... | @@ -3853,7 +3853,7 @@ fn airEquality( |
| 3853 | | 3853 | |
| 3854 | if (f.liveness.isUnused(inst)) { | 3854 | if (f.liveness.isUnused(inst)) { |
| 3855 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); | 3855 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); |
| 3856 | return CValue.none; | 3856 | return .none; |
| 3857 | } | 3857 | } |
| 3858 | | 3858 | |
| 3859 | const operand_ty = f.air.typeOf(bin_op.lhs); | 3859 | const operand_ty = f.air.typeOf(bin_op.lhs); |
| ... | @@ -3909,7 +3909,7 @@ fn airCmpLtErrorsLen(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -3909,7 +3909,7 @@ fn airCmpLtErrorsLen(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3909 | | 3909 | |
| 3910 | if (f.liveness.isUnused(inst)) { | 3910 | if (f.liveness.isUnused(inst)) { |
| 3911 | try reap(f, inst, &.{un_op}); | 3911 | try reap(f, inst, &.{un_op}); |
| 3912 | return CValue.none; | 3912 | return .none; |
| 3913 | } | 3913 | } |
| 3914 | | 3914 | |
| 3915 | const inst_ty = f.air.typeOfIndex(inst); | 3915 | const inst_ty = f.air.typeOfIndex(inst); |
| ... | @@ -3930,7 +3930,7 @@ fn airPtrAddSub(f: *Function, inst: Air.Inst.Index, operator: u8) !CValue { | ... | @@ -3930,7 +3930,7 @@ fn airPtrAddSub(f: *Function, inst: Air.Inst.Index, operator: u8) !CValue { |
| 3930 | const bin_op = f.air.extraData(Air.Bin, ty_pl.payload).data; | 3930 | const bin_op = f.air.extraData(Air.Bin, ty_pl.payload).data; |
| 3931 | if (f.liveness.isUnused(inst)) { | 3931 | if (f.liveness.isUnused(inst)) { |
| 3932 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); | 3932 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); |
| 3933 | return CValue.none; | 3933 | return .none; |
| 3934 | } | 3934 | } |
| 3935 | | 3935 | |
| 3936 | const lhs = try f.resolveInst(bin_op.lhs); | 3936 | const lhs = try f.resolveInst(bin_op.lhs); |
| ... | @@ -3971,7 +3971,7 @@ fn airMinMax(f: *Function, inst: Air.Inst.Index, operator: u8, operation: []cons | ... | @@ -3971,7 +3971,7 @@ fn airMinMax(f: *Function, inst: Air.Inst.Index, operator: u8, operation: []cons |
| 3971 | | 3971 | |
| 3972 | if (f.liveness.isUnused(inst)) { | 3972 | if (f.liveness.isUnused(inst)) { |
| 3973 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); | 3973 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); |
| 3974 | return CValue.none; | 3974 | return .none; |
| 3975 | } | 3975 | } |
| 3976 | | 3976 | |
| 3977 | const inst_ty = f.air.typeOfIndex(inst); | 3977 | const inst_ty = f.air.typeOfIndex(inst); |
| ... | @@ -4010,7 +4010,7 @@ fn airSlice(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -4010,7 +4010,7 @@ fn airSlice(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4010 | | 4010 | |
| 4011 | if (f.liveness.isUnused(inst)) { | 4011 | if (f.liveness.isUnused(inst)) { |
| 4012 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); | 4012 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); |
| 4013 | return CValue.none; | 4013 | return .none; |
| 4014 | } | 4014 | } |
| 4015 | | 4015 | |
| 4016 | const ptr = try f.resolveInst(bin_op.lhs); | 4016 | const ptr = try f.resolveInst(bin_op.lhs); |
| ... | @@ -4097,7 +4097,7 @@ fn airCall( | ... | @@ -4097,7 +4097,7 @@ fn airCall( |
| 4097 | var lowered_ret_buf: LowerFnRetTyBuffer = undefined; | 4097 | var lowered_ret_buf: LowerFnRetTyBuffer = undefined; |
| 4098 | const lowered_ret_ty = lowerFnRetTy(ret_ty, &lowered_ret_buf, target); | 4098 | const lowered_ret_ty = lowerFnRetTy(ret_ty, &lowered_ret_buf, target); |
| 4099 | | 4099 | |
| 4100 | const result_local: CValue = if (modifier == .always_tail) r: { | 4100 | const result_local = if (modifier == .always_tail) r: { |
| 4101 | try writer.writeAll("zig_always_tail return "); | 4101 | try writer.writeAll("zig_always_tail return "); |
| 4102 | break :r .none; | 4102 | break :r .none; |
| 4103 | } else if (!lowered_ret_ty.hasRuntimeBitsIgnoreComptime()) | 4103 | } else if (!lowered_ret_ty.hasRuntimeBitsIgnoreComptime()) |
| ... | @@ -4187,7 +4187,7 @@ fn airDbgStmt(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -4187,7 +4187,7 @@ fn airDbgStmt(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4187 | // Perhaps an additional compilation option is in order? | 4187 | // Perhaps an additional compilation option is in order? |
| 4188 | //try writer.print("#line {d}\n", .{dbg_stmt.line + 1}); | 4188 | //try writer.print("#line {d}\n", .{dbg_stmt.line + 1}); |
| 4189 | try writer.print("/* file:{d}:{d} */\n", .{ dbg_stmt.line + 1, dbg_stmt.column + 1 }); | 4189 | try writer.print("/* file:{d}:{d} */\n", .{ dbg_stmt.line + 1, dbg_stmt.column + 1 }); |
| 4190 | return CValue.none; | 4190 | return .none; |
| 4191 | } | 4191 | } |
| 4192 | | 4192 | |
| 4193 | fn airDbgInline(f: *Function, inst: Air.Inst.Index) !CValue { | 4193 | fn airDbgInline(f: *Function, inst: Air.Inst.Index) !CValue { |
| ... | @@ -4196,7 +4196,7 @@ fn airDbgInline(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -4196,7 +4196,7 @@ fn airDbgInline(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4196 | const function = f.air.values[ty_pl.payload].castTag(.function).?.data; | 4196 | const function = f.air.values[ty_pl.payload].castTag(.function).?.data; |
| 4197 | const mod = f.object.dg.module; | 4197 | const mod = f.object.dg.module; |
| 4198 | try writer.print("/* dbg func:{s} */\n", .{mod.declPtr(function.owner_decl).name}); | 4198 | try writer.print("/* dbg func:{s} */\n", .{mod.declPtr(function.owner_decl).name}); |
| 4199 | return CValue.none; | 4199 | return .none; |
| 4200 | } | 4200 | } |
| 4201 | | 4201 | |
| 4202 | fn airDbgVar(f: *Function, inst: Air.Inst.Index) !CValue { | 4202 | fn airDbgVar(f: *Function, inst: Air.Inst.Index) !CValue { |
| ... | @@ -4208,7 +4208,7 @@ fn airDbgVar(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -4208,7 +4208,7 @@ fn airDbgVar(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4208 | try reap(f, inst, &.{pl_op.operand}); | 4208 | try reap(f, inst, &.{pl_op.operand}); |
| 4209 | const writer = f.object.writer(); | 4209 | const writer = f.object.writer(); |
| 4210 | try writer.print("/* var:{s} */\n", .{name}); | 4210 | try writer.print("/* var:{s} */\n", .{name}); |
| 4211 | return CValue.none; | 4211 | return .none; |
| 4212 | } | 4212 | } |
| 4213 | | 4213 | |
| 4214 | fn airBlock(f: *Function, inst: Air.Inst.Index) !CValue { | 4214 | fn airBlock(f: *Function, inst: Air.Inst.Index) !CValue { |
| ... | @@ -4224,7 +4224,7 @@ fn airBlock(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -4224,7 +4224,7 @@ fn airBlock(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4224 | const result = if (inst_ty.tag() != .void and !f.liveness.isUnused(inst)) | 4224 | const result = if (inst_ty.tag() != .void and !f.liveness.isUnused(inst)) |
| 4225 | try f.allocLocal(inst, inst_ty) | 4225 | try f.allocLocal(inst, inst_ty) |
| 4226 | else | 4226 | else |
| 4227 | CValue{ .none = {} }; | 4227 | .none; |
| 4228 | | 4228 | |
| 4229 | try f.blocks.putNoClobber(f.object.dg.gpa, inst, .{ | 4229 | try f.blocks.putNoClobber(f.object.dg.gpa, inst, .{ |
| 4230 | .block_id = block_id, | 4230 | .block_id = block_id, |
| ... | @@ -4294,7 +4294,7 @@ fn lowerTry( | ... | @@ -4294,7 +4294,7 @@ fn lowerTry( |
| 4294 | | 4294 | |
| 4295 | if (!payload_has_bits) { | 4295 | if (!payload_has_bits) { |
| 4296 | if (!operand_is_ptr) { | 4296 | if (!operand_is_ptr) { |
| 4297 | return CValue.none; | 4297 | return .none; |
| 4298 | } else { | 4298 | } else { |
| 4299 | return err_union; | 4299 | return err_union; |
| 4300 | } | 4300 | } |
| ... | @@ -4303,7 +4303,7 @@ fn lowerTry( | ... | @@ -4303,7 +4303,7 @@ fn lowerTry( |
| 4303 | try reap(f, inst, &.{operand}); | 4303 | try reap(f, inst, &.{operand}); |
| 4304 | | 4304 | |
| 4305 | if (f.liveness.isUnused(inst)) { | 4305 | if (f.liveness.isUnused(inst)) { |
| 4306 | return CValue.none; | 4306 | return .none; |
| 4307 | } | 4307 | } |
| 4308 | | 4308 | |
| 4309 | const target = f.object.dg.module.getTarget(); | 4309 | const target = f.object.dg.module.getTarget(); |
| ... | @@ -4359,7 +4359,7 @@ fn airBr(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -4359,7 +4359,7 @@ fn airBr(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4359 | } | 4359 | } |
| 4360 | | 4360 | |
| 4361 | try writer.print("goto zig_block_{d};\n", .{block.block_id}); | 4361 | try writer.print("goto zig_block_{d};\n", .{block.block_id}); |
| 4362 | return CValue.none; | 4362 | return .none; |
| 4363 | } | 4363 | } |
| 4364 | | 4364 | |
| 4365 | fn airBitcast(f: *Function, inst: Air.Inst.Index) !CValue { | 4365 | fn airBitcast(f: *Function, inst: Air.Inst.Index) !CValue { |
| ... | @@ -4369,7 +4369,7 @@ fn airBitcast(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -4369,7 +4369,7 @@ fn airBitcast(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4369 | // https://github.com/ziglang/zig/issues/13410 | 4369 | // https://github.com/ziglang/zig/issues/13410 |
| 4370 | if (f.liveness.isUnused(inst) or !dest_ty.hasRuntimeBits()) { | 4370 | if (f.liveness.isUnused(inst) or !dest_ty.hasRuntimeBits()) { |
| 4371 | try reap(f, inst, &.{ty_op.operand}); | 4371 | try reap(f, inst, &.{ty_op.operand}); |
| 4372 | return CValue.none; | 4372 | return .none; |
| 4373 | } | 4373 | } |
| 4374 | | 4374 | |
| 4375 | const operand = try f.resolveInst(ty_op.operand); | 4375 | const operand = try f.resolveInst(ty_op.operand); |
| ... | @@ -4441,11 +4441,11 @@ fn airBitcast(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -4441,11 +4441,11 @@ fn airBitcast(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4441 | | 4441 | |
| 4442 | fn airBreakpoint(writer: anytype) !CValue { | 4442 | fn airBreakpoint(writer: anytype) !CValue { |
| 4443 | try writer.writeAll("zig_breakpoint();\n"); | 4443 | try writer.writeAll("zig_breakpoint();\n"); |
| 4444 | return CValue.none; | 4444 | return .none; |
| 4445 | } | 4445 | } |
| 4446 | | 4446 | |
| 4447 | fn airRetAddr(f: *Function, inst: Air.Inst.Index) !CValue { | 4447 | fn 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; |
| 4449 | const writer = f.object.writer(); | 4449 | const writer = f.object.writer(); |
| 4450 | const local = try f.allocLocal(inst, Type.usize); | 4450 | const local = try f.allocLocal(inst, Type.usize); |
| 4451 | try f.writeCValue(writer, local, .Other); | 4451 | try f.writeCValue(writer, local, .Other); |
| ... | @@ -4456,7 +4456,7 @@ fn airRetAddr(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -4456,7 +4456,7 @@ fn airRetAddr(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4456 | } | 4456 | } |
| 4457 | | 4457 | |
| 4458 | fn airFrameAddress(f: *Function, inst: Air.Inst.Index) !CValue { | 4458 | fn 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; |
| 4460 | const writer = f.object.writer(); | 4460 | const writer = f.object.writer(); |
| 4461 | const local = try f.allocLocal(inst, Type.usize); | 4461 | const local = try f.allocLocal(inst, Type.usize); |
| 4462 | try f.writeCValue(writer, local, .Other); | 4462 | try f.writeCValue(writer, local, .Other); |
| ... | @@ -4474,7 +4474,7 @@ fn airFence(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -4474,7 +4474,7 @@ fn airFence(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4474 | try writeMemoryOrder(writer, atomic_order); | 4474 | try writeMemoryOrder(writer, atomic_order); |
| 4475 | try writer.writeAll(");\n"); | 4475 | try writer.writeAll(");\n"); |
| 4476 | | 4476 | |
| 4477 | return CValue.none; | 4477 | return .none; |
| 4478 | } | 4478 | } |
| 4479 | | 4479 | |
| 4480 | fn airUnreach(f: *Function) !CValue { | 4480 | fn airUnreach(f: *Function) !CValue { |
| ... | @@ -4482,7 +4482,7 @@ fn airUnreach(f: *Function) !CValue { | ... | @@ -4482,7 +4482,7 @@ fn airUnreach(f: *Function) !CValue { |
| 4482 | if (f.object.dg.decl) |decl| if (decl.ty.fnCallingConvention() == .Naked) return .none; | 4482 | if (f.object.dg.decl) |decl| if (decl.ty.fnCallingConvention() == .Naked) return .none; |
| 4483 | | 4483 | |
| 4484 | try f.object.writer().writeAll("zig_unreachable();\n"); | 4484 | try f.object.writer().writeAll("zig_unreachable();\n"); |
| 4485 | return CValue.none; | 4485 | return .none; |
| 4486 | } | 4486 | } |
| 4487 | | 4487 | |
| 4488 | fn airLoop(f: *Function, inst: Air.Inst.Index) !CValue { | 4488 | fn airLoop(f: *Function, inst: Air.Inst.Index) !CValue { |
| ... | @@ -4514,7 +4514,7 @@ fn airLoop(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -4514,7 +4514,7 @@ fn airLoop(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4514 | deinitFreeLocalsMap(gpa, new_free_locals); | 4514 | deinitFreeLocalsMap(gpa, new_free_locals); |
| 4515 | new_free_locals.* = old_free_locals.move(); | 4515 | new_free_locals.* = old_free_locals.move(); |
| 4516 | | 4516 | |
| 4517 | return CValue.none; | 4517 | return .none; |
| 4518 | } | 4518 | } |
| 4519 | | 4519 | |
| 4520 | fn airCondBr(f: *Function, inst: Air.Inst.Index) !CValue { | 4520 | fn airCondBr(f: *Function, inst: Air.Inst.Index) !CValue { |
| ... | @@ -4579,7 +4579,7 @@ fn airCondBr(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -4579,7 +4579,7 @@ fn airCondBr(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4579 | | 4579 | |
| 4580 | try f.object.indent_writer.insertNewline(); | 4580 | try f.object.indent_writer.insertNewline(); |
| 4581 | | 4581 | |
| 4582 | return CValue.none; | 4582 | return .none; |
| 4583 | } | 4583 | } |
| 4584 | | 4584 | |
| 4585 | fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue { | 4585 | fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue { |
| ... | @@ -4691,7 +4691,7 @@ fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -4691,7 +4691,7 @@ fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4691 | | 4691 | |
| 4692 | f.object.indent_writer.popIndent(); | 4692 | f.object.indent_writer.popIndent(); |
| 4693 | try writer.writeAll("}\n"); | 4693 | try writer.writeAll("}\n"); |
| 4694 | return CValue.none; | 4694 | return .none; |
| 4695 | } | 4695 | } |
| 4696 | | 4696 | |
| 4697 | fn asmInputNeedsLocal(constraint: []const u8, value: CValue) bool { | 4697 | fn asmInputNeedsLocal(constraint: []const u8, value: CValue) bool { |
| ... | @@ -4713,8 +4713,8 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -4713,8 +4713,8 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4713 | const inputs = @ptrCast([]const Air.Inst.Ref, f.air.extra[extra_i..][0..extra.data.inputs_len]); | 4713 | const inputs = @ptrCast([]const Air.Inst.Ref, f.air.extra[extra_i..][0..extra.data.inputs_len]); |
| 4714 | extra_i += inputs.len; | 4714 | extra_i += inputs.len; |
| 4715 | | 4715 | |
| 4716 | const result: CValue = r: { | 4716 | const result = r: { |
| 4717 | if (!is_volatile and f.liveness.isUnused(inst)) break :r CValue.none; | 4717 | if (!is_volatile and f.liveness.isUnused(inst)) break :r .none; |
| 4718 | | 4718 | |
| 4719 | const writer = f.object.writer(); | 4719 | const writer = f.object.writer(); |
| 4720 | const inst_ty = f.air.typeOfIndex(inst); | 4720 | const inst_ty = f.air.typeOfIndex(inst); |
| ... | @@ -4899,7 +4899,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -4899,7 +4899,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4899 | const input_val = try f.resolveInst(input); | 4899 | const input_val = try f.resolveInst(input); |
| 4900 | try writer.print("{s}(", .{fmtStringLiteral(if (is_reg) "r" else constraint, null)}); | 4900 | try writer.print("{s}(", .{fmtStringLiteral(if (is_reg) "r" else constraint, null)}); |
| 4901 | try f.writeCValue(writer, if (asmInputNeedsLocal(constraint, input_val)) local: { | 4901 | 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 }; |
| 4903 | locals_index += 1; | 4903 | locals_index += 1; |
| 4904 | break :local input_local; | 4904 | break :local input_local; |
| 4905 | } else input_val, .Other); | 4905 | } else input_val, .Other); |
| ... | @@ -4932,7 +4932,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -4932,7 +4932,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue { |
| 4932 | const is_reg = constraint[1] == '{'; | 4932 | const is_reg = constraint[1] == '{'; |
| 4933 | if (is_reg) { | 4933 | if (is_reg) { |
| 4934 | try f.writeCValueDeref(writer, if (output == .none) | 4934 | try f.writeCValueDeref(writer, if (output == .none) |
| 4935 | CValue{ .local_ref = local.new_local } | 4935 | .{ .local_ref = local.new_local } |
| 4936 | else | 4936 | else |
| 4937 | try f.resolveInst(output)); | 4937 | try f.resolveInst(output)); |
| 4938 | try writer.writeAll(" = "); | 4938 | try writer.writeAll(" = "); |
| ... | @@ -4967,7 +4967,7 @@ fn airIsNull( | ... | @@ -4967,7 +4967,7 @@ fn airIsNull( |
| 4967 | | 4967 | |
| 4968 | if (f.liveness.isUnused(inst)) { | 4968 | if (f.liveness.isUnused(inst)) { |
| 4969 | try reap(f, inst, &.{un_op}); | 4969 | try reap(f, inst, &.{un_op}); |
| 4970 | return CValue.none; | 4970 | return .none; |
| 4971 | } | 4971 | } |
| 4972 | | 4972 | |
| 4973 | const writer = f.object.writer(); | 4973 | const writer = f.object.writer(); |
| ... | @@ -5017,7 +5017,7 @@ fn airOptionalPayload(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -5017,7 +5017,7 @@ fn airOptionalPayload(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5017 | | 5017 | |
| 5018 | if (f.liveness.isUnused(inst)) { | 5018 | if (f.liveness.isUnused(inst)) { |
| 5019 | try reap(f, inst, &.{ty_op.operand}); | 5019 | try reap(f, inst, &.{ty_op.operand}); |
| 5020 | return CValue.none; | 5020 | return .none; |
| 5021 | } | 5021 | } |
| 5022 | | 5022 | |
| 5023 | const operand = try f.resolveInst(ty_op.operand); | 5023 | const operand = try f.resolveInst(ty_op.operand); |
| ... | @@ -5028,7 +5028,7 @@ fn airOptionalPayload(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -5028,7 +5028,7 @@ fn airOptionalPayload(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5028 | const payload_ty = opt_ty.optionalChild(&buf); | 5028 | const payload_ty = opt_ty.optionalChild(&buf); |
| 5029 | | 5029 | |
| 5030 | if (!payload_ty.hasRuntimeBitsIgnoreComptime()) { | 5030 | if (!payload_ty.hasRuntimeBitsIgnoreComptime()) { |
| 5031 | return CValue.none; | 5031 | return .none; |
| 5032 | } | 5032 | } |
| 5033 | | 5033 | |
| 5034 | const inst_ty = f.air.typeOfIndex(inst); | 5034 | const inst_ty = f.air.typeOfIndex(inst); |
| ... | @@ -5069,7 +5069,7 @@ fn airOptionalPayloadPtr(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -5069,7 +5069,7 @@ fn airOptionalPayloadPtr(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5069 | | 5069 | |
| 5070 | if (f.liveness.isUnused(inst)) { | 5070 | if (f.liveness.isUnused(inst)) { |
| 5071 | try reap(f, inst, &.{ty_op.operand}); | 5071 | try reap(f, inst, &.{ty_op.operand}); |
| 5072 | return CValue.none; | 5072 | return .none; |
| 5073 | } | 5073 | } |
| 5074 | | 5074 | |
| 5075 | const writer = f.object.writer(); | 5075 | const writer = f.object.writer(); |
| ... | @@ -5080,7 +5080,7 @@ fn airOptionalPayloadPtr(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -5080,7 +5080,7 @@ fn airOptionalPayloadPtr(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5080 | const inst_ty = f.air.typeOfIndex(inst); | 5080 | const inst_ty = f.air.typeOfIndex(inst); |
| 5081 | | 5081 | |
| 5082 | if (!inst_ty.childType().hasRuntimeBitsIgnoreComptime()) { | 5082 | if (!inst_ty.childType().hasRuntimeBitsIgnoreComptime()) { |
| 5083 | return CValue{ .undef = inst_ty }; | 5083 | return .{ .undef = inst_ty }; |
| 5084 | } | 5084 | } |
| 5085 | | 5085 | |
| 5086 | const local = try f.allocLocal(inst, inst_ty); | 5086 | const local = try f.allocLocal(inst, inst_ty); |
| ... | @@ -5112,7 +5112,7 @@ fn airOptionalPayloadPtrSet(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -5112,7 +5112,7 @@ fn airOptionalPayloadPtrSet(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5112 | | 5112 | |
| 5113 | if (opt_ty.optionalReprIsPayload()) { | 5113 | if (opt_ty.optionalReprIsPayload()) { |
| 5114 | if (f.liveness.isUnused(inst)) { | 5114 | if (f.liveness.isUnused(inst)) { |
| 5115 | return CValue.none; | 5115 | return .none; |
| 5116 | } | 5116 | } |
| 5117 | const local = try f.allocLocal(inst, inst_ty); | 5117 | const local = try f.allocLocal(inst, inst_ty); |
| 5118 | // The payload and the optional are the same value. | 5118 | // The payload and the optional are the same value. |
| ... | @@ -5129,7 +5129,7 @@ fn airOptionalPayloadPtrSet(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -5129,7 +5129,7 @@ fn airOptionalPayloadPtrSet(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5129 | try writer.writeAll(";\n"); | 5129 | try writer.writeAll(";\n"); |
| 5130 | | 5130 | |
| 5131 | if (f.liveness.isUnused(inst)) { | 5131 | if (f.liveness.isUnused(inst)) { |
| 5132 | return CValue.none; | 5132 | return .none; |
| 5133 | } | 5133 | } |
| 5134 | | 5134 | |
| 5135 | const local = try f.allocLocal(inst, inst_ty); | 5135 | const local = try f.allocLocal(inst, inst_ty); |
| ... | @@ -5232,7 +5232,7 @@ fn airFieldParentPtr(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -5232,7 +5232,7 @@ fn airFieldParentPtr(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5232 | | 5232 | |
| 5233 | if (f.liveness.isUnused(inst)) { | 5233 | if (f.liveness.isUnused(inst)) { |
| 5234 | try reap(f, inst, &.{extra.field_ptr}); | 5234 | try reap(f, inst, &.{extra.field_ptr}); |
| 5235 | return CValue.none; | 5235 | return .none; |
| 5236 | } | 5236 | } |
| 5237 | | 5237 | |
| 5238 | const target = f.object.dg.module.getTarget(); | 5238 | const target = f.object.dg.module.getTarget(); |
| ... | @@ -5355,13 +5355,13 @@ fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -5355,13 +5355,13 @@ fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5355 | | 5355 | |
| 5356 | if (f.liveness.isUnused(inst)) { | 5356 | if (f.liveness.isUnused(inst)) { |
| 5357 | try reap(f, inst, &.{extra.struct_operand}); | 5357 | try reap(f, inst, &.{extra.struct_operand}); |
| 5358 | return CValue.none; | 5358 | return .none; |
| 5359 | } | 5359 | } |
| 5360 | | 5360 | |
| 5361 | const inst_ty = f.air.typeOfIndex(inst); | 5361 | const inst_ty = f.air.typeOfIndex(inst); |
| 5362 | if (!inst_ty.hasRuntimeBitsIgnoreComptime()) { | 5362 | if (!inst_ty.hasRuntimeBitsIgnoreComptime()) { |
| 5363 | try reap(f, inst, &.{extra.struct_operand}); | 5363 | try reap(f, inst, &.{extra.struct_operand}); |
| 5364 | return CValue.none; | 5364 | return .none; |
| 5365 | } | 5365 | } |
| 5366 | | 5366 | |
| 5367 | const target = f.object.dg.module.getTarget(); | 5367 | const target = f.object.dg.module.getTarget(); |
| ... | @@ -5512,7 +5512,7 @@ fn airUnwrapErrUnionErr(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -5512,7 +5512,7 @@ fn airUnwrapErrUnionErr(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5512 | | 5512 | |
| 5513 | if (f.liveness.isUnused(inst)) { | 5513 | if (f.liveness.isUnused(inst)) { |
| 5514 | try reap(f, inst, &.{ty_op.operand}); | 5514 | try reap(f, inst, &.{ty_op.operand}); |
| 5515 | return CValue.none; | 5515 | return .none; |
| 5516 | } | 5516 | } |
| 5517 | | 5517 | |
| 5518 | const inst_ty = f.air.typeOfIndex(inst); | 5518 | const inst_ty = f.air.typeOfIndex(inst); |
| ... | @@ -5549,7 +5549,7 @@ fn airUnwrapErrUnionPay(f: *Function, inst: Air.Inst.Index, is_ptr: bool) !CValu | ... | @@ -5549,7 +5549,7 @@ fn airUnwrapErrUnionPay(f: *Function, inst: Air.Inst.Index, is_ptr: bool) !CValu |
| 5549 | | 5549 | |
| 5550 | if (f.liveness.isUnused(inst)) { | 5550 | if (f.liveness.isUnused(inst)) { |
| 5551 | try reap(f, inst, &.{ty_op.operand}); | 5551 | try reap(f, inst, &.{ty_op.operand}); |
| 5552 | return CValue.none; | 5552 | return .none; |
| 5553 | } | 5553 | } |
| 5554 | | 5554 | |
| 5555 | const inst_ty = f.air.typeOfIndex(inst); | 5555 | const inst_ty = f.air.typeOfIndex(inst); |
| ... | @@ -5560,7 +5560,7 @@ fn airUnwrapErrUnionPay(f: *Function, inst: Air.Inst.Index, is_ptr: bool) !CValu | ... | @@ -5560,7 +5560,7 @@ fn airUnwrapErrUnionPay(f: *Function, inst: Air.Inst.Index, is_ptr: bool) !CValu |
| 5560 | const error_union_ty = if (operand_is_ptr) operand_ty.childType() else operand_ty; | 5560 | const error_union_ty = if (operand_is_ptr) operand_ty.childType() else operand_ty; |
| 5561 | | 5561 | |
| 5562 | if (!error_union_ty.errorUnionPayload().hasRuntimeBits()) { | 5562 | if (!error_union_ty.errorUnionPayload().hasRuntimeBits()) { |
| 5563 | if (!is_ptr) return CValue.none; | 5563 | if (!is_ptr) return .none; |
| 5564 | | 5564 | |
| 5565 | const w = f.object.writer(); | 5565 | const w = f.object.writer(); |
| 5566 | const local = try f.allocLocal(inst, inst_ty); | 5566 | const local = try f.allocLocal(inst, inst_ty); |
| ... | @@ -5591,7 +5591,7 @@ fn airWrapOptional(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -5591,7 +5591,7 @@ fn airWrapOptional(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5591 | | 5591 | |
| 5592 | if (f.liveness.isUnused(inst)) { | 5592 | if (f.liveness.isUnused(inst)) { |
| 5593 | try reap(f, inst, &.{ty_op.operand}); | 5593 | try reap(f, inst, &.{ty_op.operand}); |
| 5594 | return CValue.none; | 5594 | return .none; |
| 5595 | } | 5595 | } |
| 5596 | | 5596 | |
| 5597 | const inst_ty = f.air.typeOfIndex(inst); | 5597 | const inst_ty = f.air.typeOfIndex(inst); |
| ... | @@ -5637,7 +5637,7 @@ fn airWrapErrUnionErr(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -5637,7 +5637,7 @@ fn airWrapErrUnionErr(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5637 | const ty_op = f.air.instructions.items(.data)[inst].ty_op; | 5637 | const ty_op = f.air.instructions.items(.data)[inst].ty_op; |
| 5638 | if (f.liveness.isUnused(inst)) { | 5638 | if (f.liveness.isUnused(inst)) { |
| 5639 | try reap(f, inst, &.{ty_op.operand}); | 5639 | try reap(f, inst, &.{ty_op.operand}); |
| 5640 | return CValue.none; | 5640 | return .none; |
| 5641 | } | 5641 | } |
| 5642 | | 5642 | |
| 5643 | const writer = f.object.writer(); | 5643 | const writer = f.object.writer(); |
| ... | @@ -5691,7 +5691,7 @@ fn airErrUnionPayloadPtrSet(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -5691,7 +5691,7 @@ fn airErrUnionPayloadPtrSet(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5691 | try writer.writeAll(";\n"); | 5691 | try writer.writeAll(";\n"); |
| 5692 | | 5692 | |
| 5693 | // Then return the payload pointer (only if it is used) | 5693 | // 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; |
| 5695 | | 5695 | |
| 5696 | const local = try f.allocLocal(inst, f.air.typeOfIndex(inst)); | 5696 | const local = try f.allocLocal(inst, f.air.typeOfIndex(inst)); |
| 5697 | try f.writeCValue(writer, local, .Other); | 5697 | try f.writeCValue(writer, local, .Other); |
| ... | @@ -5702,7 +5702,7 @@ fn airErrUnionPayloadPtrSet(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -5702,7 +5702,7 @@ fn airErrUnionPayloadPtrSet(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5702 | } | 5702 | } |
| 5703 | | 5703 | |
| 5704 | fn airErrReturnTrace(f: *Function, inst: Air.Inst.Index) !CValue { | 5704 | fn 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; |
| 5706 | return f.fail("TODO: C backend: implement airErrReturnTrace", .{}); | 5706 | return f.fail("TODO: C backend: implement airErrReturnTrace", .{}); |
| 5707 | } | 5707 | } |
| 5708 | | 5708 | |
| ... | @@ -5720,7 +5720,7 @@ fn airWrapErrUnionPay(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -5720,7 +5720,7 @@ fn airWrapErrUnionPay(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5720 | const ty_op = f.air.instructions.items(.data)[inst].ty_op; | 5720 | const ty_op = f.air.instructions.items(.data)[inst].ty_op; |
| 5721 | if (f.liveness.isUnused(inst)) { | 5721 | if (f.liveness.isUnused(inst)) { |
| 5722 | try reap(f, inst, &.{ty_op.operand}); | 5722 | try reap(f, inst, &.{ty_op.operand}); |
| 5723 | return CValue.none; | 5723 | return .none; |
| 5724 | } | 5724 | } |
| 5725 | | 5725 | |
| 5726 | const inst_ty = f.air.typeOfIndex(inst); | 5726 | const inst_ty = f.air.typeOfIndex(inst); |
| ... | @@ -5758,7 +5758,7 @@ fn airIsErr(f: *Function, inst: Air.Inst.Index, is_ptr: bool, operator: []const | ... | @@ -5758,7 +5758,7 @@ fn airIsErr(f: *Function, inst: Air.Inst.Index, is_ptr: bool, operator: []const |
| 5758 | | 5758 | |
| 5759 | if (f.liveness.isUnused(inst)) { | 5759 | if (f.liveness.isUnused(inst)) { |
| 5760 | try reap(f, inst, &.{un_op}); | 5760 | try reap(f, inst, &.{un_op}); |
| 5761 | return CValue.none; | 5761 | return .none; |
| 5762 | } | 5762 | } |
| 5763 | | 5763 | |
| 5764 | const writer = f.object.writer(); | 5764 | const writer = f.object.writer(); |
| ... | @@ -5796,7 +5796,7 @@ fn airArrayToSlice(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -5796,7 +5796,7 @@ fn airArrayToSlice(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5796 | | 5796 | |
| 5797 | if (f.liveness.isUnused(inst)) { | 5797 | if (f.liveness.isUnused(inst)) { |
| 5798 | try reap(f, inst, &.{ty_op.operand}); | 5798 | try reap(f, inst, &.{ty_op.operand}); |
| 5799 | return CValue.none; | 5799 | return .none; |
| 5800 | } | 5800 | } |
| 5801 | | 5801 | |
| 5802 | const operand = try f.resolveInst(ty_op.operand); | 5802 | const operand = try f.resolveInst(ty_op.operand); |
| ... | @@ -5812,7 +5812,7 @@ fn airArrayToSlice(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -5812,7 +5812,7 @@ fn airArrayToSlice(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5812 | // &(*(void *)p)[0], although LLVM does via GetElementPtr | 5812 | // &(*(void *)p)[0], although LLVM does via GetElementPtr |
| 5813 | if (operand == .undef) { | 5813 | if (operand == .undef) { |
| 5814 | var buf: Type.SlicePtrFieldTypeBuffer = undefined; | 5814 | 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); |
| 5816 | } else if (array_ty.hasRuntimeBitsIgnoreComptime()) { | 5816 | } else if (array_ty.hasRuntimeBitsIgnoreComptime()) { |
| 5817 | try writer.writeAll("&("); | 5817 | try writer.writeAll("&("); |
| 5818 | try f.writeCValueDeref(writer, operand); | 5818 | try f.writeCValueDeref(writer, operand); |
| ... | @@ -5834,7 +5834,7 @@ fn airFloatCast(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -5834,7 +5834,7 @@ fn airFloatCast(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5834 | | 5834 | |
| 5835 | if (f.liveness.isUnused(inst)) { | 5835 | if (f.liveness.isUnused(inst)) { |
| 5836 | try reap(f, inst, &.{ty_op.operand}); | 5836 | try reap(f, inst, &.{ty_op.operand}); |
| 5837 | return CValue.none; | 5837 | return .none; |
| 5838 | } | 5838 | } |
| 5839 | | 5839 | |
| 5840 | const inst_ty = f.air.typeOfIndex(inst); | 5840 | const inst_ty = f.air.typeOfIndex(inst); |
| ... | @@ -5882,7 +5882,7 @@ fn airPtrToInt(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -5882,7 +5882,7 @@ fn airPtrToInt(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5882 | | 5882 | |
| 5883 | if (f.liveness.isUnused(inst)) { | 5883 | if (f.liveness.isUnused(inst)) { |
| 5884 | try reap(f, inst, &.{un_op}); | 5884 | try reap(f, inst, &.{un_op}); |
| 5885 | return CValue.none; | 5885 | return .none; |
| 5886 | } | 5886 | } |
| 5887 | | 5887 | |
| 5888 | const operand = try f.resolveInst(un_op); | 5888 | const operand = try f.resolveInst(un_op); |
| ... | @@ -5910,7 +5910,7 @@ fn airUnBuiltinCall( | ... | @@ -5910,7 +5910,7 @@ fn airUnBuiltinCall( |
| 5910 | | 5910 | |
| 5911 | if (f.liveness.isUnused(inst)) { | 5911 | if (f.liveness.isUnused(inst)) { |
| 5912 | try reap(f, inst, &.{ty_op.operand}); | 5912 | try reap(f, inst, &.{ty_op.operand}); |
| 5913 | return CValue.none; | 5913 | return .none; |
| 5914 | } | 5914 | } |
| 5915 | | 5915 | |
| 5916 | const operand = try f.resolveInst(ty_op.operand); | 5916 | const operand = try f.resolveInst(ty_op.operand); |
| ... | @@ -5942,7 +5942,7 @@ fn airBinBuiltinCall( | ... | @@ -5942,7 +5942,7 @@ fn airBinBuiltinCall( |
| 5942 | | 5942 | |
| 5943 | if (f.liveness.isUnused(inst)) { | 5943 | if (f.liveness.isUnused(inst)) { |
| 5944 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); | 5944 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); |
| 5945 | return CValue.none; | 5945 | return .none; |
| 5946 | } | 5946 | } |
| 5947 | | 5947 | |
| 5948 | const lhs = try f.resolveInst(bin_op.lhs); | 5948 | 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 | ... | @@ -6065,7 +6065,7 @@ fn airCmpxchg(f: *Function, inst: Air.Inst.Index, flavor: [*:0]const u8) !CValue |
| 6065 | | 6065 | |
| 6066 | if (f.liveness.isUnused(inst)) { | 6066 | if (f.liveness.isUnused(inst)) { |
| 6067 | try freeLocal(f, inst, local.new_local, 0); | 6067 | try freeLocal(f, inst, local.new_local, 0); |
| 6068 | return CValue.none; | 6068 | return .none; |
| 6069 | } | 6069 | } |
| 6070 | | 6070 | |
| 6071 | return local; | 6071 | return local; |
| ... | @@ -6108,7 +6108,7 @@ fn airAtomicRmw(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6108,7 +6108,7 @@ fn airAtomicRmw(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6108 | | 6108 | |
| 6109 | if (f.liveness.isUnused(inst)) { | 6109 | if (f.liveness.isUnused(inst)) { |
| 6110 | try freeLocal(f, inst, local.new_local, 0); | 6110 | try freeLocal(f, inst, local.new_local, 0); |
| 6111 | return CValue.none; | 6111 | return .none; |
| 6112 | } | 6112 | } |
| 6113 | | 6113 | |
| 6114 | return local; | 6114 | return local; |
| ... | @@ -6120,7 +6120,7 @@ fn airAtomicLoad(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6120,7 +6120,7 @@ fn airAtomicLoad(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6120 | try reap(f, inst, &.{atomic_load.ptr}); | 6120 | try reap(f, inst, &.{atomic_load.ptr}); |
| 6121 | const ptr_ty = f.air.typeOf(atomic_load.ptr); | 6121 | const ptr_ty = f.air.typeOf(atomic_load.ptr); |
| 6122 | if (!ptr_ty.isVolatilePtr() and f.liveness.isUnused(inst)) { | 6122 | if (!ptr_ty.isVolatilePtr() and f.liveness.isUnused(inst)) { |
| 6123 | return CValue.none; | 6123 | return .none; |
| 6124 | } | 6124 | } |
| 6125 | | 6125 | |
| 6126 | const inst_ty = f.air.typeOfIndex(inst); | 6126 | const inst_ty = f.air.typeOfIndex(inst); |
| ... | @@ -6163,7 +6163,7 @@ fn airAtomicStore(f: *Function, inst: Air.Inst.Index, order: [*:0]const u8) !CVa | ... | @@ -6163,7 +6163,7 @@ fn airAtomicStore(f: *Function, inst: Air.Inst.Index, order: [*:0]const u8) !CVa |
| 6163 | try f.object.dg.renderTypeForBuiltinFnName(writer, ptr_ty.childType()); | 6163 | try f.object.dg.renderTypeForBuiltinFnName(writer, ptr_ty.childType()); |
| 6164 | try writer.writeAll(");\n"); | 6164 | try writer.writeAll(");\n"); |
| 6165 | | 6165 | |
| 6166 | return CValue.none; | 6166 | return .none; |
| 6167 | } | 6167 | } |
| 6168 | | 6168 | |
| 6169 | fn airMemset(f: *Function, inst: Air.Inst.Index) !CValue { | 6169 | fn airMemset(f: *Function, inst: Air.Inst.Index) !CValue { |
| ... | @@ -6206,7 +6206,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6206,7 +6206,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6206 | try reap(f, inst, &.{ pl_op.operand, extra.lhs, extra.rhs }); | 6206 | try reap(f, inst, &.{ pl_op.operand, extra.lhs, extra.rhs }); |
| 6207 | try freeLocal(f, inst, index.new_local, 0); | 6207 | try freeLocal(f, inst, index.new_local, 0); |
| 6208 | | 6208 | |
| 6209 | return CValue.none; | 6209 | return .none; |
| 6210 | } | 6210 | } |
| 6211 | | 6211 | |
| 6212 | try reap(f, inst, &.{ pl_op.operand, extra.lhs, extra.rhs }); | 6212 | try reap(f, inst, &.{ pl_op.operand, extra.lhs, extra.rhs }); |
| ... | @@ -6218,7 +6218,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6218,7 +6218,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6218 | try f.writeCValue(writer, len, .FunctionArgument); | 6218 | try f.writeCValue(writer, len, .FunctionArgument); |
| 6219 | try writer.writeAll(");\n"); | 6219 | try writer.writeAll(");\n"); |
| 6220 | | 6220 | |
| 6221 | return CValue.none; | 6221 | return .none; |
| 6222 | } | 6222 | } |
| 6223 | | 6223 | |
| 6224 | fn airMemcpy(f: *Function, inst: Air.Inst.Index) !CValue { | 6224 | fn airMemcpy(f: *Function, inst: Air.Inst.Index) !CValue { |
| ... | @@ -6238,7 +6238,7 @@ fn airMemcpy(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6238,7 +6238,7 @@ fn airMemcpy(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6238 | try f.writeCValue(writer, len, .FunctionArgument); | 6238 | try f.writeCValue(writer, len, .FunctionArgument); |
| 6239 | try writer.writeAll(");\n"); | 6239 | try writer.writeAll(");\n"); |
| 6240 | | 6240 | |
| 6241 | return CValue.none; | 6241 | return .none; |
| 6242 | } | 6242 | } |
| 6243 | | 6243 | |
| 6244 | fn airSetUnionTag(f: *Function, inst: Air.Inst.Index) !CValue { | 6244 | fn airSetUnionTag(f: *Function, inst: Air.Inst.Index) !CValue { |
| ... | @@ -6251,7 +6251,7 @@ fn airSetUnionTag(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6251,7 +6251,7 @@ fn airSetUnionTag(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6251 | const union_ty = f.air.typeOf(bin_op.lhs).childType(); | 6251 | const union_ty = f.air.typeOf(bin_op.lhs).childType(); |
| 6252 | const target = f.object.dg.module.getTarget(); | 6252 | const target = f.object.dg.module.getTarget(); |
| 6253 | const layout = union_ty.unionGetLayout(target); | 6253 | const layout = union_ty.unionGetLayout(target); |
| 6254 | if (layout.tag_size == 0) return CValue.none; | 6254 | if (layout.tag_size == 0) return .none; |
| 6255 | | 6255 | |
| 6256 | try writer.writeByte('('); | 6256 | try writer.writeByte('('); |
| 6257 | try f.writeCValue(writer, union_ptr, .Other); | 6257 | try f.writeCValue(writer, union_ptr, .Other); |
| ... | @@ -6259,7 +6259,7 @@ fn airSetUnionTag(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6259,7 +6259,7 @@ fn airSetUnionTag(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6259 | try f.writeCValue(writer, new_tag, .Other); | 6259 | try f.writeCValue(writer, new_tag, .Other); |
| 6260 | try writer.writeAll(";\n"); | 6260 | try writer.writeAll(";\n"); |
| 6261 | | 6261 | |
| 6262 | return CValue.none; | 6262 | return .none; |
| 6263 | } | 6263 | } |
| 6264 | | 6264 | |
| 6265 | fn airGetUnionTag(f: *Function, inst: Air.Inst.Index) !CValue { | 6265 | fn airGetUnionTag(f: *Function, inst: Air.Inst.Index) !CValue { |
| ... | @@ -6267,7 +6267,7 @@ fn airGetUnionTag(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6267,7 +6267,7 @@ fn airGetUnionTag(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6267 | | 6267 | |
| 6268 | if (f.liveness.isUnused(inst)) { | 6268 | if (f.liveness.isUnused(inst)) { |
| 6269 | try reap(f, inst, &.{ty_op.operand}); | 6269 | try reap(f, inst, &.{ty_op.operand}); |
| 6270 | return CValue.none; | 6270 | return .none; |
| 6271 | } | 6271 | } |
| 6272 | | 6272 | |
| 6273 | const operand = try f.resolveInst(ty_op.operand); | 6273 | const operand = try f.resolveInst(ty_op.operand); |
| ... | @@ -6277,7 +6277,7 @@ fn airGetUnionTag(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6277,7 +6277,7 @@ fn airGetUnionTag(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6277 | | 6277 | |
| 6278 | const target = f.object.dg.module.getTarget(); | 6278 | const target = f.object.dg.module.getTarget(); |
| 6279 | const layout = un_ty.unionGetLayout(target); | 6279 | const layout = un_ty.unionGetLayout(target); |
| 6280 | if (layout.tag_size == 0) return CValue.none; | 6280 | if (layout.tag_size == 0) return .none; |
| 6281 | | 6281 | |
| 6282 | const inst_ty = f.air.typeOfIndex(inst); | 6282 | const inst_ty = f.air.typeOfIndex(inst); |
| 6283 | const writer = f.object.writer(); | 6283 | const writer = f.object.writer(); |
| ... | @@ -6295,7 +6295,7 @@ fn airTagName(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6295,7 +6295,7 @@ fn airTagName(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6295 | | 6295 | |
| 6296 | if (f.liveness.isUnused(inst)) { | 6296 | if (f.liveness.isUnused(inst)) { |
| 6297 | try reap(f, inst, &.{un_op}); | 6297 | try reap(f, inst, &.{un_op}); |
| 6298 | return CValue.none; | 6298 | return .none; |
| 6299 | } | 6299 | } |
| 6300 | | 6300 | |
| 6301 | const inst_ty = f.air.typeOfIndex(inst); | 6301 | const inst_ty = f.air.typeOfIndex(inst); |
| ... | @@ -6320,7 +6320,7 @@ fn airErrorName(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6320,7 +6320,7 @@ fn airErrorName(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6320 | | 6320 | |
| 6321 | if (f.liveness.isUnused(inst)) { | 6321 | if (f.liveness.isUnused(inst)) { |
| 6322 | try reap(f, inst, &.{un_op}); | 6322 | try reap(f, inst, &.{un_op}); |
| 6323 | return CValue.none; | 6323 | return .none; |
| 6324 | } | 6324 | } |
| 6325 | | 6325 | |
| 6326 | const writer = f.object.writer(); | 6326 | const writer = f.object.writer(); |
| ... | @@ -6340,7 +6340,7 @@ fn airSplat(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6340,7 +6340,7 @@ fn airSplat(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6340 | const ty_op = f.air.instructions.items(.data)[inst].ty_op; | 6340 | const ty_op = f.air.instructions.items(.data)[inst].ty_op; |
| 6341 | if (f.liveness.isUnused(inst)) { | 6341 | if (f.liveness.isUnused(inst)) { |
| 6342 | try reap(f, inst, &.{ty_op.operand}); | 6342 | try reap(f, inst, &.{ty_op.operand}); |
| 6343 | return CValue.none; | 6343 | return .none; |
| 6344 | } | 6344 | } |
| 6345 | | 6345 | |
| 6346 | const inst_ty = f.air.typeOfIndex(inst); | 6346 | const inst_ty = f.air.typeOfIndex(inst); |
| ... | @@ -6356,13 +6356,13 @@ fn airSplat(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6356,13 +6356,13 @@ fn airSplat(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6356 | } | 6356 | } |
| 6357 | | 6357 | |
| 6358 | fn airSelect(f: *Function, inst: Air.Inst.Index) !CValue { | 6358 | fn 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; |
| 6360 | | 6360 | |
| 6361 | return f.fail("TODO: C backend: implement airSelect", .{}); | 6361 | return f.fail("TODO: C backend: implement airSelect", .{}); |
| 6362 | } | 6362 | } |
| 6363 | | 6363 | |
| 6364 | fn airShuffle(f: *Function, inst: Air.Inst.Index) !CValue { | 6364 | fn 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; |
| 6366 | | 6366 | |
| 6367 | return f.fail("TODO: C backend: implement airShuffle", .{}); | 6367 | return f.fail("TODO: C backend: implement airShuffle", .{}); |
| 6368 | } | 6368 | } |
| ... | @@ -6372,7 +6372,7 @@ fn airReduce(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6372,7 +6372,7 @@ fn airReduce(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6372 | | 6372 | |
| 6373 | if (f.liveness.isUnused(inst)) { | 6373 | if (f.liveness.isUnused(inst)) { |
| 6374 | try reap(f, inst, &.{reduce.operand}); | 6374 | try reap(f, inst, &.{reduce.operand}); |
| 6375 | return CValue.none; | 6375 | return .none; |
| 6376 | } | 6376 | } |
| 6377 | | 6377 | |
| 6378 | const target = f.object.dg.module.getTarget(); | 6378 | const target = f.object.dg.module.getTarget(); |
| ... | @@ -6545,7 +6545,7 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6545,7 +6545,7 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6545 | } | 6545 | } |
| 6546 | } | 6546 | } |
| 6547 | | 6547 | |
| 6548 | if (f.liveness.isUnused(inst)) return CValue.none; | 6548 | if (f.liveness.isUnused(inst)) return .none; |
| 6549 | | 6549 | |
| 6550 | const target = f.object.dg.module.getTarget(); | 6550 | const target = f.object.dg.module.getTarget(); |
| 6551 | | 6551 | |
| ... | @@ -6590,7 +6590,7 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6590,7 +6590,7 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6590 | | 6590 | |
| 6591 | const element_ty = f.air.typeOf(element); | 6591 | const element_ty = f.air.typeOf(element); |
| 6592 | try f.writeCValue(writer, switch (element_ty.zigTypeTag()) { | 6592 | try f.writeCValue(writer, switch (element_ty.zigTypeTag()) { |
| 6593 | .Array => CValue{ .undef = element_ty }, | 6593 | .Array => .{ .undef = element_ty }, |
| 6594 | else => resolved_element, | 6594 | else => resolved_element, |
| 6595 | }, .Initializer); | 6595 | }, .Initializer); |
| 6596 | empty = false; | 6596 | empty = false; |
| ... | @@ -6697,7 +6697,7 @@ fn airUnionInit(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6697,7 +6697,7 @@ fn airUnionInit(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6697 | | 6697 | |
| 6698 | if (f.liveness.isUnused(inst)) { | 6698 | if (f.liveness.isUnused(inst)) { |
| 6699 | try reap(f, inst, &.{extra.init}); | 6699 | try reap(f, inst, &.{extra.init}); |
| 6700 | return CValue.none; | 6700 | return .none; |
| 6701 | } | 6701 | } |
| 6702 | | 6702 | |
| 6703 | const union_ty = f.air.typeOfIndex(inst); | 6703 | const union_ty = f.air.typeOfIndex(inst); |
| ... | @@ -6756,7 +6756,7 @@ fn airPrefetch(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6756,7 +6756,7 @@ fn airPrefetch(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6756 | // The available prefetch intrinsics do not accept a cache argument; only | 6756 | // The available prefetch intrinsics do not accept a cache argument; only |
| 6757 | // address, rw, and locality. So unless the cache is data, we do not lower | 6757 | // address, rw, and locality. So unless the cache is data, we do not lower |
| 6758 | // this instruction. | 6758 | // this instruction. |
| 6759 | .instruction => return CValue.none, | 6759 | .instruction => return .none, |
| 6760 | } | 6760 | } |
| 6761 | const ptr = try f.resolveInst(prefetch.ptr); | 6761 | const ptr = try f.resolveInst(prefetch.ptr); |
| 6762 | try reap(f, inst, &.{prefetch.ptr}); | 6762 | try reap(f, inst, &.{prefetch.ptr}); |
| ... | @@ -6766,11 +6766,11 @@ fn airPrefetch(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6766,11 +6766,11 @@ fn airPrefetch(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6766 | try writer.print(", {d}, {d});\n", .{ | 6766 | try writer.print(", {d}, {d});\n", .{ |
| 6767 | @enumToInt(prefetch.rw), prefetch.locality, | 6767 | @enumToInt(prefetch.rw), prefetch.locality, |
| 6768 | }); | 6768 | }); |
| 6769 | return CValue.none; | 6769 | return .none; |
| 6770 | } | 6770 | } |
| 6771 | | 6771 | |
| 6772 | fn airWasmMemorySize(f: *Function, inst: Air.Inst.Index) !CValue { | 6772 | fn 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; |
| 6774 | | 6774 | |
| 6775 | const pl_op = f.air.instructions.items(.data)[inst].pl_op; | 6775 | const pl_op = f.air.instructions.items(.data)[inst].pl_op; |
| 6776 | | 6776 | |
| ... | @@ -6807,7 +6807,7 @@ fn airFloatNeg(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6807,7 +6807,7 @@ fn airFloatNeg(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6807 | const un_op = f.air.instructions.items(.data)[inst].un_op; | 6807 | const un_op = f.air.instructions.items(.data)[inst].un_op; |
| 6808 | if (f.liveness.isUnused(inst)) { | 6808 | if (f.liveness.isUnused(inst)) { |
| 6809 | try reap(f, inst, &.{un_op}); | 6809 | try reap(f, inst, &.{un_op}); |
| 6810 | return CValue.none; | 6810 | return .none; |
| 6811 | } | 6811 | } |
| 6812 | | 6812 | |
| 6813 | const operand = try f.resolveInst(un_op); | 6813 | const operand = try f.resolveInst(un_op); |
| ... | @@ -6829,7 +6829,7 @@ fn airUnFloatOp(f: *Function, inst: Air.Inst.Index, operation: []const u8) !CVal | ... | @@ -6829,7 +6829,7 @@ fn airUnFloatOp(f: *Function, inst: Air.Inst.Index, operation: []const u8) !CVal |
| 6829 | const un_op = f.air.instructions.items(.data)[inst].un_op; | 6829 | const un_op = f.air.instructions.items(.data)[inst].un_op; |
| 6830 | if (f.liveness.isUnused(inst)) { | 6830 | if (f.liveness.isUnused(inst)) { |
| 6831 | try reap(f, inst, &.{un_op}); | 6831 | try reap(f, inst, &.{un_op}); |
| 6832 | return CValue.none; | 6832 | return .none; |
| 6833 | } | 6833 | } |
| 6834 | const operand = try f.resolveInst(un_op); | 6834 | const operand = try f.resolveInst(un_op); |
| 6835 | try reap(f, inst, &.{un_op}); | 6835 | try reap(f, inst, &.{un_op}); |
| ... | @@ -6851,7 +6851,7 @@ fn airBinFloatOp(f: *Function, inst: Air.Inst.Index, operation: []const u8) !CVa | ... | @@ -6851,7 +6851,7 @@ fn airBinFloatOp(f: *Function, inst: Air.Inst.Index, operation: []const u8) !CVa |
| 6851 | const bin_op = f.air.instructions.items(.data)[inst].bin_op; | 6851 | const bin_op = f.air.instructions.items(.data)[inst].bin_op; |
| 6852 | if (f.liveness.isUnused(inst)) { | 6852 | if (f.liveness.isUnused(inst)) { |
| 6853 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); | 6853 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs }); |
| 6854 | return CValue.none; | 6854 | return .none; |
| 6855 | } | 6855 | } |
| 6856 | const lhs = try f.resolveInst(bin_op.lhs); | 6856 | const lhs = try f.resolveInst(bin_op.lhs); |
| 6857 | const rhs = try f.resolveInst(bin_op.rhs); | 6857 | const rhs = try f.resolveInst(bin_op.rhs); |
| ... | @@ -6878,7 +6878,7 @@ fn airMulAdd(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -6878,7 +6878,7 @@ fn airMulAdd(f: *Function, inst: Air.Inst.Index) !CValue { |
| 6878 | const bin_op = f.air.extraData(Air.Bin, pl_op.payload).data; | 6878 | const bin_op = f.air.extraData(Air.Bin, pl_op.payload).data; |
| 6879 | if (f.liveness.isUnused(inst)) { | 6879 | if (f.liveness.isUnused(inst)) { |
| 6880 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs, pl_op.operand }); | 6880 | try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs, pl_op.operand }); |
| 6881 | return CValue.none; | 6881 | return .none; |
| 6882 | } | 6882 | } |
| 6883 | const inst_ty = f.air.typeOfIndex(inst); | 6883 | const inst_ty = f.air.typeOfIndex(inst); |
| 6884 | const mulend1 = try f.resolveInst(bin_op.lhs); | 6884 | const mulend1 = try f.resolveInst(bin_op.lhs); |