diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2025-06-13 04:46:30 -0400 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2025-06-19 11:45:06 -0400 |
| commit | 917640810e7f3e18daff9e75b5ecefe761a1896c (patch) | |
| tree | 579e627d695f898d411a3cb1fbc0578d1a763cc2 /lib/std/Target.zig | |
| parent | 16d78bc0c024da307c7ab5f6b94622e6b4b37397 (diff) | |
| download | zig-917640810e7f3e18daff9e75b5ecefe761a1896c.tar.gz zig-917640810e7f3e18daff9e75b5ecefe761a1896c.zip | |
Target: pass and use locals by pointer instead of by value
This struct is larger than 256 bytes and code that copies it
consistently shows up in profiles of the compiler.
Diffstat (limited to 'lib/std/Target.zig')
| -rw-r--r-- | lib/std/Target.zig | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/lib/std/Target.zig b/lib/std/Target.zig index 347b3357f5..b31f6c2de9 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -1074,7 +1074,7 @@ pub const ObjectFormat = enum { } }; -pub fn toElfMachine(target: Target) std.elf.EM { +pub fn toElfMachine(target: *const Target) std.elf.EM { return switch (target.cpu.arch) { .amdgcn => .AMDGPU, .arc => .ARC_COMPACT, @@ -1115,7 +1115,7 @@ pub fn toElfMachine(target: Target) std.elf.EM { }; } -pub fn toCoffMachine(target: Target) std.coff.MachineType { +pub fn toCoffMachine(target: *const Target) std.coff.MachineType { return switch (target.cpu.arch) { .arm => .ARM, .thumb => .ARMNT, @@ -1999,7 +1999,7 @@ pub const Cpu = struct { } }; -pub fn zigTriple(target: Target, allocator: Allocator) Allocator.Error![]u8 { +pub fn zigTriple(target: *const Target, allocator: Allocator) Allocator.Error![]u8 { return Query.fromTarget(target).zigTriple(allocator); } @@ -2007,7 +2007,7 @@ pub fn hurdTupleSimple(allocator: Allocator, arch: Cpu.Arch, abi: Abi) ![]u8 { return std.fmt.allocPrint(allocator, "{s}-{s}", .{ @tagName(arch), @tagName(abi) }); } -pub fn hurdTuple(target: Target, allocator: Allocator) ![]u8 { +pub fn hurdTuple(target: *const Target, allocator: Allocator) ![]u8 { return hurdTupleSimple(allocator, target.cpu.arch, target.abi); } @@ -2015,63 +2015,63 @@ pub fn linuxTripleSimple(allocator: Allocator, arch: Cpu.Arch, os_tag: Os.Tag, a return std.fmt.allocPrint(allocator, "{s}-{s}-{s}", .{ @tagName(arch), @tagName(os_tag), @tagName(abi) }); } -pub fn linuxTriple(target: Target, allocator: Allocator) ![]u8 { +pub fn linuxTriple(target: *const Target, allocator: Allocator) ![]u8 { return linuxTripleSimple(allocator, target.cpu.arch, target.os.tag, target.abi); } -pub fn exeFileExt(target: Target) [:0]const u8 { +pub fn exeFileExt(target: *const Target) [:0]const u8 { return target.os.tag.exeFileExt(target.cpu.arch); } -pub fn staticLibSuffix(target: Target) [:0]const u8 { +pub fn staticLibSuffix(target: *const Target) [:0]const u8 { return target.os.tag.staticLibSuffix(target.abi); } -pub fn dynamicLibSuffix(target: Target) [:0]const u8 { +pub fn dynamicLibSuffix(target: *const Target) [:0]const u8 { return target.os.tag.dynamicLibSuffix(); } -pub fn libPrefix(target: Target) [:0]const u8 { +pub fn libPrefix(target: *const Target) [:0]const u8 { return target.os.tag.libPrefix(target.abi); } -pub inline fn isMinGW(target: Target) bool { +pub inline fn isMinGW(target: *const Target) bool { return target.os.tag == .windows and target.abi.isGnu(); } -pub inline fn isGnuLibC(target: Target) bool { +pub inline fn isGnuLibC(target: *const Target) bool { return switch (target.os.tag) { .hurd, .linux => target.abi.isGnu(), else => false, }; } -pub inline fn isMuslLibC(target: Target) bool { +pub inline fn isMuslLibC(target: *const Target) bool { return target.os.tag == .linux and target.abi.isMusl(); } -pub inline fn isDarwinLibC(target: Target) bool { +pub inline fn isDarwinLibC(target: *const Target) bool { return switch (target.abi) { .none, .macabi, .simulator => target.os.tag.isDarwin(), else => false, }; } -pub inline fn isFreeBSDLibC(target: Target) bool { +pub inline fn isFreeBSDLibC(target: *const Target) bool { return switch (target.abi) { .none, .eabihf => target.os.tag == .freebsd, else => false, }; } -pub inline fn isNetBSDLibC(target: Target) bool { +pub inline fn isNetBSDLibC(target: *const Target) bool { return switch (target.abi) { .none, .eabi, .eabihf => target.os.tag == .netbsd, else => false, }; } -pub inline fn isWasiLibC(target: Target) bool { +pub inline fn isWasiLibC(target: *const Target) bool { return target.os.tag == .wasi and target.abi.isMusl(); } @@ -2576,7 +2576,7 @@ pub const DynamicLinker = struct { } }; -pub fn standardDynamicLinkerPath(target: Target) DynamicLinker { +pub fn standardDynamicLinkerPath(target: *const Target) DynamicLinker { return DynamicLinker.standard(target.cpu, target.os, target.abi); } @@ -2645,11 +2645,11 @@ pub fn ptrBitWidth_arch_abi(cpu_arch: Cpu.Arch, abi: Abi) u16 { }; } -pub fn ptrBitWidth(target: Target) u16 { +pub fn ptrBitWidth(target: *const Target) u16 { return ptrBitWidth_cpu_abi(target.cpu, target.abi); } -pub fn stackAlignment(target: Target) u16 { +pub fn stackAlignment(target: *const Target) u16 { // Overrides for when the stack alignment is not equal to the pointer width. switch (target.cpu.arch) { .m68k, @@ -2697,7 +2697,7 @@ pub fn stackAlignment(target: Target) u16 { /// Default signedness of `char` for the native C compiler for this target /// Note that char signedness is implementation-defined and many compilers provide /// an option to override the default signedness e.g. GCC's -funsigned-char / -fsigned-char -pub fn cCharSignedness(target: Target) std.builtin.Signedness { +pub fn cCharSignedness(target: *const Target) std.builtin.Signedness { if (target.os.tag.isDarwin() or target.os.tag == .windows or target.os.tag == .uefi) return .signed; return switch (target.cpu.arch) { @@ -2740,7 +2740,7 @@ pub const CType = enum { longdouble, }; -pub fn cTypeByteSize(t: Target, c_type: CType) u16 { +pub fn cTypeByteSize(t: *const Target, c_type: CType) u16 { return switch (c_type) { .char, .short, @@ -2766,7 +2766,7 @@ pub fn cTypeByteSize(t: Target, c_type: CType) u16 { }; } -pub fn cTypeBitSize(target: Target, c_type: CType) u16 { +pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 { switch (target.os.tag) { .freestanding, .other => switch (target.cpu.arch) { .msp430 => switch (c_type) { @@ -3077,7 +3077,7 @@ pub fn cTypeBitSize(target: Target, c_type: CType) u16 { } } -pub fn cTypeAlignment(target: Target, c_type: CType) u16 { +pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 { // Overrides for unusual alignments switch (target.cpu.arch) { .avr => return 1, @@ -3172,7 +3172,7 @@ pub fn cTypeAlignment(target: Target, c_type: CType) u16 { ); } -pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 { +pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 { // Overrides for unusual alignments switch (target.cpu.arch) { .arc => switch (c_type) { @@ -3265,7 +3265,7 @@ pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 { ); } -pub fn cMaxIntAlignment(target: std.Target) u16 { +pub fn cMaxIntAlignment(target: *const Target) u16 { return switch (target.cpu.arch) { .avr => 1, @@ -3328,7 +3328,7 @@ pub fn cMaxIntAlignment(target: std.Target) u16 { }; } -pub fn cCallingConvention(target: Target) ?std.builtin.CallingConvention { +pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention { return switch (target.cpu.arch) { .x86_64 => switch (target.os.tag) { .windows, .uefi => .{ .x86_64_win = .{} }, |
