mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
stage2: remove some dead code, fix build on aarch64
This commit is contained in:
parent
7e7d1df4da
commit
c29c79b17a
@ -13,6 +13,7 @@ const InstallDirectoryOptions = std.build.InstallDirectoryOptions;
|
|||||||
pub fn build(b: *Builder) !void {
|
pub fn build(b: *Builder) !void {
|
||||||
b.setPreferredReleaseMode(.ReleaseFast);
|
b.setPreferredReleaseMode(.ReleaseFast);
|
||||||
const mode = b.standardReleaseOptions();
|
const mode = b.standardReleaseOptions();
|
||||||
|
const target = b.standardTargetOptions(.{});
|
||||||
|
|
||||||
var docgen_exe = b.addExecutable("docgen", "doc/docgen.zig");
|
var docgen_exe = b.addExecutable("docgen", "doc/docgen.zig");
|
||||||
|
|
||||||
@ -54,6 +55,7 @@ pub fn build(b: *Builder) !void {
|
|||||||
if (!only_install_lib_files) {
|
if (!only_install_lib_files) {
|
||||||
var exe = b.addExecutable("zig", "src-self-hosted/main.zig");
|
var exe = b.addExecutable("zig", "src-self-hosted/main.zig");
|
||||||
exe.setBuildMode(mode);
|
exe.setBuildMode(mode);
|
||||||
|
exe.setTarget(target);
|
||||||
test_step.dependOn(&exe.step);
|
test_step.dependOn(&exe.step);
|
||||||
b.default_step.dependOn(&exe.step);
|
b.default_step.dependOn(&exe.step);
|
||||||
|
|
||||||
|
|||||||
@ -325,7 +325,14 @@ fn identifier(mod: *Module, scope: *Scope, ident: *ast.Node.Identifier) InnerErr
|
|||||||
16 => if (is_signed) Value.initTag(.i16_type) else Value.initTag(.u16_type),
|
16 => if (is_signed) Value.initTag(.i16_type) else Value.initTag(.u16_type),
|
||||||
32 => if (is_signed) Value.initTag(.i32_type) else Value.initTag(.u32_type),
|
32 => if (is_signed) Value.initTag(.i32_type) else Value.initTag(.u32_type),
|
||||||
64 => if (is_signed) Value.initTag(.i64_type) else Value.initTag(.u64_type),
|
64 => if (is_signed) Value.initTag(.i64_type) else Value.initTag(.u64_type),
|
||||||
else => return mod.failNode(scope, &ident.base, "TODO implement arbitrary integer bitwidth types", .{}),
|
else => {
|
||||||
|
const int_type_payload = try scope.arena().create(Value.Payload.IntType);
|
||||||
|
int_type_payload.* = .{ .signed = is_signed, .bits = bit_count };
|
||||||
|
return mod.addZIRInstConst(scope, src, .{
|
||||||
|
.ty = Type.initTag(.comptime_int),
|
||||||
|
.val = Value.initPayload(&int_type_payload.base),
|
||||||
|
});
|
||||||
|
},
|
||||||
};
|
};
|
||||||
return mod.addZIRInstConst(scope, src, .{
|
return mod.addZIRInstConst(scope, src, .{
|
||||||
.ty = Type.initTag(.type),
|
.ty = Type.initTag(.type),
|
||||||
@ -582,30 +589,6 @@ fn getSimplePrimitiveValue(name: []const u8) ?TypedValue {
|
|||||||
.val = Value.initTag(tag),
|
.val = Value.initTag(tag),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (mem.eql(u8, name, "null")) {
|
|
||||||
return TypedValue{
|
|
||||||
.ty = Type.initTag(.@"null"),
|
|
||||||
.val = Value.initTag(.null_value),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (mem.eql(u8, name, "undefined")) {
|
|
||||||
return TypedValue{
|
|
||||||
.ty = Type.initTag(.@"undefined"),
|
|
||||||
.val = Value.initTag(.undef),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (mem.eql(u8, name, "true")) {
|
|
||||||
return TypedValue{
|
|
||||||
.ty = Type.initTag(.bool),
|
|
||||||
.val = Value.initTag(.bool_true),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (mem.eql(u8, name, "false")) {
|
|
||||||
return TypedValue{
|
|
||||||
.ty = Type.initTag(.bool),
|
|
||||||
.val = Value.initTag(.bool_false),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -70,6 +70,7 @@ pub const Value = extern union {
|
|||||||
// After this, the tag requires a payload.
|
// After this, the tag requires a payload.
|
||||||
|
|
||||||
ty,
|
ty,
|
||||||
|
int_type,
|
||||||
int_u64,
|
int_u64,
|
||||||
int_i64,
|
int_i64,
|
||||||
int_big_positive,
|
int_big_positive,
|
||||||
@ -178,6 +179,7 @@ pub const Value = extern union {
|
|||||||
};
|
};
|
||||||
return Value{ .ptr_otherwise = &new_payload.base };
|
return Value{ .ptr_otherwise = &new_payload.base };
|
||||||
},
|
},
|
||||||
|
.int_type => return self.copyPayloadShallow(allocator, Payload.IntType),
|
||||||
.int_u64 => return self.copyPayloadShallow(allocator, Payload.Int_u64),
|
.int_u64 => return self.copyPayloadShallow(allocator, Payload.Int_u64),
|
||||||
.int_i64 => return self.copyPayloadShallow(allocator, Payload.Int_i64),
|
.int_i64 => return self.copyPayloadShallow(allocator, Payload.Int_i64),
|
||||||
.int_big_positive => {
|
.int_big_positive => {
|
||||||
@ -287,6 +289,13 @@ pub const Value = extern union {
|
|||||||
.bool_true => return out_stream.writeAll("true"),
|
.bool_true => return out_stream.writeAll("true"),
|
||||||
.bool_false => return out_stream.writeAll("false"),
|
.bool_false => return out_stream.writeAll("false"),
|
||||||
.ty => return val.cast(Payload.Ty).?.ty.format("", options, out_stream),
|
.ty => return val.cast(Payload.Ty).?.ty.format("", options, out_stream),
|
||||||
|
.int_type => {
|
||||||
|
const int_type = val.cast(Payload.IntType).?;
|
||||||
|
return out_stream.print("{}{}", .{
|
||||||
|
if (int_type.signed) "s" else "u",
|
||||||
|
int_type.bits,
|
||||||
|
});
|
||||||
|
},
|
||||||
.int_u64 => return std.fmt.formatIntValue(val.cast(Payload.Int_u64).?.int, "", options, out_stream),
|
.int_u64 => return std.fmt.formatIntValue(val.cast(Payload.Int_u64).?.int, "", options, out_stream),
|
||||||
.int_i64 => return std.fmt.formatIntValue(val.cast(Payload.Int_i64).?.int, "", options, out_stream),
|
.int_i64 => return std.fmt.formatIntValue(val.cast(Payload.Int_i64).?.int, "", options, out_stream),
|
||||||
.int_big_positive => return out_stream.print("{}", .{val.cast(Payload.IntBigPositive).?.asBigInt()}),
|
.int_big_positive => return out_stream.print("{}", .{val.cast(Payload.IntBigPositive).?.asBigInt()}),
|
||||||
@ -335,6 +344,7 @@ pub const Value = extern union {
|
|||||||
pub fn toType(self: Value) Type {
|
pub fn toType(self: Value) Type {
|
||||||
return switch (self.tag()) {
|
return switch (self.tag()) {
|
||||||
.ty => self.cast(Payload.Ty).?.ty,
|
.ty => self.cast(Payload.Ty).?.ty,
|
||||||
|
.int_type => @panic("TODO int type to type"),
|
||||||
|
|
||||||
.u8_type => Type.initTag(.u8),
|
.u8_type => Type.initTag(.u8),
|
||||||
.i8_type => Type.initTag(.i8),
|
.i8_type => Type.initTag(.i8),
|
||||||
@ -404,6 +414,7 @@ pub const Value = extern union {
|
|||||||
pub fn toBigInt(self: Value, space: *BigIntSpace) BigIntConst {
|
pub fn toBigInt(self: Value, space: *BigIntSpace) BigIntConst {
|
||||||
switch (self.tag()) {
|
switch (self.tag()) {
|
||||||
.ty,
|
.ty,
|
||||||
|
.int_type,
|
||||||
.u8_type,
|
.u8_type,
|
||||||
.i8_type,
|
.i8_type,
|
||||||
.u16_type,
|
.u16_type,
|
||||||
@ -475,6 +486,7 @@ pub const Value = extern union {
|
|||||||
pub fn toUnsignedInt(self: Value) u64 {
|
pub fn toUnsignedInt(self: Value) u64 {
|
||||||
switch (self.tag()) {
|
switch (self.tag()) {
|
||||||
.ty,
|
.ty,
|
||||||
|
.int_type,
|
||||||
.u8_type,
|
.u8_type,
|
||||||
.i8_type,
|
.i8_type,
|
||||||
.u16_type,
|
.u16_type,
|
||||||
@ -553,7 +565,7 @@ pub const Value = extern union {
|
|||||||
/// Asserts that the value is a float or an integer.
|
/// Asserts that the value is a float or an integer.
|
||||||
pub fn toF128(self: Value) f128 {
|
pub fn toF128(self: Value) f128 {
|
||||||
return switch (self.tag()) {
|
return switch (self.tag()) {
|
||||||
.float_16 => self.cast(Payload.Float_16).?.val,
|
.float_16 => @panic("TODO soft float"),
|
||||||
.float_32 => self.cast(Payload.Float_32).?.val,
|
.float_32 => self.cast(Payload.Float_32).?.val,
|
||||||
.float_64 => self.cast(Payload.Float_64).?.val,
|
.float_64 => self.cast(Payload.Float_64).?.val,
|
||||||
.float_128 => self.cast(Payload.Float_128).?.val,
|
.float_128 => self.cast(Payload.Float_128).?.val,
|
||||||
@ -573,6 +585,7 @@ pub const Value = extern union {
|
|||||||
pub fn intBitCountTwosComp(self: Value) usize {
|
pub fn intBitCountTwosComp(self: Value) usize {
|
||||||
switch (self.tag()) {
|
switch (self.tag()) {
|
||||||
.ty,
|
.ty,
|
||||||
|
.int_type,
|
||||||
.u8_type,
|
.u8_type,
|
||||||
.i8_type,
|
.i8_type,
|
||||||
.u16_type,
|
.u16_type,
|
||||||
@ -650,6 +663,7 @@ pub const Value = extern union {
|
|||||||
pub fn intFitsInType(self: Value, ty: Type, target: Target) bool {
|
pub fn intFitsInType(self: Value, ty: Type, target: Target) bool {
|
||||||
switch (self.tag()) {
|
switch (self.tag()) {
|
||||||
.ty,
|
.ty,
|
||||||
|
.int_type,
|
||||||
.u8_type,
|
.u8_type,
|
||||||
.i8_type,
|
.i8_type,
|
||||||
.u16_type,
|
.u16_type,
|
||||||
@ -763,6 +777,7 @@ pub const Value = extern union {
|
|||||||
pub fn floatHasFraction(self: Value) bool {
|
pub fn floatHasFraction(self: Value) bool {
|
||||||
return switch (self.tag()) {
|
return switch (self.tag()) {
|
||||||
.ty,
|
.ty,
|
||||||
|
.int_type,
|
||||||
.u8_type,
|
.u8_type,
|
||||||
.i8_type,
|
.i8_type,
|
||||||
.u16_type,
|
.u16_type,
|
||||||
@ -832,6 +847,7 @@ pub const Value = extern union {
|
|||||||
pub fn orderAgainstZero(lhs: Value) std.math.Order {
|
pub fn orderAgainstZero(lhs: Value) std.math.Order {
|
||||||
return switch (lhs.tag()) {
|
return switch (lhs.tag()) {
|
||||||
.ty,
|
.ty,
|
||||||
|
.int_type,
|
||||||
.u8_type,
|
.u8_type,
|
||||||
.i8_type,
|
.i8_type,
|
||||||
.u16_type,
|
.u16_type,
|
||||||
@ -955,6 +971,7 @@ pub const Value = extern union {
|
|||||||
pub fn pointerDeref(self: Value, allocator: *Allocator) error{ AnalysisFail, OutOfMemory }!Value {
|
pub fn pointerDeref(self: Value, allocator: *Allocator) error{ AnalysisFail, OutOfMemory }!Value {
|
||||||
return switch (self.tag()) {
|
return switch (self.tag()) {
|
||||||
.ty,
|
.ty,
|
||||||
|
.int_type,
|
||||||
.u8_type,
|
.u8_type,
|
||||||
.i8_type,
|
.i8_type,
|
||||||
.u16_type,
|
.u16_type,
|
||||||
@ -1028,6 +1045,7 @@ pub const Value = extern union {
|
|||||||
pub fn elemValue(self: Value, allocator: *Allocator, index: usize) error{OutOfMemory}!Value {
|
pub fn elemValue(self: Value, allocator: *Allocator, index: usize) error{OutOfMemory}!Value {
|
||||||
switch (self.tag()) {
|
switch (self.tag()) {
|
||||||
.ty,
|
.ty,
|
||||||
|
.int_type,
|
||||||
.u8_type,
|
.u8_type,
|
||||||
.i8_type,
|
.i8_type,
|
||||||
.u16_type,
|
.u16_type,
|
||||||
@ -1118,6 +1136,7 @@ pub const Value = extern union {
|
|||||||
pub fn isNull(self: Value) bool {
|
pub fn isNull(self: Value) bool {
|
||||||
return switch (self.tag()) {
|
return switch (self.tag()) {
|
||||||
.ty,
|
.ty,
|
||||||
|
.int_type,
|
||||||
.u8_type,
|
.u8_type,
|
||||||
.i8_type,
|
.i8_type,
|
||||||
.u16_type,
|
.u16_type,
|
||||||
@ -1266,6 +1285,12 @@ pub const Value = extern union {
|
|||||||
ty: Type,
|
ty: Type,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const IntType = struct {
|
||||||
|
base: Payload = Payload{ .tag = .int_type },
|
||||||
|
bits: u16,
|
||||||
|
signed: bool,
|
||||||
|
};
|
||||||
|
|
||||||
pub const Repeated = struct {
|
pub const Repeated = struct {
|
||||||
base: Payload = Payload{ .tag = .ty },
|
base: Payload = Payload{ .tag = .ty },
|
||||||
/// This value is repeated some number of times. The amount of times to repeat
|
/// This value is repeated some number of times. The amount of times to repeat
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user