Skip to content

Commit c829f2f

Browse files
FireFox317andrewrk
authored andcommitted
Add mips support to standard library
1 parent a9eb4a6 commit c829f2f

File tree

22 files changed

+138
-14
lines changed

22 files changed

+138
-14
lines changed

lib/std/bloom_filter.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ fn hashFunc(out: []u8, Ki: usize, in: []const u8) void {
160160
}
161161

162162
test "std.BloomFilter" {
163+
// https://github.com/ziglang/zig/issues/5127
164+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
165+
163166
inline for ([_]type{ bool, u1, u2, u3, u4 }) |Cell| {
164167
const emptyCell = if (Cell == bool) false else @as(Cell, 0);
165168
const BF = BloomFilter(128 * 8, 8, Cell, builtin.endian, hashFunc);

lib/std/crypto/gimli.zig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ pub fn hash(out: []u8, in: []const u8) void {
162162
}
163163

164164
test "hash" {
165+
// https://github.com/ziglang/zig/issues/5127
166+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
167+
165168
// a test vector (30) from NIST KAT submission.
166169
var msg: [58 / 2]u8 = undefined;
167170
try std.fmt.hexToBytes(&msg, "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C");
@@ -307,6 +310,9 @@ pub const Aead = struct {
307310
};
308311

309312
test "cipher" {
313+
// https://github.com/ziglang/zig/issues/5127
314+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
315+
310316
var key: [32]u8 = undefined;
311317
try std.fmt.hexToBytes(&key, "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F");
312318
var nonce: [16]u8 = undefined;

lib/std/fmt.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,7 @@ test "positional/alignment/width/precision" {
16611661
}
16621662

16631663
test "vector" {
1664-
if (builtin.arch == .mipsel) {
1664+
if (builtin.arch == .mipsel or builtin.arch == .mips) {
16651665
// https://github.com/ziglang/zig/issues/3317
16661666
return error.SkipZigTest;
16671667
}

lib/std/hash/auto_hash.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ test "testHash union" {
357357

358358
test "testHash vector" {
359359
// Disabled because of #3317
360-
if (@import("builtin").arch == .mipsel) return error.SkipZigTest;
360+
if (@import("builtin").arch == .mipsel or @import("builtin").arch == .mips) return error.SkipZigTest;
361361

362362
const a: @Vector(4, u32) = [_]u32{ 1, 2, 3, 4 };
363363
const b: @Vector(4, u32) = [_]u32{ 1, 2, 3, 5 };

lib/std/hash_map.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,9 @@ test "basic hash map usage" {
463463
}
464464

465465
test "iterator hash map" {
466+
// https://github.com/ziglang/zig/issues/5127
467+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
468+
466469
var reset_map = AutoHashMap(i32, i32).init(std.testing.allocator);
467470
defer reset_map.deinit();
468471

lib/std/io/test.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ test "File seek ops" {
126126
}
127127

128128
test "setEndPos" {
129+
// https://github.com/ziglang/zig/issues/5127
130+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
131+
129132
const tmp_file_name = "temp_test_file.txt";
130133
var file = try fs.cwd().createFile(tmp_file_name, .{});
131134
defer {

lib/std/json.zig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2249,6 +2249,9 @@ test "integer after float has proper type" {
22492249
}
22502250

22512251
test "escaped characters" {
2252+
// https://github.com/ziglang/zig/issues/5127
2253+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
2254+
22522255
var arena_allocator = std.heap.ArenaAllocator.init(std.testing.allocator);
22532256
defer arena_allocator.deinit();
22542257
const input =
@@ -2281,6 +2284,9 @@ test "escaped characters" {
22812284
}
22822285

22832286
test "string copy option" {
2287+
// https://github.com/ziglang/zig/issues/5127
2288+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
2289+
22842290
const input =
22852291
\\{
22862292
\\ "noescape": "aą😂",

lib/std/json/test.zig

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,18 @@ test "y_string_1_2_3_bytes_UTF-8_sequences" {
332332
}
333333

334334
test "y_string_accepted_surrogate_pair" {
335+
// https://github.com/ziglang/zig/issues/5127
336+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
337+
335338
ok(
336339
\\["\uD801\udc37"]
337340
);
338341
}
339342

340343
test "y_string_accepted_surrogate_pairs" {
344+
// https://github.com/ziglang/zig/issues/5127
345+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
346+
341347
ok(
342348
\\["\ud83d\ude39\ud83d\udc8d"]
343349
);
@@ -404,6 +410,9 @@ test "y_string_in_array_with_leading_space" {
404410
}
405411

406412
test "y_string_last_surrogates_1_and_2" {
413+
// https://github.com/ziglang/zig/issues/5127
414+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
415+
407416
ok(
408417
\\["\uDBFF\uDFFF"]
409418
);
@@ -464,6 +473,9 @@ test "y_string_space" {
464473
}
465474

466475
test "y_string_surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF" {
476+
// https://github.com/ziglang/zig/issues/5127
477+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
478+
467479
ok(
468480
\\["\uD834\uDd1e"]
469481
);
@@ -506,60 +518,90 @@ test "y_string_unescaped_char_delete" {
506518
}
507519

508520
test "y_string_unicode_2" {
521+
// https://github.com/ziglang/zig/issues/5127
522+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
523+
509524
ok(
510525
\\["⍂㈴⍂"]
511526
);
512527
}
513528

514529
test "y_string_unicodeEscapedBackslash" {
530+
// https://github.com/ziglang/zig/issues/5127
531+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
532+
515533
ok(
516534
\\["\u005C"]
517535
);
518536
}
519537

520538
test "y_string_unicode_escaped_double_quote" {
539+
// https://github.com/ziglang/zig/issues/5127
540+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
541+
521542
ok(
522543
\\["\u0022"]
523544
);
524545
}
525546

526547
test "y_string_unicode" {
548+
// https://github.com/ziglang/zig/issues/5127
549+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
550+
527551
ok(
528552
\\["\uA66D"]
529553
);
530554
}
531555

532556
test "y_string_unicode_U+10FFFE_nonchar" {
557+
// https://github.com/ziglang/zig/issues/5127
558+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
559+
533560
ok(
534561
\\["\uDBFF\uDFFE"]
535562
);
536563
}
537564

538565
test "y_string_unicode_U+1FFFE_nonchar" {
566+
// https://github.com/ziglang/zig/issues/5127
567+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
568+
539569
ok(
540570
\\["\uD83F\uDFFE"]
541571
);
542572
}
543573

544574
test "y_string_unicode_U+200B_ZERO_WIDTH_SPACE" {
575+
// https://github.com/ziglang/zig/issues/5127
576+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
577+
545578
ok(
546579
\\["\u200B"]
547580
);
548581
}
549582

550583
test "y_string_unicode_U+2064_invisible_plus" {
584+
// https://github.com/ziglang/zig/issues/5127
585+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
586+
551587
ok(
552588
\\["\u2064"]
553589
);
554590
}
555591

556592
test "y_string_unicode_U+FDD0_nonchar" {
593+
// https://github.com/ziglang/zig/issues/5127
594+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
595+
557596
ok(
558597
\\["\uFDD0"]
559598
);
560599
}
561600

562601
test "y_string_unicode_U+FFFE_nonchar" {
602+
// https://github.com/ziglang/zig/issues/5127
603+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
604+
563605
ok(
564606
\\["\uFFFE"]
565607
);
@@ -1811,42 +1853,63 @@ test "i_object_key_lone_2nd_surrogate" {
18111853
}
18121854

18131855
test "i_string_1st_surrogate_but_2nd_missing" {
1856+
// https://github.com/ziglang/zig/issues/5127
1857+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
1858+
18141859
anyStreamingErrNonStreaming(
18151860
\\["\uDADA"]
18161861
);
18171862
}
18181863

18191864
test "i_string_1st_valid_surrogate_2nd_invalid" {
1865+
// https://github.com/ziglang/zig/issues/5127
1866+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
1867+
18201868
anyStreamingErrNonStreaming(
18211869
\\["\uD888\u1234"]
18221870
);
18231871
}
18241872

18251873
test "i_string_incomplete_surrogate_and_escape_valid" {
1874+
// https://github.com/ziglang/zig/issues/5127
1875+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
1876+
18261877
anyStreamingErrNonStreaming(
18271878
\\["\uD800\n"]
18281879
);
18291880
}
18301881

18311882
test "i_string_incomplete_surrogate_pair" {
1883+
// https://github.com/ziglang/zig/issues/5127
1884+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
1885+
18321886
anyStreamingErrNonStreaming(
18331887
\\["\uDd1ea"]
18341888
);
18351889
}
18361890

18371891
test "i_string_incomplete_surrogates_escape_valid" {
1892+
// https://github.com/ziglang/zig/issues/5127
1893+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
1894+
18381895
anyStreamingErrNonStreaming(
18391896
\\["\uD800\uD800\n"]
18401897
);
18411898
}
18421899

18431900
test "i_string_invalid_lonely_surrogate" {
1901+
// https://github.com/ziglang/zig/issues/5127
1902+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
1903+
18441904
anyStreamingErrNonStreaming(
18451905
\\["\ud800"]
18461906
);
18471907
}
18481908

18491909
test "i_string_invalid_surrogate" {
1910+
// https://github.com/ziglang/zig/issues/5127
1911+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
1912+
18501913
anyStreamingErrNonStreaming(
18511914
\\["\ud800abc"]
18521915
);
@@ -1859,6 +1922,9 @@ test "i_string_invalid_utf-8" {
18591922
}
18601923

18611924
test "i_string_inverted_surrogates_U+1D11E" {
1925+
// https://github.com/ziglang/zig/issues/5127
1926+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
1927+
18621928
anyStreamingErrNonStreaming(
18631929
\\["\uDd1e\uD834"]
18641930
);
@@ -1871,6 +1937,9 @@ test "i_string_iso_latin_1" {
18711937
}
18721938

18731939
test "i_string_lone_second_surrogate" {
1940+
// https://github.com/ziglang/zig/issues/5127
1941+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
1942+
18741943
anyStreamingErrNonStreaming(
18751944
\\["\uDFAA"]
18761945
);

lib/std/os/bits/linux.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub usingnamespace switch (builtin.arch) {
1414
.aarch64 => @import("linux/arm64.zig"),
1515
.arm => @import("linux/arm-eabi.zig"),
1616
.riscv64 => @import("linux/riscv64.zig"),
17-
.mipsel => @import("linux/mipsel.zig"),
17+
.mips, .mipsel => @import("linux/mips.zig"),
1818
else => struct {},
1919
};
2020

File renamed without changes.

lib/std/os/linux.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub usingnamespace switch (builtin.arch) {
1919
.aarch64 => @import("linux/arm64.zig"),
2020
.arm => @import("linux/arm-eabi.zig"),
2121
.riscv64 => @import("linux/riscv64.zig"),
22-
.mipsel => @import("linux/mipsel.zig"),
22+
.mips, .mipsel => @import("linux/mips.zig"),
2323
else => struct {},
2424
};
2525
pub usingnamespace @import("bits.zig");
File renamed without changes.

lib/std/os/linux/tls.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const TLSVariant = enum {
4848
};
4949

5050
const tls_variant = switch (builtin.arch) {
51-
.arm, .armeb, .aarch64, .aarch64_be, .riscv32, .riscv64, .mipsel => TLSVariant.VariantI,
51+
.arm, .armeb, .aarch64, .aarch64_be, .riscv32, .riscv64, .mips, .mipsel => TLSVariant.VariantI,
5252
.x86_64, .i386 => TLSVariant.VariantII,
5353
else => @compileError("undefined tls_variant for this architecture"),
5454
};
@@ -64,20 +64,20 @@ const tls_tcb_size = switch (builtin.arch) {
6464

6565
// Controls if the TP points to the end of the TCB instead of its beginning
6666
const tls_tp_points_past_tcb = switch (builtin.arch) {
67-
.riscv32, .riscv64, .mipsel, .powerpc64, .powerpc64le => true,
67+
.riscv32, .riscv64, .mips, .mipsel, .powerpc64, .powerpc64le => true,
6868
else => false,
6969
};
7070

7171
// Some architectures add some offset to the tp and dtv addresses in order to
7272
// make the generated code more efficient
7373

7474
const tls_tp_offset = switch (builtin.arch) {
75-
.mipsel => 0x7000,
75+
.mips, .mipsel => 0x7000,
7676
else => 0,
7777
};
7878

7979
const tls_dtv_offset = switch (builtin.arch) {
80-
.mipsel => 0x8000,
80+
.mips, .mipsel => 0x8000,
8181
.riscv32, .riscv64 => 0x800,
8282
else => 0,
8383
};
@@ -156,7 +156,7 @@ pub fn setThreadPointer(addr: usize) void {
156156
: [addr] "r" (addr)
157157
);
158158
},
159-
.mipsel => {
159+
.mips, .mipsel => {
160160
const rc = std.os.linux.syscall1(.set_thread_area, addr);
161161
assert(rc == 0);
162162
},

lib/std/special/c.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ fn clone() callconv(.Naked) void {
354354
\\ ecall
355355
);
356356
},
357-
.mipsel => {
357+
.mips, .mipsel => {
358358
asm volatile (
359359
\\ # Save function pointer and argument pointer on new thread stack
360360
\\ and $5, $5, -8

lib/std/start.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ fn _start() callconv(.Naked) noreturn {
108108
: [argc] "=r" (-> [*]usize)
109109
);
110110
},
111-
.mipsel => {
111+
.mips, .mipsel => {
112112
// Need noat here because LLVM is free to pick any register
113113
starting_stack_ptr = asm (
114114
\\ .set noat

lib/std/unicode.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,9 @@ fn calcUtf16LeLen(utf8: []const u8) usize {
660660
}
661661

662662
test "utf8ToUtf16LeStringLiteral" {
663+
// https://github.com/ziglang/zig/issues/5127
664+
if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
665+
663666
{
664667
const bytes = [_:0]u16{0x41};
665668
const utf16 = utf8ToUtf16LeStringLiteral("A");

src/analyze.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ bool want_first_arg_sret(CodeGen *g, FnTypeId *fn_type_id) {
10071007
{
10081008
X64CABIClass abi_class = type_c_abi_x86_64_class(g, fn_type_id->return_type);
10091009
return abi_class == X64CABIClass_MEMORY || abi_class == X64CABIClass_MEMORY_nobyval;
1010-
} else if (g->zig_target->arch == ZigLLVM_mipsel) {
1010+
} else if (g->zig_target->arch == ZigLLVM_mips || g->zig_target->arch == ZigLLVM_mipsel) {
10111011
return false;
10121012
}
10131013
zig_panic("TODO implement C ABI for this architecture. See https://github.com/ziglang/zig/issues/1481");

0 commit comments

Comments
 (0)