Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/compiler/aro/aro/target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ pub fn get32BitArchVariant(target: std.Target) ?std.Target {
.ve,
.bpfel,
.bpfeb,
.kvx,
.s390x,
=> return null,

Expand Down Expand Up @@ -551,6 +552,7 @@ pub fn get64BitArchVariant(target: std.Target) ?std.Target {
.nvptx64,
.wasm64,
.spirv64,
.kvx,
.loongarch64,
.mips64,
.mips64el,
Expand Down Expand Up @@ -636,8 +638,9 @@ pub fn toLLVMTriple(target: std.Target, buf: []u8) []const u8 {
.wasm32 => "wasm32",
.wasm64 => "wasm64",
.ve => "ve",
// Note: propeller1, kalimba and or1k are not supported in LLVM; this is the Zig arch name
// Note: propeller1, kalimba, kvx, and or1k are not supported in LLVM; this is the Zig arch name
.kalimba => "kalimba",
.kvx => "kvx",
.propeller => "propeller",
.or1k => "or1k",
};
Expand Down
35 changes: 33 additions & 2 deletions lib/std/Target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ pub const csky = @import("Target/csky.zig");
pub const hexagon = @import("Target/hexagon.zig");
pub const hppa = @import("Target/generic.zig");
pub const kalimba = @import("Target/generic.zig");
pub const kvx = @import("Target/kvx.zig");
pub const lanai = @import("Target/lanai.zig");
pub const loongarch = @import("Target/loongarch.zig");
pub const m68k = @import("Target/m68k.zig");
Expand Down Expand Up @@ -1035,14 +1036,15 @@ pub fn toElfMachine(target: *const Target) std.elf.EM {
.aarch64, .aarch64_be => .AARCH64,
.alpha => .ALPHA,
.amdgcn => .AMDGPU,
.arc, .arceb => .ARC_COMPACT,
.arc, .arceb => .ARC_COMPACT2,
.arm, .armeb, .thumb, .thumbeb => .ARM,
.avr => .AVR,
.bpfeb, .bpfel => .BPF,
.csky => .CSKY,
.hexagon => .QDSP6,
.hppa, .hppa64 => .PARISC,
.kalimba => .CSR_KALIMBA,
.kvx => .KVX,
.lanai => .LANAI,
.loongarch32, .loongarch64 => .LOONGARCH,
.m68k => .@"68K",
Expand Down Expand Up @@ -1105,6 +1107,7 @@ pub fn toCoffMachine(target: *const Target) std.coff.IMAGE.FILE.MACHINE {
.hppa,
.hppa64,
.kalimba,
.kvx,
.lanai,
.m68k,
.microblaze,
Expand Down Expand Up @@ -1310,6 +1313,7 @@ pub const Cpu = struct {
hppa,
hppa64,
kalimba,
kvx,
lanai,
loongarch32,
loongarch64,
Expand Down Expand Up @@ -1385,6 +1389,7 @@ pub const Cpu = struct {
hexagon,
hppa,
kalimba,
kvx,
lanai,
loongarch,
m68k,
Expand Down Expand Up @@ -1420,6 +1425,7 @@ pub const Cpu = struct {
.hexagon => .hexagon,
.hppa, .hppa64 => .hppa,
.kalimba => .kalimba,
.kvx => .kvx,
.lanai => .lanai,
.loongarch32, .loongarch64 => .loongarch,
.m68k => .m68k,
Expand Down Expand Up @@ -1623,6 +1629,7 @@ pub const Cpu = struct {
.csky,
.hexagon,
.kalimba,
.kvx,
.loongarch32,
.loongarch64,
.microblazeel,
Expand Down Expand Up @@ -1847,6 +1854,10 @@ pub const Cpu = struct {
.hppa64_elf,
=> &.{.hppa64},

.kvx_lp64,
.kvx_ilp32,
=> &.{.kvx},

.lanai_sysv,
=> &.{.lanai},

Expand Down Expand Up @@ -1936,6 +1947,7 @@ pub const Cpu = struct {
return switch (arch) {
.amdgcn => &amdgcn.cpu.gfx600,
.avr => &avr.cpu.avr1,
.kvx => &kvx.cpu.coolidge_v1,
.loongarch32 => &loongarch.cpu.generic_la32,
.loongarch64 => &loongarch.cpu.generic_la64,
.mips, .mipsel => &mips.cpu.mips32,
Expand Down Expand Up @@ -1987,6 +1999,7 @@ pub const Cpu = struct {
.bpfel, .bpfeb => &bpf.cpu.v3,
.csky => &csky.cpu.ck810, // gcc/clang do not have a generic csky model.
.hexagon => &hexagon.cpu.hexagonv68, // gcc/clang do not have a generic hexagon model.
.kvx => &kvx.cpu.coolidge_v2,
.lanai => &lanai.cpu.v11, // clang does not have a generic lanai model.
.loongarch64 => &loongarch.cpu.la64v1_0,
.m68k => &m68k.cpu.M68000,
Expand Down Expand Up @@ -2440,6 +2453,7 @@ pub const DynamicLinker = struct {
.aarch64,
.aarch64_be,
.hexagon,
.kvx,
.m68k,
.microblaze,
.microblazeel,
Expand Down Expand Up @@ -2666,16 +2680,20 @@ pub const DynamicLinker = struct {
},

.netbsd => switch (cpu.arch) {
.alpha,
.arm,
.armeb,
.aarch64,
.aarch64_be,
.hppa,
.m68k,
.mips,
.mipsel,
.mips64,
.mips64el,
.powerpc,
.sh,
.sheb,
.sparc,
.sparc64,
.x86,
Expand All @@ -2685,13 +2703,17 @@ pub const DynamicLinker = struct {
},

.openbsd => switch (cpu.arch) {
.alpha,
.arm,
.aarch64,
.hppa,
.mips64,
.mips64el,
.powerpc,
.powerpc64,
.riscv64,
.sh,
.sheb,
.sparc64,
.x86,
.x86_64,
Expand Down Expand Up @@ -2817,6 +2839,7 @@ pub fn ptrBitWidth_arch_abi(cpu_arch: Cpu.Arch, abi: Abi) u16 {
.bpfeb,
.bpfel,
.hppa64,
.kvx,
.loongarch64,
.mips64,
.mips64el,
Expand Down Expand Up @@ -2870,6 +2893,7 @@ pub fn stackAlignment(target: *const Target) u16 {
.ve,
.wasm32,
.wasm64,
.x86_64,
=> return 16,
// Some of the following prongs should really be testing the ABI, but our current `Abi` enum
// can't handle that level of nuance yet.
Expand All @@ -2882,7 +2906,7 @@ pub fn stackAlignment(target: *const Target) u16 {
.riscv64be,
=> if (!target.cpu.has(.riscv, .e)) return 16,
.x86 => if (target.os.tag != .windows and target.os.tag != .uefi) return 16,
.x86_64 => return 16,
.kvx => return 32,
else => {},
}

Expand Down Expand Up @@ -3375,6 +3399,7 @@ pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
.aarch64_be,
.alpha,
.hppa64,
.kvx,
.loongarch32,
.loongarch64,
.mips64,
Expand Down Expand Up @@ -3482,6 +3507,7 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
.aarch64_be,
.alpha,
.hppa64,
.kvx,
.loongarch32,
.loongarch64,
.mips64,
Expand Down Expand Up @@ -3557,6 +3583,7 @@ pub fn cMaxIntAlignment(target: *const Target) u16 {
.bpfel,
.bpfeb,
.hppa64,
.kvx,
.loongarch64,
.mips64,
.mips64el,
Expand Down Expand Up @@ -3626,6 +3653,10 @@ pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention
.hppa => .{ .hppa_elf = .{} },
.hppa64 => .{ .hppa64_elf = .{} },
.kalimba => null,
.kvx => switch (target.abi) {
.ilp32 => .{ .kvx_ilp32 = .{} },
else => .{ .kvx_lp64 = .{} },
},
.lanai => .{ .lanai_sysv = .{} },
.loongarch64 => .{ .loongarch64_lp64 = .{} },
.loongarch32 => .{ .loongarch32_ilp32 = .{} },
Expand Down
64 changes: 64 additions & 0 deletions lib/std/Target/kvx.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//! This file is auto-generated by tools/update_cpu_features.zig.

const std = @import("../std.zig");
const CpuFeature = std.Target.Cpu.Feature;
const CpuModel = std.Target.Cpu.Model;

pub const Feature = enum {
v3_1,
v3_2,
v4_1,
};

pub const featureSet = CpuFeature.FeatureSetFns(Feature).featureSet;
pub const featureSetHas = CpuFeature.FeatureSetFns(Feature).featureSetHas;
pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;

pub const all_features = blk: {
const len = @typeInfo(Feature).@"enum".fields.len;
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
var result: [len]CpuFeature = undefined;
result[@intFromEnum(Feature.v3_1)] = .{
.llvm_name = null,
.description = "Enable ISA v3.1",
.dependencies = featureSet(&[_]Feature{}),
};
result[@intFromEnum(Feature.v3_2)] = .{
.llvm_name = null,
.description = "Enable ISA v3.2",
.dependencies = featureSet(&[_]Feature{
.v3_1,
}),
};
result[@intFromEnum(Feature.v4_1)] = .{
.llvm_name = null,
.description = "Enable ISA v4.1",
.dependencies = featureSet(&[_]Feature{
.v3_2,
}),
};
const ti = @typeInfo(Feature);
for (&result, 0..) |*elem, i| {
elem.index = i;
elem.name = ti.@"enum".fields[i].name;
}
break :blk result;
};

pub const cpu = struct {
pub const coolidge_v1: CpuModel = .{
.name = "coolidge_v1",
.llvm_name = null,
.features = featureSet(&[_]Feature{
.v3_1,
}),
};
pub const coolidge_v2: CpuModel = .{
.name = "coolidge_v2",
.llvm_name = null,
.features = featureSet(&[_]Feature{
.v3_2,
}),
};
};
4 changes: 4 additions & 0 deletions lib/std/builtin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ pub const CallingConvention = union(enum(u8)) {
/// The standard `hppa64` calling convention.
hppa64_elf: CommonOptions,

kvx_lp64: CommonOptions,
kvx_ilp32: CommonOptions,

/// The standard `lanai` calling convention.
lanai_sysv: CommonOptions,

Expand Down Expand Up @@ -959,6 +962,7 @@ pub const VaList = switch (builtin.cpu.arch) {
.csky,
.hppa,
.hppa64,
.kvx,
.lanai,
.loongarch32,
.loongarch64,
Expand Down
Loading