authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2019-11-07 00:56:16+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2019-11-07 10:30:47+02:00
log7000316113e44ab9c6bdacaef17915d25fb764ed
tree8b9ec784be3b1dd4def9fa15e89392145f28840b
parent9394d14815d1a3105f8ea9b3a1a73ea4bc834e7a
signaturelock-open Commit is signed but in an unrecognized format.

self hosted compiler: fix calling convention in type.zig


1 files changed, 12 insertions(+), 48 deletions(-)

src-self-hosted/type.zig+12-48
......@@ -265,16 +265,7 @@ pub const Type = struct {
265265
266266 pub const Generic = struct {
267267 param_count: usize,
268 cc: CC,
269
270 pub const CC = union(CallingConvention) {
271 Auto,
272 C,
273 Cold,
274 Naked,
275 Stdcall,
276 Async: *Type, // allocator type
277 };
268 cc: CallingConvention,
278269 };
279270
280271 pub fn hash(self: *const Key) u32 {
......@@ -283,10 +274,7 @@ pub const Type = struct {
283274 switch (self.data) {
284275 Kind.Generic => |generic| {
285276 result +%= hashAny(generic.param_count, 1);
286 switch (generic.cc) {
287 CallingConvention.Async => |allocator_type| result +%= hashAny(allocator_type, 2),
288 else => result +%= hashAny(CallingConvention(generic.cc), 3),
289 }
277 result +%= hashAny(generic.cc, 3);
290278 },
291279 Kind.Normal => |normal| {
292280 result +%= hashAny(normal.return_type, 4);
......@@ -311,14 +299,7 @@ pub const Type = struct {
311299 Kind.Generic => |*self_generic| {
312300 const other_generic = &other.data.Generic;
313301 if (self_generic.param_count != other_generic.param_count) return false;
314 if (CallingConvention(self_generic.cc) != CallingConvention(other_generic.cc)) return false;
315 switch (self_generic.cc) {
316 CallingConvention.Async => |self_allocator_type| {
317 const other_allocator_type = other_generic.cc.Async;
318 if (self_allocator_type != other_allocator_type) return false;
319 },
320 else => {},
321 }
302 if (self_generic.cc != other_generic.cc) return false;
322303 },
323304 Kind.Normal => |*self_normal| {
324305 const other_normal = &other.data.Normal;
......@@ -337,12 +318,7 @@ pub const Type = struct {
337318
338319 pub fn deref(key: Key, comp: *Compilation) void {
339320 switch (key.data) {
340 Kind.Generic => |generic| {
341 switch (generic.cc) {
342 CallingConvention.Async => |allocator_type| allocator_type.base.deref(comp),
343 else => {},
344 }
345 },
321 Kind.Generic => {},
346322 Kind.Normal => |normal| {
347323 normal.return_type.base.deref(comp);
348324 for (normal.params) |param| {
......@@ -354,12 +330,7 @@ pub const Type = struct {
354330
355331 pub fn ref(key: Key) void {
356332 switch (key.data) {
357 Kind.Generic => |generic| {
358 switch (generic.cc) {
359 CallingConvention.Async => |allocator_type| allocator_type.base.ref(),
360 else => {},
361 }
362 },
333 Kind.Generic => {},
363334 Kind.Normal => |normal| {
364335 normal.return_type.base.ref();
365336 for (normal.params) |param| {
......@@ -370,14 +341,7 @@ pub const Type = struct {
370341 }
371342 };
372343
373 pub const CallingConvention = enum {
374 Auto,
375 C,
376 Cold,
377 Naked,
378 Stdcall,
379 Async,
380 };
344 const CallingConvention = builtin.CallingConvention;
381345
382346 pub const Param = struct {
383347 is_noalias: bool,
......@@ -386,12 +350,12 @@ pub const Type = struct {
386350
387351 fn ccFnTypeStr(cc: CallingConvention) []const u8 {
388352 return switch (cc) {
389 CallingConvention.Auto => "",
390 CallingConvention.C => "extern ",
391 CallingConvention.Cold => "coldcc ",
392 CallingConvention.Naked => "nakedcc ",
393 CallingConvention.Stdcall => "stdcallcc ",
394 CallingConvention.Async => unreachable,
353 .Auto => "",
354 .C => "extern ",
355 .Cold => "coldcc ",
356 .Naked => "nakedcc ",
357 .Stdcall => "stdcallcc ",
358 .Async => "async ",
395359 };
396360 }
397361