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;
1313pub fn build(b: *Builder) !void {
1414 b.setPreferredReleaseMode(.ReleaseFast);
1515 const mode = b.standardReleaseOptions();
16 const target = b.standardTargetOptions(.{});
1617
1718 var docgen_exe = b.addExecutable("docgen", "doc/docgen.zig");
1819
......@@ -54,6 +55,7 @@ pub fn build(b: *Builder) !void {
5455 if (!only_install_lib_files) {
5556 var exe = b.addExecutable("zig", "src-self-hosted/main.zig");
5657 exe.setBuildMode(mode);
58 exe.setTarget(target);
5759 test_step.dependOn(&exe.step);
5860 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
325325 16 => if (is_signed) Value.initTag(.i16_type) else Value.initTag(.u16_type),
326326 32 => if (is_signed) Value.initTag(.i32_type) else Value.initTag(.u32_type),
327327 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 },
329336 };
330337 return mod.addZIRInstConst(scope, src, .{
331338 .ty = Type.initTag(.type),
......@@ -582,30 +589,6 @@ fn getSimplePrimitiveValue(name: []const u8) ?TypedValue {
582589 .val = Value.initTag(tag),
583590 };
584591 }
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 }
609592 return null;
610593}
611594
src-self-hosted/value.zig+26-1
......@@ -70,6 +70,7 @@ pub const Value = extern union {
7070 // After this, the tag requires a payload.
7171
7272 ty,
73 int_type,
7374 int_u64,
7475 int_i64,
7576 int_big_positive,
......@@ -178,6 +179,7 @@ pub const Value = extern union {
178179 };
179180 return Value{ .ptr_otherwise = &new_payload.base };
180181 },
182 .int_type => return self.copyPayloadShallow(allocator, Payload.IntType),
181183 .int_u64 => return self.copyPayloadShallow(allocator, Payload.Int_u64),
182184 .int_i64 => return self.copyPayloadShallow(allocator, Payload.Int_i64),
183185 .int_big_positive => {
......@@ -287,6 +289,13 @@ pub const Value = extern union {
287289 .bool_true => return out_stream.writeAll("true"),
288290 .bool_false => return out_stream.writeAll("false"),
289291 .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 },
290299 .int_u64 => return std.fmt.formatIntValue(val.cast(Payload.Int_u64).?.int, "", options, out_stream),
291300 .int_i64 => return std.fmt.formatIntValue(val.cast(Payload.Int_i64).?.int, "", options, out_stream),
292301 .int_big_positive => return out_stream.print("{}", .{val.cast(Payload.IntBigPositive).?.asBigInt()}),
......@@ -335,6 +344,7 @@ pub const Value = extern union {
335344 pub fn toType(self: Value) Type {
336345 return switch (self.tag()) {
337346 .ty => self.cast(Payload.Ty).?.ty,
347 .int_type => @panic("TODO int type to type"),
338348
339349 .u8_type => Type.initTag(.u8),
340350 .i8_type => Type.initTag(.i8),
......@@ -404,6 +414,7 @@ pub const Value = extern union {
404414 pub fn toBigInt(self: Value, space: *BigIntSpace) BigIntConst {
405415 switch (self.tag()) {
406416 .ty,
417 .int_type,
407418 .u8_type,
408419 .i8_type,
409420 .u16_type,
......@@ -475,6 +486,7 @@ pub const Value = extern union {
475486 pub fn toUnsignedInt(self: Value) u64 {
476487 switch (self.tag()) {
477488 .ty,
489 .int_type,
478490 .u8_type,
479491 .i8_type,
480492 .u16_type,
......@@ -553,7 +565,7 @@ pub const Value = extern union {
553565 /// Asserts that the value is a float or an integer.
554566 pub fn toF128(self: Value) f128 {
555567 return switch (self.tag()) {
556 .float_16 => self.cast(Payload.Float_16).?.val,
568 .float_16 => @panic("TODO soft float"),
557569 .float_32 => self.cast(Payload.Float_32).?.val,
558570 .float_64 => self.cast(Payload.Float_64).?.val,
559571 .float_128 => self.cast(Payload.Float_128).?.val,
......@@ -573,6 +585,7 @@ pub const Value = extern union {
573585 pub fn intBitCountTwosComp(self: Value) usize {
574586 switch (self.tag()) {
575587 .ty,
588 .int_type,
576589 .u8_type,
577590 .i8_type,
578591 .u16_type,
......@@ -650,6 +663,7 @@ pub const Value = extern union {
650663 pub fn intFitsInType(self: Value, ty: Type, target: Target) bool {
651664 switch (self.tag()) {
652665 .ty,
666 .int_type,
653667 .u8_type,
654668 .i8_type,
655669 .u16_type,
......@@ -763,6 +777,7 @@ pub const Value = extern union {
763777 pub fn floatHasFraction(self: Value) bool {
764778 return switch (self.tag()) {
765779 .ty,
780 .int_type,
766781 .u8_type,
767782 .i8_type,
768783 .u16_type,
......@@ -832,6 +847,7 @@ pub const Value = extern union {
832847 pub fn orderAgainstZero(lhs: Value) std.math.Order {
833848 return switch (lhs.tag()) {
834849 .ty,
850 .int_type,
835851 .u8_type,
836852 .i8_type,
837853 .u16_type,
......@@ -955,6 +971,7 @@ pub const Value = extern union {
955971 pub fn pointerDeref(self: Value, allocator: *Allocator) error{ AnalysisFail, OutOfMemory }!Value {
956972 return switch (self.tag()) {
957973 .ty,
974 .int_type,
958975 .u8_type,
959976 .i8_type,
960977 .u16_type,
......@@ -1028,6 +1045,7 @@ pub const Value = extern union {
10281045 pub fn elemValue(self: Value, allocator: *Allocator, index: usize) error{OutOfMemory}!Value {
10291046 switch (self.tag()) {
10301047 .ty,
1048 .int_type,
10311049 .u8_type,
10321050 .i8_type,
10331051 .u16_type,
......@@ -1118,6 +1136,7 @@ pub const Value = extern union {
11181136 pub fn isNull(self: Value) bool {
11191137 return switch (self.tag()) {
11201138 .ty,
1139 .int_type,
11211140 .u8_type,
11221141 .i8_type,
11231142 .u16_type,
......@@ -1266,6 +1285,12 @@ pub const Value = extern union {
12661285 ty: Type,
12671286 };
12681287
1288 pub const IntType = struct {
1289 base: Payload = Payload{ .tag = .int_type },
1290 bits: u16,
1291 signed: bool,
1292 };
1293
12691294 pub const Repeated = struct {
12701295 base: Payload = Payload{ .tag = .ty },
12711296 /// This value is repeated some number of times. The amount of times to repeat