Skip to content

Commit 0ca3582

Browse files
committed
update CPU features to LLVM 16
1 parent 1e7083d commit 0ca3582

21 files changed

+1784
-155
lines changed

build.zig

+7
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ pub fn build(b: *Builder) !void {
9797
"llvm-has-arc",
9898
"Whether LLVM has the experimental target arc enabled",
9999
) orelse false;
100+
const llvm_has_xtensa = b.option(
101+
bool,
102+
"llvm-has-xtensa",
103+
"Whether LLVM has the experimental target xtensa enabled",
104+
) orelse false;
100105
const enable_macos_sdk = b.option(bool, "enable-macos-sdk", "Run tests requiring presence of macOS SDK and frameworks") orelse false;
101106
const enable_symlinks_windows = b.option(bool, "enable-symlinks-windows", "Run tests requiring presence of symlinks on Windows") orelse false;
102107
const config_h_path_option = b.option([]const u8, "config_h", "Path to the generated config.h");
@@ -186,6 +191,7 @@ pub fn build(b: *Builder) !void {
186191
exe_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k);
187192
exe_options.addOption(bool, "llvm_has_csky", llvm_has_csky);
188193
exe_options.addOption(bool, "llvm_has_arc", llvm_has_arc);
194+
exe_options.addOption(bool, "llvm_has_xtensa", llvm_has_xtensa);
189195
exe_options.addOption(bool, "force_gpa", force_gpa);
190196
exe_options.addOption(bool, "only_c", only_c);
191197
exe_options.addOption(bool, "omit_pkg_fetching_code", false);
@@ -340,6 +346,7 @@ pub fn build(b: *Builder) !void {
340346
test_cases_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k);
341347
test_cases_options.addOption(bool, "llvm_has_csky", llvm_has_csky);
342348
test_cases_options.addOption(bool, "llvm_has_arc", llvm_has_arc);
349+
test_cases_options.addOption(bool, "llvm_has_xtensa", llvm_has_xtensa);
343350
test_cases_options.addOption(bool, "force_gpa", force_gpa);
344351
test_cases_options.addOption(bool, "only_c", only_c);
345352
test_cases_options.addOption(bool, "enable_qemu", b.enable_qemu);

lib/std/target.zig

