authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-03-14 22:17:19-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-03-15 01:04:21-04:00
log238615984064f52b6ff31b5750824a9c764fdb15
tree19cc9479a8c7c0274b69537ec30a045955f91199
parentd14a9e82feca6467176d188d2eccf6ff51606952

x86_64: use short union init


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

src/arch/x86_64/CodeGen.zig+12-12
...@@ -1037,7 +1037,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -1037,7 +1037,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
1037fn processDeath(self: *Self, inst: Air.Inst.Index) void {1037fn processDeath(self: *Self, inst: Air.Inst.Index) void {
1038 const air_tags = self.air.instructions.items(.tag);1038 const air_tags = self.air.instructions.items(.tag);
1039 if (air_tags[inst] == .constant) return; // Constants are immortal.1039 if (air_tags[inst] == .constant) return; // Constants are immortal.
1040 log.debug("%{d} => {}", .{ inst, MCValue{ .dead = {} } });1040 log.debug("%{d} => {}", .{ inst, MCValue.dead });
1041 // When editing this function, note that the logic must synchronize with `reuseOperand`.1041 // When editing this function, note that the logic must synchronize with `reuseOperand`.
1042 const prev_value = self.getResolvedInstValue(inst);1042 const prev_value = self.getResolvedInstValue(inst);
1043 const branch = &self.branch_stack.items[self.branch_stack.items.len - 1];1043 const branch = &self.branch_stack.items[self.branch_stack.items.len - 1];
...@@ -4729,7 +4729,7 @@ fn airBlock(self: *Self, inst: Air.Inst.Index) !void {...@@ -4729,7 +4729,7 @@ fn airBlock(self: *Self, inst: Air.Inst.Index) !void {
4729 // break instruction will choose a MCValue for the block result and overwrite4729 // break instruction will choose a MCValue for the block result and overwrite
4730 // this field. Following break instructions will use that MCValue to put their4730 // this field. Following break instructions will use that MCValue to put their
4731 // block results.4731 // block results.
4732 .mcv = MCValue{ .none = {} },4732 .mcv = .none,
4733 });4733 });
4734 defer self.blocks.getPtr(inst).?.relocs.deinit(self.gpa);4734 defer self.blocks.getPtr(inst).?.relocs.deinit(self.gpa);
47354735
...@@ -5145,9 +5145,9 @@ fn airAsm(self: *Self, inst: Air.Inst.Index) !void {...@@ -5145,9 +5145,9 @@ fn airAsm(self: *Self, inst: Air.Inst.Index) !void {
5145 const reg_name = output[2 .. output.len - 1];5145 const reg_name = output[2 .. output.len - 1];
5146 const reg = parseRegName(reg_name) orelse5146 const reg = parseRegName(reg_name) orelse
5147 return self.fail("unrecognized register: '{s}'", .{reg_name});5147 return self.fail("unrecognized register: '{s}'", .{reg_name});
5148 break :result MCValue{ .register = reg };5148 break :result .{ .register = reg };
5149 } else {5149 } else {
5150 break :result MCValue{ .none = {} };5150 break :result .none;
5151 }5151 }
5152 };5152 };
51535153
...@@ -6289,7 +6289,7 @@ fn resolveInst(self: *Self, inst: Air.Inst.Ref) InnerError!MCValue {...@@ -6289,7 +6289,7 @@ fn resolveInst(self: *Self, inst: Air.Inst.Ref) InnerError!MCValue {
6289 if (ref_int < Air.Inst.Ref.typed_value_map.len) {6289 if (ref_int < Air.Inst.Ref.typed_value_map.len) {
6290 const tv = Air.Inst.Ref.typed_value_map[ref_int];6290 const tv = Air.Inst.Ref.typed_value_map[ref_int];
6291 if (!tv.ty.hasRuntimeBitsIgnoreComptime() and !tv.ty.isError()) {6291 if (!tv.ty.hasRuntimeBitsIgnoreComptime() and !tv.ty.isError()) {
6292 return MCValue{ .none = {} };6292 return .none;
6293 }6293 }
6294 return self.genTypedValue(tv);6294 return self.genTypedValue(tv);
6295 }6295 }
...@@ -6297,7 +6297,7 @@ fn resolveInst(self: *Self, inst: Air.Inst.Ref) InnerError!MCValue {...@@ -6297,7 +6297,7 @@ fn resolveInst(self: *Self, inst: Air.Inst.Ref) InnerError!MCValue {
6297 // If the type has no codegen bits, no need to store it.6297 // If the type has no codegen bits, no need to store it.
6298 const inst_ty = self.air.typeOf(inst);6298 const inst_ty = self.air.typeOf(inst);
6299 if (!inst_ty.hasRuntimeBitsIgnoreComptime() and !inst_ty.isError())6299 if (!inst_ty.hasRuntimeBitsIgnoreComptime() and !inst_ty.isError())
6300 return MCValue{ .none = {} };6300 return .none;
63016301
6302 const inst_index = @intCast(Air.Inst.Index, ref_int - Air.Inst.Ref.typed_value_map.len);6302 const inst_index = @intCast(Air.Inst.Index, ref_int - Air.Inst.Ref.typed_value_map.len);
6303 switch (self.air.instructions.items(.tag)[inst_index]) {6303 switch (self.air.instructions.items(.tag)[inst_index]) {
...@@ -6406,7 +6406,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {...@@ -6406,7 +6406,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
6406 switch (cc) {6406 switch (cc) {
6407 .Naked => {6407 .Naked => {
6408 assert(result.args.len == 0);6408 assert(result.args.len == 0);
6409 result.return_value = .{ .unreach = {} };6409 result.return_value = .unreach;
6410 result.stack_byte_count = 0;6410 result.stack_byte_count = 0;
6411 result.stack_align = 1;6411 result.stack_align = 1;
6412 return result;6412 return result;
...@@ -6414,10 +6414,10 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {...@@ -6414,10 +6414,10 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
6414 .C => {6414 .C => {
6415 // Return values6415 // Return values
6416 if (ret_ty.zigTypeTag() == .NoReturn) {6416 if (ret_ty.zigTypeTag() == .NoReturn) {
6417 result.return_value = .{ .unreach = {} };6417 result.return_value = .unreach;
6418 } else if (!ret_ty.hasRuntimeBitsIgnoreComptime() and !ret_ty.isError()) {6418 } else if (!ret_ty.hasRuntimeBitsIgnoreComptime() and !ret_ty.isError()) {
6419 // TODO: is this even possible for C calling convention?6419 // TODO: is this even possible for C calling convention?
6420 result.return_value = .{ .none = {} };6420 result.return_value = .none;
6421 } else {6421 } else {
6422 const ret_ty_size = @intCast(u32, ret_ty.abiSize(self.target.*));6422 const ret_ty_size = @intCast(u32, ret_ty.abiSize(self.target.*));
6423 if (ret_ty_size == 0) {6423 if (ret_ty_size == 0) {
...@@ -6489,9 +6489,9 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {...@@ -6489,9 +6489,9 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
6489 .Unspecified => {6489 .Unspecified => {
6490 // Return values6490 // Return values
6491 if (ret_ty.zigTypeTag() == .NoReturn) {6491 if (ret_ty.zigTypeTag() == .NoReturn) {
6492 result.return_value = .{ .unreach = {} };6492 result.return_value = .unreach;
6493 } else if (!ret_ty.hasRuntimeBitsIgnoreComptime() and !ret_ty.isError()) {6493 } else if (!ret_ty.hasRuntimeBitsIgnoreComptime() and !ret_ty.isError()) {
6494 result.return_value = .{ .none = {} };6494 result.return_value = .none;
6495 } else {6495 } else {
6496 const ret_ty_size = @intCast(u32, ret_ty.abiSize(self.target.*));6496 const ret_ty_size = @intCast(u32, ret_ty.abiSize(self.target.*));
6497 if (ret_ty_size == 0) {6497 if (ret_ty_size == 0) {
...@@ -6516,7 +6516,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {...@@ -6516,7 +6516,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
65166516
6517 for (param_types, result.args) |ty, *arg| {6517 for (param_types, result.args) |ty, *arg| {
6518 if (!ty.hasRuntimeBits()) {6518 if (!ty.hasRuntimeBits()) {
6519 arg.* = .{ .none = {} };6519 arg.* = .none;
6520 continue;6520 continue;
6521 }6521 }
6522 const param_size = @intCast(u32, ty.abiSize(self.target.*));6522 const param_size = @intCast(u32, ty.abiSize(self.target.*));