mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
zig fmt
This commit is contained in:
parent
a59c35cbf8
commit
aa52bb8327
@ -572,7 +572,7 @@ pub fn appendZigProcessFlags(
|
||||
try zig_args.append(switch (unwind_tables) {
|
||||
.none => "-fno-unwind-tables",
|
||||
.sync => "-funwind-tables",
|
||||
.@"async" => "-fasync-unwind-tables",
|
||||
.async => "-fasync-unwind-tables",
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -1691,7 +1691,7 @@ pub const Cpu = struct {
|
||||
pub fn fromCallingConvention(cc: std.builtin.CallingConvention.Tag) []const Arch {
|
||||
return switch (cc) {
|
||||
.auto,
|
||||
.@"async",
|
||||
.async,
|
||||
.naked,
|
||||
.@"inline",
|
||||
=> unreachable,
|
||||
|
||||
@ -246,7 +246,7 @@ pub const CallingConvention = union(enum(u8)) {
|
||||
/// The calling convention of a function that can be called with `async` syntax. An `async` call
|
||||
/// of a runtime-known function must target a function with this calling convention.
|
||||
/// Comptime-known functions with other calling conventions may be coerced to this one.
|
||||
@"async",
|
||||
async,
|
||||
|
||||
/// Functions with this calling convention have no prologue or epilogue, making the function
|
||||
/// uncallable in regular Zig code. This can be useful when integrating with assembly.
|
||||
@ -849,7 +849,7 @@ pub const LinkMode = enum {
|
||||
pub const UnwindTables = enum {
|
||||
none,
|
||||
sync,
|
||||
@"async",
|
||||
async,
|
||||
};
|
||||
|
||||
/// This data structure is used by the Zig language code generation and
|
||||
|
||||
@ -1521,9 +1521,9 @@ pub const Attribute = union(Kind) {
|
||||
pub const UwTable = enum(u32) {
|
||||
none,
|
||||
sync,
|
||||
@"async",
|
||||
async,
|
||||
|
||||
pub const default = UwTable.@"async";
|
||||
pub const default = UwTable.async;
|
||||
};
|
||||
|
||||
pub const VScaleRange = packed struct(u32) {
|
||||
|
||||
@ -6466,7 +6466,7 @@ pub fn addCCArgs(
|
||||
try argv.append("-fno-asynchronous-unwind-tables");
|
||||
try argv.append("-funwind-tables");
|
||||
},
|
||||
.@"async" => try argv.append("-fasynchronous-unwind-tables"),
|
||||
.async => try argv.append("-fasynchronous-unwind-tables"),
|
||||
}
|
||||
|
||||
try argv.append("-nostdinc");
|
||||
|
||||
@ -26687,7 +26687,7 @@ fn explainWhyTypeIsNotExtern(
|
||||
}
|
||||
switch (ty.fnCallingConvention(zcu)) {
|
||||
.auto => try sema.errNote(src_loc, msg, "extern function must specify calling convention", .{}),
|
||||
.@"async" => try sema.errNote(src_loc, msg, "async function cannot be extern", .{}),
|
||||
.async => try sema.errNote(src_loc, msg, "async function cannot be extern", .{}),
|
||||
.@"inline" => try sema.errNote(src_loc, msg, "inline function cannot be extern", .{}),
|
||||
else => return,
|
||||
}
|
||||
|
||||
@ -382,7 +382,7 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error
|
||||
}
|
||||
}
|
||||
switch (fn_info.cc) {
|
||||
.auto, .@"async", .naked, .@"inline" => try writer.print("callconv(.{}) ", .{std.zig.fmtId(@tagName(fn_info.cc))}),
|
||||
.auto, .async, .naked, .@"inline" => try writer.print("callconv(.{}) ", .{std.zig.fmtId(@tagName(fn_info.cc))}),
|
||||
else => try writer.print("callconv({any}) ", .{fn_info.cc}),
|
||||
}
|
||||
}
|
||||
|
||||
@ -4453,7 +4453,7 @@ pub fn callconvSupported(zcu: *Zcu, cc: std.builtin.CallingConvention) union(enu
|
||||
const backend = target_util.zigBackend(target, zcu.comp.config.use_llvm);
|
||||
switch (cc) {
|
||||
.auto, .@"inline" => return .ok,
|
||||
.@"async" => return .{ .bad_backend = backend }, // nothing supports async currently
|
||||
.async => return .{ .bad_backend = backend }, // nothing supports async currently
|
||||
.naked => {}, // depends only on backend
|
||||
else => for (cc.archs()) |allowed_arch| {
|
||||
if (allowed_arch == target.cpu.arch) break;
|
||||
|
||||
@ -2758,7 +2758,7 @@ pub const Object = struct {
|
||||
llvm_arg_i += 1;
|
||||
}
|
||||
|
||||
if (fn_info.cc == .@"async") {
|
||||
if (fn_info.cc == .async) {
|
||||
@panic("TODO: LLVM backend lower async function");
|
||||
}
|
||||
|
||||
@ -2910,7 +2910,7 @@ pub const Object = struct {
|
||||
try attributes.addFnAttr(.nounwind, &o.builder);
|
||||
if (owner_mod.unwind_tables != .none) {
|
||||
try attributes.addFnAttr(
|
||||
.{ .uwtable = if (owner_mod.unwind_tables == .@"async") .@"async" else .sync },
|
||||
.{ .uwtable = if (owner_mod.unwind_tables == .async) .async else .sync },
|
||||
&o.builder,
|
||||
);
|
||||
}
|
||||
@ -11871,7 +11871,7 @@ fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: *const s
|
||||
}
|
||||
return switch (cc_tag) {
|
||||
.@"inline" => unreachable,
|
||||
.auto, .@"async" => .fastcc,
|
||||
.auto, .async => .fastcc,
|
||||
.naked => .ccc,
|
||||
.x86_64_sysv => .x86_64_sysvcc,
|
||||
.x86_64_win => .win64cc,
|
||||
@ -12379,7 +12379,7 @@ const ParamTypeIterator = struct {
|
||||
return .byval;
|
||||
}
|
||||
},
|
||||
.@"async" => {
|
||||
.async => {
|
||||
@panic("TODO implement async function lowering in the LLVM backend");
|
||||
},
|
||||
.x86_64_sysv => return it.nextSystemV(ty),
|
||||
@ -12634,7 +12634,7 @@ fn ccAbiPromoteInt(
|
||||
) ?std.builtin.Signedness {
|
||||
const target = zcu.getTarget();
|
||||
switch (cc) {
|
||||
.auto, .@"inline", .@"async" => return null,
|
||||
.auto, .@"inline", .async => return null,
|
||||
else => {},
|
||||
}
|
||||
const int_info = switch (ty.zigTypeTag(zcu)) {
|
||||
|
||||
@ -325,7 +325,7 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
|
||||
// See the `-fno-exceptions` logic for WASI.
|
||||
// The old 32-bit x86 variant of SEH doesn't use tables.
|
||||
const unwind_tables: std.builtin.UnwindTables =
|
||||
if (target.os.tag == .wasi or (target.cpu.arch == .x86 and target.os.tag == .windows)) .none else .@"async";
|
||||
if (target.os.tag == .wasi or (target.cpu.arch == .x86 and target.os.tag == .windows)) .none else .async;
|
||||
|
||||
const config = Compilation.Config.resolve(.{
|
||||
.output_mode = output_mode,
|
||||
|
||||
@ -48,7 +48,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo
|
||||
const optimize_mode = comp.compilerRtOptMode();
|
||||
const strip = comp.compilerRtStrip();
|
||||
const unwind_tables: std.builtin.UnwindTables =
|
||||
if (target.cpu.arch == .x86 and target.os.tag == .windows) .none else .@"async";
|
||||
if (target.cpu.arch == .x86 and target.os.tag == .windows) .none else .async;
|
||||
const link_libcpp = target.os.tag.isDarwin();
|
||||
|
||||
const config = Compilation.Config.resolve(.{
|
||||
|
||||
@ -29,7 +29,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
|
||||
const output_mode = .Lib;
|
||||
const target = &comp.root_mod.resolved_target.result;
|
||||
const unwind_tables: std.builtin.UnwindTables =
|
||||
if (target.cpu.arch == .x86 and target.os.tag == .windows) .none else .@"async";
|
||||
if (target.cpu.arch == .x86 and target.os.tag == .windows) .none else .async;
|
||||
const config = Compilation.Config.resolve(.{
|
||||
.output_mode = output_mode,
|
||||
.resolved_target = comp.root_mod.resolved_target,
|
||||
|
||||
@ -29,7 +29,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
|
||||
const target = comp.getTarget();
|
||||
|
||||
// The old 32-bit x86 variant of SEH doesn't use tables.
|
||||
const unwind_tables: std.builtin.UnwindTables = if (target.cpu.arch != .x86) .@"async" else .none;
|
||||
const unwind_tables: std.builtin.UnwindTables = if (target.cpu.arch != .x86) .async else .none;
|
||||
|
||||
switch (crt_file) {
|
||||
.crt2_o => {
|
||||
|
||||
@ -3596,7 +3596,7 @@ fn updateLazyType(
|
||||
// For better or worse, we try to match what Clang emits.
|
||||
break :cc switch (func_type.cc) {
|
||||
.@"inline" => .nocall,
|
||||
.@"async", .auto, .naked => .normal,
|
||||
.async, .auto, .naked => .normal,
|
||||
.x86_64_sysv => .LLVM_X86_64SysV,
|
||||
.x86_64_win => .LLVM_Win64,
|
||||
.x86_64_regcall_v3_sysv => .LLVM_X86RegCall,
|
||||
|
||||
12
src/main.zig
12
src/main.zig
@ -1416,7 +1416,7 @@ fn buildOutputType(
|
||||
} else if (mem.eql(u8, arg, "-funwind-tables")) {
|
||||
mod_opts.unwind_tables = .sync;
|
||||
} else if (mem.eql(u8, arg, "-fasync-unwind-tables")) {
|
||||
mod_opts.unwind_tables = .@"async";
|
||||
mod_opts.unwind_tables = .async;
|
||||
} else if (mem.eql(u8, arg, "-fno-unwind-tables")) {
|
||||
mod_opts.unwind_tables = .none;
|
||||
} else if (mem.eql(u8, arg, "-fstack-check")) {
|
||||
@ -2035,15 +2035,15 @@ fn buildOutputType(
|
||||
.none => {
|
||||
mod_opts.unwind_tables = .sync;
|
||||
},
|
||||
.sync, .@"async" => {},
|
||||
.sync, .async => {},
|
||||
} else {
|
||||
mod_opts.unwind_tables = .sync;
|
||||
},
|
||||
.no_unwind_tables => mod_opts.unwind_tables = .none,
|
||||
.asynchronous_unwind_tables => mod_opts.unwind_tables = .@"async",
|
||||
.asynchronous_unwind_tables => mod_opts.unwind_tables = .async,
|
||||
.no_asynchronous_unwind_tables => if (mod_opts.unwind_tables) |uwt| switch (uwt) {
|
||||
.none, .sync => {},
|
||||
.@"async" => {
|
||||
.async => {
|
||||
mod_opts.unwind_tables = .sync;
|
||||
},
|
||||
} else {
|
||||
@ -2951,7 +2951,7 @@ fn buildOutputType(
|
||||
create_module.opts.any_fuzz = true;
|
||||
if (mod_opts.unwind_tables) |uwt| switch (uwt) {
|
||||
.none => {},
|
||||
.sync, .@"async" => create_module.opts.any_unwind_tables = true,
|
||||
.sync, .async => create_module.opts.any_unwind_tables = true,
|
||||
};
|
||||
if (mod_opts.strip == false)
|
||||
create_module.opts.any_non_stripped = true;
|
||||
@ -7413,7 +7413,7 @@ fn handleModArg(
|
||||
create_module.opts.any_fuzz = true;
|
||||
if (mod_opts.unwind_tables) |uwt| switch (uwt) {
|
||||
.none => {},
|
||||
.sync, .@"async" => create_module.opts.any_unwind_tables = true,
|
||||
.sync, .async => create_module.opts.any_unwind_tables = true,
|
||||
};
|
||||
if (mod_opts.strip == false)
|
||||
create_module.opts.any_non_stripped = true;
|
||||
|
||||
@ -483,12 +483,12 @@ pub fn clangSupportsNoImplicitFloatArg(target: *const std.Target) bool {
|
||||
pub fn defaultUnwindTables(target: *const std.Target, libunwind: bool, libtsan: bool) std.builtin.UnwindTables {
|
||||
if (target.os.tag == .windows) {
|
||||
// The old 32-bit x86 variant of SEH doesn't use tables.
|
||||
return if (target.cpu.arch != .x86) .@"async" else .none;
|
||||
return if (target.cpu.arch != .x86) .async else .none;
|
||||
}
|
||||
if (target.os.tag.isDarwin()) return .@"async";
|
||||
if (libunwind) return .@"async";
|
||||
if (libtsan) return .@"async";
|
||||
if (std.debug.Dwarf.abi.supportsUnwinding(target)) return .@"async";
|
||||
if (target.os.tag.isDarwin()) return .async;
|
||||
if (libunwind) return .async;
|
||||
if (libtsan) return .async;
|
||||
if (std.debug.Dwarf.abi.supportsUnwinding(target)) return .async;
|
||||
return .none;
|
||||
}
|
||||
|
||||
@ -815,7 +815,7 @@ pub fn compilerRtIntAbbrev(bits: u16) []const u8 {
|
||||
|
||||
pub fn fnCallConvAllowsZigTypes(cc: std.builtin.CallingConvention) bool {
|
||||
return switch (cc) {
|
||||
.auto, .@"async", .@"inline" => true,
|
||||
.auto, .async, .@"inline" => true,
|
||||
// For now we want to authorize PTX kernel to use zig objects, even if
|
||||
// we end up exposing the ABI. The goal is to experiment with more
|
||||
// integrated CPU/GPU code.
|
||||
|
||||
@ -29,7 +29,7 @@ pub fn build(b: *std.Build) void {
|
||||
.root_source_file = b.path("unwind.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.unwind_tables = if (target.result.os.tag.isDarwin()) .@"async" else null,
|
||||
.unwind_tables = if (target.result.os.tag.isDarwin()) .async else null,
|
||||
.omit_frame_pointer = false,
|
||||
}),
|
||||
});
|
||||
@ -54,7 +54,7 @@ pub fn build(b: *std.Build) void {
|
||||
.root_source_file = b.path("unwind.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.unwind_tables = .@"async",
|
||||
.unwind_tables = .async,
|
||||
.omit_frame_pointer = true,
|
||||
}),
|
||||
// self-hosted lacks omit_frame_pointer support
|
||||
@ -101,7 +101,7 @@ pub fn build(b: *std.Build) void {
|
||||
.root_source_file = b.path("shared_lib_unwind.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.unwind_tables = if (target.result.os.tag.isDarwin()) .@"async" else null,
|
||||
.unwind_tables = if (target.result.os.tag.isDarwin()) .async else null,
|
||||
.omit_frame_pointer = true,
|
||||
}),
|
||||
// zig objcopy doesn't support incremental binaries
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user