| ... | @@ -340,7 +340,6 @@ const DataLayoutBuilder = struct { | ... | @@ -340,7 +340,6 @@ const DataLayoutBuilder = struct { |
| 340 | _: std.fmt.FormatOptions, | 340 | _: std.fmt.FormatOptions, |
| 341 | writer: anytype, | 341 | writer: anytype, |
| 342 | ) @TypeOf(writer).Error!void { | 342 | ) @TypeOf(writer).Error!void { |
| 343 | const is_aarch64_windows = self.target.cpu.arch == .aarch64 and self.target.os.tag == .windows; | | |
| 344 | try writer.writeByte(switch (self.target.cpu.arch.endian()) { | 343 | try writer.writeByte(switch (self.target.cpu.arch.endian()) { |
| 345 | .Little => 'e', | 344 | .Little => 'e', |
| 346 | .Big => 'E', | 345 | .Big => 'E', |
| ... | @@ -407,7 +406,8 @@ const DataLayoutBuilder = struct { | ... | @@ -407,7 +406,8 @@ const DataLayoutBuilder = struct { |
| 407 | }; | 406 | }; |
| 408 | if (self.target.cpu.arch == .aarch64_32) continue; | 407 | if (self.target.cpu.arch == .aarch64_32) continue; |
| 409 | if (!info.force_in_data_layout and matches_default and | 408 | if (!info.force_in_data_layout and matches_default and |
| 410 | self.target.cpu.arch != .riscv64 and !is_aarch64_windows and | 409 | self.target.cpu.arch != .riscv64 and !(self.target.cpu.arch == .aarch64 and |
| | 410 | (self.target.os.tag == .uefi or self.target.os.tag == .windows)) and |
| 411 | self.target.cpu.arch != .bpfeb and self.target.cpu.arch != .bpfel) continue; | 411 | self.target.cpu.arch != .bpfeb and self.target.cpu.arch != .bpfel) continue; |
| 412 | try writer.writeAll("-p"); | 412 | try writer.writeAll("-p"); |
| 413 | if (info.llvm != .default) try writer.print("{d}", .{@intFromEnum(info.llvm)}); | 413 | if (info.llvm != .default) try writer.print("{d}", .{@intFromEnum(info.llvm)}); |
| ... | @@ -423,7 +423,7 @@ const DataLayoutBuilder = struct { | ... | @@ -423,7 +423,7 @@ const DataLayoutBuilder = struct { |
| 423 | if (self.target.cpu.arch == .s390x) try self.typeAlignment(.integer, 1, 8, 8, false, writer); | 423 | if (self.target.cpu.arch == .s390x) try self.typeAlignment(.integer, 1, 8, 8, false, writer); |
| 424 | try self.typeAlignment(.integer, 8, 8, 8, false, writer); | 424 | try self.typeAlignment(.integer, 8, 8, 8, false, writer); |
| 425 | try self.typeAlignment(.integer, 16, 16, 16, false, writer); | 425 | try self.typeAlignment(.integer, 16, 16, 16, false, writer); |
| 426 | try self.typeAlignment(.integer, 32, if (is_aarch64_windows) 0 else 32, 32, false, writer); | 426 | try self.typeAlignment(.integer, 32, 32, 32, false, writer); |
| 427 | try self.typeAlignment(.integer, 64, 32, 64, false, writer); | 427 | try self.typeAlignment(.integer, 64, 32, 64, false, writer); |
| 428 | try self.typeAlignment(.integer, 128, 32, 64, false, writer); | 428 | try self.typeAlignment(.integer, 128, 32, 64, false, writer); |
| 429 | if (backendSupportsF16(self.target)) try self.typeAlignment(.float, 16, 16, 16, false, writer); | 429 | if (backendSupportsF16(self.target)) try self.typeAlignment(.float, 16, 16, 16, false, writer); |
| ... | @@ -453,8 +453,15 @@ const DataLayoutBuilder = struct { | ... | @@ -453,8 +453,15 @@ const DataLayoutBuilder = struct { |
| 453 | try self.typeAlignment(.vector, 128, 128, 128, true, writer); | 453 | try self.typeAlignment(.vector, 128, 128, 128, true, writer); |
| 454 | }, | 454 | }, |
| 455 | } | 455 | } |
| 456 | if (self.target.os.tag != .windows and self.target.cpu.arch != .avr) | 456 | const swap_agg_nat = switch (self.target.cpu.arch) { |
| 457 | try self.typeAlignment(.aggregate, 0, 0, 64, false, writer); | 457 | .x86, .x86_64 => switch (self.target.os.tag) { |
| | 458 | .uefi, .windows => true, |
| | 459 | else => false, |
| | 460 | }, |
| | 461 | .avr => true, |
| | 462 | else => false, |
| | 463 | }; |
| | 464 | if (!swap_agg_nat) try self.typeAlignment(.aggregate, 0, 0, 64, false, writer); |
| 458 | for (@as([]const u24, switch (self.target.cpu.arch) { | 465 | for (@as([]const u24, switch (self.target.cpu.arch) { |
| 459 | .avr => &.{8}, | 466 | .avr => &.{8}, |
| 460 | .msp430 => &.{ 8, 16 }, | 467 | .msp430 => &.{ 8, 16 }, |
| ... | @@ -498,6 +505,7 @@ const DataLayoutBuilder = struct { | ... | @@ -498,6 +505,7 @@ const DataLayoutBuilder = struct { |
| 498 | 0 => try writer.print("-n{d}", .{natural}), | 505 | 0 => try writer.print("-n{d}", .{natural}), |
| 499 | else => try writer.print(":{d}", .{natural}), | 506 | else => try writer.print(":{d}", .{natural}), |
| 500 | }; | 507 | }; |
| | 508 | if (swap_agg_nat) try self.typeAlignment(.aggregate, 0, 0, 64, false, writer); |
| 501 | if (self.target.cpu.arch == .hexagon) { | 509 | if (self.target.cpu.arch == .hexagon) { |
| 502 | try self.typeAlignment(.integer, 64, 64, 64, true, writer); | 510 | try self.typeAlignment(.integer, 64, 64, 64, true, writer); |
| 503 | try self.typeAlignment(.integer, 32, 32, 32, true, writer); | 511 | try self.typeAlignment(.integer, 32, 32, 32, true, writer); |
| ... | @@ -506,11 +514,9 @@ const DataLayoutBuilder = struct { | ... | @@ -506,11 +514,9 @@ const DataLayoutBuilder = struct { |
| 506 | try self.typeAlignment(.float, 32, 32, 32, true, writer); | 514 | try self.typeAlignment(.float, 32, 32, 32, true, writer); |
| 507 | try self.typeAlignment(.float, 64, 64, 64, true, writer); | 515 | try self.typeAlignment(.float, 64, 64, 64, true, writer); |
| 508 | } | 516 | } |
| 509 | if (self.target.os.tag == .windows or self.target.cpu.arch == .avr) | | |
| 510 | try self.typeAlignment(.aggregate, 0, 0, 64, false, writer); | | |
| 511 | const stack_abi = self.target.stackAlignment() * 8; | 517 | const stack_abi = self.target.stackAlignment() * 8; |
| 512 | if (self.target.os.tag == .windows or self.target.cpu.arch == .msp430 or | 518 | if (self.target.os.tag == .uefi or self.target.os.tag == .windows or |
| 513 | stack_abi != ptr_bit_width) | 519 | self.target.cpu.arch == .msp430 or stack_abi != ptr_bit_width) |
| 514 | try writer.print("-S{d}", .{stack_abi}); | 520 | try writer.print("-S{d}", .{stack_abi}); |
| 515 | switch (self.target.cpu.arch) { | 521 | switch (self.target.cpu.arch) { |
| 516 | .hexagon, .ve => { | 522 | .hexagon, .ve => { |
| ... | @@ -571,22 +577,21 @@ const DataLayoutBuilder = struct { | ... | @@ -571,22 +577,21 @@ const DataLayoutBuilder = struct { |
| 571 | .integer => { | 577 | .integer => { |
| 572 | if (self.target.ptrBitWidth() <= 16 and size >= 128) return; | 578 | if (self.target.ptrBitWidth() <= 16 and size >= 128) return; |
| 573 | abi = @min(abi, self.target.maxIntAlignment() * 8); | 579 | abi = @min(abi, self.target.maxIntAlignment() * 8); |
| 574 | switch (self.target.os.tag) { | | |
| 575 | .linux => switch (self.target.cpu.arch) { | | |
| 576 | .aarch64, | | |
| 577 | .aarch64_be, | | |
| 578 | .aarch64_32, | | |
| 579 | .mips, | | |
| 580 | .mipsel, | | |
| 581 | => pref = @max(pref, 32), | | |
| 582 | else => {}, | | |
| 583 | }, | | |
| 584 | else => {}, | | |
| 585 | } | | |
| 586 | switch (self.target.cpu.arch) { | 580 | switch (self.target.cpu.arch) { |
| 587 | .aarch64, | 581 | .aarch64, |
| 588 | .aarch64_be, | 582 | .aarch64_be, |
| 589 | .aarch64_32, | 583 | .aarch64_32, |
| | 584 | => if (size == 128) { |
| | 585 | abi = size; |
| | 586 | pref = size; |
| | 587 | } else switch (self.target.os.tag) { |
| | 588 | .macos => {}, |
| | 589 | .uefi, .windows => { |
| | 590 | pref = size; |
| | 591 | force_abi = size >= 32; |
| | 592 | }, |
| | 593 | else => pref = @max(pref, 32), |
| | 594 | }, |
| 590 | .bpfeb, | 595 | .bpfeb, |
| 591 | .bpfel, | 596 | .bpfel, |
| 592 | .nvptx, | 597 | .nvptx, |
| ... | @@ -597,6 +602,9 @@ const DataLayoutBuilder = struct { | ... | @@ -597,6 +602,9 @@ const DataLayoutBuilder = struct { |
| 597 | pref = size; | 602 | pref = size; |
| 598 | }, | 603 | }, |
| 599 | .hexagon => force_abi = true, | 604 | .hexagon => force_abi = true, |
| | 605 | .mips, |
| | 606 | .mipsel, |
| | 607 | => pref = @max(pref, 32), |
| 600 | .mips64, | 608 | .mips64, |
| 601 | .mips64el, | 609 | .mips64el, |
| 602 | => if (size <= 32) { | 610 | => if (size <= 32) { |
| ... | @@ -617,7 +625,8 @@ const DataLayoutBuilder = struct { | ... | @@ -617,7 +625,8 @@ const DataLayoutBuilder = struct { |
| 617 | 128 => abi = 64, | 625 | 128 => abi = 64, |
| 618 | else => {}, | 626 | else => {}, |
| 619 | } | 627 | } |
| 620 | } else if ((self.target.cpu.arch.isPPC64() and (size == 256 or size == 512)) or | 628 | } else if ((self.target.cpu.arch.isPPC64() and self.target.os.tag == .linux and |
| | 629 | (size == 256 or size == 512)) or |
| 621 | (self.target.cpu.arch.isNvptx() and (size == 16 or size == 32))) | 630 | (self.target.cpu.arch.isNvptx() and (size == 16 or size == 32))) |
| 622 | { | 631 | { |
| 623 | force_abi = true; | 632 | force_abi = true; |
| ... | @@ -646,17 +655,21 @@ const DataLayoutBuilder = struct { | ... | @@ -646,17 +655,21 @@ const DataLayoutBuilder = struct { |
| 646 | .hexagon => if (size == 32 or size == 64) { | 655 | .hexagon => if (size == 32 or size == 64) { |
| 647 | force_abi = true; | 656 | force_abi = true; |
| 648 | }, | 657 | }, |
| 649 | .aarch64_32 => if (size == 128) { | 658 | .aarch64_32, .amdgcn => if (size == 128) { |
| 650 | abi = size; | 659 | abi = size; |
| 651 | pref = size; | 660 | pref = size; |
| 652 | }, | 661 | }, |
| | 662 | .wasm32, .wasm64 => if (self.target.os.tag == .emscripten and size == 128) { |
| | 663 | abi = 64; |
| | 664 | pref = 64; |
| | 665 | }, |
| 653 | .ve => if (size == 64) { | 666 | .ve => if (size == 64) { |
| 654 | abi = size; | 667 | abi = size; |
| 655 | pref = size; | 668 | pref = size; |
| 656 | }, | 669 | }, |
| 657 | else => {}, | 670 | else => {}, |
| 658 | }, | 671 | }, |
| 659 | .aggregate => if (self.target.os.tag == .windows or | 672 | .aggregate => if (self.target.os.tag == .uefi or self.target.os.tag == .windows or |
| 660 | self.target.cpu.arch.isARM() or self.target.cpu.arch.isThumb()) | 673 | self.target.cpu.arch.isARM() or self.target.cpu.arch.isThumb()) |
| 661 | { | 674 | { |
| 662 | pref = @min(pref, self.target.ptrBitWidth()); | 675 | pref = @min(pref, self.target.ptrBitWidth()); |