authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-07-21 21:18:51+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-07-21 22:34:14+03:00
logc29c79b17aa4b8ce5fe35ae1fd4f06201ab059ba
tree213ae0f87561515d31d3133c315920d2e06ee0fb
parent7e7d1df4daedecf32d97ad21c85e23bcaac29e7a
signaturelock-open Commit is signed but in an unrecognized format.

stage2: remove some dead code, fix build on aarch64


3 files changed, 36 insertions(+), 26 deletions(-)

build.zig+2
...@@ -13,6 +13,7 @@ const InstallDirectoryOptions = std.build.InstallDirectoryOptions;...@@ -13,6 +13,7 @@ const InstallDirectoryOptions = std.build.InstallDirectoryOptions;
13pub fn build(b: *Builder) !void {13pub fn build(b: *Builder) !void {
14 b.setPreferredReleaseMode(.ReleaseFast);14 b.setPreferredReleaseMode(.ReleaseFast);
15 const mode = b.standardReleaseOptions();15 const mode = b.standardReleaseOptions();
16 const target = b.standardTargetOptions(.{});
1617
17 var docgen_exe = b.addExecutable("docgen", "doc/docgen.zig");18 var docgen_exe = b.addExecutable("docgen", "doc/docgen.zig");
1819
...@@ -54,6 +55,7 @@ pub fn build(b: *Builder) !void {...@@ -54,6 +55,7 @@ pub fn build(b: *Builder) !void {
54 if (!only_install_lib_files) {55 if (!only_install_lib_files) {
55 var exe = b.addExecutable("zig", "src-self-hosted/main.zig");56 var exe = b.addExecutable("zig", "src-self-hosted/main.zig");
56 exe.setBuildMode(mode);57 exe.setBuildMode(mode);
58 exe.setTarget(target);
57 test_step.dependOn(&exe.step);59 test_step.dependOn(&exe.step);
58 b.default_step.dependOn(&exe.step);60 b.default_step.dependOn(&exe.step);
5961
src-self-hosted/astgen.zig+8-25
...@@ -325,7 +325,14 @@ fn identifier(mod: *Module, scope: *Scope, ident: *ast.Node.Identifier) InnerErr...@@ -325,7 +325,14 @@ fn identifier(mod: *Module, scope: *Scope, ident: *ast.Node.Identifier) InnerErr
325 16 => if (is_signed) Value.initTag(.i16_type) else Value.initTag(.u16_type),325 16 => if (is_signed) Value.initTag(.i16_type) else Value.initTag(.u16_type),
326 32 => if (is_signed) Value.initTag(.i32_type) else Value.initTag(.u32_type),326 32 => if (is_signed) Value.initTag(.i32_type) else Value.initTag(.u32_type),
327 64 => if (is_signed) Value.initTag(.i64_type) else Value.initTag(.u64_type),327 64 => if (is_signed) Value.initTag(.i64_type) else Value.initTag(.u64_type),
328 else => return mod.failNode(scope, &ident.base, "TODO implement arbitrary integer bitwidth types", .{}),328 else => {
329 const int_type_payload = try scope.arena().create(Value.Payload.IntType);
330 int_type_payload.* = .{ .signed = is_signed, .bits = bit_count };
331 return mod.addZIRInstConst(scope, src, .{
332 .ty = Type.initTag(.comptime_int),
333 .val = Value.initPayload(&int_type_payload.base),
334 });
335 },
329 };336 };
330 return mod.addZIRInstConst(scope, src, .{337 return mod.addZIRInstConst(scope, src, .{
331 .ty = Type.initTag(.type),338 .ty = Type.initTag(.type),
...@@ -582,30 +589,6 @@ fn getSimplePrimitiveValue(name: []const u8) ?TypedValue {...@@ -582,30 +589,6 @@ fn getSimplePrimitiveValue(name: []const u8) ?TypedValue {
582 .val = Value.initTag(tag),589 .val = Value.initTag(tag),
583 };590 };
584 }591 }
585 if (mem.eql(u8, name, "null")) {
586 return TypedValue{
587 .ty = Type.initTag(.@"null"),
588 .val = Value.initTag(.null_value),
589 };
590 }
591 if (mem.eql(u8, name, "undefined")) {
592 return TypedValue{
593 .ty = Type.initTag(.@"undefined"),
594 .val = Value.initTag(.undef),
595 };
596 }
597 if (mem.eql(u8, name, "true")) {
598 return TypedValue{
599 .ty = Type.initTag(.bool),
600 .val = Value.initTag(.bool_true),
601 };
602 }
603 if (mem.eql(u8, name, "false")) {
604 return TypedValue{
605 .ty = Type.initTag(.bool),
606 .val = Value.initTag(.bool_false),
607 };
608 }
609 return null;592 return null;
610}593}
611594
src-self-hosted/value.zig+26-1
...@@ -70,6 +70,7 @@ pub const Value = extern union {...@@ -70,6 +70,7 @@ pub const Value = extern union {
70 // After this, the tag requires a payload.70 // After this, the tag requires a payload.
7171
72 ty,72 ty,
73 int_type,
73 int_u64,74 int_u64,
74 int_i64,75 int_i64,
75 int_big_positive,76 int_big_positive,
...@@ -178,6 +179,7 @@ pub const Value = extern union {...@@ -178,6 +179,7 @@ pub const Value = extern union {
178 };179 };
179 return Value{ .ptr_otherwise = &new_payload.base };180 return Value{ .ptr_otherwise = &new_payload.base };
180 },181 },
182 .int_type => return self.copyPayloadShallow(allocator, Payload.IntType),
181 .int_u64 => return self.copyPayloadShallow(allocator, Payload.Int_u64),183 .int_u64 => return self.copyPayloadShallow(allocator, Payload.Int_u64),
182 .int_i64 => return self.copyPayloadShallow(allocator, Payload.Int_i64),184 .int_i64 => return self.copyPayloadShallow(allocator, Payload.Int_i64),
183 .int_big_positive => {185 .int_big_positive => {
...@@ -287,6 +289,13 @@ pub const Value = extern union {...@@ -287,6 +289,13 @@ pub const Value = extern union {
287 .bool_true => return out_stream.writeAll("true"),289 .bool_true => return out_stream.writeAll("true"),
288 .bool_false => return out_stream.writeAll("false"),290 .bool_false => return out_stream.writeAll("false"),
289 .ty => return val.cast(Payload.Ty).?.ty.format("", options, out_stream),291 .ty => return val.cast(Payload.Ty).?.ty.format("", options, out_stream),
292 .int_type => {
293 const int_type = val.cast(Payload.IntType).?;
294 return out_stream.print("{}{}", .{
295 if (int_type.signed) "s" else "u",
296 int_type.bits,
297 });
298 },
290 .int_u64 => return std.fmt.formatIntValue(val.cast(Payload.Int_u64).?.int, "", options, out_stream),299 .int_u64 => return std.fmt.formatIntValue(val.cast(Payload.Int_u64).?.int, "", options, out_stream),
291 .int_i64 => return std.fmt.formatIntValue(val.cast(Payload.Int_i64).?.int, "", options, out_stream),300 .int_i64 => return std.fmt.formatIntValue(val.cast(Payload.Int_i64).?.int, "", options, out_stream),
292 .int_big_positive => return out_stream.print("{}", .{val.cast(Payload.IntBigPositive).?.asBigInt()}),301 .int_big_positive => return out_stream.print("{}", .{val.cast(Payload.IntBigPositive).?.asBigInt()}),
...@@ -335,6 +344,7 @@ pub const Value = extern union {...@@ -335,6 +344,7 @@ pub const Value = extern union {
335 pub fn toType(self: Value) Type {344 pub fn toType(self: Value) Type {
336 return switch (self.tag()) {345 return switch (self.tag()) {
337 .ty => self.cast(Payload.Ty).?.ty,346 .ty => self.cast(Payload.Ty).?.ty,
347 .int_type => @panic("TODO int type to type"),
338348
339 .u8_type => Type.initTag(.u8),349 .u8_type => Type.initTag(.u8),
340 .i8_type => Type.initTag(.i8),350 .i8_type => Type.initTag(.i8),
...@@ -404,6 +414,7 @@ pub const Value = extern union {...@@ -404,6 +414,7 @@ pub const Value = extern union {
404 pub fn toBigInt(self: Value, space: *BigIntSpace) BigIntConst {414 pub fn toBigInt(self: Value, space: *BigIntSpace) BigIntConst {
405 switch (self.tag()) {415 switch (self.tag()) {
406 .ty,416 .ty,
417 .int_type,
407 .u8_type,418 .u8_type,
408 .i8_type,419 .i8_type,
409 .u16_type,420 .u16_type,
...@@ -475,6 +486,7 @@ pub const Value = extern union {...@@ -475,6 +486,7 @@ pub const Value = extern union {
475 pub fn toUnsignedInt(self: Value) u64 {486 pub fn toUnsignedInt(self: Value) u64 {
476 switch (self.tag()) {487 switch (self.tag()) {
477 .ty,488 .ty,
489 .int_type,
478 .u8_type,490 .u8_type,
479 .i8_type,491 .i8_type,
480 .u16_type,492 .u16_type,
...@@ -553,7 +565,7 @@ pub const Value = extern union {...@@ -553,7 +565,7 @@ pub const Value = extern union {
553 /// Asserts that the value is a float or an integer.565 /// Asserts that the value is a float or an integer.
554 pub fn toF128(self: Value) f128 {566 pub fn toF128(self: Value) f128 {
555 return switch (self.tag()) {567 return switch (self.tag()) {
556 .float_16 => self.cast(Payload.Float_16).?.val,568 .float_16 => @panic("TODO soft float"),
557 .float_32 => self.cast(Payload.Float_32).?.val,569 .float_32 => self.cast(Payload.Float_32).?.val,
558 .float_64 => self.cast(Payload.Float_64).?.val,570 .float_64 => self.cast(Payload.Float_64).?.val,
559 .float_128 => self.cast(Payload.Float_128).?.val,571 .float_128 => self.cast(Payload.Float_128).?.val,
...@@ -573,6 +585,7 @@ pub const Value = extern union {...@@ -573,6 +585,7 @@ pub const Value = extern union {
573 pub fn intBitCountTwosComp(self: Value) usize {585 pub fn intBitCountTwosComp(self: Value) usize {
574 switch (self.tag()) {586 switch (self.tag()) {
575 .ty,587 .ty,
588 .int_type,
576 .u8_type,589 .u8_type,
577 .i8_type,590 .i8_type,
578 .u16_type,591 .u16_type,
...@@ -650,6 +663,7 @@ pub const Value = extern union {...@@ -650,6 +663,7 @@ pub const Value = extern union {
650 pub fn intFitsInType(self: Value, ty: Type, target: Target) bool {663 pub fn intFitsInType(self: Value, ty: Type, target: Target) bool {
651 switch (self.tag()) {664 switch (self.tag()) {
652 .ty,665 .ty,
666 .int_type,
653 .u8_type,667 .u8_type,
654 .i8_type,668 .i8_type,
655 .u16_type,669 .u16_type,
...@@ -763,6 +777,7 @@ pub const Value = extern union {...@@ -763,6 +777,7 @@ pub const Value = extern union {
763 pub fn floatHasFraction(self: Value) bool {777 pub fn floatHasFraction(self: Value) bool {
764 return switch (self.tag()) {778 return switch (self.tag()) {
765 .ty,779 .ty,
780 .int_type,
766 .u8_type,781 .u8_type,
767 .i8_type,782 .i8_type,
768 .u16_type,783 .u16_type,
...@@ -832,6 +847,7 @@ pub const Value = extern union {...@@ -832,6 +847,7 @@ pub const Value = extern union {
832 pub fn orderAgainstZero(lhs: Value) std.math.Order {847 pub fn orderAgainstZero(lhs: Value) std.math.Order {
833 return switch (lhs.tag()) {848 return switch (lhs.tag()) {
834 .ty,849 .ty,
850 .int_type,
835 .u8_type,851 .u8_type,
836 .i8_type,852 .i8_type,
837 .u16_type,853 .u16_type,
...@@ -955,6 +971,7 @@ pub const Value = extern union {...@@ -955,6 +971,7 @@ pub const Value = extern union {
955 pub fn pointerDeref(self: Value, allocator: *Allocator) error{ AnalysisFail, OutOfMemory }!Value {971 pub fn pointerDeref(self: Value, allocator: *Allocator) error{ AnalysisFail, OutOfMemory }!Value {
956 return switch (self.tag()) {972 return switch (self.tag()) {
957 .ty,973 .ty,
974 .int_type,
958 .u8_type,975 .u8_type,
959 .i8_type,976 .i8_type,
960 .u16_type,977 .u16_type,
...@@ -1028,6 +1045,7 @@ pub const Value = extern union {...@@ -1028,6 +1045,7 @@ pub const Value = extern union {
1028 pub fn elemValue(self: Value, allocator: *Allocator, index: usize) error{OutOfMemory}!Value {1045 pub fn elemValue(self: Value, allocator: *Allocator, index: usize) error{OutOfMemory}!Value {
1029 switch (self.tag()) {1046 switch (self.tag()) {
1030 .ty,1047 .ty,
1048 .int_type,
1031 .u8_type,1049 .u8_type,
1032 .i8_type,1050 .i8_type,
1033 .u16_type,1051 .u16_type,
...@@ -1118,6 +1136,7 @@ pub const Value = extern union {...@@ -1118,6 +1136,7 @@ pub const Value = extern union {
1118 pub fn isNull(self: Value) bool {1136 pub fn isNull(self: Value) bool {
1119 return switch (self.tag()) {1137 return switch (self.tag()) {
1120 .ty,1138 .ty,
1139 .int_type,
1121 .u8_type,1140 .u8_type,
1122 .i8_type,1141 .i8_type,
1123 .u16_type,1142 .u16_type,
...@@ -1266,6 +1285,12 @@ pub const Value = extern union {...@@ -1266,6 +1285,12 @@ pub const Value = extern union {
1266 ty: Type,1285 ty: Type,
1267 };1286 };
12681287
1288 pub const IntType = struct {
1289 base: Payload = Payload{ .tag = .int_type },
1290 bits: u16,
1291 signed: bool,
1292 };
1293
1269 pub const Repeated = struct {1294 pub const Repeated = struct {
1270 base: Payload = Payload{ .tag = .ty },1295 base: Payload = Payload{ .tag = .ty },
1271 /// This value is repeated some number of times. The amount of times to repeat1296 /// This value is repeated some number of times. The amount of times to repeat