llvm-backend: fix uefi data layout

the old logic caused the uefi case to fall through which caused an
assertion assertion in llvm to fail, as the data layout was wrong.
This commit is contained in:
bnuuydev 2025-10-15 03:23:57 +01:00 committed by Alex Rønne Petersen
parent 48f8133bea
commit 173f497e29

View File

@ -332,13 +332,13 @@ pub fn dataLayout(target: *const std.Target) []const u8 {
.hexagon => "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048", .hexagon => "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048",
.lanai => "E-m:e-p:32:32-i64:64-a:0:32-n32-S64", .lanai => "E-m:e-p:32:32-i64:64-a:0:32-n32-S64",
.aarch64 => if (target.ofmt == .macho) .aarch64 => if (target.ofmt == .macho)
if (target.os.tag == .windows) if (target.os.tag == .windows or target.os.tag == .uefi)
"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32" "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
else if (target.abi == .ilp32) else if (target.abi == .ilp32)
"e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32" "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
else else
"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32" "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
else if (target.os.tag == .windows) else if (target.os.tag == .windows or target.os.tag == .uefi)
"e-m:w-p270:32:32-p271:32:32-p272:64:64-p:64:64-i32:32-i64:64-i128:128-n32:64-S128-Fn32" "e-m:w-p270:32:32-p271:32:32-p272:64:64-p:64:64-i32:32-i64:64-i128:128-n32:64-S128-Fn32"
else else
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32", "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32",
@ -353,7 +353,7 @@ pub fn dataLayout(target: *const std.Target) []const u8 {
"E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64",
.thumb => if (target.ofmt == .macho) .thumb => if (target.ofmt == .macho)
"e-m:o-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" "e-m:o-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
else if (target.os.tag == .windows) else if (target.os.tag == .windows or target.os.tag == .uefi)
"e-m:w-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" "e-m:w-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
else else
"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64",
@ -419,7 +419,7 @@ pub fn dataLayout(target: *const std.Target) []const u8 {
"E-m:l-p1:32:32-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64" "E-m:l-p1:32:32-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64"
else else
"E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64", "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64",
.x86 => if (target.os.tag == .windows) switch (target.abi) { .x86 => if (target.os.tag == .windows or target.os.tag == .uefi) switch (target.abi) {
.cygnus => "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:32-n8:16:32-a:0:32-S32", .cygnus => "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:32-n8:16:32-a:0:32-S32",
.gnu => if (target.ofmt == .coff) .gnu => if (target.ofmt == .coff)
"e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:32-n8:16:32-a:0:32-S32" "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:32-n8:16:32-a:0:32-S32"
@ -449,7 +449,7 @@ pub fn dataLayout(target: *const std.Target) []const u8 {
"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
else switch (target.abi) { else switch (target.abi) {
.gnux32, .muslx32 => "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", .gnux32, .muslx32 => "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128",
else => if (target.os.tag == .windows and target.ofmt == .coff) else => if ((target.os.tag == .windows or target.os.tag == .uefi) and target.ofmt == .coff)
"e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
else else
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128",