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