+21-1
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ pub const Target = struct {
459459
pub const bpf = @import("target/bpf.zig");
460460
pub const csky = @import("target/csky.zig");
461461
pub const hexagon = @import("target/hexagon.zig");
462+
pub const loongarch = @import("target/loongarch.zig");
462463
pub const m68k = @import("target/m68k.zig");
463464
pub const mips = @import("target/mips.zig");
464465
pub const msp430 = @import("target/msp430.zig");
@@ -471,6 +472,7 @@ pub const Target = struct {
471472
pub const ve = @import("target/ve.zig");
472473
pub const wasm = @import("target/wasm.zig");
473474
pub const x86 = @import("target/x86.zig");
475+
pub const xtensa = @import("target/xtensa.zig");
474476

475477
pub const Abi = enum {
476478
none,
@@ -1007,6 +1009,7 @@ pub const Target = struct {
10071009
.thumbeb => .ARM,
10081010
.x86 => .@"386",
10091011
.xcore => .XCORE,
1012+
.xtensa => .XTENSA,
10101013
.nvptx => .NONE,
10111014
.amdil => .NONE,
10121015
.hsail => .NONE,
@@ -1032,7 +1035,7 @@ pub const Target = struct {
10321035
.spir64 => .NONE,
10331036
.wasm64 => .NONE,
10341037
.renderscript64 => .NONE,
1035-
.amdgcn => .NONE,
1038+
.amdgcn => .AMDGPU,
10361039
.bpfel => .BPF,
10371040
.bpfeb => .BPF,
10381041
.csky => .CSKY,
@@ -1122,6 +1125,7 @@ pub const Target = struct {
11221125
.amdil64,
11231126
.bpfel,
11241127
.csky,
1128+
.xtensa,
11251129
.hexagon,
11261130
.hsail,
11271131
.hsail64,
@@ -1236,6 +1240,7 @@ pub const Target = struct {
12361240
.spirv32,
12371241
.loongarch32,
12381242
.dxil,
1243+
.xtensa,
12391244
=> return 32,
12401245

12411246
.aarch64,
@@ -1271,6 +1276,7 @@ pub const Target = struct {
12711276
.arm, .armeb, .thumb, .thumbeb => "arm",
12721277
.aarch64, .aarch64_be, .aarch64_32 => "aarch64",
12731278
.bpfel, .bpfeb => "bpf",
1279+
.loongarch32, .loongarch64 => "loongarch",
12741280
.mips, .mipsel, .mips64, .mips64el => "mips",
12751281
.powerpc, .powerpcle, .powerpc64, .powerpc64le => "powerpc",
12761282
.amdgcn => "amdgpu",
@@ -1290,9 +1296,13 @@ pub const Target = struct {
12901296
return switch (arch) {
12911297
.arm, .armeb, .thumb, .thumbeb => &arm.all_features,
12921298
.aarch64, .aarch64_be, .aarch64_32 => &aarch64.all_features,
1299+
.arc => &arc.all_features,
12931300
.avr => &avr.all_features,
12941301
.bpfel, .bpfeb => &bpf.all_features,
1302+
.csky => &csky.all_features,
12951303
.hexagon => &hexagon.all_features,
1304+
.loongarch32, .loongarch64 => &loongarch.all_features,
1305+
.m68k => &m68k.all_features,
12961306
.mips, .mipsel, .mips64, .mips64el => &mips.all_features,
12971307
.msp430 => &msp430.all_features,
12981308
.powerpc, .powerpcle, .powerpc64, .powerpc64le => &powerpc.all_features,
@@ -1302,6 +1312,7 @@ pub const Target = struct {
13021312
.spirv32, .spirv64 => &spirv.all_features,
13031313
.s390x => &s390x.all_features,
13041314
.x86, .x86_64 => &x86.all_features,
1315+
.xtensa => &xtensa.all_features,
13051316
.nvptx, .nvptx64 => &nvptx.all_features,
13061317
.ve => &ve.all_features,
13071318
.wasm32, .wasm64 => &wasm.all_features,
@@ -1313,11 +1324,15 @@ pub const Target = struct {
13131324
/// All processors Zig is aware of, sorted lexicographically by name.
13141325
pub fn allCpuModels(arch: Arch) []const *const Cpu.Model {
13151326
return switch (arch) {
1327+
.arc => comptime allCpusFromDecls(arc.cpu),
13161328
.arm, .armeb, .thumb, .thumbeb => comptime allCpusFromDecls(arm.cpu),
13171329
.aarch64, .aarch64_be, .aarch64_32 => comptime allCpusFromDecls(aarch64.cpu),
13181330
.avr => comptime allCpusFromDecls(avr.cpu),
13191331
.bpfel, .bpfeb => comptime allCpusFromDecls(bpf.cpu),
1332+
.csky => comptime allCpusFromDecls(csky.cpu),
13201333
.hexagon => comptime allCpusFromDecls(hexagon.cpu),
1334+
.loongarch32, .loongarch64 => comptime allCpusFromDecls(loongarch.cpu),
1335+
.m68k => comptime allCpusFromDecls(m68k.cpu),
13211336
.mips, .mipsel, .mips64, .mips64el => comptime allCpusFromDecls(mips.cpu),
13221337
.msp430 => comptime allCpusFromDecls(msp430.cpu),
13231338
.powerpc, .powerpcle, .powerpc64, .powerpc64le => comptime allCpusFromDecls(powerpc.cpu),
@@ -1326,6 +1341,7 @@ pub const Target = struct {
13261341
.sparc, .sparc64, .sparcel => comptime allCpusFromDecls(sparc.cpu),
13271342
.s390x => comptime allCpusFromDecls(s390x.cpu),
13281343
.x86, .x86_64 => comptime allCpusFromDecls(x86.cpu),
1344+
.xtensa => comptime allCpusFromDecls(xtensa.cpu),
13291345
.nvptx, .nvptx64 => comptime allCpusFromDecls(nvptx.cpu),
13301346
.ve => comptime allCpusFromDecls(ve.cpu),
13311347
.wasm32, .wasm64 => comptime allCpusFromDecls(wasm.cpu),
@@ -1373,6 +1389,8 @@ pub const Target = struct {
13731389
.avr => &avr.cpu.avr2,
13741390
.bpfel, .bpfeb => &bpf.cpu.generic,
13751391
.hexagon => &hexagon.cpu.generic,
1392+
.loongarch32 => &loongarch.cpu.generic_la32,
1393+
.loongarch64 => &loongarch.cpu.generic_la64,
13761394
.m68k => &m68k.cpu.generic,
13771395
.mips, .mipsel => &mips.cpu.mips32,
13781396
.mips64, .mips64el => &mips.cpu.mips64,
@@ -1720,6 +1738,7 @@ pub const Target = struct {
17201738
.dxil,
17211739
.loongarch32,
17221740
.loongarch64,
1741+
.xtensa,
17231742
=> return result,
17241743
},
17251744

@@ -1884,6 +1903,7 @@ pub const Target = struct {
18841903
.dxil,
18851904
.loongarch32,
18861905
.loongarch64,
1906+
.xtensa,
18871907
=> 16,
18881908
};
18891909
}

0 commit comments

Comments
 (0)