| author | |
| committer | |
| log | 17e0afd0e5d8850171bdfeba9456ebfd38d11e3a |
| tree | b07bd9d85134bc610c35621dea2d6a5d4a1ab36d |
| parent | d092c752f3e2e0e162e9bab57d3f84de6ccde7c9 |
10 files changed, 465 insertions(+), 7 deletions(-)
lib/compiler/translate-c/Translator.zig+4| ... | ... | @@ -475,8 +475,12 @@ pub const builtin_typedef_map = std.StaticStringMap([]const u8).initComptime(.{ |
| 475 | 475 | .{ "int8_t", "i8" }, |
| 476 | 476 | .{ "uint16_t", "u16" }, |
| 477 | 477 | .{ "int16_t", "i16" }, |
| 478 | .{ "uint24_t", "u24" }, | |
| 479 | .{ "int24_t", "i24" }, | |
| 478 | 480 | .{ "uint32_t", "u32" }, |
| 479 | 481 | .{ "int32_t", "i32" }, |
| 482 | .{ "uint48_t", "u48" }, | |
| 483 | .{ "int48_t", "i48" }, | |
| 480 | 484 | .{ "uint64_t", "u64" }, |
| 481 | 485 | .{ "int64_t", "i64" }, |
| 482 | 486 | .{ "intptr_t", "isize" }, |
lib/std/Target.zig+50-3| ... | ... | @@ -68,6 +68,8 @@ pub const Os = struct { |
| 68 | 68 | opengl, |
| 69 | 69 | vulkan, |
| 70 | 70 | |
| 71 | tios, | |
| 72 | ||
| 71 | 73 | // LLVM tags deliberately omitted: |
| 72 | 74 | // - bridgeos |
| 73 | 75 | // - cheriotrtos |
| ... | ... | @@ -207,6 +209,8 @@ pub const Os = struct { |
| 207 | 209 | .opencl, |
| 208 | 210 | .opengl, |
| 209 | 211 | .vulkan, |
| 212 | ||
| 213 | .tios, | |
| 210 | 214 | => .semver, |
| 211 | 215 | |
| 212 | 216 | .hurd => .hurd, |
| ... | ... | @@ -670,6 +674,12 @@ pub const Os = struct { |
| 670 | 674 | .max = .{ .major = 4, .minor = 6, .patch = 0 }, |
| 671 | 675 | }, |
| 672 | 676 | }, |
| 677 | .tios => .{ | |
| 678 | .semver = .{ | |
| 679 | .min = .{ .major = 5, .minor = 0, .patch = 0 }, | |
| 680 | .max = .{ .major = 5, .minor = 8, .patch = 4 }, | |
| 681 | }, | |
| 682 | }, | |
| 673 | 683 | .vulkan => .{ |
| 674 | 684 | .semver = .{ |
| 675 | 685 | .min = .{ .major = 1, .minor = 2, .patch = 0 }, |
| ... | ... | @@ -758,6 +768,7 @@ pub const wasm = @import("Target/wasm.zig"); |
| 758 | 768 | pub const x86 = @import("Target/x86.zig"); |
| 759 | 769 | pub const xcore = @import("Target/xcore.zig"); |
| 760 | 770 | pub const xtensa = @import("Target/xtensa.zig"); |
| 771 | pub const z80 = @import("Target/generic.zig"); | |
| 761 | 772 | |
| 762 | 773 | pub const Abi = enum { |
| 763 | 774 | none, |
| ... | ... | @@ -942,6 +953,7 @@ pub const Abi = enum { |
| 942 | 953 | .opencl, |
| 943 | 954 | .opengl, |
| 944 | 955 | .vulkan, |
| 956 | .tios, | |
| 945 | 957 | => .none, |
| 946 | 958 | }; |
| 947 | 959 | } |
| ... | ... | @@ -1068,6 +1080,7 @@ pub fn toElfMachine(target: *const Target) std.elf.EM { |
| 1068 | 1080 | .avr => .AVR, |
| 1069 | 1081 | .bpfeb, .bpfel => .BPF, |
| 1070 | 1082 | .csky => .CSKY, |
| 1083 | .ez80 => .Z80, | |
| 1071 | 1084 | .hexagon => .QDSP6, |
| 1072 | 1085 | .hppa, .hppa64 => .PARISC, |
| 1073 | 1086 | .kalimba => .CSR_KALIMBA, |
| ... | ... | @@ -1130,6 +1143,7 @@ pub fn toCoffMachine(target: *const Target) std.coff.IMAGE.FILE.MACHINE { |
| 1130 | 1143 | .bpfeb, |
| 1131 | 1144 | .bpfel, |
| 1132 | 1145 | .csky, |
| 1146 | .ez80, | |
| 1133 | 1147 | .hexagon, |
| 1134 | 1148 | .hppa, |
| 1135 | 1149 | .hppa64, |
| ... | ... | @@ -1336,6 +1350,7 @@ pub const Cpu = struct { |
| 1336 | 1350 | bpfeb, |
| 1337 | 1351 | bpfel, |
| 1338 | 1352 | csky, |
| 1353 | ez80, | |
| 1339 | 1354 | hexagon, |
| 1340 | 1355 | hppa, |
| 1341 | 1356 | hppa64, |
| ... | ... | @@ -1437,6 +1452,7 @@ pub const Cpu = struct { |
| 1437 | 1452 | x86, |
| 1438 | 1453 | xcore, |
| 1439 | 1454 | xtensa, |
| 1455 | z80, | |
| 1440 | 1456 | }; |
| 1441 | 1457 | |
| 1442 | 1458 | pub inline fn family(arch: Arch) Family { |
| ... | ... | @@ -1449,6 +1465,7 @@ pub const Cpu = struct { |
| 1449 | 1465 | .avr => .avr, |
| 1450 | 1466 | .bpfeb, .bpfel => .bpf, |
| 1451 | 1467 | .csky => .csky, |
| 1468 | .ez80 => .z80, | |
| 1452 | 1469 | .hexagon => .hexagon, |
| 1453 | 1470 | .hppa, .hppa64 => .hppa, |
| 1454 | 1471 | .kalimba => .kalimba, |
| ... | ... | @@ -1678,6 +1695,7 @@ pub const Cpu = struct { |
| 1678 | 1695 | .x86_64, |
| 1679 | 1696 | .xcore, |
| 1680 | 1697 | .xtensa, |
| 1698 | .ez80, | |
| 1681 | 1699 | => .little, |
| 1682 | 1700 | |
| 1683 | 1701 | .aarch64_be, |
| ... | ... | @@ -1948,6 +1966,10 @@ pub const Cpu = struct { |
| 1948 | 1966 | .spirv_fragment, |
| 1949 | 1967 | .spirv_vertex, |
| 1950 | 1968 | => &.{ .spirv32, .spirv64 }, |
| 1969 | ||
| 1970 | .ez80_cet, | |
| 1971 | .ez80_tiflags, | |
| 1972 | => &.{.ez80}, | |
| 1951 | 1973 | }; |
| 1952 | 1974 | } |
| 1953 | 1975 | }; |
| ... | ... | @@ -2236,6 +2258,7 @@ pub fn requiresLibC(target: *const Target) bool { |
| 2236 | 2258 | .plan9, |
| 2237 | 2259 | .other, |
| 2238 | 2260 | .@"3ds", |
| 2261 | .tios, | |
| 2239 | 2262 | => false, |
| 2240 | 2263 | }; |
| 2241 | 2264 | } |
| ... | ... | @@ -2398,6 +2421,8 @@ pub const DynamicLinker = struct { |
| 2398 | 2421 | .ps5, |
| 2399 | 2422 | .psp, |
| 2400 | 2423 | .vita, |
| 2424 | ||
| 2425 | .tios, | |
| 2401 | 2426 | => .none, |
| 2402 | 2427 | }; |
| 2403 | 2428 | } |
| ... | ... | @@ -2815,6 +2840,8 @@ pub const DynamicLinker = struct { |
| 2815 | 2840 | .opencl, |
| 2816 | 2841 | .opengl, |
| 2817 | 2842 | .vulkan, |
| 2843 | ||
| 2844 | .tios, | |
| 2818 | 2845 | => none, |
| 2819 | 2846 | |
| 2820 | 2847 | // TODO go over each item in this list and either move it to the above list, or |
| ... | ... | @@ -2849,6 +2876,9 @@ pub fn ptrBitWidth_arch_abi(cpu_arch: Cpu.Arch, abi: Abi) u16 { |
| 2849 | 2876 | .x86_16, |
| 2850 | 2877 | => 16, |
| 2851 | 2878 | |
| 2879 | .ez80, | |
| 2880 | => 24, | |
| 2881 | ||
| 2852 | 2882 | .arc, |
| 2853 | 2883 | .arceb, |
| 2854 | 2884 | .arm, |
| ... | ... | @@ -2917,6 +2947,8 @@ pub fn ptrBitWidth(target: *const Target) u16 { |
| 2917 | 2947 | pub fn stackAlignment(target: *const Target) u16 { |
| 2918 | 2948 | // Overrides for when the stack alignment is not equal to the pointer width. |
| 2919 | 2949 | switch (target.cpu.arch) { |
| 2950 | .ez80, | |
| 2951 | => return 1, | |
| 2920 | 2952 | .m68k, |
| 2921 | 2953 | => return 2, |
| 2922 | 2954 | .amdgcn, |
| ... | ... | @@ -2997,6 +3029,7 @@ pub fn cCharSignedness(target: *const Target) std.builtin.Signedness { |
| 2997 | 3029 | .arc, |
| 2998 | 3030 | .arceb, |
| 2999 | 3031 | .csky, |
| 3032 | .ez80, | |
| 3000 | 3033 | .hexagon, |
| 3001 | 3034 | .msp430, |
| 3002 | 3035 | .powerpc, |
| ... | ... | @@ -3364,6 +3397,13 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 { |
| 3364 | 3397 | .long, .ulong => return 64, |
| 3365 | 3398 | .longlong, .ulonglong, .double, .longdouble => return 64, |
| 3366 | 3399 | }, |
| 3400 | .tios => switch (c_type) { | |
| 3401 | .char => return 8, | |
| 3402 | .short, .ushort => return 16, | |
| 3403 | .int, .uint => return 24, | |
| 3404 | .long, .ulong, .float, .double => return 32, | |
| 3405 | .longlong, .ulonglong, .longdouble => return 64, | |
| 3406 | }, | |
| 3367 | 3407 | |
| 3368 | 3408 | .ps3, |
| 3369 | 3409 | .contiki, |
| ... | ... | @@ -3376,7 +3416,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 { |
| 3376 | 3416 | pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 { |
| 3377 | 3417 | // Overrides for unusual alignments |
| 3378 | 3418 | switch (target.cpu.arch) { |
| 3379 | .avr => return 1, | |
| 3419 | .avr, .ez80 => return 1, | |
| 3380 | 3420 | .x86 => switch (target.os.tag) { |
| 3381 | 3421 | .windows, .uefi => switch (c_type) { |
| 3382 | 3422 | .longlong, .ulonglong, .double => return 8, |
| ... | ... | @@ -3406,6 +3446,8 @@ pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 { |
| 3406 | 3446 | return @min( |
| 3407 | 3447 | std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8), |
| 3408 | 3448 | @as(u16, switch (target.cpu.arch) { |
| 3449 | .ez80 => 1, | |
| 3450 | ||
| 3409 | 3451 | .msp430, |
| 3410 | 3452 | .x86_16, |
| 3411 | 3453 | => 2, |
| ... | ... | @@ -3484,7 +3526,7 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 { |
| 3484 | 3526 | .longdouble => return 4, |
| 3485 | 3527 | else => {}, |
| 3486 | 3528 | }, |
| 3487 | .avr => return 1, | |
| 3529 | .avr, .ez80 => return 1, | |
| 3488 | 3530 | .x86 => switch (target.os.tag) { |
| 3489 | 3531 | .windows, .uefi => switch (c_type) { |
| 3490 | 3532 | .longdouble => switch (target.abi) { |
| ... | ... | @@ -3516,6 +3558,8 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 { |
| 3516 | 3558 | return @min( |
| 3517 | 3559 | std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8), |
| 3518 | 3560 | @as(u16, switch (target.cpu.arch) { |
| 3561 | .ez80 => 1, | |
| 3562 | ||
| 3519 | 3563 | .x86_16, .msp430 => 2, |
| 3520 | 3564 | |
| 3521 | 3565 | .arc, |
| ... | ... | @@ -3587,7 +3631,9 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 { |
| 3587 | 3631 | |
| 3588 | 3632 | pub fn cMaxIntAlignment(target: *const Target) u16 { |
| 3589 | 3633 | return switch (target.cpu.arch) { |
| 3590 | .avr => 1, | |
| 3634 | .avr, | |
| 3635 | .ez80, | |
| 3636 | => 1, | |
| 3591 | 3637 | |
| 3592 | 3638 | .msp430, .x86_16 => 2, |
| 3593 | 3639 | |
| ... | ... | @@ -3726,6 +3772,7 @@ pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention |
| 3726 | 3772 | .amdgcn => .{ .amdgcn_device = .{} }, |
| 3727 | 3773 | .nvptx, .nvptx64 => .nvptx_device, |
| 3728 | 3774 | .spirv32, .spirv64 => .spirv_device, |
| 3775 | .ez80 => .ez80_cet, | |
| 3729 | 3776 | }; |
| 3730 | 3777 | } |
| 3731 | 3778 |
lib/std/builtin.zig+4| ... | ... | @@ -341,6 +341,10 @@ pub const CallingConvention = union(enum(u8)) { |
| 341 | 341 | spirv_fragment, |
| 342 | 342 | spirv_vertex, |
| 343 | 343 | |
| 344 | // Calling conventions for the `ez80` architecture. | |
| 345 | ez80_cet, | |
| 346 | ez80_tiflags, | |
| 347 | ||
| 344 | 348 | /// Options shared across most calling conventions. |
| 345 | 349 | pub const CommonOptions = struct { |
| 346 | 350 | /// The boundary the stack is aligned to when the function is called. |
lib/zig.h+340-1| ... | ... | @@ -79,6 +79,9 @@ |
| 79 | 79 | #elif defined(__I86__) |
| 80 | 80 | #define zig_x86_16 |
| 81 | 81 | #define zig_x86 |
| 82 | #elif defined (__ez80) | |
| 83 | #define zig_ez80 | |
| 84 | #define zig_z80 | |
| 82 | 85 | #endif |
| 83 | 86 | |
| 84 | 87 | #if defined(zig_msvc) || __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
| ... | ... | @@ -409,6 +412,8 @@ |
| 409 | 412 | #define zig_trap() __asm__ volatile("int $0x3") |
| 410 | 413 | #elif defined(zig_x86) |
| 411 | 414 | #define zig_trap() __asm__ volatile("ud2") |
| 415 | #elif defined(zig_z80) | |
| 416 | #define zig_trap() __asm__ volatile("rst 00h") | |
| 412 | 417 | #else |
| 413 | 418 | #define zig_trap() zig_trap_unavailable |
| 414 | 419 | #endif |
| ... | ... | @@ -511,7 +516,7 @@ zig_extern void *memcpy (void *zig_restrict, void const *zig_restrict, size_t); |
| 511 | 516 | zig_extern void *memset (void *, int, size_t); |
| 512 | 517 | zig_extern void *memmove (void *, void const *, size_t); |
| 513 | 518 | |
| 514 | /* ================ Bool and 8/16/32/64-bit Integer Support ================= */ | |
| 519 | /* ================ Bool and 8/16/24/32/48/64-bit Integer Support ================= */ | |
| 515 | 520 | |
| 516 | 521 | #include <limits.h> |
| 517 | 522 | |
| ... | ... | @@ -590,6 +595,16 @@ typedef signed long long int16_t; |
| 590 | 595 | #define INT16_MAX ( INT16_C(0x7FFF)) |
| 591 | 596 | #define UINT16_MAX ( INT16_C(0xFFFF)) |
| 592 | 597 | |
| 598 | #if defined(zig_ez80) | |
| 599 | typedef unsigned int uint24_t; | |
| 600 | typedef signed int int24_t; | |
| 601 | #define INT24_C(c) c | |
| 602 | #define UINT24_C(c) c##U | |
| 603 | #endif | |
| 604 | #define INT24_MIN (~INT24_C(0x7FFF)) | |
| 605 | #define INT24_MAX ( INT24_C(0x7FFF)) | |
| 606 | #define UINT24_MAX ( INT24_C(0xFFFF)) | |
| 607 | ||
| 593 | 608 | #if SCHAR_MIN == ~0x7FFFFFFF && SCHAR_MAX == 0x7FFFFFFF && UCHAR_MAX == 0xFFFFFFFF |
| 594 | 609 | typedef unsigned char uint32_t; |
| 595 | 610 | typedef signed char int32_t; |
| ... | ... | @@ -620,6 +635,17 @@ typedef signed long long int32_t; |
| 620 | 635 | #define INT32_MAX ( INT32_C(0x7FFFFFFF)) |
| 621 | 636 | #define UINT32_MAX ( INT32_C(0xFFFFFFFF)) |
| 622 | 637 | |
| 638 | #if defined(zig_ez80) | |
| 639 | typedef unsigned __int48 uint48_t; | |
| 640 | typedef signed __int48 int48_t; | |
| 641 | #define INT48_C(c) c | |
| 642 | /* no suffix */ | |
| 643 | #define UINT48_C(c) ((uint48_t)(c)) | |
| 644 | #endif | |
| 645 | #define INT48_MIN (~INT48_C(0x7FFFFFFFFFFF)) | |
| 646 | #define INT48_MAX ( INT48_C(0x7FFFFFFFFFFF)) | |
| 647 | #define UINT48_MAX ( INT48_C(0xFFFFFFFFFFFF)) | |
| 648 | ||
| 623 | 649 | #if SCHAR_MIN == ~0x7FFFFFFFFFFFFFFF && SCHAR_MAX == 0x7FFFFFFFFFFFFFFF && UCHAR_MAX == 0xFFFFFFFFFFFFFFFF |
| 624 | 650 | typedef unsigned char uint64_t; |
| 625 | 651 | typedef signed char int64_t; |
| ... | ... | @@ -663,10 +689,18 @@ typedef ptrdiff_t intptr_t; |
| 663 | 689 | #define zig_maxInt_i16 INT16_MAX |
| 664 | 690 | #define zig_minInt_u16 UINT16_C(0) |
| 665 | 691 | #define zig_maxInt_u16 UINT16_MAX |
| 692 | #define zig_minInt_i24 INT24_MIN | |
| 693 | #define zig_maxInt_i24 INT24_MAX | |
| 694 | #define zig_minInt_u24 UINT24_C(0) | |
| 695 | #define zig_maxInt_u24 UINT24_MAX | |
| 666 | 696 | #define zig_minInt_i32 INT32_MIN |
| 667 | 697 | #define zig_maxInt_i32 INT32_MAX |
| 668 | 698 | #define zig_minInt_u32 UINT32_C(0) |
| 669 | 699 | #define zig_maxInt_u32 UINT32_MAX |
| 700 | #define zig_minInt_i48 INT48_MIN | |
| 701 | #define zig_maxInt_i48 INT48_MAX | |
| 702 | #define zig_minInt_u48 UINT48_C(0) | |
| 703 | #define zig_maxInt_u48 UINT48_MAX | |
| 670 | 704 | #define zig_minInt_i64 INT64_MIN |
| 671 | 705 | #define zig_maxInt_i64 INT64_MAX |
| 672 | 706 | #define zig_minInt_u64 UINT64_C(0) |
| ... | ... | @@ -786,6 +820,17 @@ zig_int_helpers(16, unsigned long long) |
| 786 | 820 | #else |
| 787 | 821 | zig_int_helpers(16, uint16_t) |
| 788 | 822 | #endif |
| 823 | #if defined(zig_ez80) | |
| 824 | #if UINT24_MAX <= UINT_MAX | |
| 825 | zig_int_helpers(24, unsigned int) | |
| 826 | #elif UINT24_MAX <= ULONG_MAX | |
| 827 | zig_int_helpers(24, unsigned long) | |
| 828 | #elif UINT24_MAX <= ULLONG_MAX | |
| 829 | zig_int_helpers(24, unsigned long long) | |
| 830 | #else | |
| 831 | zig_int_helpers(24, uint24_t) | |
| 832 | #endif | |
| 833 | #endif | |
| 789 | 834 | #if UINT32_MAX <= UINT_MAX |
| 790 | 835 | zig_int_helpers(32, unsigned int) |
| 791 | 836 | #elif UINT32_MAX <= ULONG_MAX |
| ... | ... | @@ -795,6 +840,17 @@ zig_int_helpers(32, unsigned long long) |
| 795 | 840 | #else |
| 796 | 841 | zig_int_helpers(32, uint32_t) |
| 797 | 842 | #endif |
| 843 | #if defined(zig_ez80) | |
| 844 | #if UINT24_MAX <= UINT_MAX | |
| 845 | zig_int_helpers(48, unsigned int) | |
| 846 | #elif UINT24_MAX <= ULONG_MAX | |
| 847 | zig_int_helpers(48, unsigned long) | |
| 848 | #elif UINT24_MAX <= ULLONG_MAX | |
| 849 | zig_int_helpers(48, unsigned long long) | |
| 850 | #else | |
| 851 | zig_int_helpers(48, uint48_t) | |
| 852 | #endif | |
| 853 | #endif | |
| 798 | 854 | #if UINT64_MAX <= UINT_MAX |
| 799 | 855 | zig_int_helpers(64, unsigned int) |
| 800 | 856 | #elif UINT64_MAX <= ULONG_MAX |
| ... | ... | @@ -909,6 +965,66 @@ static inline bool zig_addo_i16(int16_t *res, int16_t lhs, int16_t rhs, uint8_t |
| 909 | 965 | #endif |
| 910 | 966 | } |
| 911 | 967 | |
| 968 | #if defined(zig_ez80) | |
| 969 | static inline bool zig_addo_u24(uint24_t *res, uint24_t lhs, uint24_t rhs, uint8_t bits) { | |
| 970 | #if zig_has_builtin(add_overflow) || defined(zig_gcc) | |
| 971 | uint24_t full_res; | |
| 972 | bool overflow = __builtin_add_overflow(lhs, rhs, &full_res); | |
| 973 | *res = zig_wrap_u24(full_res, bits); | |
| 974 | return overflow || full_res < zig_minInt_u(24, bits) || full_res > zig_maxInt_u(24, bits); | |
| 975 | #else | |
| 976 | uint32_t full_res; | |
| 977 | bool overflow = zig_addo_u32(&full_res, lhs, rhs, bits); | |
| 978 | *res = (uint24_t)full_res; | |
| 979 | return overflow; | |
| 980 | #endif | |
| 981 | } | |
| 982 | ||
| 983 | static inline bool zig_addo_i24(int24_t *res, int24_t lhs, int24_t rhs, uint8_t bits) { | |
| 984 | #if zig_has_builtin(add_overflow) || defined(zig_gcc) | |
| 985 | int24_t full_res; | |
| 986 | bool overflow = __builtin_add_overflow(lhs, rhs, &full_res); | |
| 987 | *res = zig_wrap_i24(full_res, bits); | |
| 988 | return overflow || full_res < zig_minInt_i(24, bits) || full_res > zig_maxInt_i(24, bits); | |
| 989 | #else | |
| 990 | int32_t full_res; | |
| 991 | bool overflow = zig_addo_i32(&full_res, lhs, rhs, bits); | |
| 992 | *res = (int24_t)full_res; | |
| 993 | return overflow; | |
| 994 | #endif | |
| 995 | } | |
| 996 | #endif | |
| 997 | ||
| 998 | #if defined(zig_ez80) | |
| 999 | static inline bool zig_addo_u48(uint48_t *res, uint48_t lhs, uint48_t rhs, uint8_t bits) { | |
| 1000 | #if zig_has_builtin(add_overflow) || defined(zig_gcc) | |
| 1001 | uint48_t full_res; | |
| 1002 | bool overflow = __builtin_add_overflow(lhs, rhs, &full_res); | |
| 1003 | *res = zig_wrap_u48(full_res, bits); | |
| 1004 | return overflow || full_res < zig_minInt_u(48, bits) || full_res > zig_maxInt_u(48, bits); | |
| 1005 | #else | |
| 1006 | uint64_t full_res; | |
| 1007 | bool overflow = zig_addo_u64(&full_res, lhs, rhs, bits); | |
| 1008 | *res = (uint48_t)full_res; | |
| 1009 | return overflow; | |
| 1010 | #endif | |
| 1011 | } | |
| 1012 | ||
| 1013 | static inline bool zig_addo_i48(int48_t *res, int48_t lhs, int48_t rhs, uint8_t bits) { | |
| 1014 | #if zig_has_builtin(add_overflow) || defined(zig_gcc) | |
| 1015 | int48_t full_res; | |
| 1016 | bool overflow = __builtin_add_overflow(lhs, rhs, &full_res); | |
| 1017 | *res = zig_wrap_i48(full_res, bits); | |
| 1018 | return overflow || full_res < zig_minInt_i(48, bits) || full_res > zig_maxInt_i(48, bits); | |
| 1019 | #else | |
| 1020 | int64_t full_res; | |
| 1021 | bool overflow = zig_addo_i64(&full_res, lhs, rhs, bits); | |
| 1022 | *res = (int48_t)full_res; | |
| 1023 | return overflow; | |
| 1024 | #endif | |
| 1025 | } | |
| 1026 | #endif | |
| 1027 | ||
| 912 | 1028 | static inline bool zig_subo_u32(uint32_t *res, uint32_t lhs, uint32_t rhs, uint8_t bits) { |
| 913 | 1029 | #if zig_has_builtin(sub_overflow) || defined(zig_gcc) |
| 914 | 1030 | uint32_t full_res; |
| ... | ... | @@ -933,6 +1049,7 @@ static inline bool zig_subo_i32(int32_t *res, int32_t lhs, int32_t rhs, uint8_t |
| 933 | 1049 | return overflow || full_res < zig_minInt_i(32, bits) || full_res > zig_maxInt_i(32, bits); |
| 934 | 1050 | } |
| 935 | 1051 | |
| 1052 | ||
| 936 | 1053 | static inline bool zig_subo_u64(uint64_t *res, uint64_t lhs, uint64_t rhs, uint8_t bits) { |
| 937 | 1054 | #if zig_has_builtin(sub_overflow) || defined(zig_gcc) |
| 938 | 1055 | uint64_t full_res; |
| ... | ... | @@ -1013,6 +1130,66 @@ static inline bool zig_subo_i16(int16_t *res, int16_t lhs, int16_t rhs, uint8_t |
| 1013 | 1130 | #endif |
| 1014 | 1131 | } |
| 1015 | 1132 | |
| 1133 | #if defined(zig_ez80) | |
| 1134 | static inline bool zig_subo_u24(uint24_t *res, uint24_t lhs, uint24_t rhs, uint8_t bits) { | |
| 1135 | #if zig_has_builtin(sub_overflow) || defined(zig_gcc) | |
| 1136 | uint24_t full_res; | |
| 1137 | bool overflow = __builtin_sub_overflow(lhs, rhs, &full_res); | |
| 1138 | *res = zig_wrap_u24(full_res, bits); | |
| 1139 | return overflow || full_res < zig_minInt_u(24, bits) || full_res > zig_maxInt_u(24, bits); | |
| 1140 | #else | |
| 1141 | uint32_t full_res; | |
| 1142 | bool overflow = zig_subo_u32(&full_res, lhs, rhs, bits); | |
| 1143 | *res = (uint24_t)full_res; | |
| 1144 | return overflow; | |
| 1145 | #endif | |
| 1146 | } | |
| 1147 | ||
| 1148 | static inline bool zig_subo_i24(int24_t *res, int24_t lhs, int24_t rhs, uint8_t bits) { | |
| 1149 | #if zig_has_builtin(sub_overflow) || defined(zig_gcc) | |
| 1150 | int24_t full_res; | |
| 1151 | bool overflow = __builtin_sub_overflow(lhs, rhs, &full_res); | |
| 1152 | *res = zig_wrap_i24(full_res, bits); | |
| 1153 | return overflow || full_res < zig_minInt_i(24, bits) || full_res > zig_maxInt_i(24, bits); | |
| 1154 | #else | |
| 1155 | int32_t full_res; | |
| 1156 | bool overflow = zig_subo_i32(&full_res, lhs, rhs, bits); | |
| 1157 | *res = (int24_t)full_res; | |
| 1158 | return overflow; | |
| 1159 | #endif | |
| 1160 | } | |
| 1161 | #endif | |
| 1162 | ||
| 1163 | #if defined(zig_ez80) | |
| 1164 | static inline bool zig_subo_u48(uint48_t *res, uint48_t lhs, uint48_t rhs, uint8_t bits) { | |
| 1165 | #if zig_has_builtin(sub_overflow) || defined(zig_gcc) | |
| 1166 | uint48_t full_res; | |
| 1167 | bool overflow = __builtin_sub_overflow(lhs, rhs, &full_res); | |
| 1168 | *res = zig_wrap_u48(full_res, bits); | |
| 1169 | return overflow || full_res < zig_minInt_u(48, bits) || full_res > zig_maxInt_u(48, bits); | |
| 1170 | #else | |
| 1171 | uint64_t full_res; | |
| 1172 | bool overflow = zig_subo_u64(&full_res, lhs, rhs, bits); | |
| 1173 | *res = (uint48_t)full_res; | |
| 1174 | return overflow; | |
| 1175 | #endif | |
| 1176 | } | |
| 1177 | ||
| 1178 | static inline bool zig_subo_i48(int48_t *res, int48_t lhs, int48_t rhs, uint8_t bits) { | |
| 1179 | #if zig_has_builtin(sub_overflow) || defined(zig_gcc) | |
| 1180 | int48_t full_res; | |
| 1181 | bool overflow = __builtin_sub_overflow(lhs, rhs, &full_res); | |
| 1182 | *res = zig_wrap_i48(full_res, bits); | |
| 1183 | return overflow || full_res < zig_minInt_i(48, bits) || full_res > zig_maxInt_i(48, bits); | |
| 1184 | #else | |
| 1185 | int64_t full_res; | |
| 1186 | bool overflow = zig_subo_i64(&full_res, lhs, rhs, bits); | |
| 1187 | *res = (int48_t)full_res; | |
| 1188 | return overflow; | |
| 1189 | #endif | |
| 1190 | } | |
| 1191 | #endif | |
| 1192 | ||
| 1016 | 1193 | static inline bool zig_mulo_u32(uint32_t *res, uint32_t lhs, uint32_t rhs, uint8_t bits) { |
| 1017 | 1194 | #if zig_has_builtin(mul_overflow) || defined(zig_gcc) |
| 1018 | 1195 | uint32_t full_res; |
| ... | ... | @@ -1121,6 +1298,66 @@ static inline bool zig_mulo_i16(int16_t *res, int16_t lhs, int16_t rhs, uint8_t |
| 1121 | 1298 | #endif |
| 1122 | 1299 | } |
| 1123 | 1300 | |
| 1301 | #if defined(zig_ez80) | |
| 1302 | static inline bool zig_mulo_u24(uint24_t *res, uint24_t lhs, uint24_t rhs, uint8_t bits) { | |
| 1303 | #if zig_has_builtin(mul_overflow) || defined(zig_gcc) | |
| 1304 | uint24_t full_res; | |
| 1305 | bool overflow = __builtin_mul_overflow(lhs, rhs, &full_res); | |
| 1306 | *res = zig_wrap_u24(full_res, bits); | |
| 1307 | return overflow || full_res < zig_minInt_u(24, bits) || full_res > zig_maxInt_u(24, bits); | |
| 1308 | #else | |
| 1309 | uint32_t full_res; | |
| 1310 | bool overflow = zig_mulo_u32(&full_res, lhs, rhs, bits); | |
| 1311 | *res = (uint24_t)full_res; | |
| 1312 | return overflow; | |
| 1313 | #endif | |
| 1314 | } | |
| 1315 | ||
| 1316 | static inline bool zig_mulo_i24(int24_t *res, int24_t lhs, int24_t rhs, uint8_t bits) { | |
| 1317 | #if zig_has_builtin(mul_overflow) || defined(zig_gcc) | |
| 1318 | int24_t full_res; | |
| 1319 | bool overflow = __builtin_mul_overflow(lhs, rhs, &full_res); | |
| 1320 | *res = zig_wrap_i24(full_res, bits); | |
| 1321 | return overflow || full_res < zig_minInt_i(24, bits) || full_res > zig_maxInt_i(24, bits); | |
| 1322 | #else | |
| 1323 | int32_t full_res; | |
| 1324 | bool overflow = zig_mulo_i32(&full_res, lhs, rhs, bits); | |
| 1325 | *res = (int24_t)full_res; | |
| 1326 | return overflow; | |
| 1327 | #endif | |
| 1328 | } | |
| 1329 | #endif | |
| 1330 | ||
| 1331 | #if defined(zig_ez80) | |
| 1332 | static inline bool zig_mulo_u48(uint48_t *res, uint48_t lhs, uint48_t rhs, uint8_t bits) { | |
| 1333 | #if zig_has_builtin(mul_overflow) || defined(zig_gcc) | |
| 1334 | uint48_t full_res; | |
| 1335 | bool overflow = __builtin_mul_overflow(lhs, rhs, &full_res); | |
| 1336 | *res = zig_wrap_u48(full_res, bits); | |
| 1337 | return overflow || full_res < zig_minInt_u(48, bits) || full_res > zig_maxInt_u(48, bits); | |
| 1338 | #else | |
| 1339 | uint64_t full_res; | |
| 1340 | bool overflow = zig_mulo_u64(&full_res, lhs, rhs, bits); | |
| 1341 | *res = (uint48_t)full_res; | |
| 1342 | return overflow; | |
| 1343 | #endif | |
| 1344 | } | |
| 1345 | ||
| 1346 | static inline bool zig_mulo_i48(int48_t *res, int48_t lhs, int48_t rhs, uint8_t bits) { | |
| 1347 | #if zig_has_builtin(mul_overflow) || defined(zig_gcc) | |
| 1348 | int48_t full_res; | |
| 1349 | bool overflow = __builtin_mul_overflow(lhs, rhs, &full_res); | |
| 1350 | *res = zig_wrap_i48(full_res, bits); | |
| 1351 | return overflow || full_res < zig_minInt_i(48, bits) || full_res > zig_maxInt_i(48, bits); | |
| 1352 | #else | |
| 1353 | int64_t full_res; | |
| 1354 | bool overflow = zig_mulo_i64(&full_res, lhs, rhs, bits); | |
| 1355 | *res = (int48_t)full_res; | |
| 1356 | return overflow; | |
| 1357 | #endif | |
| 1358 | } | |
| 1359 | #endif | |
| 1360 | ||
| 1124 | 1361 | #define zig_int_builtins(w) \ |
| 1125 | 1362 | static inline bool zig_shlo_u##w(uint##w##_t *res, uint##w##_t lhs, uint8_t rhs, uint8_t bits) { \ |
| 1126 | 1363 | *res = zig_shlw_u##w(lhs, rhs, bits); \ |
| ... | ... | @@ -1180,7 +1417,13 @@ static inline bool zig_mulo_i16(int16_t *res, int16_t lhs, int16_t rhs, uint8_t |
| 1180 | 1417 | } |
| 1181 | 1418 | zig_int_builtins(8) |
| 1182 | 1419 | zig_int_builtins(16) |
| 1420 | #if defined(zig_ez80) | |
| 1421 | zig_int_builtins(24) | |
| 1422 | #endif | |
| 1183 | 1423 | zig_int_builtins(32) |
| 1424 | #if defined(zig_ez80) | |
| 1425 | zig_int_builtins(48) | |
| 1426 | #endif | |
| 1184 | 1427 | zig_int_builtins(64) |
| 1185 | 1428 | |
| 1186 | 1429 | #define zig_builtin8(name, val) __builtin_##name(val) |
| ... | ... | @@ -1189,6 +1432,11 @@ typedef unsigned int zig_Builtin8; |
| 1189 | 1432 | #define zig_builtin16(name, val) __builtin_##name(val) |
| 1190 | 1433 | typedef unsigned int zig_Builtin16; |
| 1191 | 1434 | |
| 1435 | #if defined(zig_ez80) | |
| 1436 | #define zig_builtin24(name, val) __builtin_##name(val) | |
| 1437 | typedef unsigned int zig_Builtin24; | |
| 1438 | #endif | |
| 1439 | ||
| 1192 | 1440 | #if INT_MIN <= INT32_MIN |
| 1193 | 1441 | #define zig_builtin32(name, val) __builtin_##name(val) |
| 1194 | 1442 | typedef unsigned int zig_Builtin32; |
| ... | ... | @@ -1197,6 +1445,11 @@ typedef unsigned int zig_Builtin32; |
| 1197 | 1445 | typedef unsigned long zig_Builtin32; |
| 1198 | 1446 | #endif |
| 1199 | 1447 | |
| 1448 | #if defined(zig_ez80) | |
| 1449 | #define zig_builtin48(name, val) __builtin_##name(val) | |
| 1450 | typedef unsigned long long zig_Builtin48; | |
| 1451 | #endif | |
| 1452 | ||
| 1200 | 1453 | #if INT_MIN <= INT64_MIN |
| 1201 | 1454 | #define zig_builtin64(name, val) __builtin_##name(val) |
| 1202 | 1455 | typedef unsigned int zig_Builtin64; |
| ... | ... | @@ -1231,6 +1484,23 @@ static inline int16_t zig_byte_swap_i16(int16_t val, uint8_t bits) { |
| 1231 | 1484 | return zig_wrap_i16((int16_t)zig_byte_swap_u16((uint16_t)val, bits), bits); |
| 1232 | 1485 | } |
| 1233 | 1486 | |
| 1487 | #if defined(zig_ez80) | |
| 1488 | static inline uint16_t zig_byte_swap_u24(uint24_t val, uint8_t bits) { | |
| 1489 | uint24_t full_res; | |
| 1490 | #if zig_has_builtin(bswap24) || defined(zig_gcc) | |
| 1491 | full_res = __builtin_bswap24(val); | |
| 1492 | #else | |
| 1493 | full_res = (uint24_t)zig_byte_swap_u8((uint8_t)(val >> 0), 8) << 16 | | |
| 1494 | (uint24_t)zig_byte_swap_u16((uint16_t)(val >> 8), 16) >> 0; | |
| 1495 | #endif | |
| 1496 | return zig_wrap_u24(full_res >> (24 - bits), bits); | |
| 1497 | } | |
| 1498 | ||
| 1499 | static inline int16_t zig_byte_swap_i24(int24_t val, uint8_t bits) { | |
| 1500 | return zig_wrap_i24((int24_t)zig_byte_swap_u24((uint24_t)val, bits), bits); | |
| 1501 | } | |
| 1502 | #endif | |
| 1503 | ||
| 1234 | 1504 | static inline uint32_t zig_byte_swap_u32(uint32_t val, uint8_t bits) { |
| 1235 | 1505 | uint32_t full_res; |
| 1236 | 1506 | #if zig_has_builtin(bswap32) || defined(zig_gcc) |
| ... | ... | @@ -1246,6 +1516,23 @@ static inline int32_t zig_byte_swap_i32(int32_t val, uint8_t bits) { |
| 1246 | 1516 | return zig_wrap_i32((int32_t)zig_byte_swap_u32((uint32_t)val, bits), bits); |
| 1247 | 1517 | } |
| 1248 | 1518 | |
| 1519 | #if defined(zig_ez80) | |
| 1520 | static inline uint32_t zig_byte_swap_u48(uint48_t val, uint8_t bits) { | |
| 1521 | uint48_t full_res; | |
| 1522 | #if zig_has_builtin(bswap48) || defined(zig_gcc) | |
| 1523 | full_res = __builtin_bswap48(val); | |
| 1524 | #else | |
| 1525 | full_res = (uint48_t)zig_byte_swap_u24((uint24_t)(val >> 0), 24) << 24 | | |
| 1526 | (uint48_t)zig_byte_swap_u24((uint24_t)(val >> 24), 24) >> 0; | |
| 1527 | #endif | |
| 1528 | return zig_wrap_u48(full_res >> (48 - bits), bits); | |
| 1529 | } | |
| 1530 | ||
| 1531 | static inline int32_t zig_byte_swap_i48(int48_t val, uint8_t bits) { | |
| 1532 | return zig_wrap_i48((int48_t)zig_byte_swap_u48((uint48_t)val, bits), bits); | |
| 1533 | } | |
| 1534 | #endif | |
| 1535 | ||
| 1249 | 1536 | static inline uint64_t zig_byte_swap_u64(uint64_t val, uint8_t bits) { |
| 1250 | 1537 | uint64_t full_res; |
| 1251 | 1538 | #if zig_has_builtin(bswap64) || defined(zig_gcc) |
| ... | ... | @@ -1294,6 +1581,23 @@ static inline int16_t zig_bit_reverse_i16(int16_t val, uint8_t bits) { |
| 1294 | 1581 | return zig_wrap_i16((int16_t)zig_bit_reverse_u16((uint16_t)val, bits), bits); |
| 1295 | 1582 | } |
| 1296 | 1583 | |
| 1584 | #if defined(zig_ez80) | |
| 1585 | static inline uint24_t zig_bit_reverse_u24(uint24_t val, uint8_t bits) { | |
| 1586 | uint24_t full_res; | |
| 1587 | #if zig_has_builtin(bitreverse24) | |
| 1588 | full_res = __builtin_bitreverse24(val); | |
| 1589 | #else | |
| 1590 | full_res = (uint24_t)zig_bit_reverse_u8((uint8_t)(val >> 0), 8) << 16 | | |
| 1591 | (uint24_t)zig_bit_reverse_u16((uint16_t)(val >> 8), 16) >> 0; | |
| 1592 | #endif | |
| 1593 | return zig_wrap_u24(full_res >> (24 - bits), bits); | |
| 1594 | } | |
| 1595 | ||
| 1596 | static inline int24_t zig_bit_reverse_i24(int24_t val, uint8_t bits) { | |
| 1597 | return zig_wrap_i24((int24_t)zig_bit_reverse_u24((uint24_t)val, bits), bits); | |
| 1598 | } | |
| 1599 | #endif | |
| 1600 | ||
| 1297 | 1601 | static inline uint32_t zig_bit_reverse_u32(uint32_t val, uint8_t bits) { |
| 1298 | 1602 | uint32_t full_res; |
| 1299 | 1603 | #if zig_has_builtin(bitreverse32) |
| ... | ... | @@ -1309,6 +1613,23 @@ static inline int32_t zig_bit_reverse_i32(int32_t val, uint8_t bits) { |
| 1309 | 1613 | return zig_wrap_i32((int32_t)zig_bit_reverse_u32((uint32_t)val, bits), bits); |
| 1310 | 1614 | } |
| 1311 | 1615 | |
| 1616 | #if defined(zig_ez80) | |
| 1617 | static inline uint32_t zig_bit_reverse_u48(uint48_t val, uint8_t bits) { | |
| 1618 | uint48_t full_res; | |
| 1619 | #if zig_has_builtin(bitreverse48) | |
| 1620 | full_res = __builtin_bitreverse48(val); | |
| 1621 | #else | |
| 1622 | full_res = (uint48_t)zig_bit_reverse_u24((uint24_t)(val >> 0), 24) << 24 | | |
| 1623 | (uint48_t)zig_bit_reverse_u24((uint24_t)(val >> 24), 24) >> 0; | |
| 1624 | #endif | |
| 1625 | return zig_wrap_u32(full_res >> (48 - bits), bits); | |
| 1626 | } | |
| 1627 | ||
| 1628 | static inline int32_t zig_bit_reverse_i48(int48_t val, uint8_t bits) { | |
| 1629 | return zig_wrap_i48((int48_t)zig_bit_reverse_u48((uint48_t)val, bits), bits); | |
| 1630 | } | |
| 1631 | #endif | |
| 1632 | ||
| 1312 | 1633 | static inline uint64_t zig_bit_reverse_u64(uint64_t val, uint8_t bits) { |
| 1313 | 1634 | uint64_t full_res; |
| 1314 | 1635 | #if zig_has_builtin(bitreverse64) |
| ... | ... | @@ -1350,7 +1671,13 @@ static inline int64_t zig_bit_reverse_i64(int64_t val, uint8_t bits) { |
| 1350 | 1671 | #endif |
| 1351 | 1672 | zig_builtin_popcount(8) |
| 1352 | 1673 | zig_builtin_popcount(16) |
| 1674 | #if defined(zig_ez80) | |
| 1675 | zig_builtin_popcount(24) | |
| 1676 | #endif | |
| 1353 | 1677 | zig_builtin_popcount(32) |
| 1678 | #if defined(zig_ez80) | |
| 1679 | zig_builtin_popcount(48) | |
| 1680 | #endif | |
| 1354 | 1681 | zig_builtin_popcount(64) |
| 1355 | 1682 | |
| 1356 | 1683 | #define zig_builtin_ctz_common(w) \ |
| ... | ... | @@ -1375,7 +1702,13 @@ zig_builtin_popcount(64) |
| 1375 | 1702 | #endif |
| 1376 | 1703 | zig_builtin_ctz(8) |
| 1377 | 1704 | zig_builtin_ctz(16) |
| 1705 | #if defined(zig_ez80) | |
| 1706 | zig_builtin_ctz(24) | |
| 1707 | #endif | |
| 1378 | 1708 | zig_builtin_ctz(32) |
| 1709 | #if defined(zig_ez80) | |
| 1710 | zig_builtin_ctz(48) | |
| 1711 | #endif | |
| 1379 | 1712 | zig_builtin_ctz(64) |
| 1380 | 1713 | |
| 1381 | 1714 | #define zig_builtin_clz_common(w) \ |
| ... | ... | @@ -1400,7 +1733,13 @@ zig_builtin_ctz(64) |
| 1400 | 1733 | #endif |
| 1401 | 1734 | zig_builtin_clz(8) |
| 1402 | 1735 | zig_builtin_clz(16) |
| 1736 | #if defined(zig_ez80) | |
| 1737 | zig_builtin_clz(24) | |
| 1738 | #endif | |
| 1403 | 1739 | zig_builtin_clz(32) |
| 1740 | #if defined(zig_ez80) | |
| 1741 | zig_builtin_clz(48) | |
| 1742 | #endif | |
| 1404 | 1743 | zig_builtin_clz(64) |
| 1405 | 1744 | |
| 1406 | 1745 | /* ======================== 128-bit Integer Support ========================= */ |
src/Type.zig+3| ... | ... | @@ -1204,6 +1204,9 @@ pub fn abiSize(ty: Type, zcu: *const Zcu) u64 { |
| 1204 | 1204 | } |
| 1205 | 1205 | |
| 1206 | 1206 | pub fn ptrAbiAlignment(target: *const Target) Alignment { |
| 1207 | // The eZ80 has 24-bit pointers, which aren't exact powers of two, tripping | |
| 1208 | // the assert. The alignment of eZ80 pointers is 1, so we bypass the check. | |
| 1209 | if (target.cpu.arch == .ez80) return .@"1"; | |
| 1207 | 1210 | return .fromNonzeroByteUnits(@divExact(target.ptrBitWidth(), 8)); |
| 1208 | 1211 | } |
| 1209 | 1212 | pub fn ptrAbiSize(target: *const Target) u64 { |
src/Zcu.zig+5| ... | ... | @@ -4022,6 +4022,9 @@ pub fn atomicPtrAlignment( |
| 4022 | 4022 | ) AtomicPtrAlignmentError!Alignment { |
| 4023 | 4023 | const target = zcu.getTarget(); |
| 4024 | 4024 | const max_atomic_bits: u16 = switch (target.cpu.arch) { |
| 4025 | .ez80, | |
| 4026 | => 8, | |
| 4027 | ||
| 4025 | 4028 | .aarch64, |
| 4026 | 4029 | .aarch64_be, |
| 4027 | 4030 | => 128, |
| ... | ... | @@ -4615,6 +4618,8 @@ pub fn callconvSupported(zcu: *Zcu, cc: std.builtin.CallingConvention) union(enu |
| 4615 | 4618 | .avr_signal, |
| 4616 | 4619 | => true, |
| 4617 | 4620 | |
| 4621 | .ez80_tiflags => true, | |
| 4622 | ||
| 4618 | 4623 | .naked => true, |
| 4619 | 4624 | |
| 4620 | 4625 | else => false, |
src/codegen/c.zig+23| ... | ... | @@ -248,7 +248,9 @@ const reserved_idents = std.StaticStringMap(void).initComptime(.{ |
| 248 | 248 | .{ "inline", {} }, |
| 249 | 249 | .{ "int", {} }, |
| 250 | 250 | .{ "int16_t", {} }, |
| 251 | .{ "int24_t", {} }, | |
| 251 | 252 | .{ "int32_t", {} }, |
| 253 | .{ "int48_t", {} }, | |
| 252 | 254 | .{ "int64_t", {} }, |
| 253 | 255 | .{ "int8_t", {} }, |
| 254 | 256 | .{ "intptr_t", {} }, |
| ... | ... | @@ -270,7 +272,9 @@ const reserved_idents = std.StaticStringMap(void).initComptime(.{ |
| 270 | 272 | .{ "typedef", {} }, |
| 271 | 273 | .{ "typeof", {} }, |
| 272 | 274 | .{ "uint16_t", {} }, |
| 275 | .{ "uint24_t", {} }, | |
| 273 | 276 | .{ "uint32_t", {} }, |
| 277 | .{ "uint48_t", {} }, | |
| 274 | 278 | .{ "uint64_t", {} }, |
| 275 | 279 | .{ "uint8_t", {} }, |
| 276 | 280 | .{ "uintptr_t", {} }, |
| ... | ... | @@ -6992,6 +6996,9 @@ fn toCallingConvention(cc: std.builtin.CallingConvention, zcu: *Zcu) ?[]const u8 |
| 6992 | 6996 | .x86_64_interrupt, |
| 6993 | 6997 | => "interrupt", |
| 6994 | 6998 | |
| 6999 | .ez80_tiflags, | |
| 7000 | => "__tiflags__", | |
| 7001 | ||
| 6995 | 7002 | else => unreachable, // `Zcu.callconvSupported` |
| 6996 | 7003 | }; |
| 6997 | 7004 | } |
| ... | ... | @@ -7285,7 +7292,9 @@ const FormatInt128 = struct { |
| 7285 | 7292 | switch (data.int_cty) { |
| 7286 | 7293 | .uint8_t, |
| 7287 | 7294 | .uint16_t, |
| 7295 | .uint24_t, | |
| 7288 | 7296 | .uint32_t, |
| 7297 | .uint48_t, | |
| 7289 | 7298 | .uint64_t, |
| 7290 | 7299 | .@"unsigned short", |
| 7291 | 7300 | .@"unsigned int", |
| ... | ... | @@ -7298,6 +7307,8 @@ const FormatInt128 = struct { |
| 7298 | 7307 | |
| 7299 | 7308 | .int8_t, |
| 7300 | 7309 | .int16_t, |
| 7310 | .int24_t, | |
| 7311 | .int48_t, | |
| 7301 | 7312 | .int32_t, |
| 7302 | 7313 | .int64_t, |
| 7303 | 7314 | .char, |
| ... | ... | @@ -7443,13 +7454,17 @@ fn minMaxMacroPrefix(int_cty: CType.Int) []const u8 { |
| 7443 | 7454 | |
| 7444 | 7455 | .uint8_t => "UINT8", |
| 7445 | 7456 | .uint16_t => "UINT16", |
| 7457 | .uint24_t => "UINT24", | |
| 7446 | 7458 | .uint32_t => "UINT32", |
| 7459 | .uint48_t => "UINT48", | |
| 7447 | 7460 | .uint64_t => "UINT64", |
| 7448 | 7461 | .zig_u128 => unreachable, |
| 7449 | 7462 | |
| 7450 | 7463 | .int8_t => "INT8", |
| 7451 | 7464 | .int16_t => "INT16", |
| 7465 | .int24_t => "INT24", | |
| 7452 | 7466 | .int32_t => "INT32", |
| 7467 | .int48_t => "INT48", | |
| 7453 | 7468 | .int64_t => "INT64", |
| 7454 | 7469 | .zig_i128 => unreachable, |
| 7455 | 7470 | |
| ... | ... | @@ -7475,13 +7490,17 @@ fn intLiteralPrefix(cty: CType.Int, is_global: bool) []const u8 { |
| 7475 | 7490 | |
| 7476 | 7491 | .uint8_t => "UINT8_C(", |
| 7477 | 7492 | .uint16_t => "UINT16_C(", |
| 7493 | .uint24_t => "UINT24_C(", | |
| 7478 | 7494 | .uint32_t => "UINT32_C(", |
| 7495 | .uint48_t => "UINT48_C(", | |
| 7479 | 7496 | .uint64_t => "UINT64_C(", |
| 7480 | 7497 | .zig_u128 => unreachable, |
| 7481 | 7498 | |
| 7482 | 7499 | .int8_t => "INT8_C(", |
| 7483 | 7500 | .int16_t => "INT16_C(", |
| 7501 | .int24_t => "INT24_C(", | |
| 7484 | 7502 | .int32_t => "INT32_C(", |
| 7503 | .int48_t => "INT48_C(", | |
| 7485 | 7504 | .int64_t => "INT64_C(", |
| 7486 | 7505 | .zig_i128 => unreachable, |
| 7487 | 7506 | |
| ... | ... | @@ -7507,13 +7526,17 @@ fn intLiteralSuffix(cty: CType.Int) []const u8 { |
| 7507 | 7526 | |
| 7508 | 7527 | .uint8_t => ")", |
| 7509 | 7528 | .uint16_t => ")", |
| 7529 | .uint24_t => ")", | |
| 7510 | 7530 | .uint32_t => ")", |
| 7531 | .uint48_t => ")", | |
| 7511 | 7532 | .uint64_t => ")", |
| 7512 | 7533 | .zig_u128 => unreachable, |
| 7513 | 7534 | |
| 7514 | 7535 | .int8_t => ")", |
| 7515 | 7536 | .int16_t => ")", |
| 7537 | .int24_t => ")", | |
| 7516 | 7538 | .int32_t => ")", |
| 7539 | .int48_t => ")", | |
| 7517 | 7540 | .int64_t => ")", |
| 7518 | 7541 | .zig_i128 => unreachable, |
| 7519 | 7542 |
src/codegen/c/type.zig+25-2| ... | ... | @@ -106,13 +106,21 @@ pub const CType = union(enum) { |
| 106 | 106 | |
| 107 | 107 | uint8_t, |
| 108 | 108 | uint16_t, |
| 109 | /// eZ80-specific | |
| 110 | uint24_t, | |
| 109 | 111 | uint32_t, |
| 112 | /// eZ80-specific | |
| 113 | uint48_t, | |
| 110 | 114 | uint64_t, |
| 111 | 115 | zig_u128, |
| 112 | 116 | |
| 113 | 117 | int8_t, |
| 114 | 118 | int16_t, |
| 119 | /// eZ80-specific | |
| 120 | int24_t, | |
| 115 | 121 | int32_t, |
| 122 | /// eZ80-specific | |
| 123 | int48_t, | |
| 116 | 124 | int64_t, |
| 117 | 125 | zig_i128, |
| 118 | 126 | |
| ... | ... | @@ -138,7 +146,9 @@ pub const CType = union(enum) { |
| 138 | 146 | |
| 139 | 147 | .uint8_t, .int8_t => 8, |
| 140 | 148 | .uint16_t, .int16_t => 16, |
| 149 | .uint24_t, .int24_t => 24, | |
| 141 | 150 | .uint32_t, .int32_t => 32, |
| 151 | .uint48_t, .int48_t => 48, | |
| 142 | 152 | .uint64_t, .int64_t => 64, |
| 143 | 153 | .zig_u128, .zig_i128 => 128, |
| 144 | 154 | // zig fmt: on |
| ... | ... | @@ -154,6 +164,7 @@ pub const CType = union(enum) { |
| 154 | 164 | pub const LimbSize = enum { |
| 155 | 165 | @"8", |
| 156 | 166 | @"16", |
| 167 | @"24", | |
| 157 | 168 | @"32", |
| 158 | 169 | @"64", |
| 159 | 170 | @"128", |
| ... | ... | @@ -161,6 +172,7 @@ pub const CType = union(enum) { |
| 161 | 172 | return switch (s) { |
| 162 | 173 | .@"8" => 8, |
| 163 | 174 | .@"16" => 16, |
| 175 | .@"24" => 24, | |
| 164 | 176 | .@"32" => 32, |
| 165 | 177 | .@"64" => 64, |
| 166 | 178 | .@"128" => 128, |
| ... | ... | @@ -170,6 +182,7 @@ pub const CType = union(enum) { |
| 170 | 182 | return switch (s) { |
| 171 | 183 | .@"8" => .uint8_t, |
| 172 | 184 | .@"16" => .uint16_t, |
| 185 | .@"24" => .uint24_t, | |
| 173 | 186 | .@"32" => .uint32_t, |
| 174 | 187 | .@"64" => .uint64_t, |
| 175 | 188 | .@"128" => .zig_u128, |
| ... | ... | @@ -179,6 +192,7 @@ pub const CType = union(enum) { |
| 179 | 192 | return switch (s) { |
| 180 | 193 | .@"8" => .int8_t, |
| 181 | 194 | .@"16" => .int16_t, |
| 195 | .@"24" => .int24_t, | |
| 182 | 196 | .@"32" => .int32_t, |
| 183 | 197 | .@"64" => .int64_t, |
| 184 | 198 | .@"128" => .zig_i128, |
| ... | ... | @@ -499,6 +513,7 @@ pub const CType = union(enum) { |
| 499 | 513 | } |
| 500 | 514 | } |
| 501 | 515 | fn classifyBitInt(signedness: std.builtin.Signedness, bits: u16, zcu: *const Zcu) IntClass { |
| 516 | const is_ez80 = zcu.getTarget().cpu.arch == .ez80; | |
| 502 | 517 | return switch (bits) { |
| 503 | 518 | 0 => .void, |
| 504 | 519 | 1...8 => switch (signedness) { |
| ... | ... | @@ -509,11 +524,19 @@ pub const CType = union(enum) { |
| 509 | 524 | .unsigned => .{ .small = .uint16_t }, |
| 510 | 525 | .signed => .{ .small = .int16_t }, |
| 511 | 526 | }, |
| 512 | 17...32 => switch (signedness) { | |
| 527 | 17...24 => switch (signedness) { | |
| 528 | .unsigned => .{ .small = if (is_ez80) .uint24_t else .uint32_t }, | |
| 529 | .signed => .{ .small = if (is_ez80) .int24_t else .int32_t }, | |
| 530 | }, | |
| 531 | 25...32 => switch (signedness) { | |
| 513 | 532 | .unsigned => .{ .small = .uint32_t }, |
| 514 | 533 | .signed => .{ .small = .int32_t }, |
| 515 | 534 | }, |
| 516 | 33...64 => switch (signedness) { | |
| 535 | 33...48 => switch (signedness) { | |
| 536 | .unsigned => .{ .small = if (is_ez80) .uint48_t else .uint64_t }, | |
| 537 | .signed => .{ .small = if (is_ez80) .int48_t else .int64_t }, | |
| 538 | }, | |
| 539 | 49...64 => switch (signedness) { | |
| 517 | 540 | .unsigned => .{ .small = .uint64_t }, |
| 518 | 541 | .signed => .{ .small = .int64_t }, |
| 519 | 542 | }, |
src/codegen/llvm.zig+7-1| ... | ... | @@ -107,6 +107,7 @@ pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8 |
| 107 | 107 | |
| 108 | 108 | .alpha, |
| 109 | 109 | .arceb, |
| 110 | .ez80, | |
| 110 | 111 | .hppa, |
| 111 | 112 | .hppa64, |
| 112 | 113 | .kalimba, |
| ... | ... | @@ -244,6 +245,7 @@ pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8 |
| 244 | 245 | .other, |
| 245 | 246 | .plan9, |
| 246 | 247 | .psp, |
| 248 | .tios, | |
| 247 | 249 | .vita, |
| 248 | 250 | => "unknown", |
| 249 | 251 | }; |
| ... | ... | @@ -473,6 +475,7 @@ pub fn dataLayout(target: *const std.Target) []const u8 { |
| 473 | 475 | |
| 474 | 476 | .alpha, |
| 475 | 477 | .arceb, |
| 478 | .ez80, | |
| 476 | 479 | .hppa, |
| 477 | 480 | .hppa64, |
| 478 | 481 | .kalimba, |
| ... | ... | @@ -1365,7 +1368,7 @@ pub const Object = struct { |
| 1365 | 1368 | for (0..field_types.len, llvm_args_start..) |field_i, llvm_arg_index| { |
| 1366 | 1369 | const param = wip.arg(@intCast(llvm_arg_index)); |
| 1367 | 1370 | const field_ptr = try wip.gepStruct(llvm_ty, arg_ptr, field_i, ""); |
| 1368 | const alignment: Builder.Alignment = .fromByteUnits(@divExact(target.ptrBitWidth(), 8)); | |
| 1371 | const alignment = Type.ptrAbiAlignment(target).toLlvm(); | |
| 1369 | 1372 | _ = try wip.store(.normal, param, field_ptr, alignment); |
| 1370 | 1373 | } |
| 1371 | 1374 | |
| ... | ... | @@ -4506,6 +4509,8 @@ pub fn toLlvmCallConvTag(cc_tag: std.builtin.CallingConvention.Tag, target: *con |
| 4506 | 4509 | .avr_gnu, |
| 4507 | 4510 | .bpf_std, |
| 4508 | 4511 | .csky_sysv, |
| 4512 | .ez80_cet, | |
| 4513 | .ez80_tiflags, | |
| 4509 | 4514 | .hexagon_sysv, |
| 4510 | 4515 | .hexagon_sysv_hvx, |
| 4511 | 4516 | .hppa_elf, |
| ... | ... | @@ -4903,6 +4908,7 @@ pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void { |
| 4903 | 4908 | // LLVM does does not have a backend for these. |
| 4904 | 4909 | .alpha, |
| 4905 | 4910 | .arceb, |
| 4911 | .ez80, | |
| 4906 | 4912 | .hppa, |
| 4907 | 4913 | .hppa64, |
| 4908 | 4914 | .kalimba, |
src/target.zig+4| ... | ... | @@ -234,6 +234,10 @@ pub fn hasLlvmSupport(target: *const std.Target, ofmt: std.Target.ObjectFormat) |
| 234 | 234 | .xtensa, |
| 235 | 235 | => false, |
| 236 | 236 | |
| 237 | // Third-party LLVM backend exists. | |
| 238 | .ez80, | |
| 239 | => false, | |
| 240 | ||
| 237 | 241 | // No LLVM backend exists. |
| 238 | 242 | .alpha, |
| 239 | 243 | .arceb, |