mirror of
https://github.com/ziglang/zig.git
synced 2026-10-14 10:27:43 -04:00
zig build fmt
This commit is contained in:
1 parent
c0c911bfa7
commit
eb3c7f5706
40 files changed
+1242
-1246
No files matched your search
Vendored
+1
-1
@@ -979,7 +979,7 @@ fn decl(p: *Parser) Error!bool {
|
|||||||
_ = try p.expectToken(.semicolon);
|
_ = try p.expectToken(.semicolon);
|
||||||
if (decl_spec.ty.is(.@"enum") or
|
if (decl_spec.ty.is(.@"enum") or
|
||||||
(decl_spec.ty.isRecord() and !decl_spec.ty.isAnonymousRecord(p.comp) and
|
(decl_spec.ty.isRecord() and !decl_spec.ty.isAnonymousRecord(p.comp) and
|
||||||
!decl_spec.ty.isTypeof())) // we follow GCC and clang's behavior here
|
!decl_spec.ty.isTypeof())) // we follow GCC and clang's behavior here
|
||||||
{
|
{
|
||||||
const specifier = decl_spec.ty.canonicalize(.standard).specifier;
|
const specifier = decl_spec.ty.canonicalize(.standard).specifier;
|
||||||
const attrs = p.attr_buf.items(.attr)[attr_buf_top..];
|
const attrs = p.attr_buf.items(.attr)[attr_buf_top..];
|
||||||
|
|||||||
Vendored
+3
-3
@@ -114,9 +114,9 @@ fn preprocessorHandler(pragma: *Pragma, pp: *Preprocessor, start_idx: TokenIndex
|
|||||||
|
|
||||||
const gcc_pragma = std.meta.stringToEnum(Directive, pp.expandedSlice(directive_tok)) orelse
|
const gcc_pragma = std.meta.stringToEnum(Directive, pp.expandedSlice(directive_tok)) orelse
|
||||||
return pp.comp.addDiagnostic(.{
|
return pp.comp.addDiagnostic(.{
|
||||||
.tag = .unknown_gcc_pragma,
|
.tag = .unknown_gcc_pragma,
|
||||||
.loc = directive_tok.loc,
|
.loc = directive_tok.loc,
|
||||||
}, pp.expansionSlice(start_idx + 1));
|
}, pp.expansionSlice(start_idx + 1));
|
||||||
|
|
||||||
switch (gcc_pragma) {
|
switch (gcc_pragma) {
|
||||||
.warning, .@"error" => {
|
.warning, .@"error" => {
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ pub fn parse(lang_tag: []const u8) error{InvalidLanguageTag}!Parsed {
|
|||||||
// Special case for qps-ploca and qps-plocm
|
// Special case for qps-ploca and qps-plocm
|
||||||
else if (std.ascii.eqlIgnoreCase(lang_code, "qps") and
|
else if (std.ascii.eqlIgnoreCase(lang_code, "qps") and
|
||||||
(std.ascii.eqlIgnoreCase(part_str, "ploca") or
|
(std.ascii.eqlIgnoreCase(part_str, "ploca") or
|
||||||
std.ascii.eqlIgnoreCase(part_str, "plocm")))
|
std.ascii.eqlIgnoreCase(part_str, "plocm")))
|
||||||
{
|
{
|
||||||
parsed.suffix = part_str;
|
parsed.suffix = part_str;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ pub const __clzsi2 = switch (builtin.cpu.arch) {
|
|||||||
.arm, .armeb, .thumb, .thumbeb => impl: {
|
.arm, .armeb, .thumb, .thumbeb => impl: {
|
||||||
const use_thumb1 =
|
const use_thumb1 =
|
||||||
(builtin.cpu.arch.isThumb() or
|
(builtin.cpu.arch.isThumb() or
|
||||||
std.Target.arm.featureSetHas(builtin.cpu.features, .noarm)) and
|
std.Target.arm.featureSetHas(builtin.cpu.features, .noarm)) and
|
||||||
!std.Target.arm.featureSetHas(builtin.cpu.features, .thumb2);
|
!std.Target.arm.featureSetHas(builtin.cpu.features, .thumb2);
|
||||||
|
|
||||||
if (use_thumb1) {
|
if (use_thumb1) {
|
||||||
|
|||||||
+26
-26
@@ -81,19 +81,19 @@ fn test_one_divmoddi4(a: i64, b: i64, expected_q: i64, expected_r: i64) !void {
|
|||||||
|
|
||||||
const cases__divmoddi4 =
|
const cases__divmoddi4 =
|
||||||
[_][4]i64{
|
[_][4]i64{
|
||||||
[_]i64{ 0, 1, 0, 0 },
|
[_]i64{ 0, 1, 0, 0 },
|
||||||
[_]i64{ 0, -1, 0, 0 },
|
[_]i64{ 0, -1, 0, 0 },
|
||||||
[_]i64{ 2, 1, 2, 0 },
|
[_]i64{ 2, 1, 2, 0 },
|
||||||
[_]i64{ 2, -1, -2, 0 },
|
[_]i64{ 2, -1, -2, 0 },
|
||||||
[_]i64{ -2, 1, -2, 0 },
|
[_]i64{ -2, 1, -2, 0 },
|
||||||
[_]i64{ -2, -1, 2, 0 },
|
[_]i64{ -2, -1, 2, 0 },
|
||||||
[_]i64{ 7, 5, 1, 2 },
|
[_]i64{ 7, 5, 1, 2 },
|
||||||
[_]i64{ -7, 5, -1, -2 },
|
[_]i64{ -7, 5, -1, -2 },
|
||||||
[_]i64{ 19, 5, 3, 4 },
|
[_]i64{ 19, 5, 3, 4 },
|
||||||
[_]i64{ 19, -5, -3, 4 },
|
[_]i64{ 19, -5, -3, 4 },
|
||||||
[_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000000))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000000))), 0 },
|
[_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000000))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000000))), 0 },
|
||||||
[_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000007))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000001))), -1 },
|
[_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000007))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000001))), -1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
test "test_divmoddi4" {
|
test "test_divmoddi4" {
|
||||||
for (cases__divmoddi4) |case| {
|
for (cases__divmoddi4) |case| {
|
||||||
@@ -215,19 +215,19 @@ pub fn __divmodsi4(a: i32, b: i32, rem: *i32) callconv(.C) i32 {
|
|||||||
|
|
||||||
const cases__divmodsi4 =
|
const cases__divmodsi4 =
|
||||||
[_][4]i32{
|
[_][4]i32{
|
||||||
[_]i32{ 0, 1, 0, 0 },
|
[_]i32{ 0, 1, 0, 0 },
|
||||||
[_]i32{ 0, -1, 0, 0 },
|
[_]i32{ 0, -1, 0, 0 },
|
||||||
[_]i32{ 2, 1, 2, 0 },
|
[_]i32{ 2, 1, 2, 0 },
|
||||||
[_]i32{ 2, -1, -2, 0 },
|
[_]i32{ 2, -1, -2, 0 },
|
||||||
[_]i32{ -2, 1, -2, 0 },
|
[_]i32{ -2, 1, -2, 0 },
|
||||||
[_]i32{ -2, -1, 2, 0 },
|
[_]i32{ -2, -1, 2, 0 },
|
||||||
[_]i32{ 7, 5, 1, 2 },
|
[_]i32{ 7, 5, 1, 2 },
|
||||||
[_]i32{ -7, 5, -1, -2 },
|
[_]i32{ -7, 5, -1, -2 },
|
||||||
[_]i32{ 19, 5, 3, 4 },
|
[_]i32{ 19, 5, 3, 4 },
|
||||||
[_]i32{ 19, -5, -3, 4 },
|
[_]i32{ 19, -5, -3, 4 },
|
||||||
[_]i32{ @bitCast(@as(u32, 0x80000000)), 8, @bitCast(@as(u32, 0xf0000000)), 0 },
|
[_]i32{ @bitCast(@as(u32, 0x80000000)), 8, @bitCast(@as(u32, 0xf0000000)), 0 },
|
||||||
[_]i32{ @bitCast(@as(u32, 0x80000007)), 8, @bitCast(@as(u32, 0xf0000001)), -1 },
|
[_]i32{ @bitCast(@as(u32, 0x80000007)), 8, @bitCast(@as(u32, 0xf0000001)), -1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
fn test_one_divmodsi4(a: i32, b: i32, expected_q: i32, expected_r: i32) !void {
|
fn test_one_divmodsi4(a: i32, b: i32, expected_q: i32, expected_r: i32) !void {
|
||||||
var r: i32 = undefined;
|
var r: i32 = undefined;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ inline fn popcountXi2(comptime ST: type, a: ST) i32 {
|
|||||||
var x: UT = @bitCast(a);
|
var x: UT = @bitCast(a);
|
||||||
x -= (x >> 1) & (~@as(UT, 0) / 3); // 0x55...55, aggregate duos
|
x -= (x >> 1) & (~@as(UT, 0) / 3); // 0x55...55, aggregate duos
|
||||||
x = ((x >> 2) & (~@as(UT, 0) / 5)) // 0x33...33, aggregate nibbles
|
x = ((x >> 2) & (~@as(UT, 0) / 5)) // 0x33...33, aggregate nibbles
|
||||||
+ (x & (~@as(UT, 0) / 5));
|
+ (x & (~@as(UT, 0) / 5));
|
||||||
x += x >> 4;
|
x += x >> 4;
|
||||||
x &= ~@as(UT, 0) / 17; // 0x0F...0F, aggregate bytes
|
x &= ~@as(UT, 0) / 17; // 0x0F...0F, aggregate bytes
|
||||||
// 8 most significant bits of x + (x<<8) + (x<<16) + ..
|
// 8 most significant bits of x + (x<<8) + (x<<16) + ..
|
||||||
|
|||||||
@@ -374,7 +374,7 @@ fn appendBlockStart(p: *Parser, block_start: BlockStart) !void {
|
|||||||
// or not of the same marker type.
|
// or not of the same marker type.
|
||||||
const should_close_list = last_pending_block.tag == .list and
|
const should_close_list = last_pending_block.tag == .list and
|
||||||
(block_start.tag != .list_item or
|
(block_start.tag != .list_item or
|
||||||
block_start.data.list_item.marker != last_pending_block.data.list.marker);
|
block_start.data.list_item.marker != last_pending_block.data.list.marker);
|
||||||
// The last block should also be closed if the new block is not a table
|
// The last block should also be closed if the new block is not a table
|
||||||
// row, which is the only allowed child of a table.
|
// row, which is the only allowed child of a table.
|
||||||
const should_close_table = last_pending_block.tag == .table and
|
const should_close_table = last_pending_block.tag == .table and
|
||||||
|
|||||||
+1
-1
@@ -299,7 +299,7 @@ pub const Os = struct {
|
|||||||
pub fn parse(str: []const u8) !WindowsVersion {
|
pub fn parse(str: []const u8) !WindowsVersion {
|
||||||
return std.meta.stringToEnum(WindowsVersion, str) orelse
|
return std.meta.stringToEnum(WindowsVersion, str) orelse
|
||||||
@enumFromInt(std.fmt.parseInt(u32, str, 0) catch
|
@enumFromInt(std.fmt.parseInt(u32, str, 0) catch
|
||||||
return error.InvalidOperatingSystemVersion);
|
return error.InvalidOperatingSystemVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This function is defined to serialize a Zig source code representation of this
|
/// This function is defined to serialize a Zig source code representation of this
|
||||||
|
|||||||
+4
-4
@@ -9879,10 +9879,10 @@ pub extern "c" fn setlocale(category: LC, locale: ?[*:0]const u8) ?[*:0]const u8
|
|||||||
|
|
||||||
pub const getcontext = if (builtin.target.abi.isAndroid() or builtin.target.os.tag == .openbsd)
|
pub const getcontext = if (builtin.target.abi.isAndroid() or builtin.target.os.tag == .openbsd)
|
||||||
{} // android bionic and openbsd libc does not implement getcontext
|
{} // android bionic and openbsd libc does not implement getcontext
|
||||||
else if (native_os == .linux and builtin.target.abi.isMusl())
|
else if (native_os == .linux and builtin.target.abi.isMusl())
|
||||||
linux.getcontext
|
linux.getcontext
|
||||||
else
|
else
|
||||||
private.getcontext;
|
private.getcontext;
|
||||||
|
|
||||||
pub const max_align_t = if (native_abi == .msvc or native_abi == .itanium)
|
pub const max_align_t = if (native_abi == .msvc or native_abi == .itanium)
|
||||||
f64
|
f64
|
||||||
|
|||||||
@@ -692,7 +692,7 @@ pub fn init(stream: anytype, options: Options) InitError(@TypeOf(stream))!Client
|
|||||||
const client_key_exchange_msg = .{@intFromEnum(tls.ContentType.handshake)} ++
|
const client_key_exchange_msg = .{@intFromEnum(tls.ContentType.handshake)} ++
|
||||||
int(u16, @intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
|
int(u16, @intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
|
||||||
array(u16, u8, .{@intFromEnum(tls.HandshakeType.client_key_exchange)} ++
|
array(u16, u8, .{@intFromEnum(tls.HandshakeType.client_key_exchange)} ++
|
||||||
array(u24, u8, array(u8, u8, key_share.secp256r1_kp.public_key.toUncompressedSec1())));
|
array(u24, u8, array(u8, u8, key_share.secp256r1_kp.public_key.toUncompressedSec1())));
|
||||||
const client_change_cipher_spec_msg = .{@intFromEnum(tls.ContentType.change_cipher_spec)} ++
|
const client_change_cipher_spec_msg = .{@intFromEnum(tls.ContentType.change_cipher_spec)} ++
|
||||||
int(u16, @intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
|
int(u16, @intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
|
||||||
array(u16, tls.ChangeCipherSpecType, .{.change_cipher_spec});
|
array(u16, tls.ChangeCipherSpecType, .{.change_cipher_spec});
|
||||||
@@ -720,11 +720,11 @@ pub fn init(stream: anytype, options: Options) InitError(@TypeOf(stream))!Client
|
|||||||
);
|
);
|
||||||
const client_verify_cleartext = .{@intFromEnum(tls.HandshakeType.finished)} ++
|
const client_verify_cleartext = .{@intFromEnum(tls.HandshakeType.finished)} ++
|
||||||
array(u24, u8, hmacExpandLabel(
|
array(u24, u8, hmacExpandLabel(
|
||||||
P.Hmac,
|
P.Hmac,
|
||||||
&master_secret,
|
&master_secret,
|
||||||
&.{ "client finished", &p.transcript_hash.peek() },
|
&.{ "client finished", &p.transcript_hash.peek() },
|
||||||
P.verify_data_length,
|
P.verify_data_length,
|
||||||
));
|
));
|
||||||
p.transcript_hash.update(&client_verify_cleartext);
|
p.transcript_hash.update(&client_verify_cleartext);
|
||||||
p.version = .{ .tls_1_2 = .{
|
p.version = .{ .tls_1_2 = .{
|
||||||
.expected_server_verify_data = hmacExpandLabel(
|
.expected_server_verify_data = hmacExpandLabel(
|
||||||
@@ -745,7 +745,7 @@ pub fn init(stream: anytype, options: Options) InitError(@TypeOf(stream))!Client
|
|||||||
var client_verify_msg = .{@intFromEnum(tls.ContentType.handshake)} ++
|
var client_verify_msg = .{@intFromEnum(tls.ContentType.handshake)} ++
|
||||||
int(u16, @intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
|
int(u16, @intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
|
||||||
array(u16, u8, nonce[P.fixed_iv_length..].* ++
|
array(u16, u8, nonce[P.fixed_iv_length..].* ++
|
||||||
@as([client_verify_cleartext.len + P.mac_length]u8, undefined));
|
@as([client_verify_cleartext.len + P.mac_length]u8, undefined));
|
||||||
P.AEAD.encrypt(
|
P.AEAD.encrypt(
|
||||||
client_verify_msg[client_verify_msg.len - P.mac_length -
|
client_verify_msg[client_verify_msg.len - P.mac_length -
|
||||||
client_verify_cleartext.len ..][0..client_verify_cleartext.len],
|
client_verify_cleartext.len ..][0..client_verify_cleartext.len],
|
||||||
|
|||||||
@@ -689,15 +689,15 @@ pub const Module = switch (native_os) {
|
|||||||
const o_file_path = mem.sliceTo(self.strings[symbol.ofile..], 0);
|
const o_file_path = mem.sliceTo(self.strings[symbol.ofile..], 0);
|
||||||
const o_file_info = self.ofiles.getPtr(o_file_path) orelse
|
const o_file_info = self.ofiles.getPtr(o_file_path) orelse
|
||||||
(self.loadOFile(allocator, o_file_path) catch |err| switch (err) {
|
(self.loadOFile(allocator, o_file_path) catch |err| switch (err) {
|
||||||
error.FileNotFound,
|
error.FileNotFound,
|
||||||
error.MissingDebugInfo,
|
error.MissingDebugInfo,
|
||||||
error.InvalidDebugInfo,
|
error.InvalidDebugInfo,
|
||||||
=> return .{
|
=> return .{
|
||||||
.relocated_address = relocated_address,
|
.relocated_address = relocated_address,
|
||||||
.symbol = symbol,
|
.symbol = symbol,
|
||||||
},
|
},
|
||||||
else => return err,
|
else => return err,
|
||||||
});
|
});
|
||||||
|
|
||||||
return .{
|
return .{
|
||||||
.relocated_address = relocated_address,
|
.relocated_address = relocated_address,
|
||||||
|
|||||||
+12
-12
@@ -960,13 +960,13 @@ pub const Request = struct {
|
|||||||
pub const WaitError = RequestError || SendError || TransferReadError ||
|
pub const WaitError = RequestError || SendError || TransferReadError ||
|
||||||
proto.HeadersParser.CheckCompleteHeadError || Response.ParseError ||
|
proto.HeadersParser.CheckCompleteHeadError || Response.ParseError ||
|
||||||
error{
|
error{
|
||||||
TooManyHttpRedirects,
|
TooManyHttpRedirects,
|
||||||
RedirectRequiresResend,
|
RedirectRequiresResend,
|
||||||
HttpRedirectLocationMissing,
|
HttpRedirectLocationMissing,
|
||||||
HttpRedirectLocationInvalid,
|
HttpRedirectLocationInvalid,
|
||||||
CompressionInitializationFailed,
|
CompressionInitializationFailed,
|
||||||
CompressionUnsupported,
|
CompressionUnsupported,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Waits for a response from the server and parses any headers that are sent.
|
/// Waits for a response from the server and parses any headers that are sent.
|
||||||
/// This function will block until the final response is received.
|
/// This function will block until the final response is received.
|
||||||
@@ -1540,12 +1540,12 @@ pub fn connect(
|
|||||||
pub const RequestError = ConnectTcpError || ConnectErrorPartial || Request.SendError ||
|
pub const RequestError = ConnectTcpError || ConnectErrorPartial || Request.SendError ||
|
||||||
std.fmt.ParseIntError || Connection.WriteError ||
|
std.fmt.ParseIntError || Connection.WriteError ||
|
||||||
error{
|
error{
|
||||||
UnsupportedUriScheme,
|
UnsupportedUriScheme,
|
||||||
UriMissingHost,
|
UriMissingHost,
|
||||||
|
|
||||||
CertificateBundleLoadFailure,
|
CertificateBundleLoadFailure,
|
||||||
UnsupportedTransferEncoding,
|
UnsupportedTransferEncoding,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const RequestOptions = struct {
|
pub const RequestOptions = struct {
|
||||||
version: http.Version = .@"HTTP/1.1",
|
version: http.Version = .@"HTTP/1.1",
|
||||||
|
|||||||
+6
-6
@@ -2851,12 +2851,12 @@ pub fn renameatW(
|
|||||||
|
|
||||||
rc =
|
rc =
|
||||||
windows.ntdll.NtSetInformationFile(
|
windows.ntdll.NtSetInformationFile(
|
||||||
src_fd,
|
src_fd,
|
||||||
&io_status_block,
|
&io_status_block,
|
||||||
rename_info,
|
rename_info,
|
||||||
@intCast(struct_len), // already checked for error.NameTooLong
|
@intCast(struct_len), // already checked for error.NameTooLong
|
||||||
.FileRenameInformation,
|
.FileRenameInformation,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (rc) {
|
switch (rc) {
|
||||||
|
|||||||
@@ -372,7 +372,7 @@ fn renderExpression(r: *Render, node: Ast.Node.Index, space: Space) Error!void {
|
|||||||
if (!ais.indentStackEmpty() and
|
if (!ais.indentStackEmpty() and
|
||||||
token_tags[i] != .colon and
|
token_tags[i] != .colon and
|
||||||
((token_tags[i] != .semicolon and token_tags[i] != .comma) or
|
((token_tags[i] != .semicolon and token_tags[i] != .comma) or
|
||||||
ais.lastSpaceModeIndent() < ais.currentIndent()))
|
ais.lastSpaceModeIndent() < ais.currentIndent()))
|
||||||
{
|
{
|
||||||
ais.popIndent();
|
ais.popIndent();
|
||||||
try ais.pushIndent(.normal);
|
try ais.pushIndent(.normal);
|
||||||
@@ -1185,9 +1185,9 @@ fn renderVarDeclWithoutFixups(
|
|||||||
{
|
{
|
||||||
const name_space = if (var_decl.ast.type_node == 0 and
|
const name_space = if (var_decl.ast.type_node == 0 and
|
||||||
(var_decl.ast.align_node != 0 or
|
(var_decl.ast.align_node != 0 or
|
||||||
var_decl.ast.addrspace_node != 0 or
|
var_decl.ast.addrspace_node != 0 or
|
||||||
var_decl.ast.section_node != 0 or
|
var_decl.ast.section_node != 0 or
|
||||||
var_decl.ast.init_node != 0))
|
var_decl.ast.init_node != 0))
|
||||||
Space.space
|
Space.space
|
||||||
else
|
else
|
||||||
Space.none;
|
Space.none;
|
||||||
|
|||||||
+11
-11
@@ -23443,7 +23443,7 @@ fn ptrCastFull(
|
|||||||
errdefer msg.destroy(sema.gpa);
|
errdefer msg.destroy(sema.gpa);
|
||||||
if (dest_info.flags.size == .many and
|
if (dest_info.flags.size == .many and
|
||||||
(src_info.flags.size == .slice or
|
(src_info.flags.size == .slice or
|
||||||
(src_info.flags.size == .one and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array)))
|
(src_info.flags.size == .one and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array)))
|
||||||
{
|
{
|
||||||
try sema.errNote(src, msg, "use 'ptr' field to convert slice to many pointer", .{});
|
try sema.errNote(src, msg, "use 'ptr' field to convert slice to many pointer", .{});
|
||||||
} else {
|
} else {
|
||||||
@@ -28136,9 +28136,9 @@ fn fieldCallBind(
|
|||||||
const first_param_type = Type.fromInterned(func_type.param_types.get(ip)[0]);
|
const first_param_type = Type.fromInterned(func_type.param_types.get(ip)[0]);
|
||||||
if (first_param_type.isGenericPoison() or
|
if (first_param_type.isGenericPoison() or
|
||||||
(first_param_type.zigTypeTag(zcu) == .pointer and
|
(first_param_type.zigTypeTag(zcu) == .pointer and
|
||||||
(first_param_type.ptrSize(zcu) == .one or
|
(first_param_type.ptrSize(zcu) == .one or
|
||||||
first_param_type.ptrSize(zcu) == .c) and
|
first_param_type.ptrSize(zcu) == .c) and
|
||||||
first_param_type.childType(zcu).eql(concrete_ty, zcu)))
|
first_param_type.childType(zcu).eql(concrete_ty, zcu)))
|
||||||
{
|
{
|
||||||
// Note that if the param type is generic poison, we know that it must
|
// Note that if the param type is generic poison, we know that it must
|
||||||
// specifically be `anytype` since it's the first parameter, meaning we
|
// specifically be `anytype` since it's the first parameter, meaning we
|
||||||
@@ -29652,7 +29652,7 @@ fn coerceExtra(
|
|||||||
|
|
||||||
if (dest_info.sentinel == .none or inst_info.sentinel == .none or
|
if (dest_info.sentinel == .none or inst_info.sentinel == .none or
|
||||||
Air.internedToRef(dest_info.sentinel) !=
|
Air.internedToRef(dest_info.sentinel) !=
|
||||||
try sema.coerceInMemory(Value.fromInterned(inst_info.sentinel), Type.fromInterned(dest_info.child)))
|
try sema.coerceInMemory(Value.fromInterned(inst_info.sentinel), Type.fromInterned(dest_info.child)))
|
||||||
break :p;
|
break :p;
|
||||||
|
|
||||||
const slice_ptr = try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty);
|
const slice_ptr = try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty);
|
||||||
@@ -30492,12 +30492,12 @@ pub fn coerceInMemoryAllowed(
|
|||||||
}
|
}
|
||||||
const ok_sent = (dest_info.sentinel == null and src_info.sentinel == null) or
|
const ok_sent = (dest_info.sentinel == null and src_info.sentinel == null) or
|
||||||
(src_info.sentinel != null and
|
(src_info.sentinel != null and
|
||||||
dest_info.sentinel != null and
|
dest_info.sentinel != null and
|
||||||
dest_info.sentinel.?.eql(
|
dest_info.sentinel.?.eql(
|
||||||
try pt.getCoerced(src_info.sentinel.?, dest_info.elem_type),
|
try pt.getCoerced(src_info.sentinel.?, dest_info.elem_type),
|
||||||
dest_info.elem_type,
|
dest_info.elem_type,
|
||||||
zcu,
|
zcu,
|
||||||
));
|
));
|
||||||
if (!ok_sent) {
|
if (!ok_sent) {
|
||||||
return .{ .array_sentinel = .{
|
return .{ .array_sentinel = .{
|
||||||
.actual = src_info.sentinel orelse Value.@"unreachable",
|
.actual = src_info.sentinel orelse Value.@"unreachable",
|
||||||
|
|||||||
+6
-5
@@ -610,11 +610,12 @@ pub fn hasRuntimeBitsInner(
|
|||||||
// in which case we want control flow to continue down below.
|
// in which case we want control flow to continue down below.
|
||||||
if (tag_ty != .none and
|
if (tag_ty != .none and
|
||||||
try Type.fromInterned(tag_ty).hasRuntimeBitsInner(
|
try Type.fromInterned(tag_ty).hasRuntimeBitsInner(
|
||||||
ignore_comptime_only,
|
ignore_comptime_only,
|
||||||
strat,
|
strat,
|
||||||
zcu,
|
zcu,
|
||||||
tid,
|
tid,
|
||||||
)) {
|
))
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
+4
-4
@@ -1496,8 +1496,8 @@ pub const SrcLoc = struct {
|
|||||||
const case = tree.fullSwitchCase(case_node).?;
|
const case = tree.fullSwitchCase(case_node).?;
|
||||||
const is_special = (case.ast.values.len == 0) or
|
const is_special = (case.ast.values.len == 0) or
|
||||||
(case.ast.values.len == 1 and
|
(case.ast.values.len == 1 and
|
||||||
node_tags[case.ast.values[0]] == .identifier and
|
node_tags[case.ast.values[0]] == .identifier and
|
||||||
mem.eql(u8, tree.tokenSlice(main_tokens[case.ast.values[0]]), "_"));
|
mem.eql(u8, tree.tokenSlice(main_tokens[case.ast.values[0]]), "_"));
|
||||||
if (!is_special) continue;
|
if (!is_special) continue;
|
||||||
|
|
||||||
return tree.nodeToSpan(case_node);
|
return tree.nodeToSpan(case_node);
|
||||||
@@ -1516,8 +1516,8 @@ pub const SrcLoc = struct {
|
|||||||
const case = tree.fullSwitchCase(case_node).?;
|
const case = tree.fullSwitchCase(case_node).?;
|
||||||
const is_special = (case.ast.values.len == 0) or
|
const is_special = (case.ast.values.len == 0) or
|
||||||
(case.ast.values.len == 1 and
|
(case.ast.values.len == 1 and
|
||||||
node_tags[case.ast.values[0]] == .identifier and
|
node_tags[case.ast.values[0]] == .identifier and
|
||||||
mem.eql(u8, tree.tokenSlice(main_tokens[case.ast.values[0]]), "_"));
|
mem.eql(u8, tree.tokenSlice(main_tokens[case.ast.values[0]]), "_"));
|
||||||
if (is_special) continue;
|
if (is_special) continue;
|
||||||
|
|
||||||
for (case.ast.values) |item_node| {
|
for (case.ast.values) |item_node| {
|
||||||
|
|||||||
@@ -685,8 +685,7 @@ fn restoreState(func: *Func, state: State, deaths: []const Air.Inst.Index, compt
|
|||||||
|
|
||||||
const ExpectedContents = [@typeInfo(RegisterManager.TrackedRegisters).array.len]RegisterLock;
|
const ExpectedContents = [@typeInfo(RegisterManager.TrackedRegisters).array.len]RegisterLock;
|
||||||
var stack align(@max(@alignOf(ExpectedContents), @alignOf(std.heap.StackFallbackAllocator(0)))) =
|
var stack align(@max(@alignOf(ExpectedContents), @alignOf(std.heap.StackFallbackAllocator(0)))) =
|
||||||
if (opts.update_tracking)
|
if (opts.update_tracking) {} else std.heap.stackFallback(@sizeOf(ExpectedContents), func.gpa);
|
||||||
{} else std.heap.stackFallback(@sizeOf(ExpectedContents), func.gpa);
|
|
||||||
|
|
||||||
var reg_locks = if (opts.update_tracking) {} else try std.ArrayList(RegisterLock).initCapacity(
|
var reg_locks = if (opts.update_tracking) {} else try std.ArrayList(RegisterLock).initCapacity(
|
||||||
stack.get(),
|
stack.get(),
|
||||||
@@ -2260,7 +2259,7 @@ fn airIntCast(func: *Func, inst: Air.Inst.Index) !void {
|
|||||||
|
|
||||||
const dst_mcv = if (dst_int_info.bits <= src_storage_bits and
|
const dst_mcv = if (dst_int_info.bits <= src_storage_bits and
|
||||||
math.divCeil(u16, dst_int_info.bits, 64) catch unreachable ==
|
math.divCeil(u16, dst_int_info.bits, 64) catch unreachable ==
|
||||||
math.divCeil(u32, src_storage_bits, 64) catch unreachable and
|
math.divCeil(u32, src_storage_bits, 64) catch unreachable and
|
||||||
func.reuseOperand(inst, ty_op.operand, 0, src_mcv)) src_mcv else dst: {
|
func.reuseOperand(inst, ty_op.operand, 0, src_mcv)) src_mcv else dst: {
|
||||||
const dst_mcv = try func.allocRegOrMem(dst_ty, inst, true);
|
const dst_mcv = try func.allocRegOrMem(dst_ty, inst, true);
|
||||||
try func.genCopy(min_ty, dst_mcv, src_mcv);
|
try func.genCopy(min_ty, dst_mcv, src_mcv);
|
||||||
@@ -2311,9 +2310,9 @@ fn airNot(func: *Func, inst: Air.Inst.Index) !void {
|
|||||||
|
|
||||||
const dst_reg: Register =
|
const dst_reg: Register =
|
||||||
if (func.reuseOperand(inst, ty_op.operand, 0, operand) and operand == .register)
|
if (func.reuseOperand(inst, ty_op.operand, 0, operand) and operand == .register)
|
||||||
operand.register
|
operand.register
|
||||||
else
|
else
|
||||||
(try func.allocRegOrMem(func.typeOfIndex(inst), inst, true)).register;
|
(try func.allocRegOrMem(func.typeOfIndex(inst), inst, true)).register;
|
||||||
|
|
||||||
switch (ty.zigTypeTag(zcu)) {
|
switch (ty.zigTypeTag(zcu)) {
|
||||||
.bool => {
|
.bool => {
|
||||||
@@ -6222,11 +6221,11 @@ fn airAsm(func: *Func, inst: Air.Inst.Index) !void {
|
|||||||
|
|
||||||
const instruction: union(enum) { mnem: Mnemonic, pseudo: Pseudo } =
|
const instruction: union(enum) { mnem: Mnemonic, pseudo: Pseudo } =
|
||||||
if (std.meta.stringToEnum(Mnemonic, mnem_str)) |mnem|
|
if (std.meta.stringToEnum(Mnemonic, mnem_str)) |mnem|
|
||||||
.{ .mnem = mnem }
|
.{ .mnem = mnem }
|
||||||
else if (std.meta.stringToEnum(Pseudo, mnem_str)) |pseudo|
|
else if (std.meta.stringToEnum(Pseudo, mnem_str)) |pseudo|
|
||||||
.{ .pseudo = pseudo }
|
.{ .pseudo = pseudo }
|
||||||
else
|
else
|
||||||
return func.fail("invalid mnem str '{s}'", .{mnem_str});
|
return func.fail("invalid mnem str '{s}'", .{mnem_str});
|
||||||
|
|
||||||
const Operand = union(enum) {
|
const Operand = union(enum) {
|
||||||
none,
|
none,
|
||||||
|
|||||||
+41
-42
@@ -82655,8 +82655,7 @@ fn restoreState(self: *CodeGen, state: State, deaths: []const Air.Inst.Index, co
|
|||||||
|
|
||||||
const ExpectedContents = [@typeInfo(RegisterManager.TrackedRegisters).array.len]RegisterLock;
|
const ExpectedContents = [@typeInfo(RegisterManager.TrackedRegisters).array.len]RegisterLock;
|
||||||
var stack align(@max(@alignOf(ExpectedContents), @alignOf(std.heap.StackFallbackAllocator(0)))) =
|
var stack align(@max(@alignOf(ExpectedContents), @alignOf(std.heap.StackFallbackAllocator(0)))) =
|
||||||
if (opts.update_tracking)
|
if (opts.update_tracking) {} else std.heap.stackFallback(@sizeOf(ExpectedContents), self.gpa);
|
||||||
{} else std.heap.stackFallback(@sizeOf(ExpectedContents), self.gpa);
|
|
||||||
|
|
||||||
var reg_locks = if (opts.update_tracking) {} else try std.ArrayList(RegisterLock).initCapacity(
|
var reg_locks = if (opts.update_tracking) {} else try std.ArrayList(RegisterLock).initCapacity(
|
||||||
stack.get(),
|
stack.get(),
|
||||||
@@ -83216,7 +83215,7 @@ fn airIntCast(self: *CodeGen, inst: Air.Inst.Index) !void {
|
|||||||
const dst_mcv = if ((if (src_mcv.getReg()) |src_reg| src_reg.class() == .general_purpose else src_abi_size > 8) and
|
const dst_mcv = if ((if (src_mcv.getReg()) |src_reg| src_reg.class() == .general_purpose else src_abi_size > 8) and
|
||||||
dst_int_info.bits <= src_storage_bits and
|
dst_int_info.bits <= src_storage_bits and
|
||||||
std.math.divCeil(u16, dst_int_info.bits, 64) catch unreachable ==
|
std.math.divCeil(u16, dst_int_info.bits, 64) catch unreachable ==
|
||||||
std.math.divCeil(u32, src_storage_bits, 64) catch unreachable and
|
std.math.divCeil(u32, src_storage_bits, 64) catch unreachable and
|
||||||
self.reuseOperand(inst, ty_op.operand, 0, src_mcv)) src_mcv else dst: {
|
self.reuseOperand(inst, ty_op.operand, 0, src_mcv)) src_mcv else dst: {
|
||||||
const dst_mcv = try self.allocRegOrMem(inst, true);
|
const dst_mcv = try self.allocRegOrMem(inst, true);
|
||||||
try self.genCopy(min_ty, dst_mcv, src_mcv, .{});
|
try self.genCopy(min_ty, dst_mcv, src_mcv, .{});
|
||||||
@@ -84695,10 +84694,10 @@ fn genIntMulDivOpMir(self: *CodeGen, tag: Mir.Inst.FixedTag, ty: Type, lhs: MCVa
|
|||||||
._ => {
|
._ => {
|
||||||
const hi_reg: Register =
|
const hi_reg: Register =
|
||||||
switch (bit_size) {
|
switch (bit_size) {
|
||||||
8 => .ah,
|
8 => .ah,
|
||||||
16, 32, 64 => .edx,
|
16, 32, 64 => .edx,
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
};
|
};
|
||||||
try self.asmRegisterRegister(.{ ._, .xor }, hi_reg, hi_reg);
|
try self.asmRegisterRegister(.{ ._, .xor }, hi_reg, hi_reg);
|
||||||
},
|
},
|
||||||
.i_ => try self.asmOpOnly(.{ ._, switch (bit_size) {
|
.i_ => try self.asmOpOnly(.{ ._, switch (bit_size) {
|
||||||
@@ -89019,9 +89018,9 @@ fn genShiftBinOpMir(
|
|||||||
.size = .fromSize(abi_size),
|
.size = .fromSize(abi_size),
|
||||||
.disp = std.math.cast(i32, @as(i64, @bitCast(addr))) orelse
|
.disp = std.math.cast(i32, @as(i64, @bitCast(addr))) orelse
|
||||||
return self.fail("TODO genShiftBinOpMir between {s} and {s}", .{
|
return self.fail("TODO genShiftBinOpMir between {s} and {s}", .{
|
||||||
@tagName(lhs_mcv),
|
@tagName(lhs_mcv),
|
||||||
@tagName(shift_mcv),
|
@tagName(shift_mcv),
|
||||||
}),
|
}),
|
||||||
} },
|
} },
|
||||||
},
|
},
|
||||||
.indirect => |reg_off| .{
|
.indirect => |reg_off| .{
|
||||||
@@ -89761,17 +89760,17 @@ fn genBinOp(
|
|||||||
|
|
||||||
const ordered_air: [2]Air.Inst.Ref = if (lhs_ty.isVector(zcu) and
|
const ordered_air: [2]Air.Inst.Ref = if (lhs_ty.isVector(zcu) and
|
||||||
switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {
|
switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {
|
||||||
.bool => false,
|
.bool => false,
|
||||||
.int => switch (air_tag) {
|
.int => switch (air_tag) {
|
||||||
.cmp_lt, .cmp_gte => true,
|
.cmp_lt, .cmp_gte => true,
|
||||||
else => false,
|
else => false,
|
||||||
},
|
},
|
||||||
.float => switch (air_tag) {
|
.float => switch (air_tag) {
|
||||||
.cmp_gte, .cmp_gt => true,
|
.cmp_gte, .cmp_gt => true,
|
||||||
else => false,
|
else => false,
|
||||||
},
|
},
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
}) .{ rhs_air, lhs_air } else .{ lhs_air, rhs_air };
|
}) .{ rhs_air, lhs_air } else .{ lhs_air, rhs_air };
|
||||||
|
|
||||||
if (lhs_ty.isAbiInt(zcu)) for (ordered_air) |op_air| {
|
if (lhs_ty.isAbiInt(zcu)) for (ordered_air) |op_air| {
|
||||||
switch (try self.resolveInst(op_air)) {
|
switch (try self.resolveInst(op_air)) {
|
||||||
@@ -91776,13 +91775,13 @@ fn genIntMulComplexOpMir(self: *CodeGen, dst_ty: Type, dst_mcv: MCValue, src_mcv
|
|||||||
.size = .fromSize(abi_size),
|
.size = .fromSize(abi_size),
|
||||||
.disp = std.math.cast(i32, @as(i64, @bitCast(addr))) orelse
|
.disp = std.math.cast(i32, @as(i64, @bitCast(addr))) orelse
|
||||||
return self.asmRegisterRegister(
|
return self.asmRegisterRegister(
|
||||||
.{ .i_, .mul },
|
.{ .i_, .mul },
|
||||||
dst_alias,
|
dst_alias,
|
||||||
registerAlias(
|
registerAlias(
|
||||||
try self.copyToTmpRegister(dst_ty, resolved_src_mcv),
|
try self.copyToTmpRegister(dst_ty, resolved_src_mcv),
|
||||||
abi_size,
|
abi_size,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
} },
|
} },
|
||||||
},
|
},
|
||||||
.indirect => |reg_off| .{
|
.indirect => |reg_off| .{
|
||||||
@@ -94101,9 +94100,9 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
|
|||||||
std.mem.eql(u8, rest, "r,m") or std.mem.eql(u8, rest, "m,r"))
|
std.mem.eql(u8, rest, "r,m") or std.mem.eql(u8, rest, "m,r"))
|
||||||
self.register_manager.tryAllocReg(maybe_inst, abi.RegisterClass.gp) orelse
|
self.register_manager.tryAllocReg(maybe_inst, abi.RegisterClass.gp) orelse
|
||||||
if (output != .none)
|
if (output != .none)
|
||||||
null
|
null
|
||||||
else
|
else
|
||||||
return self.fail("ran out of registers lowering inline asm", .{})
|
return self.fail("ran out of registers lowering inline asm", .{})
|
||||||
else if (std.mem.startsWith(u8, rest, "{") and std.mem.endsWith(u8, rest, "}"))
|
else if (std.mem.startsWith(u8, rest, "{") and std.mem.endsWith(u8, rest, "}"))
|
||||||
parseRegName(rest["{".len .. rest.len - "}".len]) orelse
|
parseRegName(rest["{".len .. rest.len - "}".len]) orelse
|
||||||
return self.fail("invalid register constraint: '{s}'", .{constraint})
|
return self.fail("invalid register constraint: '{s}'", .{constraint})
|
||||||
@@ -96965,9 +96964,9 @@ fn airAtomicLoad(self: *CodeGen, inst: Air.Inst.Index) !void {
|
|||||||
|
|
||||||
const dst_mcv =
|
const dst_mcv =
|
||||||
if (self.reuseOperand(inst, atomic_load.ptr, 0, ptr_mcv))
|
if (self.reuseOperand(inst, atomic_load.ptr, 0, ptr_mcv))
|
||||||
ptr_mcv
|
ptr_mcv
|
||||||
else
|
else
|
||||||
try self.allocRegOrMem(inst, true);
|
try self.allocRegOrMem(inst, true);
|
||||||
|
|
||||||
try self.load(dst_mcv, ptr_ty, ptr_mcv);
|
try self.load(dst_mcv, ptr_ty, ptr_mcv);
|
||||||
return self.finishAir(inst, dst_mcv, .{ atomic_load.ptr, .none, .none });
|
return self.finishAir(inst, dst_mcv, .{ atomic_load.ptr, .none, .none });
|
||||||
@@ -103712,9 +103711,9 @@ const Select = struct {
|
|||||||
if (cg.intInfo(ty.childType(zcu))) |int_info| int_info.signedness == .signed else false,
|
if (cg.intInfo(ty.childType(zcu))) |int_info| int_info.signedness == .signed else false,
|
||||||
.signed_int_or_full_vec => |size| ty.isVector(zcu) and @divExact(size.bitSize(cg.target), 8) >= ty.abiSize(zcu) and
|
.signed_int_or_full_vec => |size| ty.isVector(zcu) and @divExact(size.bitSize(cg.target), 8) >= ty.abiSize(zcu) and
|
||||||
if (cg.intInfo(ty.childType(zcu))) |int_info| switch (int_info.signedness) {
|
if (cg.intInfo(ty.childType(zcu))) |int_info| switch (int_info.signedness) {
|
||||||
.signed => true,
|
.signed => true,
|
||||||
.unsigned => int_info.bits >= 8 and std.math.isPowerOfTwo(int_info.bits),
|
.unsigned => int_info.bits >= 8 and std.math.isPowerOfTwo(int_info.bits),
|
||||||
} else false,
|
} else false,
|
||||||
.unsigned_int_vec => |size| ty.isVector(zcu) and @divExact(size.bitSize(cg.target), 8) >= ty.abiSize(zcu) and
|
.unsigned_int_vec => |size| ty.isVector(zcu) and @divExact(size.bitSize(cg.target), 8) >= ty.abiSize(zcu) and
|
||||||
if (cg.intInfo(ty.childType(zcu))) |int_info| int_info.signedness == .unsigned else false,
|
if (cg.intInfo(ty.childType(zcu))) |int_info| int_info.signedness == .unsigned else false,
|
||||||
.size => |size| @divExact(size.bitSize(cg.target), 8) >= ty.abiSize(zcu),
|
.size => |size| @divExact(size.bitSize(cg.target), 8) >= ty.abiSize(zcu),
|
||||||
@@ -103736,26 +103735,26 @@ const Select = struct {
|
|||||||
if (cg.intInfo(ty.scalarType(zcu))) |int_info| of_is.is.bitSize(cg.target) >= int_info.bits else false,
|
if (cg.intInfo(ty.scalarType(zcu))) |int_info| of_is.is.bitSize(cg.target) >= int_info.bits else false,
|
||||||
.scalar_signed_int => |of_is| @divExact(of_is.of.bitSize(cg.target), 8) >= cg.unalignedSize(ty) and
|
.scalar_signed_int => |of_is| @divExact(of_is.of.bitSize(cg.target), 8) >= cg.unalignedSize(ty) and
|
||||||
if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .signed and
|
if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .signed and
|
||||||
of_is.is.bitSize(cg.target) >= int_info.bits else false,
|
of_is.is.bitSize(cg.target) >= int_info.bits else false,
|
||||||
.scalar_unsigned_int => |of_is| @divExact(of_is.of.bitSize(cg.target), 8) >= cg.unalignedSize(ty) and
|
.scalar_unsigned_int => |of_is| @divExact(of_is.of.bitSize(cg.target), 8) >= cg.unalignedSize(ty) and
|
||||||
if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .unsigned and
|
if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .unsigned and
|
||||||
of_is.is.bitSize(cg.target) >= int_info.bits else false,
|
of_is.is.bitSize(cg.target) >= int_info.bits else false,
|
||||||
.multiple_scalar_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
|
.multiple_scalar_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
|
||||||
if (cg.intInfo(ty.scalarType(zcu))) |int_info| of_is.is.bitSize(cg.target) >= int_info.bits else false,
|
if (cg.intInfo(ty.scalarType(zcu))) |int_info| of_is.is.bitSize(cg.target) >= int_info.bits else false,
|
||||||
.multiple_scalar_signed_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
|
.multiple_scalar_signed_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
|
||||||
if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .signed and
|
if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .signed and
|
||||||
of_is.is.bitSize(cg.target) >= int_info.bits else false,
|
of_is.is.bitSize(cg.target) >= int_info.bits else false,
|
||||||
.multiple_scalar_unsigned_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
|
.multiple_scalar_unsigned_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
|
||||||
if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .unsigned and
|
if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .unsigned and
|
||||||
of_is.is.bitSize(cg.target) >= int_info.bits else false,
|
of_is.is.bitSize(cg.target) >= int_info.bits else false,
|
||||||
.multiple_scalar_exact_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
|
.multiple_scalar_exact_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
|
||||||
if (cg.intInfo(ty.scalarType(zcu))) |int_info| of_is.is == int_info.bits else false,
|
if (cg.intInfo(ty.scalarType(zcu))) |int_info| of_is.is == int_info.bits else false,
|
||||||
.multiple_scalar_exact_signed_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
|
.multiple_scalar_exact_signed_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
|
||||||
if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .signed and
|
if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .signed and
|
||||||
of_is.is == int_info.bits else false,
|
of_is.is == int_info.bits else false,
|
||||||
.multiple_scalar_exact_unsigned_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
|
.multiple_scalar_exact_unsigned_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
|
||||||
if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .unsigned and
|
if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .unsigned and
|
||||||
of_is.is == int_info.bits else false,
|
of_is.is == int_info.bits else false,
|
||||||
.scalar_remainder_int => |of_is| if (cg.intInfo(ty.scalarType(zcu))) |int_info|
|
.scalar_remainder_int => |of_is| if (cg.intInfo(ty.scalarType(zcu))) |int_info|
|
||||||
of_is.is.bitSize(cg.target) >= (int_info.bits - 1) % of_is.of.bitSize(cg.target) + 1
|
of_is.is.bitSize(cg.target) >= (int_info.bits - 1) % of_is.of.bitSize(cg.target) + 1
|
||||||
else
|
else
|
||||||
|
|||||||
+1
-1
@@ -423,7 +423,7 @@ pub fn generateSymbol(
|
|||||||
|
|
||||||
const padding = abi_size -
|
const padding = abi_size -
|
||||||
(math.cast(usize, Type.fromInterned(vector_type.child).abiSize(zcu) * vector_type.len) orelse
|
(math.cast(usize, Type.fromInterned(vector_type.child).abiSize(zcu) * vector_type.len) orelse
|
||||||
return error.Overflow);
|
return error.Overflow);
|
||||||
if (padding > 0) try code.appendNTimes(gpa, 0, padding);
|
if (padding > 0) try code.appendNTimes(gpa, 0, padding);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
+3
-3
@@ -1990,7 +1990,7 @@ pub const DeclGen = struct {
|
|||||||
if (dest_bits <= 64 and src_bits <= 64) {
|
if (dest_bits <= 64 and src_bits <= 64) {
|
||||||
const needs_cast = src_int_info == null or
|
const needs_cast = src_int_info == null or
|
||||||
(toCIntBits(dest_int_info.bits) != toCIntBits(src_int_info.?.bits) or
|
(toCIntBits(dest_int_info.bits) != toCIntBits(src_int_info.?.bits) or
|
||||||
dest_int_info.signedness != src_int_info.?.signedness);
|
dest_int_info.signedness != src_int_info.?.signedness);
|
||||||
return !needs_cast and !src_is_ptr;
|
return !needs_cast and !src_is_ptr;
|
||||||
} else return false;
|
} else return false;
|
||||||
}
|
}
|
||||||
@@ -2031,7 +2031,7 @@ pub const DeclGen = struct {
|
|||||||
if (dest_bits <= 64 and src_bits <= 64) {
|
if (dest_bits <= 64 and src_bits <= 64) {
|
||||||
const needs_cast = src_int_info == null or
|
const needs_cast = src_int_info == null or
|
||||||
(toCIntBits(dest_int_info.bits) != toCIntBits(src_int_info.?.bits) or
|
(toCIntBits(dest_int_info.bits) != toCIntBits(src_int_info.?.bits) or
|
||||||
dest_int_info.signedness != src_int_info.?.signedness);
|
dest_int_info.signedness != src_int_info.?.signedness);
|
||||||
|
|
||||||
if (needs_cast) {
|
if (needs_cast) {
|
||||||
try w.writeByte('(');
|
try w.writeByte('(');
|
||||||
@@ -4348,7 +4348,7 @@ fn airEquality(
|
|||||||
.aligned, .array, .vector, .fwd_decl, .function => unreachable,
|
.aligned, .array, .vector, .fwd_decl, .function => unreachable,
|
||||||
.aggregate => |aggregate| if (aggregate.fields.len == 2 and
|
.aggregate => |aggregate| if (aggregate.fields.len == 2 and
|
||||||
(aggregate.fields.at(0, ctype_pool).name.index == .is_null or
|
(aggregate.fields.at(0, ctype_pool).name.index == .is_null or
|
||||||
aggregate.fields.at(1, ctype_pool).name.index == .is_null))
|
aggregate.fields.at(1, ctype_pool).name.index == .is_null))
|
||||||
{
|
{
|
||||||
try f.writeCValueMember(writer, lhs, .{ .identifier = "is_null" });
|
try f.writeCValueMember(writer, lhs, .{ .identifier = "is_null" });
|
||||||
try writer.writeAll(" || ");
|
try writer.writeAll(" || ");
|
||||||
|
|||||||
+34
-35
@@ -758,12 +758,12 @@ pub const Info = union(enum) {
|
|||||||
fn tag(pointer_info: Pointer) Pool.Tag {
|
fn tag(pointer_info: Pointer) Pool.Tag {
|
||||||
return @enumFromInt(@intFromEnum(Pool.Tag.pointer) +
|
return @enumFromInt(@intFromEnum(Pool.Tag.pointer) +
|
||||||
@as(u2, @bitCast(packed struct(u2) {
|
@as(u2, @bitCast(packed struct(u2) {
|
||||||
@"const": bool,
|
@"const": bool,
|
||||||
@"volatile": bool,
|
@"volatile": bool,
|
||||||
}{
|
}{
|
||||||
.@"const" = pointer_info.@"const",
|
.@"const" = pointer_info.@"const",
|
||||||
.@"volatile" = pointer_info.@"volatile",
|
.@"volatile" = pointer_info.@"volatile",
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -887,24 +887,24 @@ pub const Info = union(enum) {
|
|||||||
pool_adapter.eql(lhs_vector_info.elem_ctype, rhs_info.vector.elem_ctype),
|
pool_adapter.eql(lhs_vector_info.elem_ctype, rhs_info.vector.elem_ctype),
|
||||||
.fwd_decl => |lhs_fwd_decl_info| lhs_fwd_decl_info.tag == rhs_info.fwd_decl.tag and
|
.fwd_decl => |lhs_fwd_decl_info| lhs_fwd_decl_info.tag == rhs_info.fwd_decl.tag and
|
||||||
switch (lhs_fwd_decl_info.name) {
|
switch (lhs_fwd_decl_info.name) {
|
||||||
.anon => |lhs_anon| rhs_info.fwd_decl.name == .anon and lhs_anon.eqlAdapted(
|
.anon => |lhs_anon| rhs_info.fwd_decl.name == .anon and lhs_anon.eqlAdapted(
|
||||||
lhs_pool,
|
lhs_pool,
|
||||||
rhs_info.fwd_decl.name.anon,
|
rhs_info.fwd_decl.name.anon,
|
||||||
rhs_pool,
|
rhs_pool,
|
||||||
pool_adapter,
|
pool_adapter,
|
||||||
),
|
),
|
||||||
.index => |lhs_index| rhs_info.fwd_decl.name == .index and
|
.index => |lhs_index| rhs_info.fwd_decl.name == .index and
|
||||||
lhs_index == rhs_info.fwd_decl.name.index,
|
lhs_index == rhs_info.fwd_decl.name.index,
|
||||||
},
|
},
|
||||||
.aggregate => |lhs_aggregate_info| lhs_aggregate_info.tag == rhs_info.aggregate.tag and
|
.aggregate => |lhs_aggregate_info| lhs_aggregate_info.tag == rhs_info.aggregate.tag and
|
||||||
lhs_aggregate_info.@"packed" == rhs_info.aggregate.@"packed" and
|
lhs_aggregate_info.@"packed" == rhs_info.aggregate.@"packed" and
|
||||||
switch (lhs_aggregate_info.name) {
|
switch (lhs_aggregate_info.name) {
|
||||||
.anon => |lhs_anon| rhs_info.aggregate.name == .anon and
|
.anon => |lhs_anon| rhs_info.aggregate.name == .anon and
|
||||||
lhs_anon.index == rhs_info.aggregate.name.anon.index and
|
lhs_anon.index == rhs_info.aggregate.name.anon.index and
|
||||||
lhs_anon.id == rhs_info.aggregate.name.anon.id,
|
lhs_anon.id == rhs_info.aggregate.name.anon.id,
|
||||||
.fwd_decl => |lhs_fwd_decl| rhs_info.aggregate.name == .fwd_decl and
|
.fwd_decl => |lhs_fwd_decl| rhs_info.aggregate.name == .fwd_decl and
|
||||||
pool_adapter.eql(lhs_fwd_decl, rhs_info.aggregate.name.fwd_decl),
|
pool_adapter.eql(lhs_fwd_decl, rhs_info.aggregate.name.fwd_decl),
|
||||||
} and lhs_aggregate_info.fields.eqlAdapted(
|
} and lhs_aggregate_info.fields.eqlAdapted(
|
||||||
lhs_pool,
|
lhs_pool,
|
||||||
rhs_info.aggregate.fields,
|
rhs_info.aggregate.fields,
|
||||||
rhs_pool,
|
rhs_pool,
|
||||||
@@ -913,13 +913,12 @@ pub const Info = union(enum) {
|
|||||||
.function => |lhs_function_info| lhs_function_info.param_ctypes.len ==
|
.function => |lhs_function_info| lhs_function_info.param_ctypes.len ==
|
||||||
rhs_info.function.param_ctypes.len and
|
rhs_info.function.param_ctypes.len and
|
||||||
pool_adapter.eql(lhs_function_info.return_ctype, rhs_info.function.return_ctype) and
|
pool_adapter.eql(lhs_function_info.return_ctype, rhs_info.function.return_ctype) and
|
||||||
for (0..lhs_function_info.param_ctypes.len) |param_index|
|
for (0..lhs_function_info.param_ctypes.len) |param_index| {
|
||||||
{
|
if (!pool_adapter.eql(
|
||||||
if (!pool_adapter.eql(
|
lhs_function_info.param_ctypes.at(param_index, lhs_pool),
|
||||||
lhs_function_info.param_ctypes.at(param_index, lhs_pool),
|
rhs_info.function.param_ctypes.at(param_index, rhs_pool),
|
||||||
rhs_info.function.param_ctypes.at(param_index, rhs_pool),
|
)) break false;
|
||||||
)) break false;
|
} else true,
|
||||||
} else true,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -2301,13 +2300,13 @@ pub const Pool = struct {
|
|||||||
const return_type = Type.fromInterned(func_info.return_type);
|
const return_type = Type.fromInterned(func_info.return_type);
|
||||||
const return_ctype: CType =
|
const return_ctype: CType =
|
||||||
if (!ip.isNoReturn(func_info.return_type)) try pool.fromType(
|
if (!ip.isNoReturn(func_info.return_type)) try pool.fromType(
|
||||||
allocator,
|
allocator,
|
||||||
scratch,
|
scratch,
|
||||||
return_type,
|
return_type,
|
||||||
pt,
|
pt,
|
||||||
mod,
|
mod,
|
||||||
kind.asParameter(),
|
kind.asParameter(),
|
||||||
) else .void;
|
) else .void;
|
||||||
for (0..func_info.param_types.len) |param_index| {
|
for (0..func_info.param_types.len) |param_index| {
|
||||||
const param_type = Type.fromInterned(
|
const param_type = Type.fromInterned(
|
||||||
func_info.param_types.get(ip)[param_index],
|
func_info.param_types.get(ip)[param_index],
|
||||||
|
|||||||
+54
-55
@@ -388,7 +388,7 @@ const DataLayoutBuilder = struct {
|
|||||||
self.target.cpu.arch != .riscv64 and
|
self.target.cpu.arch != .riscv64 and
|
||||||
self.target.cpu.arch != .loongarch64 and
|
self.target.cpu.arch != .loongarch64 and
|
||||||
!(self.target.cpu.arch == .aarch64 and
|
!(self.target.cpu.arch == .aarch64 and
|
||||||
(self.target.os.tag == .uefi or self.target.os.tag == .windows)) and
|
(self.target.os.tag == .uefi or self.target.os.tag == .windows)) and
|
||||||
self.target.cpu.arch != .bpfeb and self.target.cpu.arch != .bpfel) continue;
|
self.target.cpu.arch != .bpfeb and self.target.cpu.arch != .bpfel) continue;
|
||||||
try writer.writeAll("-p");
|
try writer.writeAll("-p");
|
||||||
if (info.llvm != .default) try writer.print("{d}", .{@intFromEnum(info.llvm)});
|
if (info.llvm != .default) try writer.print("{d}", .{@intFromEnum(info.llvm)});
|
||||||
@@ -859,55 +859,54 @@ pub const Object = struct {
|
|||||||
builder.data_layout = try builder.fmt("{}", .{DataLayoutBuilder{ .target = target }});
|
builder.data_layout = try builder.fmt("{}", .{DataLayoutBuilder{ .target = target }});
|
||||||
|
|
||||||
const debug_compile_unit, const debug_enums_fwd_ref, const debug_globals_fwd_ref =
|
const debug_compile_unit, const debug_enums_fwd_ref, const debug_globals_fwd_ref =
|
||||||
if (!builder.strip)
|
if (!builder.strip) debug_info: {
|
||||||
debug_info: {
|
// We fully resolve all paths at this point to avoid lack of
|
||||||
// We fully resolve all paths at this point to avoid lack of
|
// source line info in stack traces or lack of debugging
|
||||||
// source line info in stack traces or lack of debugging
|
// information which, if relative paths were used, would be
|
||||||
// information which, if relative paths were used, would be
|
// very location dependent.
|
||||||
// very location dependent.
|
// TODO: the only concern I have with this is WASI as either host or target, should
|
||||||
// TODO: the only concern I have with this is WASI as either host or target, should
|
// we leave the paths as relative then?
|
||||||
// we leave the paths as relative then?
|
// TODO: This is totally wrong. In dwarf, paths are encoded as relative to
|
||||||
// TODO: This is totally wrong. In dwarf, paths are encoded as relative to
|
// a particular directory, and then the directory path is specified elsewhere.
|
||||||
// a particular directory, and then the directory path is specified elsewhere.
|
// In the compiler frontend we have it stored correctly in this
|
||||||
// In the compiler frontend we have it stored correctly in this
|
// way already, but here we throw all that sweet information
|
||||||
// way already, but here we throw all that sweet information
|
// into the garbage can by converting into absolute paths. What
|
||||||
// into the garbage can by converting into absolute paths. What
|
// a terrible tragedy.
|
||||||
// a terrible tragedy.
|
const compile_unit_dir = blk: {
|
||||||
const compile_unit_dir = blk: {
|
if (comp.zcu) |zcu| m: {
|
||||||
if (comp.zcu) |zcu| m: {
|
const d = try zcu.main_mod.root.joinString(arena, "");
|
||||||
const d = try zcu.main_mod.root.joinString(arena, "");
|
if (d.len == 0) break :m;
|
||||||
if (d.len == 0) break :m;
|
if (std.fs.path.isAbsolute(d)) break :blk d;
|
||||||
if (std.fs.path.isAbsolute(d)) break :blk d;
|
break :blk std.fs.realpathAlloc(arena, d) catch break :blk d;
|
||||||
break :blk std.fs.realpathAlloc(arena, d) catch break :blk d;
|
}
|
||||||
}
|
break :blk try std.process.getCwdAlloc(arena);
|
||||||
break :blk try std.process.getCwdAlloc(arena);
|
};
|
||||||
};
|
|
||||||
|
|
||||||
const debug_file = try builder.debugFile(
|
const debug_file = try builder.debugFile(
|
||||||
try builder.metadataString(comp.root_name),
|
try builder.metadataString(comp.root_name),
|
||||||
try builder.metadataString(compile_unit_dir),
|
try builder.metadataString(compile_unit_dir),
|
||||||
);
|
);
|
||||||
|
|
||||||
const debug_enums_fwd_ref = try builder.debugForwardReference();
|
const debug_enums_fwd_ref = try builder.debugForwardReference();
|
||||||
const debug_globals_fwd_ref = try builder.debugForwardReference();
|
const debug_globals_fwd_ref = try builder.debugForwardReference();
|
||||||
|
|
||||||
const debug_compile_unit = try builder.debugCompileUnit(
|
const debug_compile_unit = try builder.debugCompileUnit(
|
||||||
debug_file,
|
debug_file,
|
||||||
// Don't use the version string here; LLVM misparses it when it
|
// Don't use the version string here; LLVM misparses it when it
|
||||||
// includes the git revision.
|
// includes the git revision.
|
||||||
try builder.metadataStringFmt("zig {d}.{d}.{d}", .{
|
try builder.metadataStringFmt("zig {d}.{d}.{d}", .{
|
||||||
build_options.semver.major,
|
build_options.semver.major,
|
||||||
build_options.semver.minor,
|
build_options.semver.minor,
|
||||||
build_options.semver.patch,
|
build_options.semver.patch,
|
||||||
}),
|
}),
|
||||||
debug_enums_fwd_ref,
|
debug_enums_fwd_ref,
|
||||||
debug_globals_fwd_ref,
|
debug_globals_fwd_ref,
|
||||||
.{ .optimized = comp.root_mod.optimize_mode != .Debug },
|
.{ .optimized = comp.root_mod.optimize_mode != .Debug },
|
||||||
);
|
);
|
||||||
|
|
||||||
try builder.metadataNamed(try builder.metadataString("llvm.dbg.cu"), &.{debug_compile_unit});
|
try builder.metadataNamed(try builder.metadataString("llvm.dbg.cu"), &.{debug_compile_unit});
|
||||||
break :debug_info .{ debug_compile_unit, debug_enums_fwd_ref, debug_globals_fwd_ref };
|
break :debug_info .{ debug_compile_unit, debug_enums_fwd_ref, debug_globals_fwd_ref };
|
||||||
} else .{.none} ** 3;
|
} else .{.none} ** 3;
|
||||||
|
|
||||||
const obj = try arena.create(Object);
|
const obj = try arena.create(Object);
|
||||||
obj.* = .{
|
obj.* = .{
|
||||||
@@ -2759,9 +2758,9 @@ pub const Object = struct {
|
|||||||
|
|
||||||
const full_fields: [2]Builder.Metadata =
|
const full_fields: [2]Builder.Metadata =
|
||||||
if (layout.tag_align.compare(.gte, layout.payload_align))
|
if (layout.tag_align.compare(.gte, layout.payload_align))
|
||||||
.{ debug_tag_type, debug_payload_type }
|
.{ debug_tag_type, debug_payload_type }
|
||||||
else
|
else
|
||||||
.{ debug_payload_type, debug_tag_type };
|
.{ debug_payload_type, debug_tag_type };
|
||||||
|
|
||||||
const debug_tagged_union_type = try o.builder.debugStructType(
|
const debug_tagged_union_type = try o.builder.debugStructType(
|
||||||
try o.builder.metadataString(name),
|
try o.builder.metadataString(name),
|
||||||
@@ -4551,11 +4550,11 @@ pub const Object = struct {
|
|||||||
// instruction is followed by a `wrap_optional`, it will return this value
|
// instruction is followed by a `wrap_optional`, it will return this value
|
||||||
// verbatim, and the result should test as non-null.
|
// verbatim, and the result should test as non-null.
|
||||||
switch (zcu.getTarget().ptrBitWidth()) {
|
switch (zcu.getTarget().ptrBitWidth()) {
|
||||||
16 => 0xaaaa,
|
16 => 0xaaaa,
|
||||||
32 => 0xaaaaaaaa,
|
32 => 0xaaaaaaaa,
|
||||||
64 => 0xaaaaaaaa_aaaaaaaa,
|
64 => 0xaaaaaaaa_aaaaaaaa,
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
};
|
};
|
||||||
const llvm_usize = try o.lowerType(Type.usize);
|
const llvm_usize = try o.lowerType(Type.usize);
|
||||||
const llvm_ptr_ty = try o.lowerType(ptr_ty);
|
const llvm_ptr_ty = try o.lowerType(ptr_ty);
|
||||||
return o.builder.castConst(.inttoptr, try o.builder.intConst(llvm_usize, int), llvm_ptr_ty);
|
return o.builder.castConst(.inttoptr, try o.builder.intConst(llvm_usize, int), llvm_ptr_ty);
|
||||||
@@ -9544,7 +9543,7 @@ pub const FuncGen = struct {
|
|||||||
|
|
||||||
if (llvm_dest_ty.isStruct(&o.builder) or
|
if (llvm_dest_ty.isStruct(&o.builder) or
|
||||||
((operand_ty.zigTypeTag(zcu) == .vector or inst_ty.zigTypeTag(zcu) == .vector) and
|
((operand_ty.zigTypeTag(zcu) == .vector or inst_ty.zigTypeTag(zcu) == .vector) and
|
||||||
operand_ty.bitSize(zcu) != inst_ty.bitSize(zcu)))
|
operand_ty.bitSize(zcu) != inst_ty.bitSize(zcu)))
|
||||||
{
|
{
|
||||||
// Both our operand and our result are values, not pointers,
|
// Both our operand and our result are values, not pointers,
|
||||||
// but LLVM won't let us bitcast struct values or vectors with padding bits.
|
// but LLVM won't let us bitcast struct values or vectors with padding bits.
|
||||||
|
|||||||
+35
-35
@@ -3821,38 +3821,38 @@ const msdos_stub: [120]u8 = .{
|
|||||||
0x40, 0x00, // Absolute offset to relocation table. 64 matches the header size (all bytes before the MS-DOS stub program).
|
0x40, 0x00, // Absolute offset to relocation table. 64 matches the header size (all bytes before the MS-DOS stub program).
|
||||||
0x00, 0x00, // Overlay number. Zero means this is the main executable.
|
0x00, 0x00, // Overlay number. Zero means this is the main executable.
|
||||||
}
|
}
|
||||||
// Reserved words.
|
// Reserved words.
|
||||||
++ .{ 0x00, 0x00 } ** 4
|
++ .{ 0x00, 0x00 } ** 4
|
||||||
// OEM-related fields.
|
// OEM-related fields.
|
||||||
++ .{
|
++ .{
|
||||||
0x00, 0x00, // OEM identifier.
|
0x00, 0x00, // OEM identifier.
|
||||||
0x00, 0x00, // OEM information.
|
0x00, 0x00, // OEM information.
|
||||||
}
|
}
|
||||||
// Reserved words.
|
// Reserved words.
|
||||||
++ .{ 0x00, 0x00 } ** 10
|
++ .{ 0x00, 0x00 } ** 10
|
||||||
// Address of the PE header (a long). This matches the size of this entire MS-DOS stub, so that's the address of what's after this MS-DOS stub.
|
// Address of the PE header (a long). This matches the size of this entire MS-DOS stub, so that's the address of what's after this MS-DOS stub.
|
||||||
++ .{ 0x78, 0x00, 0x00, 0x00 }
|
++ .{ 0x78, 0x00, 0x00, 0x00 }
|
||||||
// What follows is a 16-bit x86 MS-DOS program of 7 instructions that prints the bytes after these instructions and then exits.
|
// What follows is a 16-bit x86 MS-DOS program of 7 instructions that prints the bytes after these instructions and then exits.
|
||||||
++ .{
|
++ .{
|
||||||
// Set the value of the data segment to the same value as the code segment.
|
// Set the value of the data segment to the same value as the code segment.
|
||||||
0x0e, // push cs
|
0x0e, // push cs
|
||||||
0x1f, // pop ds
|
0x1f, // pop ds
|
||||||
// Set the DX register to the address of the message.
|
// Set the DX register to the address of the message.
|
||||||
// If you count all bytes of these 7 instructions you get 14, so that's the address of what's after these instructions.
|
// If you count all bytes of these 7 instructions you get 14, so that's the address of what's after these instructions.
|
||||||
0xba, 14, 0x00, // mov dx, 14
|
0xba, 14, 0x00, // mov dx, 14
|
||||||
// Set AH to the system call code for printing a message.
|
// Set AH to the system call code for printing a message.
|
||||||
0xb4, 0x09, // mov ah, 0x09
|
0xb4, 0x09, // mov ah, 0x09
|
||||||
// Perform the system call to print the message.
|
// Perform the system call to print the message.
|
||||||
0xcd, 0x21, // int 0x21
|
0xcd, 0x21, // int 0x21
|
||||||
// Set AH to 0x4c which is the system call code for exiting, and set AL to 0x01 which is the exit code.
|
// Set AH to 0x4c which is the system call code for exiting, and set AL to 0x01 which is the exit code.
|
||||||
0xb8, 0x01, 0x4c, // mov ax, 0x4c01
|
0xb8, 0x01, 0x4c, // mov ax, 0x4c01
|
||||||
// Peform the system call to exit the program with exit code 1.
|
// Peform the system call to exit the program with exit code 1.
|
||||||
0xcd, 0x21, // int 0x21
|
0xcd, 0x21, // int 0x21
|
||||||
}
|
}
|
||||||
// Message to print.
|
// Message to print.
|
||||||
++ "This program cannot be run in DOS mode.".*
|
++ "This program cannot be run in DOS mode.".*
|
||||||
// Message terminators.
|
// Message terminators.
|
||||||
++ .{
|
++ .{
|
||||||
'$', // We do not pass a length to the print system call; the string is terminated by this character.
|
'$', // We do not pass a length to the print system call; the string is terminated by this character.
|
||||||
0x00, 0x00, // Terminating zero bytes.
|
0x00, 0x00, // Terminating zero bytes.
|
||||||
};
|
};
|
||||||
+24
-24
@@ -1995,30 +1995,30 @@ pub const WipNav = struct {
|
|||||||
errdefer _ = if (!decl_gop.found_existing) dwarf.decls.pop();
|
errdefer _ = if (!decl_gop.found_existing) dwarf.decls.pop();
|
||||||
const was_generic_decl = decl_gop.found_existing and
|
const was_generic_decl = decl_gop.found_existing and
|
||||||
switch (try dwarf.debug_info.declAbbrevCode(wip_nav.unit, decl_gop.value_ptr.*)) {
|
switch (try dwarf.debug_info.declAbbrevCode(wip_nav.unit, decl_gop.value_ptr.*)) {
|
||||||
.null,
|
.null,
|
||||||
.decl_alias,
|
.decl_alias,
|
||||||
.decl_empty_enum,
|
.decl_empty_enum,
|
||||||
.decl_enum,
|
.decl_enum,
|
||||||
.decl_namespace_struct,
|
.decl_namespace_struct,
|
||||||
.decl_struct,
|
.decl_struct,
|
||||||
.decl_packed_struct,
|
.decl_packed_struct,
|
||||||
.decl_union,
|
.decl_union,
|
||||||
.decl_var,
|
.decl_var,
|
||||||
.decl_const,
|
.decl_const,
|
||||||
.decl_const_runtime_bits,
|
.decl_const_runtime_bits,
|
||||||
.decl_const_comptime_state,
|
.decl_const_comptime_state,
|
||||||
.decl_const_runtime_bits_comptime_state,
|
.decl_const_runtime_bits_comptime_state,
|
||||||
.decl_empty_func,
|
.decl_empty_func,
|
||||||
.decl_func,
|
.decl_func,
|
||||||
.decl_empty_func_generic,
|
.decl_empty_func_generic,
|
||||||
.decl_func_generic,
|
.decl_func_generic,
|
||||||
=> false,
|
=> false,
|
||||||
.generic_decl_var,
|
.generic_decl_var,
|
||||||
.generic_decl_const,
|
.generic_decl_const,
|
||||||
.generic_decl_func,
|
.generic_decl_func,
|
||||||
=> true,
|
=> true,
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
};
|
};
|
||||||
if (parent_type.getCaptures(zcu).len == 0) {
|
if (parent_type.getCaptures(zcu).len == 0) {
|
||||||
if (was_generic_decl) try dwarf.freeCommonEntry(wip_nav.unit, decl_gop.value_ptr.*);
|
if (was_generic_decl) try dwarf.freeCommonEntry(wip_nav.unit, decl_gop.value_ptr.*);
|
||||||
decl_gop.value_ptr.* = orig_entry;
|
decl_gop.value_ptr.* = orig_entry;
|
||||||
|
|||||||
@@ -236,11 +236,11 @@ pub fn validateEFlags(
|
|||||||
|
|
||||||
const fabi: riscv.Eflags.FloatAbi =
|
const fabi: riscv.Eflags.FloatAbi =
|
||||||
if (std.Target.riscv.featureSetHas(features, .d))
|
if (std.Target.riscv.featureSetHas(features, .d))
|
||||||
.double
|
.double
|
||||||
else if (std.Target.riscv.featureSetHas(features, .f))
|
else if (std.Target.riscv.featureSetHas(features, .f))
|
||||||
.single
|
.single
|
||||||
else
|
else
|
||||||
.soft;
|
.soft;
|
||||||
|
|
||||||
if (flags.fabi != fabi) {
|
if (flags.fabi != fabi) {
|
||||||
any_errors = true;
|
any_errors = true;
|
||||||
|
|||||||
@@ -217,20 +217,20 @@ fn initSections(elf_file: *Elf) !void {
|
|||||||
if (elf_file.section_indexes.eh_frame == null) {
|
if (elf_file.section_indexes.eh_frame == null) {
|
||||||
elf_file.section_indexes.eh_frame = elf_file.sectionByName(".eh_frame") orelse
|
elf_file.section_indexes.eh_frame = elf_file.sectionByName(".eh_frame") orelse
|
||||||
try elf_file.addSection(.{
|
try elf_file.addSection(.{
|
||||||
.name = try elf_file.insertShString(".eh_frame"),
|
.name = try elf_file.insertShString(".eh_frame"),
|
||||||
.type = if (elf_file.getTarget().cpu.arch == .x86_64)
|
.type = if (elf_file.getTarget().cpu.arch == .x86_64)
|
||||||
elf.SHT_X86_64_UNWIND
|
elf.SHT_X86_64_UNWIND
|
||||||
else
|
else
|
||||||
elf.SHT_PROGBITS,
|
elf.SHT_PROGBITS,
|
||||||
.flags = elf.SHF_ALLOC,
|
.flags = elf.SHF_ALLOC,
|
||||||
.addralign = elf_file.ptrWidthBytes(),
|
.addralign = elf_file.ptrWidthBytes(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
elf_file.section_indexes.eh_frame_rela = elf_file.sectionByName(".rela.eh_frame") orelse
|
elf_file.section_indexes.eh_frame_rela = elf_file.sectionByName(".rela.eh_frame") orelse
|
||||||
try elf_file.addRelaShdr(
|
try elf_file.addRelaShdr(
|
||||||
try elf_file.insertShString(".rela.eh_frame"),
|
try elf_file.insertShString(".rela.eh_frame"),
|
||||||
elf_file.section_indexes.eh_frame.?,
|
elf_file.section_indexes.eh_frame.?,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
try initComdatGroups(elf_file);
|
try initComdatGroups(elf_file);
|
||||||
|
|||||||
@@ -551,7 +551,7 @@ pub const GotSection = struct {
|
|||||||
switch (entry.tag) {
|
switch (entry.tag) {
|
||||||
.got => if (symbol.?.flags.import or symbol.?.isIFunc(elf_file) or
|
.got => if (symbol.?.flags.import or symbol.?.isIFunc(elf_file) or
|
||||||
((elf_file.isEffectivelyDynLib() or (elf_file.base.isExe() and comp.config.pie)) and
|
((elf_file.isEffectivelyDynLib() or (elf_file.base.isExe() and comp.config.pie)) and
|
||||||
!symbol.?.isAbs(elf_file)))
|
!symbol.?.isAbs(elf_file)))
|
||||||
{
|
{
|
||||||
num += 1;
|
num += 1;
|
||||||
},
|
},
|
||||||
|
|||||||
+8
-8
@@ -1617,14 +1617,14 @@ fn initOutputSections(self: *MachO) !void {
|
|||||||
}
|
}
|
||||||
self.text_sect_index = self.getSectionByName("__TEXT", "__text") orelse
|
self.text_sect_index = self.getSectionByName("__TEXT", "__text") orelse
|
||||||
try self.addSection("__TEXT", "__text", .{
|
try self.addSection("__TEXT", "__text", .{
|
||||||
.alignment = switch (self.getTarget().cpu.arch) {
|
.alignment = switch (self.getTarget().cpu.arch) {
|
||||||
.x86_64 => 0,
|
.x86_64 => 0,
|
||||||
.aarch64 => 2,
|
.aarch64 => 2,
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
},
|
},
|
||||||
.flags = macho.S_REGULAR |
|
.flags = macho.S_REGULAR |
|
||||||
macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS,
|
macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS,
|
||||||
});
|
});
|
||||||
self.data_sect_index = self.getSectionByName("__DATA", "__data") orelse
|
self.data_sect_index = self.getSectionByName("__DATA", "__data") orelse
|
||||||
try self.addSection("__DATA", "__data", .{});
|
try self.addSection("__DATA", "__data", .{});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,10 +149,10 @@ pub fn initOutputSection(sect: macho.section_64, macho_file: *MachO) !u8 {
|
|||||||
if (macho_file.base.isRelocatable()) {
|
if (macho_file.base.isRelocatable()) {
|
||||||
const osec = macho_file.getSectionByName(sect.segName(), sect.sectName()) orelse
|
const osec = macho_file.getSectionByName(sect.segName(), sect.sectName()) orelse
|
||||||
try macho_file.addSection(
|
try macho_file.addSection(
|
||||||
sect.segName(),
|
sect.segName(),
|
||||||
sect.sectName(),
|
sect.sectName(),
|
||||||
.{ .flags = sect.flags },
|
.{ .flags = sect.flags },
|
||||||
);
|
);
|
||||||
return osec;
|
return osec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1104,8 +1104,8 @@ fn createTlvDescriptor(
|
|||||||
|
|
||||||
const sect_index = macho_file.getSectionByName("__DATA", "__thread_vars") orelse
|
const sect_index = macho_file.getSectionByName("__DATA", "__thread_vars") orelse
|
||||||
try macho_file.addSection("__DATA", "__thread_vars", .{
|
try macho_file.addSection("__DATA", "__thread_vars", .{
|
||||||
.flags = macho.S_THREAD_LOCAL_VARIABLES,
|
.flags = macho.S_THREAD_LOCAL_VARIABLES,
|
||||||
});
|
});
|
||||||
sym.out_n_sect = sect_index;
|
sym.out_n_sect = sect_index;
|
||||||
atom.out_n_sect = sect_index;
|
atom.out_n_sect = sect_index;
|
||||||
|
|
||||||
|
|||||||
@@ -102,8 +102,8 @@ fn mark(roots: []*Atom, objects: []const File.Index, macho_file: *MachO) void {
|
|||||||
const isec = atom.getInputSection(macho_file);
|
const isec = atom.getInputSection(macho_file);
|
||||||
if (isec.isDontDeadStripIfReferencesLive() and
|
if (isec.isDontDeadStripIfReferencesLive() and
|
||||||
!(mem.eql(u8, isec.sectName(), "__eh_frame") or
|
!(mem.eql(u8, isec.sectName(), "__eh_frame") or
|
||||||
mem.eql(u8, isec.sectName(), "__compact_unwind") or
|
mem.eql(u8, isec.sectName(), "__compact_unwind") or
|
||||||
isec.attrs() & macho.S_ATTR_DEBUG != 0) and
|
isec.attrs() & macho.S_ATTR_DEBUG != 0) and
|
||||||
!atom.isAlive() and refersLive(atom, macho_file))
|
!atom.isAlive() and refersLive(atom, macho_file))
|
||||||
{
|
{
|
||||||
markLive(atom, macho_file);
|
markLive(atom, macho_file);
|
||||||
|
|||||||
+4
-4
@@ -5919,8 +5919,8 @@ pub const ClangArgIterator = struct {
|
|||||||
|
|
||||||
self.arg_iterator_response_file =
|
self.arg_iterator_response_file =
|
||||||
initArgIteratorResponseFile(arena, resp_file_path) catch |err| {
|
initArgIteratorResponseFile(arena, resp_file_path) catch |err| {
|
||||||
fatal("unable to read response file '{s}': {s}", .{ resp_file_path, @errorName(err) });
|
fatal("unable to read response file '{s}': {s}", .{ resp_file_path, @errorName(err) });
|
||||||
};
|
};
|
||||||
// NOTE: The ArgIteratorResponseFile returns tokens from next() that are slices of an
|
// NOTE: The ArgIteratorResponseFile returns tokens from next() that are slices of an
|
||||||
// internal buffer. This internal buffer is arena allocated, so it is not cleaned up here.
|
// internal buffer. This internal buffer is arena allocated, so it is not cleaned up here.
|
||||||
|
|
||||||
@@ -6233,8 +6233,8 @@ fn cmdAstCheck(
|
|||||||
file.tree.?.tokens.len * (@sizeOf(std.zig.Token.Tag) + @sizeOf(Ast.ByteOffset));
|
file.tree.?.tokens.len * (@sizeOf(std.zig.Token.Tag) + @sizeOf(Ast.ByteOffset));
|
||||||
const tree_bytes = @sizeOf(Ast) + file.tree.?.nodes.len *
|
const tree_bytes = @sizeOf(Ast) + file.tree.?.nodes.len *
|
||||||
(@sizeOf(Ast.Node.Tag) +
|
(@sizeOf(Ast.Node.Tag) +
|
||||||
@sizeOf(Ast.Node.Data) +
|
@sizeOf(Ast.Node.Data) +
|
||||||
@sizeOf(Ast.TokenIndex));
|
@sizeOf(Ast.TokenIndex));
|
||||||
const instruction_bytes = file.zir.?.instructions.len *
|
const instruction_bytes = file.zir.?.instructions.len *
|
||||||
// Here we don't use @sizeOf(Zir.Inst.Data) because it would include
|
// Here we don't use @sizeOf(Zir.Inst.Data) because it would include
|
||||||
// the debug safety tag but we want to measure release size.
|
// the debug safety tag but we want to measure release size.
|
||||||
|
|||||||
+13
-14
@@ -2570,9 +2570,9 @@ fn transInitListExprRecord(
|
|||||||
// Unions and Structs are both represented as RecordDecl
|
// Unions and Structs are both represented as RecordDecl
|
||||||
const record_ty = ty.getAsRecordType() orelse
|
const record_ty = ty.getAsRecordType() orelse
|
||||||
blk: {
|
blk: {
|
||||||
is_union_type = true;
|
is_union_type = true;
|
||||||
break :blk ty.getAsUnionType();
|
break :blk ty.getAsUnionType();
|
||||||
} orelse unreachable;
|
} orelse unreachable;
|
||||||
const record_decl = record_ty.getDecl();
|
const record_decl = record_ty.getDecl();
|
||||||
const record_def = record_decl.getDefinition() orelse
|
const record_def = record_decl.getDefinition() orelse
|
||||||
unreachable;
|
unreachable;
|
||||||
@@ -4006,7 +4006,7 @@ fn transCPtrCast(
|
|||||||
if (!src_ty.isArrayType() and ((src_child_type.isConstQualified() and
|
if (!src_ty.isArrayType() and ((src_child_type.isConstQualified() and
|
||||||
!child_type.isConstQualified()) or
|
!child_type.isConstQualified()) or
|
||||||
(src_child_type.isVolatileQualified() and
|
(src_child_type.isVolatileQualified() and
|
||||||
!child_type.isVolatileQualified())))
|
!child_type.isVolatileQualified())))
|
||||||
{
|
{
|
||||||
return removeCVQualifiers(c, dst_type_node, expr);
|
return removeCVQualifiers(c, dst_type_node, expr);
|
||||||
} else {
|
} else {
|
||||||
@@ -4092,8 +4092,8 @@ fn transFloatingLiteralQuad(c: *Context, expr: *const clang.FloatingLiteral, use
|
|||||||
false;
|
false;
|
||||||
break :fmt_decimal if (could_roundtrip) try c.arena.dupe(u8, temp_str) else null;
|
break :fmt_decimal if (could_roundtrip) try c.arena.dupe(u8, temp_str) else null;
|
||||||
}
|
}
|
||||||
// otherwise, fall back to the hexadecimal format
|
// otherwise, fall back to the hexadecimal format
|
||||||
orelse try std.fmt.allocPrint(c.arena, "{x}", .{quad});
|
orelse try std.fmt.allocPrint(c.arena, "{x}", .{quad});
|
||||||
|
|
||||||
var node = try Tag.float_literal.create(c.arena, str);
|
var node = try Tag.float_literal.create(c.arena, str);
|
||||||
if (is_negative) node = try Tag.negate.create(c.arena, node);
|
if (is_negative) node = try Tag.negate.create(c.arena, node);
|
||||||
@@ -5080,15 +5080,14 @@ fn finishTransFnProto(
|
|||||||
const is_noalias = param_qt.isRestrictQualified();
|
const is_noalias = param_qt.isRestrictQualified();
|
||||||
|
|
||||||
const param_name: ?[]const u8 =
|
const param_name: ?[]const u8 =
|
||||||
if (fn_decl) |decl|
|
if (fn_decl) |decl| blk: {
|
||||||
blk: {
|
const param = decl.getParamDecl(@as(c_uint, @intCast(i)));
|
||||||
const param = decl.getParamDecl(@as(c_uint, @intCast(i)));
|
const param_name: []const u8 = try c.str(@as(*const clang.NamedDecl, @ptrCast(param)).getName_bytes_begin());
|
||||||
const param_name: []const u8 = try c.str(@as(*const clang.NamedDecl, @ptrCast(param)).getName_bytes_begin());
|
if (param_name.len < 1)
|
||||||
if (param_name.len < 1)
|
break :blk null;
|
||||||
break :blk null;
|
|
||||||
|
|
||||||
break :blk param_name;
|
break :blk param_name;
|
||||||
} else null;
|
} else null;
|
||||||
const type_node = try transQualType(c, scope, param_qt, source_loc);
|
const type_node = try transQualType(c, scope, param_qt, source_loc);
|
||||||
|
|
||||||
fn_params.addOneAssumeCapacity().* = .{
|
fn_params.addOneAssumeCapacity().* = .{
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ test "exporting comptime-known value" {
|
|||||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||||
if (builtin.zig_backend == .stage2_x86_64 and
|
if (builtin.zig_backend == .stage2_x86_64 and
|
||||||
(builtin.target.ofmt != .elf and
|
(builtin.target.ofmt != .elf and
|
||||||
builtin.target.ofmt != .macho and
|
builtin.target.ofmt != .macho and
|
||||||
builtin.target.ofmt != .coff)) return error.SkipZigTest;
|
builtin.target.ofmt != .coff)) return error.SkipZigTest;
|
||||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||||
|
|||||||
+70
-70
@@ -475,7 +475,7 @@ fn testCommentString(b: *Build, opts: Options) *Step {
|
|||||||
const test_step = addTestStep(b, "comment-string", opts);
|
const test_step = addTestStep(b, "comment-string", opts);
|
||||||
|
|
||||||
const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
|
const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
|
||||||
\\pub fn main() void {}
|
\\pub fn main() void {}
|
||||||
});
|
});
|
||||||
|
|
||||||
const check = exe.checkObject();
|
const check = exe.checkObject();
|
||||||
@@ -490,7 +490,7 @@ fn testCommentStringStaticLib(b: *Build, opts: Options) *Step {
|
|||||||
const test_step = addTestStep(b, "comment-string-static-lib", opts);
|
const test_step = addTestStep(b, "comment-string-static-lib", opts);
|
||||||
|
|
||||||
const lib = addStaticLibrary(b, opts, .{ .name = "lib", .zig_source_bytes =
|
const lib = addStaticLibrary(b, opts, .{ .name = "lib", .zig_source_bytes =
|
||||||
\\export fn foo() void {}
|
\\export fn foo() void {}
|
||||||
});
|
});
|
||||||
|
|
||||||
const check = lib.checkObject();
|
const check = lib.checkObject();
|
||||||
@@ -861,23 +861,23 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {
|
|||||||
const test_step = addTestStep(b, "emit-relocatable", opts);
|
const test_step = addTestStep(b, "emit-relocatable", opts);
|
||||||
|
|
||||||
const a_o = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
|
const a_o = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
|
||||||
\\const std = @import("std");
|
\\const std = @import("std");
|
||||||
\\extern var bar: i32;
|
\\extern var bar: i32;
|
||||||
\\export fn foo() i32 {
|
\\export fn foo() i32 {
|
||||||
\\ return bar;
|
\\ return bar;
|
||||||
\\}
|
\\}
|
||||||
\\export fn printFoo() void {
|
\\export fn printFoo() void {
|
||||||
\\ std.debug.print("foo={d}\n", .{foo()});
|
\\ std.debug.print("foo={d}\n", .{foo()});
|
||||||
\\}
|
\\}
|
||||||
});
|
});
|
||||||
a_o.linkLibC();
|
a_o.linkLibC();
|
||||||
|
|
||||||
const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes =
|
const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes =
|
||||||
\\#include <stdio.h>
|
\\#include <stdio.h>
|
||||||
\\int bar = 42;
|
\\int bar = 42;
|
||||||
\\void printBar() {
|
\\void printBar() {
|
||||||
\\ fprintf(stderr, "bar=%d\n", bar);
|
\\ fprintf(stderr, "bar=%d\n", bar);
|
||||||
\\}
|
\\}
|
||||||
});
|
});
|
||||||
b_o.linkLibC();
|
b_o.linkLibC();
|
||||||
|
|
||||||
@@ -886,13 +886,13 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {
|
|||||||
c_o.addObject(b_o);
|
c_o.addObject(b_o);
|
||||||
|
|
||||||
const exe = addExecutable(b, opts, .{ .name = "test", .zig_source_bytes =
|
const exe = addExecutable(b, opts, .{ .name = "test", .zig_source_bytes =
|
||||||
\\const std = @import("std");
|
\\const std = @import("std");
|
||||||
\\extern fn printFoo() void;
|
\\extern fn printFoo() void;
|
||||||
\\extern fn printBar() void;
|
\\extern fn printBar() void;
|
||||||
\\pub fn main() void {
|
\\pub fn main() void {
|
||||||
\\ printFoo();
|
\\ printFoo();
|
||||||
\\ printBar();
|
\\ printBar();
|
||||||
\\}
|
\\}
|
||||||
});
|
});
|
||||||
exe.addObject(c_o);
|
exe.addObject(c_o);
|
||||||
exe.linkLibC();
|
exe.linkLibC();
|
||||||
@@ -1920,8 +1920,8 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
|
|||||||
g_o.linkLibC();
|
g_o.linkLibC();
|
||||||
|
|
||||||
const h_o = addObject(b, opts, .{ .name = "h", .c_source_bytes =
|
const h_o = addObject(b, opts, .{ .name = "h", .c_source_bytes =
|
||||||
\\#include <stdio.h>
|
\\#include <stdio.h>
|
||||||
\\__attribute__((destructor)) void fini2() { printf("8"); }
|
\\__attribute__((destructor)) void fini2() { printf("8"); }
|
||||||
});
|
});
|
||||||
h_o.linkLibC();
|
h_o.linkLibC();
|
||||||
|
|
||||||
@@ -2495,23 +2495,23 @@ fn testMergeStrings2(b: *Build, opts: Options) *Step {
|
|||||||
const test_step = addTestStep(b, "merge-strings2", opts);
|
const test_step = addTestStep(b, "merge-strings2", opts);
|
||||||
|
|
||||||
const obj1 = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
|
const obj1 = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
|
||||||
\\const std = @import("std");
|
\\const std = @import("std");
|
||||||
\\export fn foo() void {
|
\\export fn foo() void {
|
||||||
\\ var arr: [5:0]u16 = [_:0]u16{ 1, 2, 3, 4, 5 };
|
\\ var arr: [5:0]u16 = [_:0]u16{ 1, 2, 3, 4, 5 };
|
||||||
\\ const slice = std.mem.sliceTo(&arr, 3);
|
\\ const slice = std.mem.sliceTo(&arr, 3);
|
||||||
\\ std.testing.expectEqualSlices(u16, arr[0..2], slice) catch unreachable;
|
\\ std.testing.expectEqualSlices(u16, arr[0..2], slice) catch unreachable;
|
||||||
\\}
|
\\}
|
||||||
});
|
});
|
||||||
|
|
||||||
const obj2 = addObject(b, opts, .{ .name = "b", .zig_source_bytes =
|
const obj2 = addObject(b, opts, .{ .name = "b", .zig_source_bytes =
|
||||||
\\const std = @import("std");
|
\\const std = @import("std");
|
||||||
\\extern fn foo() void;
|
\\extern fn foo() void;
|
||||||
\\pub fn main() void {
|
\\pub fn main() void {
|
||||||
\\ foo();
|
\\ foo();
|
||||||
\\ var arr: [5:0]u16 = [_:0]u16{ 5, 4, 3, 2, 1 };
|
\\ var arr: [5:0]u16 = [_:0]u16{ 5, 4, 3, 2, 1 };
|
||||||
\\ const slice = std.mem.sliceTo(&arr, 3);
|
\\ const slice = std.mem.sliceTo(&arr, 3);
|
||||||
\\ std.testing.expectEqualSlices(u16, arr[0..2], slice) catch unreachable;
|
\\ std.testing.expectEqualSlices(u16, arr[0..2], slice) catch unreachable;
|
||||||
\\}
|
\\}
|
||||||
});
|
});
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -2752,17 +2752,17 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
|
|||||||
});
|
});
|
||||||
obj2.linkLibCpp();
|
obj2.linkLibCpp();
|
||||||
const obj3 = addObject(b, opts, .{ .name = "obj3", .cpp_source_bytes =
|
const obj3 = addObject(b, opts, .{ .name = "obj3", .cpp_source_bytes =
|
||||||
\\#include <iostream>
|
\\#include <iostream>
|
||||||
\\#include <stdexcept>
|
\\#include <stdexcept>
|
||||||
\\extern int try_again();
|
\\extern int try_again();
|
||||||
\\int main() {
|
\\int main() {
|
||||||
\\ try {
|
\\ try {
|
||||||
\\ try_again();
|
\\ try_again();
|
||||||
\\ } catch (const std::exception &e) {
|
\\ } catch (const std::exception &e) {
|
||||||
\\ std::cout << "exception=" << e.what();
|
\\ std::cout << "exception=" << e.what();
|
||||||
\\ }
|
\\ }
|
||||||
\\ return 0;
|
\\ return 0;
|
||||||
\\}
|
\\}
|
||||||
});
|
});
|
||||||
obj3.linkLibCpp();
|
obj3.linkLibCpp();
|
||||||
|
|
||||||
@@ -2864,15 +2864,15 @@ fn testRelocatableMergeStrings(b: *Build, opts: Options) *Step {
|
|||||||
const test_step = addTestStep(b, "relocatable-merge-strings", opts);
|
const test_step = addTestStep(b, "relocatable-merge-strings", opts);
|
||||||
|
|
||||||
const obj1 = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
|
const obj1 = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
|
||||||
\\.section .rodata.str1.1,"aMS",@progbits,1
|
\\.section .rodata.str1.1,"aMS",@progbits,1
|
||||||
\\val1:
|
\\val1:
|
||||||
\\.ascii "Hello \0"
|
\\.ascii "Hello \0"
|
||||||
\\.section .rodata.str1.1,"aMS",@progbits,1
|
\\.section .rodata.str1.1,"aMS",@progbits,1
|
||||||
\\val5:
|
\\val5:
|
||||||
\\.ascii "World \0"
|
\\.ascii "World \0"
|
||||||
\\.section .rodata.str1.1,"aMS",@progbits,1
|
\\.section .rodata.str1.1,"aMS",@progbits,1
|
||||||
\\val7:
|
\\val7:
|
||||||
\\.ascii "Hello \0"
|
\\.ascii "Hello \0"
|
||||||
});
|
});
|
||||||
|
|
||||||
const obj2 = addObject(b, opts, .{ .name = "b" });
|
const obj2 = addObject(b, opts, .{ .name = "b" });
|
||||||
@@ -3030,18 +3030,18 @@ fn testThunks(b: *Build, opts: Options) *Step {
|
|||||||
const test_step = addTestStep(b, "thunks", opts);
|
const test_step = addTestStep(b, "thunks", opts);
|
||||||
|
|
||||||
const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
|
const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
|
||||||
\\void foo();
|
\\void foo();
|
||||||
\\__attribute__((section(".bar"))) void bar() {
|
\\__attribute__((section(".bar"))) void bar() {
|
||||||
\\ return foo();
|
\\ return foo();
|
||||||
\\}
|
\\}
|
||||||
\\__attribute__((section(".foo"))) void foo() {
|
\\__attribute__((section(".foo"))) void foo() {
|
||||||
\\ return bar();
|
\\ return bar();
|
||||||
\\}
|
\\}
|
||||||
\\int main() {
|
\\int main() {
|
||||||
\\ foo();
|
\\ foo();
|
||||||
\\ bar();
|
\\ bar();
|
||||||
\\ return 0;
|
\\ return 0;
|
||||||
\\}
|
\\}
|
||||||
});
|
});
|
||||||
|
|
||||||
const check = exe.checkObject();
|
const check = exe.checkObject();
|
||||||
|
|||||||
+816
-816
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -203,7 +203,7 @@ fn printOutput(
|
|||||||
if (mem.startsWith(u8, triple, "wasm32") or
|
if (mem.startsWith(u8, triple, "wasm32") or
|
||||||
mem.startsWith(u8, triple, "riscv64-linux") or
|
mem.startsWith(u8, triple, "riscv64-linux") or
|
||||||
(mem.startsWith(u8, triple, "x86_64-linux") and
|
(mem.startsWith(u8, triple, "x86_64-linux") and
|
||||||
builtin.os.tag != .linux or builtin.cpu.arch != .x86_64))
|
builtin.os.tag != .linux or builtin.cpu.arch != .x86_64))
|
||||||
{
|
{
|
||||||
// skip execution
|
// skip execution
|
||||||
break :code_block;
|
break :code_block;
|
||||||
|
|||||||
@@ -99,8 +99,8 @@ pub fn main() anyerror!void {
|
|||||||
|
|
||||||
const version = Version.parse(parsed_json.value.DefaultProperties.MACOSX_DEPLOYMENT_TARGET) orelse
|
const version = Version.parse(parsed_json.value.DefaultProperties.MACOSX_DEPLOYMENT_TARGET) orelse
|
||||||
fatal("don't know how to parse SDK version: {s}", .{
|
fatal("don't know how to parse SDK version: {s}", .{
|
||||||
parsed_json.value.DefaultProperties.MACOSX_DEPLOYMENT_TARGET,
|
parsed_json.value.DefaultProperties.MACOSX_DEPLOYMENT_TARGET,
|
||||||
});
|
});
|
||||||
const os_ver: OsVer = switch (version.major) {
|
const os_ver: OsVer = switch (version.major) {
|
||||||
10 => .catalina,
|
10 => .catalina,
|
||||||
11 => .big_sur,
|
11 => .big_sur,
|
||||||
|
|||||||
@@ -761,7 +761,7 @@ pub fn main() anyerror!void {
|
|||||||
if ((std.mem.startsWith(u8, name, "mno-") and
|
if ((std.mem.startsWith(u8, name, "mno-") and
|
||||||
llvm_to_zig_cpu_features.contains(name["mno-".len..])) or
|
llvm_to_zig_cpu_features.contains(name["mno-".len..])) or
|
||||||
(std.mem.startsWith(u8, name, "m") and
|
(std.mem.startsWith(u8, name, "m") and
|
||||||
llvm_to_zig_cpu_features.contains(name["m".len..])))
|
llvm_to_zig_cpu_features.contains(name["m".len..])))
|
||||||
{
|
{
|
||||||
try stdout.print("m(\"{s}\"),\n", .{name});
|
try stdout.print("m(\"{s}\"),\n", .{name});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in new issue
Block a user