Skip to content

Commit

Permalink
Merge pull request #21031 from linusg/std-target-naming
Browse files Browse the repository at this point in the history
std.Target: Function naming cleanup
  • Loading branch information
andrewrk authored Aug 14, 2024
2 parents eb7f318 + 4ef956e commit 78fb9c0
Show file tree
Hide file tree
Showing 35 changed files with 206 additions and 206 deletions.
6 changes: 3 additions & 3 deletions lib/compiler/aro/aro/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5631,15 +5631,15 @@ pub const Result = struct {
};
const a_spec = a.ty.canonicalize(.standard).specifier;
const b_spec = b.ty.canonicalize(.standard).specifier;
if (p.comp.target.c_type_bit_size(.longdouble) == 128) {
if (p.comp.target.cTypeBitSize(.longdouble) == 128) {
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[0])) return;
}
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[1])) return;
if (p.comp.target.c_type_bit_size(.longdouble) == 80) {
if (p.comp.target.cTypeBitSize(.longdouble) == 80) {
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[0])) return;
}
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[2])) return;
if (p.comp.target.c_type_bit_size(.longdouble) == 64) {
if (p.comp.target.cTypeBitSize(.longdouble) == 64) {
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[0])) return;
}
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[3])) return;
Expand Down
46 changes: 23 additions & 23 deletions lib/compiler/aro/aro/Type.zig
Original file line number Diff line number Diff line change
Expand Up @@ -991,19 +991,19 @@ pub fn sizeof(ty: Type, comp: *const Compilation) ?u64 {
.incomplete_array => return if (comp.langopts.emulate == .msvc) @as(?u64, 0) else null,
.func, .var_args_func, .old_style_func, .void, .bool => 1,
.char, .schar, .uchar => 1,
.short => comp.target.c_type_byte_size(.short),
.ushort => comp.target.c_type_byte_size(.ushort),
.int => comp.target.c_type_byte_size(.int),
.uint => comp.target.c_type_byte_size(.uint),
.long => comp.target.c_type_byte_size(.long),
.ulong => comp.target.c_type_byte_size(.ulong),
.long_long => comp.target.c_type_byte_size(.longlong),
.ulong_long => comp.target.c_type_byte_size(.ulonglong),
.long_double => comp.target.c_type_byte_size(.longdouble),
.short => comp.target.cTypeByteSize(.short),
.ushort => comp.target.cTypeByteSize(.ushort),
.int => comp.target.cTypeByteSize(.int),
.uint => comp.target.cTypeByteSize(.uint),
.long => comp.target.cTypeByteSize(.long),
.ulong => comp.target.cTypeByteSize(.ulong),
.long_long => comp.target.cTypeByteSize(.longlong),
.ulong_long => comp.target.cTypeByteSize(.ulonglong),
.long_double => comp.target.cTypeByteSize(.longdouble),
.int128, .uint128 => 16,
.fp16, .float16 => 2,
.float => comp.target.c_type_byte_size(.float),
.double => comp.target.c_type_byte_size(.double),
.float => comp.target.cTypeByteSize(.float),
.double => comp.target.cTypeByteSize(.double),
.float80 => 16,
.float128 => 16,
.bit_int => {
Expand Down Expand Up @@ -1049,7 +1049,7 @@ pub fn bitSizeof(ty: Type, comp: *const Compilation) ?u64 {
.typeof_expr => ty.data.expr.ty.bitSizeof(comp),
.attributed => ty.data.attributed.base.bitSizeof(comp),
.bit_int => return ty.data.int.bits,
.long_double => comp.target.c_type_bit_size(.longdouble),
.long_double => comp.target.cTypeBitSize(.longdouble),
.float80 => return 80,
else => 8 * (ty.sizeof(comp) orelse return null),
};
Expand Down Expand Up @@ -1104,24 +1104,24 @@ pub fn alignof(ty: Type, comp: *const Compilation) u29 {
=> return ty.makeReal().alignof(comp),
// zig fmt: on

.short => comp.target.c_type_alignment(.short),
.ushort => comp.target.c_type_alignment(.ushort),
.int => comp.target.c_type_alignment(.int),
.uint => comp.target.c_type_alignment(.uint),
.short => comp.target.cTypeAlignment(.short),
.ushort => comp.target.cTypeAlignment(.ushort),
.int => comp.target.cTypeAlignment(.int),
.uint => comp.target.cTypeAlignment(.uint),

.long => comp.target.c_type_alignment(.long),
.ulong => comp.target.c_type_alignment(.ulong),
.long_long => comp.target.c_type_alignment(.longlong),
.ulong_long => comp.target.c_type_alignment(.ulonglong),
.long => comp.target.cTypeAlignment(.long),
.ulong => comp.target.cTypeAlignment(.ulong),
.long_long => comp.target.cTypeAlignment(.longlong),
.ulong_long => comp.target.cTypeAlignment(.ulonglong),

.bit_int => @min(
std.math.ceilPowerOfTwoPromote(u16, (ty.data.int.bits + 7) / 8),
16, // comp.target.maxIntAlignment(), please use your own logic for this value as it is implementation-defined
),

.float => comp.target.c_type_alignment(.float),
.double => comp.target.c_type_alignment(.double),
.long_double => comp.target.c_type_alignment(.longdouble),
.float => comp.target.cTypeAlignment(.float),
.double => comp.target.cTypeAlignment(.double),
.long_double => comp.target.cTypeAlignment(.longdouble),

.int128, .uint128 => if (comp.target.cpu.arch == .s390x and comp.target.os.tag == .linux and comp.target.isGnu()) 8 else 16,
.fp16, .float16 => 2,
Expand Down
4 changes: 2 additions & 2 deletions lib/compiler/aro/aro/target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ pub const FPSemantics = enum {
/// Only intended for generating float.h macros for the preprocessor
pub fn forType(ty: std.Target.CType, target: std.Target) FPSemantics {
std.debug.assert(ty == .float or ty == .double or ty == .longdouble);
return switch (target.c_type_bit_size(ty)) {
return switch (target.cTypeBitSize(ty)) {
32 => .IEEESingle,
64 => .IEEEDouble,
80 => .x87ExtendedDouble,
Expand Down Expand Up @@ -350,7 +350,7 @@ pub const FPSemantics = enum {
};

pub fn isLP64(target: std.Target) bool {
return target.c_type_bit_size(.int) == 32 and target.ptrBitWidth() == 64;
return target.cTypeBitSize(.int) == 32 and target.ptrBitWidth() == 64;
}

pub fn isKnownWindowsMSVCEnvironment(target: std.Target) bool {
Expand Down
20 changes: 10 additions & 10 deletions lib/std/Target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ pub const Cpu = struct {
}
};

pub fn feature_set_fns(comptime F: type) type {
pub fn FeatureSetFns(comptime F: type) type {
return struct {
/// Populates only the feature bits specified.
pub fn featureSet(features: []const F) Set {
Expand Down Expand Up @@ -2017,7 +2017,7 @@ pub const CType = enum {
longdouble,
};

pub fn c_type_byte_size(t: Target, c_type: CType) u16 {
pub fn cTypeByteSize(t: Target, c_type: CType) u16 {
return switch (c_type) {
.char,
.short,
Expand All @@ -2030,20 +2030,20 @@ pub fn c_type_byte_size(t: Target, c_type: CType) u16 {
.ulonglong,
.float,
.double,
=> @divExact(c_type_bit_size(t, c_type), 8),
=> @divExact(cTypeBitSize(t, c_type), 8),

.longdouble => switch (c_type_bit_size(t, c_type)) {
.longdouble => switch (cTypeBitSize(t, c_type)) {
16 => 2,
32 => 4,
64 => 8,
80 => @intCast(std.mem.alignForward(usize, 10, c_type_alignment(t, .longdouble))),
80 => @intCast(std.mem.alignForward(usize, 10, cTypeAlignment(t, .longdouble))),
128 => 16,
else => unreachable,
},
};
}

pub fn c_type_bit_size(target: Target, c_type: CType) u16 {
pub fn cTypeBitSize(target: Target, c_type: CType) u16 {
switch (target.os.tag) {
.freestanding, .other => switch (target.cpu.arch) {
.msp430 => switch (c_type) {
Expand Down Expand Up @@ -2340,7 +2340,7 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 {
}
}

pub fn c_type_alignment(target: Target, c_type: CType) u16 {
pub fn cTypeAlignment(target: Target, c_type: CType) u16 {
// Overrides for unusual alignments
switch (target.cpu.arch) {
.avr => return 1,
Expand All @@ -2360,7 +2360,7 @@ pub fn c_type_alignment(target: Target, c_type: CType) u16 {

// Next-power-of-two-aligned, up to a maximum.
return @min(
std.math.ceilPowerOfTwoAssert(u16, (c_type_bit_size(target, c_type) + 7) / 8),
std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
@as(u16, switch (target.cpu.arch) {
.arm, .armeb, .thumb, .thumbeb => switch (target.os.tag) {
.netbsd => switch (target.abi) {
Expand Down Expand Up @@ -2432,7 +2432,7 @@ pub fn c_type_alignment(target: Target, c_type: CType) u16 {
);
}

pub fn c_type_preferred_alignment(target: Target, c_type: CType) u16 {
pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 {
// Overrides for unusual alignments
switch (target.cpu.arch) {
.arm, .armeb, .thumb, .thumbeb => switch (target.os.tag) {
Expand Down Expand Up @@ -2485,7 +2485,7 @@ pub fn c_type_preferred_alignment(target: Target, c_type: CType) u16 {

// Next-power-of-two-aligned, up to a maximum.
return @min(
std.math.ceilPowerOfTwoAssert(u16, (c_type_bit_size(target, c_type) + 7) / 8),
std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
@as(u16, switch (target.cpu.arch) {
.msp430 => 2,

Expand Down
8 changes: 4 additions & 4 deletions lib/std/Target/aarch64.zig
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ pub const Feature = enum {
zcz_gp,
};

pub const featureSet = CpuFeature.feature_set_fns(Feature).featureSet;
pub const featureSetHas = CpuFeature.feature_set_fns(Feature).featureSetHas;
pub const featureSetHasAny = CpuFeature.feature_set_fns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.feature_set_fns(Feature).featureSetHasAll;
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: {
@setEvalBranchQuota(2000);
Expand Down
8 changes: 4 additions & 4 deletions lib/std/Target/amdgpu.zig
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ pub const Feature = enum {
xnack_support,
};

pub const featureSet = CpuFeature.feature_set_fns(Feature).featureSet;
pub const featureSetHas = CpuFeature.feature_set_fns(Feature).featureSetHas;
pub const featureSetHasAny = CpuFeature.feature_set_fns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.feature_set_fns(Feature).featureSetHasAll;
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;
Expand Down
8 changes: 4 additions & 4 deletions lib/std/Target/arc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ pub const Feature = enum {
norm,
};

pub const featureSet = CpuFeature.feature_set_fns(Feature).featureSet;
pub const featureSetHas = CpuFeature.feature_set_fns(Feature).featureSetHas;
pub const featureSetHasAny = CpuFeature.feature_set_fns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.feature_set_fns(Feature).featureSetHasAll;
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;
Expand Down
8 changes: 4 additions & 4 deletions lib/std/Target/arm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ pub const Feature = enum {
zcz,
};

pub const featureSet = CpuFeature.feature_set_fns(Feature).featureSet;
pub const featureSetHas = CpuFeature.feature_set_fns(Feature).featureSetHas;
pub const featureSetHasAny = CpuFeature.feature_set_fns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.feature_set_fns(Feature).featureSetHasAll;
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: {
@setEvalBranchQuota(10000);
Expand Down
8 changes: 4 additions & 4 deletions lib/std/Target/avr.zig
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ pub const Feature = enum {
xmegau,
};

pub const featureSet = CpuFeature.feature_set_fns(Feature).featureSet;
pub const featureSetHas = CpuFeature.feature_set_fns(Feature).featureSetHas;
pub const featureSetHasAny = CpuFeature.feature_set_fns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.feature_set_fns(Feature).featureSetHasAll;
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;
Expand Down
8 changes: 4 additions & 4 deletions lib/std/Target/bpf.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ pub const Feature = enum {
dwarfris,
};

pub const featureSet = CpuFeature.feature_set_fns(Feature).featureSet;
pub const featureSetHas = CpuFeature.feature_set_fns(Feature).featureSetHas;
pub const featureSetHasAny = CpuFeature.feature_set_fns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.feature_set_fns(Feature).featureSetHasAll;
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;
Expand Down
8 changes: 4 additions & 4 deletions lib/std/Target/csky.zig
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ pub const Feature = enum {
vdspv2,
};

pub const featureSet = CpuFeature.feature_set_fns(Feature).featureSet;
pub const featureSetHas = CpuFeature.feature_set_fns(Feature).featureSetHas;
pub const featureSetHasAny = CpuFeature.feature_set_fns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.feature_set_fns(Feature).featureSetHasAll;
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;
Expand Down
8 changes: 4 additions & 4 deletions lib/std/Target/hexagon.zig
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ pub const Feature = enum {
zreg,
};

pub const featureSet = CpuFeature.feature_set_fns(Feature).featureSet;
pub const featureSetHas = CpuFeature.feature_set_fns(Feature).featureSetHas;
pub const featureSetHasAny = CpuFeature.feature_set_fns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.feature_set_fns(Feature).featureSetHasAll;
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;
Expand Down
8 changes: 4 additions & 4 deletions lib/std/Target/loongarch.zig
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ pub const Feature = enum {
ual,
};

pub const featureSet = CpuFeature.feature_set_fns(Feature).featureSet;
pub const featureSetHas = CpuFeature.feature_set_fns(Feature).featureSetHas;
pub const featureSetHasAny = CpuFeature.feature_set_fns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.feature_set_fns(Feature).featureSetHasAll;
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;
Expand Down
8 changes: 4 additions & 4 deletions lib/std/Target/m68k.zig
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ pub const Feature = enum {
reserve_d7,
};

pub const featureSet = CpuFeature.feature_set_fns(Feature).featureSet;
pub const featureSetHas = CpuFeature.feature_set_fns(Feature).featureSetHas;
pub const featureSetHasAny = CpuFeature.feature_set_fns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.feature_set_fns(Feature).featureSetHasAll;
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;
Expand Down
8 changes: 4 additions & 4 deletions lib/std/Target/mips.zig
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ pub const Feature = enum {
xgot,
};

pub const featureSet = CpuFeature.feature_set_fns(Feature).featureSet;
pub const featureSetHas = CpuFeature.feature_set_fns(Feature).featureSetHas;
pub const featureSetHasAny = CpuFeature.feature_set_fns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.feature_set_fns(Feature).featureSetHasAll;
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;
Expand Down
8 changes: 4 additions & 4 deletions lib/std/Target/msp430.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ pub const Feature = enum {
hwmultf5,
};

pub const featureSet = CpuFeature.feature_set_fns(Feature).featureSet;
pub const featureSetHas = CpuFeature.feature_set_fns(Feature).featureSetHas;
pub const featureSetHasAny = CpuFeature.feature_set_fns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.feature_set_fns(Feature).featureSetHasAll;
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;
Expand Down
8 changes: 4 additions & 4 deletions lib/std/Target/nvptx.zig
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ pub const Feature = enum {
sm_90a,
};

pub const featureSet = CpuFeature.feature_set_fns(Feature).featureSet;
pub const featureSetHas = CpuFeature.feature_set_fns(Feature).featureSetHas;
pub const featureSetHasAny = CpuFeature.feature_set_fns(Feature).featureSetHasAny;
pub const featureSetHasAll = CpuFeature.feature_set_fns(Feature).featureSetHasAll;
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;
Expand Down
Loading

0 comments on commit 78fb9c0

Please sign in to comment.