| author | |
| committer | |
| log | 7efca2e6f51458de8e70a6f5cbbc292026321681 |
| tree | 67595e90e73b9cb2637848d1fdd950f3463f2c4e |
| parent | db4fea6689eb34959028cad3b63de45da65683d3 |
| parent | 75263e160e477a210a3d2a007b6d66c63b85001f |
53 files changed, 1291 insertions(+), 767 deletions(-)
ci/azure/linux_script+1-1| ... | ... | @@ -9,7 +9,7 @@ sudo apt-get install -y cmake s3cmd tidy |
| 9 | 9 | ZIGDIR="$(pwd)" |
| 10 | 10 | ARCH="$(uname -m)" |
| 11 | 11 | TARGET="$ARCH-linux-musl" |
| 12 | CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.8.0-dev.2703+c12704a33" | |
| 12 | CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.8.1-dev.94+535615117" | |
| 13 | 13 | PREFIX="$HOME/$CACHE_BASENAME" |
| 14 | 14 | MCPU="baseline" |
| 15 | 15 | JOBS="-j$(nproc)" |
ci/azure/macos_script+1-1| ... | ... | @@ -9,7 +9,7 @@ ZIGDIR="$(pwd)" |
| 9 | 9 | ARCH="x86_64" |
| 10 | 10 | TARGET="$ARCH-macos-gnu" |
| 11 | 11 | MCPU="baseline" |
| 12 | CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.8.0-dev.2703+c12704a33" | |
| 12 | CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.8.1-dev.94+535615117" | |
| 13 | 13 | PREFIX="$HOME/$CACHE_BASENAME" |
| 14 | 14 | JOBS="-j2" |
| 15 | 15 |
doc/langref.html.in+1-1| ... | ... | @@ -783,7 +783,7 @@ pub fn main() void { |
| 783 | 783 | Because Zig source code is {#link|UTF-8 encoded|Source Encoding#}, any non-ASCII bytes appearing within a string literal |
| 784 | 784 | in source code carry their UTF-8 meaning into the content of the string in the Zig program; |
| 785 | 785 | the bytes are not modified by the compiler. |
| 786 | However, it is possible to embbed non-UTF-8 bytes into a string literal using <code>\xNN</code> notation. | |
| 786 | However, it is possible to embed non-UTF-8 bytes into a string literal using <code>\xNN</code> notation. | |
| 787 | 787 | </p> |
| 788 | 788 | <p> |
| 789 | 789 | Unicode code point literals have type {#syntax#}comptime_int{#endsyntax#}, the same as |
lib/std/Thread.zig+9-9| ... | ... | @@ -700,7 +700,7 @@ const LinuxThreadImpl = struct { |
| 700 | 700 | \\ int $128 |
| 701 | 701 | : |
| 702 | 702 | : [ptr] "r" (@ptrToInt(self.mapped.ptr)), |
| 703 | [len] "r" (self.mapped.len) | |
| 703 | [len] "r" (self.mapped.len), | |
| 704 | 704 | : "memory" |
| 705 | 705 | ), |
| 706 | 706 | .x86_64 => asm volatile ( |
| ... | ... | @@ -713,7 +713,7 @@ const LinuxThreadImpl = struct { |
| 713 | 713 | \\ syscall |
| 714 | 714 | : |
| 715 | 715 | : [ptr] "r" (@ptrToInt(self.mapped.ptr)), |
| 716 | [len] "r" (self.mapped.len) | |
| 716 | [len] "r" (self.mapped.len), | |
| 717 | 717 | : "memory" |
| 718 | 718 | ), |
| 719 | 719 | .arm, .armeb, .thumb, .thumbeb => asm volatile ( |
| ... | ... | @@ -726,7 +726,7 @@ const LinuxThreadImpl = struct { |
| 726 | 726 | \\ svc 0 |
| 727 | 727 | : |
| 728 | 728 | : [ptr] "r" (@ptrToInt(self.mapped.ptr)), |
| 729 | [len] "r" (self.mapped.len) | |
| 729 | [len] "r" (self.mapped.len), | |
| 730 | 730 | : "memory" |
| 731 | 731 | ), |
| 732 | 732 | .aarch64, .aarch64_be, .aarch64_32 => asm volatile ( |
| ... | ... | @@ -739,7 +739,7 @@ const LinuxThreadImpl = struct { |
| 739 | 739 | \\ svc 0 |
| 740 | 740 | : |
| 741 | 741 | : [ptr] "r" (@ptrToInt(self.mapped.ptr)), |
| 742 | [len] "r" (self.mapped.len) | |
| 742 | [len] "r" (self.mapped.len), | |
| 743 | 743 | : "memory" |
| 744 | 744 | ), |
| 745 | 745 | .mips, .mipsel => asm volatile ( |
| ... | ... | @@ -753,7 +753,7 @@ const LinuxThreadImpl = struct { |
| 753 | 753 | \\ syscall |
| 754 | 754 | : |
| 755 | 755 | : [ptr] "r" (@ptrToInt(self.mapped.ptr)), |
| 756 | [len] "r" (self.mapped.len) | |
| 756 | [len] "r" (self.mapped.len), | |
| 757 | 757 | : "memory" |
| 758 | 758 | ), |
| 759 | 759 | .mips64, .mips64el => asm volatile ( |
| ... | ... | @@ -766,7 +766,7 @@ const LinuxThreadImpl = struct { |
| 766 | 766 | \\ syscall |
| 767 | 767 | : |
| 768 | 768 | : [ptr] "r" (@ptrToInt(self.mapped.ptr)), |
| 769 | [len] "r" (self.mapped.len) | |
| 769 | [len] "r" (self.mapped.len), | |
| 770 | 770 | : "memory" |
| 771 | 771 | ), |
| 772 | 772 | .powerpc, .powerpcle, .powerpc64, .powerpc64le => asm volatile ( |
| ... | ... | @@ -780,7 +780,7 @@ const LinuxThreadImpl = struct { |
| 780 | 780 | \\ blr |
| 781 | 781 | : |
| 782 | 782 | : [ptr] "r" (@ptrToInt(self.mapped.ptr)), |
| 783 | [len] "r" (self.mapped.len) | |
| 783 | [len] "r" (self.mapped.len), | |
| 784 | 784 | : "memory" |
| 785 | 785 | ), |
| 786 | 786 | .riscv64 => asm volatile ( |
| ... | ... | @@ -793,7 +793,7 @@ const LinuxThreadImpl = struct { |
| 793 | 793 | \\ ecall |
| 794 | 794 | : |
| 795 | 795 | : [ptr] "r" (@ptrToInt(self.mapped.ptr)), |
| 796 | [len] "r" (self.mapped.len) | |
| 796 | [len] "r" (self.mapped.len), | |
| 797 | 797 | : "memory" |
| 798 | 798 | ), |
| 799 | 799 | .sparcv9 => asm volatile ( |
| ... | ... | @@ -821,7 +821,7 @@ const LinuxThreadImpl = struct { |
| 821 | 821 | \\ t 0x6d |
| 822 | 822 | : |
| 823 | 823 | : [ptr] "r" (@ptrToInt(self.mapped.ptr)), |
| 824 | [len] "r" (self.mapped.len) | |
| 824 | [len] "r" (self.mapped.len), | |
| 825 | 825 | : "memory" |
| 826 | 826 | ), |
| 827 | 827 | else => |cpu_arch| @compileError("Unsupported linux arch: " ++ @tagName(cpu_arch)), |
lib/std/array_hash_map.zig+44| ... | ... | @@ -293,6 +293,22 @@ pub fn ArrayHashMap( |
| 293 | 293 | return self.unmanaged.getPtrAdapted(key, ctx); |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | /// Find the actual key associated with an adapted key | |
| 297 | pub fn getKey(self: Self, key: K) ?K { | |
| 298 | return self.unmanaged.getKeyContext(key, self.ctx); | |
| 299 | } | |
| 300 | pub fn getKeyAdapted(self: Self, key: anytype, ctx: anytype) ?K { | |
| 301 | return self.unmanaged.getKeyAdapted(key, ctx); | |
| 302 | } | |
| 303 | ||
| 304 | /// Find a pointer to the actual key associated with an adapted key | |
| 305 | pub fn getKeyPtr(self: Self, key: K) ?*K { | |
| 306 | return self.unmanaged.getKeyPtrContext(key, self.ctx); | |
| 307 | } | |
| 308 | pub fn getKeyPtrAdapted(self: Self, key: anytype, ctx: anytype) ?*K { | |
| 309 | return self.unmanaged.getKeyPtrAdapted(key, ctx); | |
| 310 | } | |
| 311 | ||
| 296 | 312 | /// Check whether a key is stored in the map |
| 297 | 313 | pub fn contains(self: Self, key: K) bool { |
| 298 | 314 | return self.unmanaged.containsContext(key, self.ctx); |
| ... | ... | @@ -967,6 +983,34 @@ pub fn ArrayHashMapUnmanaged( |
| 967 | 983 | return if (@sizeOf(*V) == 0) @as(*V, undefined) else &self.values()[index]; |
| 968 | 984 | } |
| 969 | 985 | |
| 986 | /// Find the actual key associated with an adapted key | |
| 987 | pub fn getKey(self: Self, key: K) ?K { | |
| 988 | if (@sizeOf(Context) != 0) | |
| 989 | @compileError("Cannot infer context " ++ @typeName(Context) ++ ", call getKeyContext instead."); | |
| 990 | return self.getKeyContext(key, undefined); | |
| 991 | } | |
| 992 | pub fn getKeyContext(self: Self, key: K, ctx: Context) ?K { | |
| 993 | return self.getKeyAdapted(key, ctx); | |
| 994 | } | |
| 995 | pub fn getKeyAdapted(self: Self, key: anytype, ctx: anytype) ?K { | |
| 996 | const index = self.getIndexAdapted(key, ctx) orelse return null; | |
| 997 | return self.keys()[index]; | |
| 998 | } | |
| 999 | ||
| 1000 | /// Find a pointer to the actual key associated with an adapted key | |
| 1001 | pub fn getKeyPtr(self: Self, key: K) ?*K { | |
| 1002 | if (@sizeOf(Context) != 0) | |
| 1003 | @compileError("Cannot infer context " ++ @typeName(Context) ++ ", call getKeyPtrContext instead."); | |
| 1004 | return self.getKeyPtrContext(key, undefined); | |
| 1005 | } | |
| 1006 | pub fn getKeyPtrContext(self: Self, key: K, ctx: Context) ?*K { | |
| 1007 | return self.getKeyPtrAdapted(key, ctx); | |
| 1008 | } | |
| 1009 | pub fn getKeyPtrAdapted(self: Self, key: anytype, ctx: anytype) ?*K { | |
| 1010 | const index = self.getIndexAdapted(key, ctx) orelse return null; | |
| 1011 | return &self.keys()[index]; | |
| 1012 | } | |
| 1013 | ||
| 970 | 1014 | /// Check whether a key is stored in the map |
| 971 | 1015 | pub fn contains(self: Self, key: K) bool { |
| 972 | 1016 | if (@sizeOf(Context) != 0) |
lib/std/atomic/Atomic.zig+18-18| ... | ... | @@ -176,69 +176,69 @@ pub fn Atomic(comptime T: type) type { |
| 176 | 176 | 2 => switch (op) { |
| 177 | 177 | .Set => asm volatile ("lock btsw %[bit], %[ptr]" |
| 178 | 178 | // LLVM doesn't support u1 flag register return values |
| 179 | : [result] "={@ccc}" (-> u8) | |
| 179 | : [result] "={@ccc}" (-> u8), | |
| 180 | 180 | : [ptr] "*p" (&self.value), |
| 181 | [bit] "X" (@as(T, bit)) | |
| 181 | [bit] "X" (@as(T, bit)), | |
| 182 | 182 | : "cc", "memory" |
| 183 | 183 | ), |
| 184 | 184 | .Reset => asm volatile ("lock btrw %[bit], %[ptr]" |
| 185 | 185 | // LLVM doesn't support u1 flag register return values |
| 186 | : [result] "={@ccc}" (-> u8) | |
| 186 | : [result] "={@ccc}" (-> u8), | |
| 187 | 187 | : [ptr] "*p" (&self.value), |
| 188 | [bit] "X" (@as(T, bit)) | |
| 188 | [bit] "X" (@as(T, bit)), | |
| 189 | 189 | : "cc", "memory" |
| 190 | 190 | ), |
| 191 | 191 | .Toggle => asm volatile ("lock btcw %[bit], %[ptr]" |
| 192 | 192 | // LLVM doesn't support u1 flag register return values |
| 193 | : [result] "={@ccc}" (-> u8) | |
| 193 | : [result] "={@ccc}" (-> u8), | |
| 194 | 194 | : [ptr] "*p" (&self.value), |
| 195 | [bit] "X" (@as(T, bit)) | |
| 195 | [bit] "X" (@as(T, bit)), | |
| 196 | 196 | : "cc", "memory" |
| 197 | 197 | ), |
| 198 | 198 | }, |
| 199 | 199 | 4 => switch (op) { |
| 200 | 200 | .Set => asm volatile ("lock btsl %[bit], %[ptr]" |
| 201 | 201 | // LLVM doesn't support u1 flag register return values |
| 202 | : [result] "={@ccc}" (-> u8) | |
| 202 | : [result] "={@ccc}" (-> u8), | |
| 203 | 203 | : [ptr] "*p" (&self.value), |
| 204 | [bit] "X" (@as(T, bit)) | |
| 204 | [bit] "X" (@as(T, bit)), | |
| 205 | 205 | : "cc", "memory" |
| 206 | 206 | ), |
| 207 | 207 | .Reset => asm volatile ("lock btrl %[bit], %[ptr]" |
| 208 | 208 | // LLVM doesn't support u1 flag register return values |
| 209 | : [result] "={@ccc}" (-> u8) | |
| 209 | : [result] "={@ccc}" (-> u8), | |
| 210 | 210 | : [ptr] "*p" (&self.value), |
| 211 | [bit] "X" (@as(T, bit)) | |
| 211 | [bit] "X" (@as(T, bit)), | |
| 212 | 212 | : "cc", "memory" |
| 213 | 213 | ), |
| 214 | 214 | .Toggle => asm volatile ("lock btcl %[bit], %[ptr]" |
| 215 | 215 | // LLVM doesn't support u1 flag register return values |
| 216 | : [result] "={@ccc}" (-> u8) | |
| 216 | : [result] "={@ccc}" (-> u8), | |
| 217 | 217 | : [ptr] "*p" (&self.value), |
| 218 | [bit] "X" (@as(T, bit)) | |
| 218 | [bit] "X" (@as(T, bit)), | |
| 219 | 219 | : "cc", "memory" |
| 220 | 220 | ), |
| 221 | 221 | }, |
| 222 | 222 | 8 => switch (op) { |
| 223 | 223 | .Set => asm volatile ("lock btsq %[bit], %[ptr]" |
| 224 | 224 | // LLVM doesn't support u1 flag register return values |
| 225 | : [result] "={@ccc}" (-> u8) | |
| 225 | : [result] "={@ccc}" (-> u8), | |
| 226 | 226 | : [ptr] "*p" (&self.value), |
| 227 | [bit] "X" (@as(T, bit)) | |
| 227 | [bit] "X" (@as(T, bit)), | |
| 228 | 228 | : "cc", "memory" |
| 229 | 229 | ), |
| 230 | 230 | .Reset => asm volatile ("lock btrq %[bit], %[ptr]" |
| 231 | 231 | // LLVM doesn't support u1 flag register return values |
| 232 | : [result] "={@ccc}" (-> u8) | |
| 232 | : [result] "={@ccc}" (-> u8), | |
| 233 | 233 | : [ptr] "*p" (&self.value), |
| 234 | [bit] "X" (@as(T, bit)) | |
| 234 | [bit] "X" (@as(T, bit)), | |
| 235 | 235 | : "cc", "memory" |
| 236 | 236 | ), |
| 237 | 237 | .Toggle => asm volatile ("lock btcq %[bit], %[ptr]" |
| 238 | 238 | // LLVM doesn't support u1 flag register return values |
| 239 | : [result] "={@ccc}" (-> u8) | |
| 239 | : [result] "={@ccc}" (-> u8), | |
| 240 | 240 | : [ptr] "*p" (&self.value), |
| 241 | [bit] "X" (@as(T, bit)) | |
| 241 | [bit] "X" (@as(T, bit)), | |
| 242 | 242 | : "cc", "memory" |
| 243 | 243 | ), |
| 244 | 244 | }, |
lib/std/build.zig+13| ... | ... | @@ -94,6 +94,8 @@ pub const Builder = struct { |
| 94 | 94 | name: []const u8, |
| 95 | 95 | type_id: TypeId, |
| 96 | 96 | description: []const u8, |
| 97 | /// If the `type_id` is `enum` this provides the list of enum options | |
| 98 | enum_options: ?[]const []const u8, | |
| 97 | 99 | }; |
| 98 | 100 | |
| 99 | 101 | const UserInputOption = struct { |
| ... | ... | @@ -482,10 +484,21 @@ pub const Builder = struct { |
| 482 | 484 | const name = self.dupe(name_raw); |
| 483 | 485 | const description = self.dupe(description_raw); |
| 484 | 486 | const type_id = comptime typeToEnum(T); |
| 487 | const enum_options = if (type_id == .@"enum") blk: { | |
| 488 | const fields = comptime std.meta.fields(T); | |
| 489 | var options = ArrayList([]const u8).initCapacity(self.allocator, fields.len) catch unreachable; | |
| 490 | ||
| 491 | inline for (fields) |field| { | |
| 492 | options.appendAssumeCapacity(field.name); | |
| 493 | } | |
| 494 | ||
| 495 | break :blk options.toOwnedSlice(); | |
| 496 | } else null; | |
| 485 | 497 | const available_option = AvailableOption{ |
| 486 | 498 | .name = name, |
| 487 | 499 | .type_id = type_id, |
| 488 | 500 | .description = description, |
| 501 | .enum_options = enum_options, | |
| 489 | 502 | }; |
| 490 | 503 | if ((self.available_options_map.fetchPut(name, available_option) catch unreachable) != null) { |
| 491 | 504 | panic("Option '{s}' declared twice", .{name}); |
lib/std/crypto/aes/aesni.zig+12-12| ... | ... | @@ -34,9 +34,9 @@ pub const Block = struct { |
| 34 | 34 | return Block{ |
| 35 | 35 | .repr = asm ( |
| 36 | 36 | \\ vaesenc %[rk], %[in], %[out] |
| 37 | : [out] "=x" (-> BlockVec) | |
| 37 | : [out] "=x" (-> BlockVec), | |
| 38 | 38 | : [in] "x" (block.repr), |
| 39 | [rk] "x" (round_key.repr) | |
| 39 | [rk] "x" (round_key.repr), | |
| 40 | 40 | ), |
| 41 | 41 | }; |
| 42 | 42 | } |
| ... | ... | @@ -46,9 +46,9 @@ pub const Block = struct { |
| 46 | 46 | return Block{ |
| 47 | 47 | .repr = asm ( |
| 48 | 48 | \\ vaesenclast %[rk], %[in], %[out] |
| 49 | : [out] "=x" (-> BlockVec) | |
| 49 | : [out] "=x" (-> BlockVec), | |
| 50 | 50 | : [in] "x" (block.repr), |
| 51 | [rk] "x" (round_key.repr) | |
| 51 | [rk] "x" (round_key.repr), | |
| 52 | 52 | ), |
| 53 | 53 | }; |
| 54 | 54 | } |
| ... | ... | @@ -58,9 +58,9 @@ pub const Block = struct { |
| 58 | 58 | return Block{ |
| 59 | 59 | .repr = asm ( |
| 60 | 60 | \\ vaesdec %[rk], %[in], %[out] |
| 61 | : [out] "=x" (-> BlockVec) | |
| 61 | : [out] "=x" (-> BlockVec), | |
| 62 | 62 | : [in] "x" (block.repr), |
| 63 | [rk] "x" (inv_round_key.repr) | |
| 63 | [rk] "x" (inv_round_key.repr), | |
| 64 | 64 | ), |
| 65 | 65 | }; |
| 66 | 66 | } |
| ... | ... | @@ -70,9 +70,9 @@ pub const Block = struct { |
| 70 | 70 | return Block{ |
| 71 | 71 | .repr = asm ( |
| 72 | 72 | \\ vaesdeclast %[rk], %[in], %[out] |
| 73 | : [out] "=x" (-> BlockVec) | |
| 73 | : [out] "=x" (-> BlockVec), | |
| 74 | 74 | : [in] "x" (block.repr), |
| 75 | [rk] "x" (inv_round_key.repr) | |
| 75 | [rk] "x" (inv_round_key.repr), | |
| 76 | 76 | ), |
| 77 | 77 | }; |
| 78 | 78 | } |
| ... | ... | @@ -190,11 +190,11 @@ fn KeySchedule(comptime Aes: type) type { |
| 190 | 190 | \\ vpxor %[ts], %[r], %[r] |
| 191 | 191 | : [r] "=&x" (-> BlockVec), |
| 192 | 192 | [s] "=&x" (s), |
| 193 | [ts] "=&x" (ts) | |
| 193 | [ts] "=&x" (ts), | |
| 194 | 194 | : [rc] "n" (rc), |
| 195 | 195 | [t] "x" (t), |
| 196 | 196 | [tx] "x" (tx), |
| 197 | [mask] "n" (@as(u8, if (second) 0xaa else 0xff)) | |
| 197 | [mask] "n" (@as(u8, if (second) 0xaa else 0xff)), | |
| 198 | 198 | ); |
| 199 | 199 | } |
| 200 | 200 | |
| ... | ... | @@ -235,8 +235,8 @@ fn KeySchedule(comptime Aes: type) type { |
| 235 | 235 | inv_round_keys[i] = Block{ |
| 236 | 236 | .repr = asm ( |
| 237 | 237 | \\ vaesimc %[rk], %[inv_rk] |
| 238 | : [inv_rk] "=x" (-> BlockVec) | |
| 239 | : [rk] "x" (round_keys[rounds - i].repr) | |
| 238 | : [inv_rk] "=x" (-> BlockVec), | |
| 239 | : [rk] "x" (round_keys[rounds - i].repr), | |
| 240 | 240 | ), |
| 241 | 241 | }; |
| 242 | 242 | } |
lib/std/crypto/aes/armcrypto.zig+14-14| ... | ... | @@ -39,10 +39,10 @@ pub const Block = struct { |
| 39 | 39 | \\ aese %[out].16b, %[zero].16b |
| 40 | 40 | \\ aesmc %[out].16b, %[out].16b |
| 41 | 41 | \\ eor %[out].16b, %[out].16b, %[rk].16b |
| 42 | : [out] "=&x" (-> BlockVec) | |
| 42 | : [out] "=&x" (-> BlockVec), | |
| 43 | 43 | : [in] "x" (block.repr), |
| 44 | 44 | [rk] "x" (round_key.repr), |
| 45 | [zero] "x" (zero) | |
| 45 | [zero] "x" (zero), | |
| 46 | 46 | ), |
| 47 | 47 | }; |
| 48 | 48 | } |
| ... | ... | @@ -54,10 +54,10 @@ pub const Block = struct { |
| 54 | 54 | \\ mov %[out].16b, %[in].16b |
| 55 | 55 | \\ aese %[out].16b, %[zero].16b |
| 56 | 56 | \\ eor %[out].16b, %[out].16b, %[rk].16b |
| 57 | : [out] "=&x" (-> BlockVec) | |
| 57 | : [out] "=&x" (-> BlockVec), | |
| 58 | 58 | : [in] "x" (block.repr), |
| 59 | 59 | [rk] "x" (round_key.repr), |
| 60 | [zero] "x" (zero) | |
| 60 | [zero] "x" (zero), | |
| 61 | 61 | ), |
| 62 | 62 | }; |
| 63 | 63 | } |
| ... | ... | @@ -70,10 +70,10 @@ pub const Block = struct { |
| 70 | 70 | \\ aesd %[out].16b, %[zero].16b |
| 71 | 71 | \\ aesimc %[out].16b, %[out].16b |
| 72 | 72 | \\ eor %[out].16b, %[out].16b, %[rk].16b |
| 73 | : [out] "=&x" (-> BlockVec) | |
| 73 | : [out] "=&x" (-> BlockVec), | |
| 74 | 74 | : [in] "x" (block.repr), |
| 75 | 75 | [rk] "x" (inv_round_key.repr), |
| 76 | [zero] "x" (zero) | |
| 76 | [zero] "x" (zero), | |
| 77 | 77 | ), |
| 78 | 78 | }; |
| 79 | 79 | } |
| ... | ... | @@ -85,10 +85,10 @@ pub const Block = struct { |
| 85 | 85 | \\ mov %[out].16b, %[in].16b |
| 86 | 86 | \\ aesd %[out].16b, %[zero].16b |
| 87 | 87 | \\ eor %[out].16b, %[out].16b, %[rk].16b |
| 88 | : [out] "=&x" (-> BlockVec) | |
| 88 | : [out] "=&x" (-> BlockVec), | |
| 89 | 89 | : [in] "x" (block.repr), |
| 90 | 90 | [rk] "x" (inv_round_key.repr), |
| 91 | [zero] "x" (zero) | |
| 91 | [zero] "x" (zero), | |
| 92 | 92 | ), |
| 93 | 93 | }; |
| 94 | 94 | } |
| ... | ... | @@ -210,11 +210,11 @@ fn KeySchedule(comptime Aes: type) type { |
| 210 | 210 | [v1] "=&x" (v1), |
| 211 | 211 | [v2] "=&x" (v2), |
| 212 | 212 | [v3] "=&x" (v3), |
| 213 | [v4] "=&x" (v4) | |
| 213 | [v4] "=&x" (v4), | |
| 214 | 214 | : [rc] "N" (rc), |
| 215 | 215 | [t] "x" (t), |
| 216 | 216 | [zero] "x" (zero), |
| 217 | [mask] "x" (mask1) | |
| 217 | [mask] "x" (mask1), | |
| 218 | 218 | ); |
| 219 | 219 | } |
| 220 | 220 | |
| ... | ... | @@ -240,12 +240,12 @@ fn KeySchedule(comptime Aes: type) type { |
| 240 | 240 | [v1] "=&x" (v1), |
| 241 | 241 | [v2] "=&x" (v2), |
| 242 | 242 | [v3] "=&x" (v3), |
| 243 | [v4] "=&x" (v4) | |
| 243 | [v4] "=&x" (v4), | |
| 244 | 244 | : [rc] "N" (if (second) @as(u8, 0) else rc), |
| 245 | 245 | [t] "x" (t), |
| 246 | 246 | [tx] "x" (tx), |
| 247 | 247 | [zero] "x" (zero), |
| 248 | [mask] "x" (if (second) mask2 else mask1) | |
| 248 | [mask] "x" (if (second) mask2 else mask1), | |
| 249 | 249 | ); |
| 250 | 250 | } |
| 251 | 251 | |
| ... | ... | @@ -286,8 +286,8 @@ fn KeySchedule(comptime Aes: type) type { |
| 286 | 286 | inv_round_keys[i] = Block{ |
| 287 | 287 | .repr = asm ( |
| 288 | 288 | \\ aesimc %[inv_rk].16b, %[rk].16b |
| 289 | : [inv_rk] "=x" (-> BlockVec) | |
| 290 | : [rk] "x" (round_keys[rounds - i].repr) | |
| 289 | : [inv_rk] "=x" (-> BlockVec), | |
| 290 | : [rk] "x" (round_keys[rounds - i].repr), | |
| 291 | 291 | ), |
| 292 | 292 | }; |
| 293 | 293 | } |
lib/std/crypto/ghash.zig+4-4| ... | ... | @@ -94,9 +94,9 @@ pub const Ghash = struct { |
| 94 | 94 | const Vector = std.meta.Vector; |
| 95 | 95 | const product = asm ( |
| 96 | 96 | \\ vpclmulqdq $0x00, %[x], %[y], %[out] |
| 97 | : [out] "=x" (-> Vector(2, u64)) | |
| 97 | : [out] "=x" (-> Vector(2, u64)), | |
| 98 | 98 | : [x] "x" (@bitCast(Vector(2, u64), @as(u128, x))), |
| 99 | [y] "x" (@bitCast(Vector(2, u64), @as(u128, y))) | |
| 99 | [y] "x" (@bitCast(Vector(2, u64), @as(u128, y))), | |
| 100 | 100 | ); |
| 101 | 101 | return product[0]; |
| 102 | 102 | } |
| ... | ... | @@ -105,9 +105,9 @@ pub const Ghash = struct { |
| 105 | 105 | const Vector = std.meta.Vector; |
| 106 | 106 | const product = asm ( |
| 107 | 107 | \\ pmull %[out].1q, %[x].1d, %[y].1d |
| 108 | : [out] "=w" (-> Vector(2, u64)) | |
| 108 | : [out] "=w" (-> Vector(2, u64)), | |
| 109 | 109 | : [x] "w" (@bitCast(Vector(2, u64), @as(u128, x))), |
| 110 | [y] "w" (@bitCast(Vector(2, u64), @as(u128, y))) | |
| 110 | [y] "w" (@bitCast(Vector(2, u64), @as(u128, y))), | |
| 111 | 111 | ); |
| 112 | 112 | return product[0]; |
| 113 | 113 | } |
lib/std/debug.zig+1-1| ... | ... | @@ -1634,7 +1634,7 @@ fn handleSegfaultWindowsExtra(info: *windows.EXCEPTION_POINTERS, comptime msg: u |
| 1634 | 1634 | |
| 1635 | 1635 | pub fn dumpStackPointerAddr(prefix: []const u8) void { |
| 1636 | 1636 | const sp = asm ("" |
| 1637 | : [argc] "={rsp}" (-> usize) | |
| 1637 | : [argc] "={rsp}" (-> usize), | |
| 1638 | 1638 | ); |
| 1639 | 1639 | std.debug.warn("{} sp = 0x{x}\n", .{ prefix, sp }); |
| 1640 | 1640 | } |
lib/std/fmt.zig+1-2| ... | ... | @@ -1200,8 +1200,6 @@ pub fn formatFloatDecimal( |
| 1200 | 1200 | while (i < precision) : (i += 1) { |
| 1201 | 1201 | try writer.writeAll("0"); |
| 1202 | 1202 | } |
| 1203 | } else { | |
| 1204 | try writer.writeAll(".0"); | |
| 1205 | 1203 | } |
| 1206 | 1204 | } |
| 1207 | 1205 | |
| ... | ... | @@ -2198,6 +2196,7 @@ test "float.hexadecimal.precision" { |
| 2198 | 2196 | test "float.decimal" { |
| 2199 | 2197 | try expectFmt("f64: 152314000000000000000000000000", "f64: {d}", .{@as(f64, 1.52314e+29)}); |
| 2200 | 2198 | try expectFmt("f32: 0", "f32: {d}", .{@as(f32, 0.0)}); |
| 2199 | try expectFmt("f32: 0", "f32: {d:.0}", .{@as(f32, 0.0)}); | |
| 2201 | 2200 | try expectFmt("f32: 1.1", "f32: {d:.1}", .{@as(f32, 1.1234)}); |
| 2202 | 2201 | try expectFmt("f32: 1234.57", "f32: {d:.2}", .{@as(f32, 1234.567)}); |
| 2203 | 2202 | // -11.1234 is converted to f64 -11.12339... internally (errol3() function takes f64). |
lib/std/hash_map.zig+48| ... | ... | @@ -561,6 +561,21 @@ pub fn HashMap( |
| 561 | 561 | return self.unmanaged.getPtrAdapted(key, ctx); |
| 562 | 562 | } |
| 563 | 563 | |
| 564 | /// Finds the actual key associated with an adapted key in the map | |
| 565 | pub fn getKey(self: Self, key: K) ?K { | |
| 566 | return self.unmanaged.getKeyContext(key, self.ctx); | |
| 567 | } | |
| 568 | pub fn getKeyAdapted(self: Self, key: anytype, ctx: anytype) ?K { | |
| 569 | return self.unmanaged.getKeyAdapted(key, ctx); | |
| 570 | } | |
| 571 | ||
| 572 | pub fn getKeyPtr(self: Self, key: K) ?*K { | |
| 573 | return self.unmanaged.getKeyPtrContext(key, self.ctx); | |
| 574 | } | |
| 575 | pub fn getKeyPtrAdapted(self: Self, key: anytype, ctx: anytype) ?*K { | |
| 576 | return self.unmanaged.getKeyPtrAdapted(key, ctx); | |
| 577 | } | |
| 578 | ||
| 564 | 579 | /// Finds the key and value associated with a key in the map |
| 565 | 580 | pub fn getEntry(self: Self, key: K) ?Entry { |
| 566 | 581 | return self.unmanaged.getEntryContext(key, self.ctx); |
| ... | ... | @@ -1124,6 +1139,38 @@ pub fn HashMapUnmanaged( |
| 1124 | 1139 | result.value_ptr.* = value; |
| 1125 | 1140 | } |
| 1126 | 1141 | |
| 1142 | /// Get an optional pointer to the actual key associated with adapted key, if present. | |
| 1143 | pub fn getKeyPtr(self: Self, key: K) ?*K { | |
| 1144 | if (@sizeOf(Context) != 0) | |
| 1145 | @compileError("Cannot infer context " ++ @typeName(Context) ++ ", call getKeyPtrContext instead."); | |
| 1146 | return self.getKeyPtrContext(key, undefined); | |
| 1147 | } | |
| 1148 | pub fn getKeyPtrContext(self: Self, key: K, ctx: Context) ?*K { | |
| 1149 | return self.getKeyPtrAdapted(key, ctx); | |
| 1150 | } | |
| 1151 | pub fn getKeyPtrAdapted(self: Self, key: anytype, ctx: anytype) ?*K { | |
| 1152 | if (self.getIndex(key, ctx)) |idx| { | |
| 1153 | return &self.keys()[idx]; | |
| 1154 | } | |
| 1155 | return null; | |
| 1156 | } | |
| 1157 | ||
| 1158 | /// Get a copy of the actual key associated with adapted key, if present. | |
| 1159 | pub fn getKey(self: Self, key: K) ?K { | |
| 1160 | if (@sizeOf(Context) != 0) | |
| 1161 | @compileError("Cannot infer context " ++ @typeName(Context) ++ ", call getKeyContext instead."); | |
| 1162 | return self.getKeyContext(key, undefined); | |
| 1163 | } | |
| 1164 | pub fn getKeyContext(self: Self, key: K, ctx: Context) ?K { | |
| 1165 | return self.getKeyAdapted(key, ctx); | |
| 1166 | } | |
| 1167 | pub fn getKeyAdapted(self: Self, key: anytype, ctx: anytype) ?K { | |
| 1168 | if (self.getIndex(key, ctx)) |idx| { | |
| 1169 | return self.keys()[idx]; | |
| 1170 | } | |
| 1171 | return null; | |
| 1172 | } | |
| 1173 | ||
| 1127 | 1174 | /// Get an optional pointer to the value associated with key, if present. |
| 1128 | 1175 | pub fn getPtr(self: Self, key: K) ?*V { |
| 1129 | 1176 | if (@sizeOf(Context) != 0) |
| ... | ... | @@ -1948,6 +1995,7 @@ test "std.hash_map getOrPutAdapted" { |
| 1948 | 1995 | try testing.expect(result.found_existing); |
| 1949 | 1996 | try testing.expectEqual(real_keys[i], result.key_ptr.*); |
| 1950 | 1997 | try testing.expectEqual(@as(u64, i) * 2, result.value_ptr.*); |
| 1998 | try testing.expectEqual(real_keys[i], map.getKeyAdapted(key_str, AdaptedContext{}).?); | |
| 1951 | 1999 | } |
| 1952 | 2000 | } |
| 1953 | 2001 |
lib/std/mem.zig+1-1| ... | ... | @@ -2860,7 +2860,7 @@ pub fn alignForwardGeneric(comptime T: type, addr: T, alignment: T) T { |
| 2860 | 2860 | pub fn doNotOptimizeAway(val: anytype) void { |
| 2861 | 2861 | asm volatile ("" |
| 2862 | 2862 | : |
| 2863 | : [val] "rm" (val) | |
| 2863 | : [val] "rm" (val), | |
| 2864 | 2864 | : "memory" |
| 2865 | 2865 | ); |
| 2866 | 2866 | } |
lib/std/os/linux/arm-eabi.zig+16-16| ... | ... | @@ -2,63 +2,63 @@ usingnamespace @import("../bits/linux.zig"); |
| 2 | 2 | |
| 3 | 3 | pub fn syscall0(number: SYS) usize { |
| 4 | 4 | return asm volatile ("svc #0" |
| 5 | : [ret] "={r0}" (-> usize) | |
| 6 | : [number] "{r7}" (@enumToInt(number)) | |
| 5 | : [ret] "={r0}" (-> usize), | |
| 6 | : [number] "{r7}" (@enumToInt(number)), | |
| 7 | 7 | : "memory" |
| 8 | 8 | ); |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | pub fn syscall1(number: SYS, arg1: usize) usize { |
| 12 | 12 | return asm volatile ("svc #0" |
| 13 | : [ret] "={r0}" (-> usize) | |
| 13 | : [ret] "={r0}" (-> usize), | |
| 14 | 14 | : [number] "{r7}" (@enumToInt(number)), |
| 15 | [arg1] "{r0}" (arg1) | |
| 15 | [arg1] "{r0}" (arg1), | |
| 16 | 16 | : "memory" |
| 17 | 17 | ); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { |
| 21 | 21 | return asm volatile ("svc #0" |
| 22 | : [ret] "={r0}" (-> usize) | |
| 22 | : [ret] "={r0}" (-> usize), | |
| 23 | 23 | : [number] "{r7}" (@enumToInt(number)), |
| 24 | 24 | [arg1] "{r0}" (arg1), |
| 25 | [arg2] "{r1}" (arg2) | |
| 25 | [arg2] "{r1}" (arg2), | |
| 26 | 26 | : "memory" |
| 27 | 27 | ); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 31 | 31 | return asm volatile ("svc #0" |
| 32 | : [ret] "={r0}" (-> usize) | |
| 32 | : [ret] "={r0}" (-> usize), | |
| 33 | 33 | : [number] "{r7}" (@enumToInt(number)), |
| 34 | 34 | [arg1] "{r0}" (arg1), |
| 35 | 35 | [arg2] "{r1}" (arg2), |
| 36 | [arg3] "{r2}" (arg3) | |
| 36 | [arg3] "{r2}" (arg3), | |
| 37 | 37 | : "memory" |
| 38 | 38 | ); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { |
| 42 | 42 | return asm volatile ("svc #0" |
| 43 | : [ret] "={r0}" (-> usize) | |
| 43 | : [ret] "={r0}" (-> usize), | |
| 44 | 44 | : [number] "{r7}" (@enumToInt(number)), |
| 45 | 45 | [arg1] "{r0}" (arg1), |
| 46 | 46 | [arg2] "{r1}" (arg2), |
| 47 | 47 | [arg3] "{r2}" (arg3), |
| 48 | [arg4] "{r3}" (arg4) | |
| 48 | [arg4] "{r3}" (arg4), | |
| 49 | 49 | : "memory" |
| 50 | 50 | ); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { |
| 54 | 54 | return asm volatile ("svc #0" |
| 55 | : [ret] "={r0}" (-> usize) | |
| 55 | : [ret] "={r0}" (-> usize), | |
| 56 | 56 | : [number] "{r7}" (@enumToInt(number)), |
| 57 | 57 | [arg1] "{r0}" (arg1), |
| 58 | 58 | [arg2] "{r1}" (arg2), |
| 59 | 59 | [arg3] "{r2}" (arg3), |
| 60 | 60 | [arg4] "{r3}" (arg4), |
| 61 | [arg5] "{r4}" (arg5) | |
| 61 | [arg5] "{r4}" (arg5), | |
| 62 | 62 | : "memory" |
| 63 | 63 | ); |
| 64 | 64 | } |
| ... | ... | @@ -73,14 +73,14 @@ pub fn syscall6( |
| 73 | 73 | arg6: usize, |
| 74 | 74 | ) usize { |
| 75 | 75 | return asm volatile ("svc #0" |
| 76 | : [ret] "={r0}" (-> usize) | |
| 76 | : [ret] "={r0}" (-> usize), | |
| 77 | 77 | : [number] "{r7}" (@enumToInt(number)), |
| 78 | 78 | [arg1] "{r0}" (arg1), |
| 79 | 79 | [arg2] "{r1}" (arg2), |
| 80 | 80 | [arg3] "{r2}" (arg3), |
| 81 | 81 | [arg4] "{r3}" (arg4), |
| 82 | 82 | [arg5] "{r4}" (arg5), |
| 83 | [arg6] "{r5}" (arg6) | |
| 83 | [arg6] "{r5}" (arg6), | |
| 84 | 84 | : "memory" |
| 85 | 85 | ); |
| 86 | 86 | } |
| ... | ... | @@ -91,7 +91,7 @@ pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: |
| 91 | 91 | pub fn restore() callconv(.Naked) void { |
| 92 | 92 | return asm volatile ("svc #0" |
| 93 | 93 | : |
| 94 | : [number] "{r7}" (@enumToInt(SYS.sigreturn)) | |
| 94 | : [number] "{r7}" (@enumToInt(SYS.sigreturn)), | |
| 95 | 95 | : "memory" |
| 96 | 96 | ); |
| 97 | 97 | } |
| ... | ... | @@ -99,7 +99,7 @@ pub fn restore() callconv(.Naked) void { |
| 99 | 99 | pub fn restore_rt() callconv(.Naked) void { |
| 100 | 100 | return asm volatile ("svc #0" |
| 101 | 101 | : |
| 102 | : [number] "{r7}" (@enumToInt(SYS.rt_sigreturn)) | |
| 102 | : [number] "{r7}" (@enumToInt(SYS.rt_sigreturn)), | |
| 103 | 103 | : "memory" |
| 104 | 104 | ); |
| 105 | 105 | } |
lib/std/os/linux/arm64.zig+15-15| ... | ... | @@ -2,63 +2,63 @@ usingnamespace @import("../bits/linux.zig"); |
| 2 | 2 | |
| 3 | 3 | pub fn syscall0(number: SYS) usize { |
| 4 | 4 | return asm volatile ("svc #0" |
| 5 | : [ret] "={x0}" (-> usize) | |
| 6 | : [number] "{x8}" (@enumToInt(number)) | |
| 5 | : [ret] "={x0}" (-> usize), | |
| 6 | : [number] "{x8}" (@enumToInt(number)), | |
| 7 | 7 | : "memory", "cc" |
| 8 | 8 | ); |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | pub fn syscall1(number: SYS, arg1: usize) usize { |
| 12 | 12 | return asm volatile ("svc #0" |
| 13 | : [ret] "={x0}" (-> usize) | |
| 13 | : [ret] "={x0}" (-> usize), | |
| 14 | 14 | : [number] "{x8}" (@enumToInt(number)), |
| 15 | [arg1] "{x0}" (arg1) | |
| 15 | [arg1] "{x0}" (arg1), | |
| 16 | 16 | : "memory", "cc" |
| 17 | 17 | ); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { |
| 21 | 21 | return asm volatile ("svc #0" |
| 22 | : [ret] "={x0}" (-> usize) | |
| 22 | : [ret] "={x0}" (-> usize), | |
| 23 | 23 | : [number] "{x8}" (@enumToInt(number)), |
| 24 | 24 | [arg1] "{x0}" (arg1), |
| 25 | [arg2] "{x1}" (arg2) | |
| 25 | [arg2] "{x1}" (arg2), | |
| 26 | 26 | : "memory", "cc" |
| 27 | 27 | ); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 31 | 31 | return asm volatile ("svc #0" |
| 32 | : [ret] "={x0}" (-> usize) | |
| 32 | : [ret] "={x0}" (-> usize), | |
| 33 | 33 | : [number] "{x8}" (@enumToInt(number)), |
| 34 | 34 | [arg1] "{x0}" (arg1), |
| 35 | 35 | [arg2] "{x1}" (arg2), |
| 36 | [arg3] "{x2}" (arg3) | |
| 36 | [arg3] "{x2}" (arg3), | |
| 37 | 37 | : "memory", "cc" |
| 38 | 38 | ); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { |
| 42 | 42 | return asm volatile ("svc #0" |
| 43 | : [ret] "={x0}" (-> usize) | |
| 43 | : [ret] "={x0}" (-> usize), | |
| 44 | 44 | : [number] "{x8}" (@enumToInt(number)), |
| 45 | 45 | [arg1] "{x0}" (arg1), |
| 46 | 46 | [arg2] "{x1}" (arg2), |
| 47 | 47 | [arg3] "{x2}" (arg3), |
| 48 | [arg4] "{x3}" (arg4) | |
| 48 | [arg4] "{x3}" (arg4), | |
| 49 | 49 | : "memory", "cc" |
| 50 | 50 | ); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { |
| 54 | 54 | return asm volatile ("svc #0" |
| 55 | : [ret] "={x0}" (-> usize) | |
| 55 | : [ret] "={x0}" (-> usize), | |
| 56 | 56 | : [number] "{x8}" (@enumToInt(number)), |
| 57 | 57 | [arg1] "{x0}" (arg1), |
| 58 | 58 | [arg2] "{x1}" (arg2), |
| 59 | 59 | [arg3] "{x2}" (arg3), |
| 60 | 60 | [arg4] "{x3}" (arg4), |
| 61 | [arg5] "{x4}" (arg5) | |
| 61 | [arg5] "{x4}" (arg5), | |
| 62 | 62 | : "memory", "cc" |
| 63 | 63 | ); |
| 64 | 64 | } |
| ... | ... | @@ -73,14 +73,14 @@ pub fn syscall6( |
| 73 | 73 | arg6: usize, |
| 74 | 74 | ) usize { |
| 75 | 75 | return asm volatile ("svc #0" |
| 76 | : [ret] "={x0}" (-> usize) | |
| 76 | : [ret] "={x0}" (-> usize), | |
| 77 | 77 | : [number] "{x8}" (@enumToInt(number)), |
| 78 | 78 | [arg1] "{x0}" (arg1), |
| 79 | 79 | [arg2] "{x1}" (arg2), |
| 80 | 80 | [arg3] "{x2}" (arg3), |
| 81 | 81 | [arg4] "{x3}" (arg4), |
| 82 | 82 | [arg5] "{x4}" (arg5), |
| 83 | [arg6] "{x5}" (arg6) | |
| 83 | [arg6] "{x5}" (arg6), | |
| 84 | 84 | : "memory", "cc" |
| 85 | 85 | ); |
| 86 | 86 | } |
| ... | ... | @@ -93,7 +93,7 @@ pub const restore = restore_rt; |
| 93 | 93 | pub fn restore_rt() callconv(.Naked) void { |
| 94 | 94 | return asm volatile ("svc #0" |
| 95 | 95 | : |
| 96 | : [number] "{x8}" (@enumToInt(SYS.rt_sigreturn)) | |
| 96 | : [number] "{x8}" (@enumToInt(SYS.rt_sigreturn)), | |
| 97 | 97 | : "memory", "cc" |
| 98 | 98 | ); |
| 99 | 99 | } |
lib/std/os/linux/i386.zig+18-18| ... | ... | @@ -2,63 +2,63 @@ usingnamespace @import("../bits/linux.zig"); |
| 2 | 2 | |
| 3 | 3 | pub fn syscall0(number: SYS) usize { |
| 4 | 4 | return asm volatile ("int $0x80" |
| 5 | : [ret] "={eax}" (-> usize) | |
| 6 | : [number] "{eax}" (@enumToInt(number)) | |
| 5 | : [ret] "={eax}" (-> usize), | |
| 6 | : [number] "{eax}" (@enumToInt(number)), | |
| 7 | 7 | : "memory" |
| 8 | 8 | ); |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | pub fn syscall1(number: SYS, arg1: usize) usize { |
| 12 | 12 | return asm volatile ("int $0x80" |
| 13 | : [ret] "={eax}" (-> usize) | |
| 13 | : [ret] "={eax}" (-> usize), | |
| 14 | 14 | : [number] "{eax}" (@enumToInt(number)), |
| 15 | [arg1] "{ebx}" (arg1) | |
| 15 | [arg1] "{ebx}" (arg1), | |
| 16 | 16 | : "memory" |
| 17 | 17 | ); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { |
| 21 | 21 | return asm volatile ("int $0x80" |
| 22 | : [ret] "={eax}" (-> usize) | |
| 22 | : [ret] "={eax}" (-> usize), | |
| 23 | 23 | : [number] "{eax}" (@enumToInt(number)), |
| 24 | 24 | [arg1] "{ebx}" (arg1), |
| 25 | [arg2] "{ecx}" (arg2) | |
| 25 | [arg2] "{ecx}" (arg2), | |
| 26 | 26 | : "memory" |
| 27 | 27 | ); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 31 | 31 | return asm volatile ("int $0x80" |
| 32 | : [ret] "={eax}" (-> usize) | |
| 32 | : [ret] "={eax}" (-> usize), | |
| 33 | 33 | : [number] "{eax}" (@enumToInt(number)), |
| 34 | 34 | [arg1] "{ebx}" (arg1), |
| 35 | 35 | [arg2] "{ecx}" (arg2), |
| 36 | [arg3] "{edx}" (arg3) | |
| 36 | [arg3] "{edx}" (arg3), | |
| 37 | 37 | : "memory" |
| 38 | 38 | ); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { |
| 42 | 42 | return asm volatile ("int $0x80" |
| 43 | : [ret] "={eax}" (-> usize) | |
| 43 | : [ret] "={eax}" (-> usize), | |
| 44 | 44 | : [number] "{eax}" (@enumToInt(number)), |
| 45 | 45 | [arg1] "{ebx}" (arg1), |
| 46 | 46 | [arg2] "{ecx}" (arg2), |
| 47 | 47 | [arg3] "{edx}" (arg3), |
| 48 | [arg4] "{esi}" (arg4) | |
| 48 | [arg4] "{esi}" (arg4), | |
| 49 | 49 | : "memory" |
| 50 | 50 | ); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { |
| 54 | 54 | return asm volatile ("int $0x80" |
| 55 | : [ret] "={eax}" (-> usize) | |
| 55 | : [ret] "={eax}" (-> usize), | |
| 56 | 56 | : [number] "{eax}" (@enumToInt(number)), |
| 57 | 57 | [arg1] "{ebx}" (arg1), |
| 58 | 58 | [arg2] "{ecx}" (arg2), |
| 59 | 59 | [arg3] "{edx}" (arg3), |
| 60 | 60 | [arg4] "{esi}" (arg4), |
| 61 | [arg5] "{edi}" (arg5) | |
| 61 | [arg5] "{edi}" (arg5), | |
| 62 | 62 | : "memory" |
| 63 | 63 | ); |
| 64 | 64 | } |
| ... | ... | @@ -83,24 +83,24 @@ pub fn syscall6( |
| 83 | 83 | \\ int $0x80 |
| 84 | 84 | \\ pop %%ebp |
| 85 | 85 | \\ add $4, %%esp |
| 86 | : [ret] "={eax}" (-> usize) | |
| 86 | : [ret] "={eax}" (-> usize), | |
| 87 | 87 | : [number] "{eax}" (@enumToInt(number)), |
| 88 | 88 | [arg1] "{ebx}" (arg1), |
| 89 | 89 | [arg2] "{ecx}" (arg2), |
| 90 | 90 | [arg3] "{edx}" (arg3), |
| 91 | 91 | [arg4] "{esi}" (arg4), |
| 92 | 92 | [arg5] "{edi}" (arg5), |
| 93 | [arg6] "rm" (arg6) | |
| 93 | [arg6] "rm" (arg6), | |
| 94 | 94 | : "memory" |
| 95 | 95 | ); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | pub fn socketcall(call: usize, args: [*]usize) usize { |
| 99 | 99 | return asm volatile ("int $0x80" |
| 100 | : [ret] "={eax}" (-> usize) | |
| 100 | : [ret] "={eax}" (-> usize), | |
| 101 | 101 | : [number] "{eax}" (@enumToInt(SYS.socketcall)), |
| 102 | 102 | [arg1] "{ebx}" (call), |
| 103 | [arg2] "{ecx}" (@ptrToInt(args)) | |
| 103 | [arg2] "{ecx}" (@ptrToInt(args)), | |
| 104 | 104 | : "memory" |
| 105 | 105 | ); |
| 106 | 106 | } |
| ... | ... | @@ -111,7 +111,7 @@ pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: |
| 111 | 111 | pub fn restore() callconv(.Naked) void { |
| 112 | 112 | return asm volatile ("int $0x80" |
| 113 | 113 | : |
| 114 | : [number] "{eax}" (@enumToInt(SYS.sigreturn)) | |
| 114 | : [number] "{eax}" (@enumToInt(SYS.sigreturn)), | |
| 115 | 115 | : "memory" |
| 116 | 116 | ); |
| 117 | 117 | } |
| ... | ... | @@ -119,7 +119,7 @@ pub fn restore() callconv(.Naked) void { |
| 119 | 119 | pub fn restore_rt() callconv(.Naked) void { |
| 120 | 120 | return asm volatile ("int $0x80" |
| 121 | 121 | : |
| 122 | : [number] "{eax}" (@enumToInt(SYS.rt_sigreturn)) | |
| 122 | : [number] "{eax}" (@enumToInt(SYS.rt_sigreturn)), | |
| 123 | 123 | : "memory" |
| 124 | 124 | ); |
| 125 | 125 | } |
lib/std/os/linux/mips.zig+20-20| ... | ... | @@ -6,8 +6,8 @@ pub fn syscall0(number: SYS) usize { |
| 6 | 6 | \\ blez $7, 1f |
| 7 | 7 | \\ subu $2, $0, $2 |
| 8 | 8 | \\ 1: |
| 9 | : [ret] "={$2}" (-> usize) | |
| 10 | : [number] "{$2}" (@enumToInt(number)) | |
| 9 | : [ret] "={$2}" (-> usize), | |
| 10 | : [number] "{$2}" (@enumToInt(number)), | |
| 11 | 11 | : "memory", "cc", "$7" |
| 12 | 12 | ); |
| 13 | 13 | } |
| ... | ... | @@ -25,9 +25,9 @@ pub fn syscall_pipe(fd: *[2]i32) usize { |
| 25 | 25 | \\ sw $2, 0($4) |
| 26 | 26 | \\ sw $3, 4($4) |
| 27 | 27 | \\ 2: |
| 28 | : [ret] "={$2}" (-> usize) | |
| 28 | : [ret] "={$2}" (-> usize), | |
| 29 | 29 | : [number] "{$2}" (@enumToInt(SYS.pipe)), |
| 30 | [fd] "{$4}" (fd) | |
| 30 | [fd] "{$4}" (fd), | |
| 31 | 31 | : "memory", "cc", "$7" |
| 32 | 32 | ); |
| 33 | 33 | } |
| ... | ... | @@ -38,9 +38,9 @@ pub fn syscall1(number: SYS, arg1: usize) usize { |
| 38 | 38 | \\ blez $7, 1f |
| 39 | 39 | \\ subu $2, $0, $2 |
| 40 | 40 | \\ 1: |
| 41 | : [ret] "={$2}" (-> usize) | |
| 41 | : [ret] "={$2}" (-> usize), | |
| 42 | 42 | : [number] "{$2}" (@enumToInt(number)), |
| 43 | [arg1] "{$4}" (arg1) | |
| 43 | [arg1] "{$4}" (arg1), | |
| 44 | 44 | : "memory", "cc", "$7" |
| 45 | 45 | ); |
| 46 | 46 | } |
| ... | ... | @@ -51,10 +51,10 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { |
| 51 | 51 | \\ blez $7, 1f |
| 52 | 52 | \\ subu $2, $0, $2 |
| 53 | 53 | \\ 1: |
| 54 | : [ret] "={$2}" (-> usize) | |
| 54 | : [ret] "={$2}" (-> usize), | |
| 55 | 55 | : [number] "{$2}" (@enumToInt(number)), |
| 56 | 56 | [arg1] "{$4}" (arg1), |
| 57 | [arg2] "{$5}" (arg2) | |
| 57 | [arg2] "{$5}" (arg2), | |
| 58 | 58 | : "memory", "cc", "$7" |
| 59 | 59 | ); |
| 60 | 60 | } |
| ... | ... | @@ -65,11 +65,11 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 65 | 65 | \\ blez $7, 1f |
| 66 | 66 | \\ subu $2, $0, $2 |
| 67 | 67 | \\ 1: |
| 68 | : [ret] "={$2}" (-> usize) | |
| 68 | : [ret] "={$2}" (-> usize), | |
| 69 | 69 | : [number] "{$2}" (@enumToInt(number)), |
| 70 | 70 | [arg1] "{$4}" (arg1), |
| 71 | 71 | [arg2] "{$5}" (arg2), |
| 72 | [arg3] "{$6}" (arg3) | |
| 72 | [arg3] "{$6}" (arg3), | |
| 73 | 73 | : "memory", "cc", "$7" |
| 74 | 74 | ); |
| 75 | 75 | } |
| ... | ... | @@ -80,12 +80,12 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 80 | 80 | \\ blez $7, 1f |
| 81 | 81 | \\ subu $2, $0, $2 |
| 82 | 82 | \\ 1: |
| 83 | : [ret] "={$2}" (-> usize) | |
| 83 | : [ret] "={$2}" (-> usize), | |
| 84 | 84 | : [number] "{$2}" (@enumToInt(number)), |
| 85 | 85 | [arg1] "{$4}" (arg1), |
| 86 | 86 | [arg2] "{$5}" (arg2), |
| 87 | 87 | [arg3] "{$6}" (arg3), |
| 88 | [arg4] "{$7}" (arg4) | |
| 88 | [arg4] "{$7}" (arg4), | |
| 89 | 89 | : "memory", "cc", "$7" |
| 90 | 90 | ); |
| 91 | 91 | } |
| ... | ... | @@ -100,13 +100,13 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 100 | 100 | \\ blez $7, 1f |
| 101 | 101 | \\ subu $2, $0, $2 |
| 102 | 102 | \\ 1: |
| 103 | : [ret] "={$2}" (-> usize) | |
| 103 | : [ret] "={$2}" (-> usize), | |
| 104 | 104 | : [number] "{$2}" (@enumToInt(number)), |
| 105 | 105 | [arg1] "{$4}" (arg1), |
| 106 | 106 | [arg2] "{$5}" (arg2), |
| 107 | 107 | [arg3] "{$6}" (arg3), |
| 108 | 108 | [arg4] "{$7}" (arg4), |
| 109 | [arg5] "r" (arg5) | |
| 109 | [arg5] "r" (arg5), | |
| 110 | 110 | : "memory", "cc", "$7" |
| 111 | 111 | ); |
| 112 | 112 | } |
| ... | ... | @@ -133,14 +133,14 @@ pub fn syscall6( |
| 133 | 133 | \\ blez $7, 1f |
| 134 | 134 | \\ subu $2, $0, $2 |
| 135 | 135 | \\ 1: |
| 136 | : [ret] "={$2}" (-> usize) | |
| 136 | : [ret] "={$2}" (-> usize), | |
| 137 | 137 | : [number] "{$2}" (@enumToInt(number)), |
| 138 | 138 | [arg1] "{$4}" (arg1), |
| 139 | 139 | [arg2] "{$5}" (arg2), |
| 140 | 140 | [arg3] "{$6}" (arg3), |
| 141 | 141 | [arg4] "{$7}" (arg4), |
| 142 | 142 | [arg5] "r" (arg5), |
| 143 | [arg6] "r" (arg6) | |
| 143 | [arg6] "r" (arg6), | |
| 144 | 144 | : "memory", "cc", "$7" |
| 145 | 145 | ); |
| 146 | 146 | } |
| ... | ... | @@ -166,7 +166,7 @@ pub fn syscall7( |
| 166 | 166 | \\ blez $7, 1f |
| 167 | 167 | \\ subu $2, $0, $2 |
| 168 | 168 | \\ 1: |
| 169 | : [ret] "={$2}" (-> usize) | |
| 169 | : [ret] "={$2}" (-> usize), | |
| 170 | 170 | : [number] "{$2}" (@enumToInt(number)), |
| 171 | 171 | [arg1] "{$4}" (arg1), |
| 172 | 172 | [arg2] "{$5}" (arg2), |
| ... | ... | @@ -174,7 +174,7 @@ pub fn syscall7( |
| 174 | 174 | [arg4] "{$7}" (arg4), |
| 175 | 175 | [arg5] "r" (arg5), |
| 176 | 176 | [arg6] "r" (arg6), |
| 177 | [arg7] "r" (arg7) | |
| 177 | [arg7] "r" (arg7), | |
| 178 | 178 | : "memory", "cc", "$7" |
| 179 | 179 | ); |
| 180 | 180 | } |
| ... | ... | @@ -185,7 +185,7 @@ pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: |
| 185 | 185 | pub fn restore() callconv(.Naked) void { |
| 186 | 186 | return asm volatile ("syscall" |
| 187 | 187 | : |
| 188 | : [number] "{$2}" (@enumToInt(SYS.sigreturn)) | |
| 188 | : [number] "{$2}" (@enumToInt(SYS.sigreturn)), | |
| 189 | 189 | : "memory", "cc", "$7" |
| 190 | 190 | ); |
| 191 | 191 | } |
| ... | ... | @@ -193,7 +193,7 @@ pub fn restore() callconv(.Naked) void { |
| 193 | 193 | pub fn restore_rt() callconv(.Naked) void { |
| 194 | 194 | return asm volatile ("syscall" |
| 195 | 195 | : |
| 196 | : [number] "{$2}" (@enumToInt(SYS.rt_sigreturn)) | |
| 196 | : [number] "{$2}" (@enumToInt(SYS.rt_sigreturn)), | |
| 197 | 197 | : "memory", "cc", "$7" |
| 198 | 198 | ); |
| 199 | 199 | } |
lib/std/os/linux/powerpc.zig+15-15| ... | ... | @@ -6,8 +6,8 @@ pub fn syscall0(number: SYS) usize { |
| 6 | 6 | \\ bns+ 1f |
| 7 | 7 | \\ neg 3, 3 |
| 8 | 8 | \\ 1: |
| 9 | : [ret] "={r3}" (-> usize) | |
| 10 | : [number] "{r0}" (@enumToInt(number)) | |
| 9 | : [ret] "={r3}" (-> usize), | |
| 10 | : [number] "{r0}" (@enumToInt(number)), | |
| 11 | 11 | : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" |
| 12 | 12 | ); |
| 13 | 13 | } |
| ... | ... | @@ -18,9 +18,9 @@ pub fn syscall1(number: SYS, arg1: usize) usize { |
| 18 | 18 | \\ bns+ 1f |
| 19 | 19 | \\ neg 3, 3 |
| 20 | 20 | \\ 1: |
| 21 | : [ret] "={r3}" (-> usize) | |
| 21 | : [ret] "={r3}" (-> usize), | |
| 22 | 22 | : [number] "{r0}" (@enumToInt(number)), |
| 23 | [arg1] "{r3}" (arg1) | |
| 23 | [arg1] "{r3}" (arg1), | |
| 24 | 24 | : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" |
| 25 | 25 | ); |
| 26 | 26 | } |
| ... | ... | @@ -31,10 +31,10 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { |
| 31 | 31 | \\ bns+ 1f |
| 32 | 32 | \\ neg 3, 3 |
| 33 | 33 | \\ 1: |
| 34 | : [ret] "={r3}" (-> usize) | |
| 34 | : [ret] "={r3}" (-> usize), | |
| 35 | 35 | : [number] "{r0}" (@enumToInt(number)), |
| 36 | 36 | [arg1] "{r3}" (arg1), |
| 37 | [arg2] "{r4}" (arg2) | |
| 37 | [arg2] "{r4}" (arg2), | |
| 38 | 38 | : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" |
| 39 | 39 | ); |
| 40 | 40 | } |
| ... | ... | @@ -45,11 +45,11 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 45 | 45 | \\ bns+ 1f |
| 46 | 46 | \\ neg 3, 3 |
| 47 | 47 | \\ 1: |
| 48 | : [ret] "={r3}" (-> usize) | |
| 48 | : [ret] "={r3}" (-> usize), | |
| 49 | 49 | : [number] "{r0}" (@enumToInt(number)), |
| 50 | 50 | [arg1] "{r3}" (arg1), |
| 51 | 51 | [arg2] "{r4}" (arg2), |
| 52 | [arg3] "{r5}" (arg3) | |
| 52 | [arg3] "{r5}" (arg3), | |
| 53 | 53 | : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" |
| 54 | 54 | ); |
| 55 | 55 | } |
| ... | ... | @@ -60,12 +60,12 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 60 | 60 | \\ bns+ 1f |
| 61 | 61 | \\ neg 3, 3 |
| 62 | 62 | \\ 1: |
| 63 | : [ret] "={r3}" (-> usize) | |
| 63 | : [ret] "={r3}" (-> usize), | |
| 64 | 64 | : [number] "{r0}" (@enumToInt(number)), |
| 65 | 65 | [arg1] "{r3}" (arg1), |
| 66 | 66 | [arg2] "{r4}" (arg2), |
| 67 | 67 | [arg3] "{r5}" (arg3), |
| 68 | [arg4] "{r6}" (arg4) | |
| 68 | [arg4] "{r6}" (arg4), | |
| 69 | 69 | : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" |
| 70 | 70 | ); |
| 71 | 71 | } |
| ... | ... | @@ -76,13 +76,13 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 76 | 76 | \\ bns+ 1f |
| 77 | 77 | \\ neg 3, 3 |
| 78 | 78 | \\ 1: |
| 79 | : [ret] "={r3}" (-> usize) | |
| 79 | : [ret] "={r3}" (-> usize), | |
| 80 | 80 | : [number] "{r0}" (@enumToInt(number)), |
| 81 | 81 | [arg1] "{r3}" (arg1), |
| 82 | 82 | [arg2] "{r4}" (arg2), |
| 83 | 83 | [arg3] "{r5}" (arg3), |
| 84 | 84 | [arg4] "{r6}" (arg4), |
| 85 | [arg5] "{r7}" (arg5) | |
| 85 | [arg5] "{r7}" (arg5), | |
| 86 | 86 | : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" |
| 87 | 87 | ); |
| 88 | 88 | } |
| ... | ... | @@ -101,14 +101,14 @@ pub fn syscall6( |
| 101 | 101 | \\ bns+ 1f |
| 102 | 102 | \\ neg 3, 3 |
| 103 | 103 | \\ 1: |
| 104 | : [ret] "={r3}" (-> usize) | |
| 104 | : [ret] "={r3}" (-> usize), | |
| 105 | 105 | : [number] "{r0}" (@enumToInt(number)), |
| 106 | 106 | [arg1] "{r3}" (arg1), |
| 107 | 107 | [arg2] "{r4}" (arg2), |
| 108 | 108 | [arg3] "{r5}" (arg3), |
| 109 | 109 | [arg4] "{r6}" (arg4), |
| 110 | 110 | [arg5] "{r7}" (arg5), |
| 111 | [arg6] "{r8}" (arg6) | |
| 111 | [arg6] "{r8}" (arg6), | |
| 112 | 112 | : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" |
| 113 | 113 | ); |
| 114 | 114 | } |
| ... | ... | @@ -121,7 +121,7 @@ pub const restore = restore_rt; |
| 121 | 121 | pub fn restore_rt() callconv(.Naked) void { |
| 122 | 122 | return asm volatile ("sc" |
| 123 | 123 | : |
| 124 | : [number] "{r0}" (@enumToInt(SYS.rt_sigreturn)) | |
| 124 | : [number] "{r0}" (@enumToInt(SYS.rt_sigreturn)), | |
| 125 | 125 | : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" |
| 126 | 126 | ); |
| 127 | 127 | } |
lib/std/os/linux/powerpc64.zig+15-15| ... | ... | @@ -6,8 +6,8 @@ pub fn syscall0(number: SYS) usize { |
| 6 | 6 | \\ bns+ 1f |
| 7 | 7 | \\ neg 3, 3 |
| 8 | 8 | \\ 1: |
| 9 | : [ret] "={r3}" (-> usize) | |
| 10 | : [number] "{r0}" (@enumToInt(number)) | |
| 9 | : [ret] "={r3}" (-> usize), | |
| 10 | : [number] "{r0}" (@enumToInt(number)), | |
| 11 | 11 | : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" |
| 12 | 12 | ); |
| 13 | 13 | } |
| ... | ... | @@ -18,9 +18,9 @@ pub fn syscall1(number: SYS, arg1: usize) usize { |
| 18 | 18 | \\ bns+ 1f |
| 19 | 19 | \\ neg 3, 3 |
| 20 | 20 | \\ 1: |
| 21 | : [ret] "={r3}" (-> usize) | |
| 21 | : [ret] "={r3}" (-> usize), | |
| 22 | 22 | : [number] "{r0}" (@enumToInt(number)), |
| 23 | [arg1] "{r3}" (arg1) | |
| 23 | [arg1] "{r3}" (arg1), | |
| 24 | 24 | : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" |
| 25 | 25 | ); |
| 26 | 26 | } |
| ... | ... | @@ -31,10 +31,10 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { |
| 31 | 31 | \\ bns+ 1f |
| 32 | 32 | \\ neg 3, 3 |
| 33 | 33 | \\ 1: |
| 34 | : [ret] "={r3}" (-> usize) | |
| 34 | : [ret] "={r3}" (-> usize), | |
| 35 | 35 | : [number] "{r0}" (@enumToInt(number)), |
| 36 | 36 | [arg1] "{r3}" (arg1), |
| 37 | [arg2] "{r4}" (arg2) | |
| 37 | [arg2] "{r4}" (arg2), | |
| 38 | 38 | : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" |
| 39 | 39 | ); |
| 40 | 40 | } |
| ... | ... | @@ -45,11 +45,11 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 45 | 45 | \\ bns+ 1f |
| 46 | 46 | \\ neg 3, 3 |
| 47 | 47 | \\ 1: |
| 48 | : [ret] "={r3}" (-> usize) | |
| 48 | : [ret] "={r3}" (-> usize), | |
| 49 | 49 | : [number] "{r0}" (@enumToInt(number)), |
| 50 | 50 | [arg1] "{r3}" (arg1), |
| 51 | 51 | [arg2] "{r4}" (arg2), |
| 52 | [arg3] "{r5}" (arg3) | |
| 52 | [arg3] "{r5}" (arg3), | |
| 53 | 53 | : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" |
| 54 | 54 | ); |
| 55 | 55 | } |
| ... | ... | @@ -60,12 +60,12 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 60 | 60 | \\ bns+ 1f |
| 61 | 61 | \\ neg 3, 3 |
| 62 | 62 | \\ 1: |
| 63 | : [ret] "={r3}" (-> usize) | |
| 63 | : [ret] "={r3}" (-> usize), | |
| 64 | 64 | : [number] "{r0}" (@enumToInt(number)), |
| 65 | 65 | [arg1] "{r3}" (arg1), |
| 66 | 66 | [arg2] "{r4}" (arg2), |
| 67 | 67 | [arg3] "{r5}" (arg3), |
| 68 | [arg4] "{r6}" (arg4) | |
| 68 | [arg4] "{r6}" (arg4), | |
| 69 | 69 | : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" |
| 70 | 70 | ); |
| 71 | 71 | } |
| ... | ... | @@ -76,13 +76,13 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 76 | 76 | \\ bns+ 1f |
| 77 | 77 | \\ neg 3, 3 |
| 78 | 78 | \\ 1: |
| 79 | : [ret] "={r3}" (-> usize) | |
| 79 | : [ret] "={r3}" (-> usize), | |
| 80 | 80 | : [number] "{r0}" (@enumToInt(number)), |
| 81 | 81 | [arg1] "{r3}" (arg1), |
| 82 | 82 | [arg2] "{r4}" (arg2), |
| 83 | 83 | [arg3] "{r5}" (arg3), |
| 84 | 84 | [arg4] "{r6}" (arg4), |
| 85 | [arg5] "{r7}" (arg5) | |
| 85 | [arg5] "{r7}" (arg5), | |
| 86 | 86 | : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" |
| 87 | 87 | ); |
| 88 | 88 | } |
| ... | ... | @@ -101,14 +101,14 @@ pub fn syscall6( |
| 101 | 101 | \\ bns+ 1f |
| 102 | 102 | \\ neg 3, 3 |
| 103 | 103 | \\ 1: |
| 104 | : [ret] "={r3}" (-> usize) | |
| 104 | : [ret] "={r3}" (-> usize), | |
| 105 | 105 | : [number] "{r0}" (@enumToInt(number)), |
| 106 | 106 | [arg1] "{r3}" (arg1), |
| 107 | 107 | [arg2] "{r4}" (arg2), |
| 108 | 108 | [arg3] "{r5}" (arg3), |
| 109 | 109 | [arg4] "{r6}" (arg4), |
| 110 | 110 | [arg5] "{r7}" (arg5), |
| 111 | [arg6] "{r8}" (arg6) | |
| 111 | [arg6] "{r8}" (arg6), | |
| 112 | 112 | : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" |
| 113 | 113 | ); |
| 114 | 114 | } |
| ... | ... | @@ -121,7 +121,7 @@ pub const restore = restore_rt; |
| 121 | 121 | pub fn restore_rt() callconv(.Naked) void { |
| 122 | 122 | return asm volatile ("sc" |
| 123 | 123 | : |
| 124 | : [number] "{r0}" (@enumToInt(SYS.rt_sigreturn)) | |
| 124 | : [number] "{r0}" (@enumToInt(SYS.rt_sigreturn)), | |
| 125 | 125 | : "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" |
| 126 | 126 | ); |
| 127 | 127 | } |
lib/std/os/linux/riscv64.zig+15-15| ... | ... | @@ -2,63 +2,63 @@ usingnamespace @import("../bits/linux.zig"); |
| 2 | 2 | |
| 3 | 3 | pub fn syscall0(number: SYS) usize { |
| 4 | 4 | return asm volatile ("ecall" |
| 5 | : [ret] "={x10}" (-> usize) | |
| 6 | : [number] "{x17}" (@enumToInt(number)) | |
| 5 | : [ret] "={x10}" (-> usize), | |
| 6 | : [number] "{x17}" (@enumToInt(number)), | |
| 7 | 7 | : "memory" |
| 8 | 8 | ); |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | pub fn syscall1(number: SYS, arg1: usize) usize { |
| 12 | 12 | return asm volatile ("ecall" |
| 13 | : [ret] "={x10}" (-> usize) | |
| 13 | : [ret] "={x10}" (-> usize), | |
| 14 | 14 | : [number] "{x17}" (@enumToInt(number)), |
| 15 | [arg1] "{x10}" (arg1) | |
| 15 | [arg1] "{x10}" (arg1), | |
| 16 | 16 | : "memory" |
| 17 | 17 | ); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { |
| 21 | 21 | return asm volatile ("ecall" |
| 22 | : [ret] "={x10}" (-> usize) | |
| 22 | : [ret] "={x10}" (-> usize), | |
| 23 | 23 | : [number] "{x17}" (@enumToInt(number)), |
| 24 | 24 | [arg1] "{x10}" (arg1), |
| 25 | [arg2] "{x11}" (arg2) | |
| 25 | [arg2] "{x11}" (arg2), | |
| 26 | 26 | : "memory" |
| 27 | 27 | ); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 31 | 31 | return asm volatile ("ecall" |
| 32 | : [ret] "={x10}" (-> usize) | |
| 32 | : [ret] "={x10}" (-> usize), | |
| 33 | 33 | : [number] "{x17}" (@enumToInt(number)), |
| 34 | 34 | [arg1] "{x10}" (arg1), |
| 35 | 35 | [arg2] "{x11}" (arg2), |
| 36 | [arg3] "{x12}" (arg3) | |
| 36 | [arg3] "{x12}" (arg3), | |
| 37 | 37 | : "memory" |
| 38 | 38 | ); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { |
| 42 | 42 | return asm volatile ("ecall" |
| 43 | : [ret] "={x10}" (-> usize) | |
| 43 | : [ret] "={x10}" (-> usize), | |
| 44 | 44 | : [number] "{x17}" (@enumToInt(number)), |
| 45 | 45 | [arg1] "{x10}" (arg1), |
| 46 | 46 | [arg2] "{x11}" (arg2), |
| 47 | 47 | [arg3] "{x12}" (arg3), |
| 48 | [arg4] "{x13}" (arg4) | |
| 48 | [arg4] "{x13}" (arg4), | |
| 49 | 49 | : "memory" |
| 50 | 50 | ); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { |
| 54 | 54 | return asm volatile ("ecall" |
| 55 | : [ret] "={x10}" (-> usize) | |
| 55 | : [ret] "={x10}" (-> usize), | |
| 56 | 56 | : [number] "{x17}" (@enumToInt(number)), |
| 57 | 57 | [arg1] "{x10}" (arg1), |
| 58 | 58 | [arg2] "{x11}" (arg2), |
| 59 | 59 | [arg3] "{x12}" (arg3), |
| 60 | 60 | [arg4] "{x13}" (arg4), |
| 61 | [arg5] "{x14}" (arg5) | |
| 61 | [arg5] "{x14}" (arg5), | |
| 62 | 62 | : "memory" |
| 63 | 63 | ); |
| 64 | 64 | } |
| ... | ... | @@ -73,14 +73,14 @@ pub fn syscall6( |
| 73 | 73 | arg6: usize, |
| 74 | 74 | ) usize { |
| 75 | 75 | return asm volatile ("ecall" |
| 76 | : [ret] "={x10}" (-> usize) | |
| 76 | : [ret] "={x10}" (-> usize), | |
| 77 | 77 | : [number] "{x17}" (@enumToInt(number)), |
| 78 | 78 | [arg1] "{x10}" (arg1), |
| 79 | 79 | [arg2] "{x11}" (arg2), |
| 80 | 80 | [arg3] "{x12}" (arg3), |
| 81 | 81 | [arg4] "{x13}" (arg4), |
| 82 | 82 | [arg5] "{x14}" (arg5), |
| 83 | [arg6] "{x15}" (arg6) | |
| 83 | [arg6] "{x15}" (arg6), | |
| 84 | 84 | : "memory" |
| 85 | 85 | ); |
| 86 | 86 | } |
| ... | ... | @@ -92,7 +92,7 @@ pub const restore = restore_rt; |
| 92 | 92 | pub fn restore_rt() callconv(.Naked) void { |
| 93 | 93 | return asm volatile ("ecall" |
| 94 | 94 | : |
| 95 | : [number] "{x17}" (@enumToInt(SYS.rt_sigreturn)) | |
| 95 | : [number] "{x17}" (@enumToInt(SYS.rt_sigreturn)), | |
| 96 | 96 | : "memory" |
| 97 | 97 | ); |
| 98 | 98 | } |
lib/std/os/linux/sparc64.zig+19-19| ... | ... | @@ -14,9 +14,9 @@ pub fn syscall_pipe(fd: *[2]i32) usize { |
| 14 | 14 | \\ st %%o1, [%%g3+4] |
| 15 | 15 | \\ clr %%o0 |
| 16 | 16 | \\2: |
| 17 | : [ret] "={o0}" (-> usize) | |
| 17 | : [ret] "={o0}" (-> usize), | |
| 18 | 18 | : [number] "{g1}" (@enumToInt(SYS.pipe)), |
| 19 | [arg] "r" (fd) | |
| 19 | [arg] "r" (fd), | |
| 20 | 20 | : "memory", "g3" |
| 21 | 21 | ); |
| 22 | 22 | } |
| ... | ... | @@ -38,8 +38,8 @@ pub fn syscall_fork() usize { |
| 38 | 38 | \\ dec %%o1 |
| 39 | 39 | \\ and %%o1, %%o0, %%o0 |
| 40 | 40 | \\ 2: |
| 41 | : [ret] "={o0}" (-> usize) | |
| 42 | : [number] "{g1}" (@enumToInt(SYS.fork)) | |
| 41 | : [ret] "={o0}" (-> usize), | |
| 42 | : [number] "{g1}" (@enumToInt(SYS.fork)), | |
| 43 | 43 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" |
| 44 | 44 | ); |
| 45 | 45 | } |
| ... | ... | @@ -51,8 +51,8 @@ pub fn syscall0(number: SYS) usize { |
| 51 | 51 | \\ nop |
| 52 | 52 | \\ neg %%o0 |
| 53 | 53 | \\ 1: |
| 54 | : [ret] "={o0}" (-> usize) | |
| 55 | : [number] "{g1}" (@enumToInt(number)) | |
| 54 | : [ret] "={o0}" (-> usize), | |
| 55 | : [number] "{g1}" (@enumToInt(number)), | |
| 56 | 56 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" |
| 57 | 57 | ); |
| 58 | 58 | } |
| ... | ... | @@ -64,9 +64,9 @@ pub fn syscall1(number: SYS, arg1: usize) usize { |
| 64 | 64 | \\ nop |
| 65 | 65 | \\ neg %%o0 |
| 66 | 66 | \\ 1: |
| 67 | : [ret] "={o0}" (-> usize) | |
| 67 | : [ret] "={o0}" (-> usize), | |
| 68 | 68 | : [number] "{g1}" (@enumToInt(number)), |
| 69 | [arg1] "{o0}" (arg1) | |
| 69 | [arg1] "{o0}" (arg1), | |
| 70 | 70 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" |
| 71 | 71 | ); |
| 72 | 72 | } |
| ... | ... | @@ -78,10 +78,10 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { |
| 78 | 78 | \\ nop |
| 79 | 79 | \\ neg %%o0 |
| 80 | 80 | \\ 1: |
| 81 | : [ret] "={o0}" (-> usize) | |
| 81 | : [ret] "={o0}" (-> usize), | |
| 82 | 82 | : [number] "{g1}" (@enumToInt(number)), |
| 83 | 83 | [arg1] "{o0}" (arg1), |
| 84 | [arg2] "{o1}" (arg2) | |
| 84 | [arg2] "{o1}" (arg2), | |
| 85 | 85 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" |
| 86 | 86 | ); |
| 87 | 87 | } |
| ... | ... | @@ -93,11 +93,11 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 93 | 93 | \\ nop |
| 94 | 94 | \\ neg %%o0 |
| 95 | 95 | \\ 1: |
| 96 | : [ret] "={o0}" (-> usize) | |
| 96 | : [ret] "={o0}" (-> usize), | |
| 97 | 97 | : [number] "{g1}" (@enumToInt(number)), |
| 98 | 98 | [arg1] "{o0}" (arg1), |
| 99 | 99 | [arg2] "{o1}" (arg2), |
| 100 | [arg3] "{o2}" (arg3) | |
| 100 | [arg3] "{o2}" (arg3), | |
| 101 | 101 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" |
| 102 | 102 | ); |
| 103 | 103 | } |
| ... | ... | @@ -109,12 +109,12 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 109 | 109 | \\ nop |
| 110 | 110 | \\ neg %%o0 |
| 111 | 111 | \\ 1: |
| 112 | : [ret] "={o0}" (-> usize) | |
| 112 | : [ret] "={o0}" (-> usize), | |
| 113 | 113 | : [number] "{g1}" (@enumToInt(number)), |
| 114 | 114 | [arg1] "{o0}" (arg1), |
| 115 | 115 | [arg2] "{o1}" (arg2), |
| 116 | 116 | [arg3] "{o2}" (arg3), |
| 117 | [arg4] "{o3}" (arg4) | |
| 117 | [arg4] "{o3}" (arg4), | |
| 118 | 118 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" |
| 119 | 119 | ); |
| 120 | 120 | } |
| ... | ... | @@ -126,13 +126,13 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 126 | 126 | \\ nop |
| 127 | 127 | \\ neg %%o0 |
| 128 | 128 | \\ 1: |
| 129 | : [ret] "={o0}" (-> usize) | |
| 129 | : [ret] "={o0}" (-> usize), | |
| 130 | 130 | : [number] "{g1}" (@enumToInt(number)), |
| 131 | 131 | [arg1] "{o0}" (arg1), |
| 132 | 132 | [arg2] "{o1}" (arg2), |
| 133 | 133 | [arg3] "{o2}" (arg3), |
| 134 | 134 | [arg4] "{o3}" (arg4), |
| 135 | [arg5] "{o4}" (arg5) | |
| 135 | [arg5] "{o4}" (arg5), | |
| 136 | 136 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" |
| 137 | 137 | ); |
| 138 | 138 | } |
| ... | ... | @@ -152,14 +152,14 @@ pub fn syscall6( |
| 152 | 152 | \\ nop |
| 153 | 153 | \\ neg %%o0 |
| 154 | 154 | \\ 1: |
| 155 | : [ret] "={o0}" (-> usize) | |
| 155 | : [ret] "={o0}" (-> usize), | |
| 156 | 156 | : [number] "{g1}" (@enumToInt(number)), |
| 157 | 157 | [arg1] "{o0}" (arg1), |
| 158 | 158 | [arg2] "{o1}" (arg2), |
| 159 | 159 | [arg3] "{o2}" (arg3), |
| 160 | 160 | [arg4] "{o3}" (arg4), |
| 161 | 161 | [arg5] "{o4}" (arg5), |
| 162 | [arg6] "{o5}" (arg6) | |
| 162 | [arg6] "{o5}" (arg6), | |
| 163 | 163 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" |
| 164 | 164 | ); |
| 165 | 165 | } |
| ... | ... | @@ -174,7 +174,7 @@ pub const restore = restore_rt; |
| 174 | 174 | pub fn restore_rt() callconv(.C) void { |
| 175 | 175 | return asm volatile ("t 0x6d" |
| 176 | 176 | : |
| 177 | : [number] "{g1}" (@enumToInt(SYS.rt_sigreturn)) | |
| 177 | : [number] "{g1}" (@enumToInt(SYS.rt_sigreturn)), | |
| 178 | 178 | : "memory", "xcc", "o0", "o1", "o2", "o3", "o4", "o5", "o7" |
| 179 | 179 | ); |
| 180 | 180 | } |
lib/std/os/linux/start_pie.zig+5-5| ... | ... | @@ -30,13 +30,13 @@ fn getDynamicSymbol() [*]elf.Dyn { |
| 30 | 30 | \\ call 1f |
| 31 | 31 | \\ 1: pop %[ret] |
| 32 | 32 | \\ lea _DYNAMIC-1b(%[ret]), %[ret] |
| 33 | : [ret] "=r" (-> [*]elf.Dyn) | |
| 33 | : [ret] "=r" (-> [*]elf.Dyn), | |
| 34 | 34 | ), |
| 35 | 35 | .x86_64 => asm volatile ( |
| 36 | 36 | \\ .weak _DYNAMIC |
| 37 | 37 | \\ .hidden _DYNAMIC |
| 38 | 38 | \\ lea _DYNAMIC(%%rip), %[ret] |
| 39 | : [ret] "=r" (-> [*]elf.Dyn) | |
| 39 | : [ret] "=r" (-> [*]elf.Dyn), | |
| 40 | 40 | ), |
| 41 | 41 | // Work around the limited offset range of `ldr` |
| 42 | 42 | .arm => asm volatile ( |
| ... | ... | @@ -47,7 +47,7 @@ fn getDynamicSymbol() [*]elf.Dyn { |
| 47 | 47 | \\ b 2f |
| 48 | 48 | \\ 1: .word _DYNAMIC-1b |
| 49 | 49 | \\ 2: |
| 50 | : [ret] "=r" (-> [*]elf.Dyn) | |
| 50 | : [ret] "=r" (-> [*]elf.Dyn), | |
| 51 | 51 | ), |
| 52 | 52 | // A simple `adr` is not enough as it has a limited offset range |
| 53 | 53 | .aarch64 => asm volatile ( |
| ... | ... | @@ -55,13 +55,13 @@ fn getDynamicSymbol() [*]elf.Dyn { |
| 55 | 55 | \\ .hidden _DYNAMIC |
| 56 | 56 | \\ adrp %[ret], _DYNAMIC |
| 57 | 57 | \\ add %[ret], %[ret], #:lo12:_DYNAMIC |
| 58 | : [ret] "=r" (-> [*]elf.Dyn) | |
| 58 | : [ret] "=r" (-> [*]elf.Dyn), | |
| 59 | 59 | ), |
| 60 | 60 | .riscv64 => asm volatile ( |
| 61 | 61 | \\ .weak _DYNAMIC |
| 62 | 62 | \\ .hidden _DYNAMIC |
| 63 | 63 | \\ lla %[ret], _DYNAMIC |
| 64 | : [ret] "=r" (-> [*]elf.Dyn) | |
| 64 | : [ret] "=r" (-> [*]elf.Dyn), | |
| 65 | 65 | ), |
| 66 | 66 | else => { |
| 67 | 67 | @compileError("PIE startup is not yet supported for this target!"); |
lib/std/os/linux/thumb.zig+16-16| ... | ... | @@ -15,8 +15,8 @@ pub fn syscall0(number: SYS) usize { |
| 15 | 15 | \\ ldr r7, [%[tmp]] |
| 16 | 16 | \\ svc #0 |
| 17 | 17 | \\ ldr r7, [%[tmp], #4] |
| 18 | : [ret] "={r0}" (-> usize) | |
| 19 | : [tmp] "{r1}" (buf) | |
| 18 | : [ret] "={r0}" (-> usize), | |
| 19 | : [tmp] "{r1}" (buf), | |
| 20 | 20 | : "memory" |
| 21 | 21 | ); |
| 22 | 22 | } |
| ... | ... | @@ -30,9 +30,9 @@ pub fn syscall1(number: SYS, arg1: usize) usize { |
| 30 | 30 | \\ ldr r7, [%[tmp]] |
| 31 | 31 | \\ svc #0 |
| 32 | 32 | \\ ldr r7, [%[tmp], #4] |
| 33 | : [ret] "={r0}" (-> usize) | |
| 33 | : [ret] "={r0}" (-> usize), | |
| 34 | 34 | : [tmp] "{r1}" (buf), |
| 35 | [arg1] "{r0}" (arg1) | |
| 35 | [arg1] "{r0}" (arg1), | |
| 36 | 36 | : "memory" |
| 37 | 37 | ); |
| 38 | 38 | } |
| ... | ... | @@ -46,10 +46,10 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { |
| 46 | 46 | \\ ldr r7, [%[tmp]] |
| 47 | 47 | \\ svc #0 |
| 48 | 48 | \\ ldr r7, [%[tmp], #4] |
| 49 | : [ret] "={r0}" (-> usize) | |
| 49 | : [ret] "={r0}" (-> usize), | |
| 50 | 50 | : [tmp] "{r2}" (buf), |
| 51 | 51 | [arg1] "{r0}" (arg1), |
| 52 | [arg2] "{r1}" (arg2) | |
| 52 | [arg2] "{r1}" (arg2), | |
| 53 | 53 | : "memory" |
| 54 | 54 | ); |
| 55 | 55 | } |
| ... | ... | @@ -63,11 +63,11 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 63 | 63 | \\ ldr r7, [%[tmp]] |
| 64 | 64 | \\ svc #0 |
| 65 | 65 | \\ ldr r7, [%[tmp], #4] |
| 66 | : [ret] "={r0}" (-> usize) | |
| 66 | : [ret] "={r0}" (-> usize), | |
| 67 | 67 | : [tmp] "{r3}" (buf), |
| 68 | 68 | [arg1] "{r0}" (arg1), |
| 69 | 69 | [arg2] "{r1}" (arg2), |
| 70 | [arg3] "{r2}" (arg3) | |
| 70 | [arg3] "{r2}" (arg3), | |
| 71 | 71 | : "memory" |
| 72 | 72 | ); |
| 73 | 73 | } |
| ... | ... | @@ -81,12 +81,12 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) |
| 81 | 81 | \\ ldr r7, [%[tmp]] |
| 82 | 82 | \\ svc #0 |
| 83 | 83 | \\ ldr r7, [%[tmp], #4] |
| 84 | : [ret] "={r0}" (-> usize) | |
| 84 | : [ret] "={r0}" (-> usize), | |
| 85 | 85 | : [tmp] "{r4}" (buf), |
| 86 | 86 | [arg1] "{r0}" (arg1), |
| 87 | 87 | [arg2] "{r1}" (arg2), |
| 88 | 88 | [arg3] "{r2}" (arg3), |
| 89 | [arg4] "{r3}" (arg4) | |
| 89 | [arg4] "{r3}" (arg4), | |
| 90 | 90 | : "memory" |
| 91 | 91 | ); |
| 92 | 92 | } |
| ... | ... | @@ -100,13 +100,13 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 100 | 100 | \\ ldr r7, [%[tmp]] |
| 101 | 101 | \\ svc #0 |
| 102 | 102 | \\ ldr r7, [%[tmp], #4] |
| 103 | : [ret] "={r0}" (-> usize) | |
| 103 | : [ret] "={r0}" (-> usize), | |
| 104 | 104 | : [tmp] "{r5}" (buf), |
| 105 | 105 | [arg1] "{r0}" (arg1), |
| 106 | 106 | [arg2] "{r1}" (arg2), |
| 107 | 107 | [arg3] "{r2}" (arg3), |
| 108 | 108 | [arg4] "{r3}" (arg4), |
| 109 | [arg5] "{r4}" (arg5) | |
| 109 | [arg5] "{r4}" (arg5), | |
| 110 | 110 | : "memory" |
| 111 | 111 | ); |
| 112 | 112 | } |
| ... | ... | @@ -128,14 +128,14 @@ pub fn syscall6( |
| 128 | 128 | \\ ldr r7, [%[tmp]] |
| 129 | 129 | \\ svc #0 |
| 130 | 130 | \\ ldr r7, [%[tmp], #4] |
| 131 | : [ret] "={r0}" (-> usize) | |
| 131 | : [ret] "={r0}" (-> usize), | |
| 132 | 132 | : [tmp] "{r6}" (buf), |
| 133 | 133 | [arg1] "{r0}" (arg1), |
| 134 | 134 | [arg2] "{r1}" (arg2), |
| 135 | 135 | [arg3] "{r2}" (arg3), |
| 136 | 136 | [arg4] "{r3}" (arg4), |
| 137 | 137 | [arg5] "{r4}" (arg5), |
| 138 | [arg6] "{r5}" (arg6) | |
| 138 | [arg6] "{r5}" (arg6), | |
| 139 | 139 | : "memory" |
| 140 | 140 | ); |
| 141 | 141 | } |
| ... | ... | @@ -148,7 +148,7 @@ pub fn restore() callconv(.Naked) void { |
| 148 | 148 | \\ mov r7, %[number] |
| 149 | 149 | \\ svc #0 |
| 150 | 150 | : |
| 151 | : [number] "I" (@enumToInt(SYS.sigreturn)) | |
| 151 | : [number] "I" (@enumToInt(SYS.sigreturn)), | |
| 152 | 152 | ); |
| 153 | 153 | } |
| 154 | 154 | |
| ... | ... | @@ -157,7 +157,7 @@ pub fn restore_rt() callconv(.Naked) void { |
| 157 | 157 | \\ mov r7, %[number] |
| 158 | 158 | \\ svc #0 |
| 159 | 159 | : |
| 160 | : [number] "I" (@enumToInt(SYS.rt_sigreturn)) | |
| 160 | : [number] "I" (@enumToInt(SYS.rt_sigreturn)), | |
| 161 | 161 | : "memory" |
| 162 | 162 | ); |
| 163 | 163 | } |
lib/std/os/linux/tls.zig+6-6| ... | ... | @@ -131,7 +131,7 @@ pub fn setThreadPointer(addr: usize) void { |
| 131 | 131 | // Update the %gs selector |
| 132 | 132 | asm volatile ("movl %[gs_val], %%gs" |
| 133 | 133 | : |
| 134 | : [gs_val] "r" (gdt_entry_number << 3 | 3) | |
| 134 | : [gs_val] "r" (gdt_entry_number << 3 | 3), | |
| 135 | 135 | ); |
| 136 | 136 | }, |
| 137 | 137 | .x86_64 => { |
| ... | ... | @@ -142,7 +142,7 @@ pub fn setThreadPointer(addr: usize) void { |
| 142 | 142 | asm volatile ( |
| 143 | 143 | \\ msr tpidr_el0, %[addr] |
| 144 | 144 | : |
| 145 | : [addr] "r" (addr) | |
| 145 | : [addr] "r" (addr), | |
| 146 | 146 | ); |
| 147 | 147 | }, |
| 148 | 148 | .arm, .thumb => { |
| ... | ... | @@ -153,7 +153,7 @@ pub fn setThreadPointer(addr: usize) void { |
| 153 | 153 | asm volatile ( |
| 154 | 154 | \\ mv tp, %[addr] |
| 155 | 155 | : |
| 156 | : [addr] "r" (addr) | |
| 156 | : [addr] "r" (addr), | |
| 157 | 157 | ); |
| 158 | 158 | }, |
| 159 | 159 | .mips, .mipsel => { |
| ... | ... | @@ -164,21 +164,21 @@ pub fn setThreadPointer(addr: usize) void { |
| 164 | 164 | asm volatile ( |
| 165 | 165 | \\ mr 2, %[addr] |
| 166 | 166 | : |
| 167 | : [addr] "r" (addr) | |
| 167 | : [addr] "r" (addr), | |
| 168 | 168 | ); |
| 169 | 169 | }, |
| 170 | 170 | .powerpc64, .powerpc64le => { |
| 171 | 171 | asm volatile ( |
| 172 | 172 | \\ mr 13, %[addr] |
| 173 | 173 | : |
| 174 | : [addr] "r" (addr) | |
| 174 | : [addr] "r" (addr), | |
| 175 | 175 | ); |
| 176 | 176 | }, |
| 177 | 177 | .sparcv9 => { |
| 178 | 178 | asm volatile ( |
| 179 | 179 | \\ mov %[addr], %%g7 |
| 180 | 180 | : |
| 181 | : [addr] "r" (addr) | |
| 181 | : [addr] "r" (addr), | |
| 182 | 182 | ); |
| 183 | 183 | }, |
| 184 | 184 | else => @compileError("Unsupported architecture"), |
lib/std/os/linux/x86_64.zig+15-15| ... | ... | @@ -2,63 +2,63 @@ usingnamespace @import("../bits/linux.zig"); |
| 2 | 2 | |
| 3 | 3 | pub fn syscall0(number: SYS) usize { |
| 4 | 4 | return asm volatile ("syscall" |
| 5 | : [ret] "={rax}" (-> usize) | |
| 6 | : [number] "{rax}" (@enumToInt(number)) | |
| 5 | : [ret] "={rax}" (-> usize), | |
| 6 | : [number] "{rax}" (@enumToInt(number)), | |
| 7 | 7 | : "rcx", "r11", "memory" |
| 8 | 8 | ); |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | pub fn syscall1(number: SYS, arg1: usize) usize { |
| 12 | 12 | return asm volatile ("syscall" |
| 13 | : [ret] "={rax}" (-> usize) | |
| 13 | : [ret] "={rax}" (-> usize), | |
| 14 | 14 | : [number] "{rax}" (@enumToInt(number)), |
| 15 | [arg1] "{rdi}" (arg1) | |
| 15 | [arg1] "{rdi}" (arg1), | |
| 16 | 16 | : "rcx", "r11", "memory" |
| 17 | 17 | ); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { |
| 21 | 21 | return asm volatile ("syscall" |
| 22 | : [ret] "={rax}" (-> usize) | |
| 22 | : [ret] "={rax}" (-> usize), | |
| 23 | 23 | : [number] "{rax}" (@enumToInt(number)), |
| 24 | 24 | [arg1] "{rdi}" (arg1), |
| 25 | [arg2] "{rsi}" (arg2) | |
| 25 | [arg2] "{rsi}" (arg2), | |
| 26 | 26 | : "rcx", "r11", "memory" |
| 27 | 27 | ); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { |
| 31 | 31 | return asm volatile ("syscall" |
| 32 | : [ret] "={rax}" (-> usize) | |
| 32 | : [ret] "={rax}" (-> usize), | |
| 33 | 33 | : [number] "{rax}" (@enumToInt(number)), |
| 34 | 34 | [arg1] "{rdi}" (arg1), |
| 35 | 35 | [arg2] "{rsi}" (arg2), |
| 36 | [arg3] "{rdx}" (arg3) | |
| 36 | [arg3] "{rdx}" (arg3), | |
| 37 | 37 | : "rcx", "r11", "memory" |
| 38 | 38 | ); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { |
| 42 | 42 | return asm volatile ("syscall" |
| 43 | : [ret] "={rax}" (-> usize) | |
| 43 | : [ret] "={rax}" (-> usize), | |
| 44 | 44 | : [number] "{rax}" (@enumToInt(number)), |
| 45 | 45 | [arg1] "{rdi}" (arg1), |
| 46 | 46 | [arg2] "{rsi}" (arg2), |
| 47 | 47 | [arg3] "{rdx}" (arg3), |
| 48 | [arg4] "{r10}" (arg4) | |
| 48 | [arg4] "{r10}" (arg4), | |
| 49 | 49 | : "rcx", "r11", "memory" |
| 50 | 50 | ); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { |
| 54 | 54 | return asm volatile ("syscall" |
| 55 | : [ret] "={rax}" (-> usize) | |
| 55 | : [ret] "={rax}" (-> usize), | |
| 56 | 56 | : [number] "{rax}" (@enumToInt(number)), |
| 57 | 57 | [arg1] "{rdi}" (arg1), |
| 58 | 58 | [arg2] "{rsi}" (arg2), |
| 59 | 59 | [arg3] "{rdx}" (arg3), |
| 60 | 60 | [arg4] "{r10}" (arg4), |
| 61 | [arg5] "{r8}" (arg5) | |
| 61 | [arg5] "{r8}" (arg5), | |
| 62 | 62 | : "rcx", "r11", "memory" |
| 63 | 63 | ); |
| 64 | 64 | } |
| ... | ... | @@ -73,14 +73,14 @@ pub fn syscall6( |
| 73 | 73 | arg6: usize, |
| 74 | 74 | ) usize { |
| 75 | 75 | return asm volatile ("syscall" |
| 76 | : [ret] "={rax}" (-> usize) | |
| 76 | : [ret] "={rax}" (-> usize), | |
| 77 | 77 | : [number] "{rax}" (@enumToInt(number)), |
| 78 | 78 | [arg1] "{rdi}" (arg1), |
| 79 | 79 | [arg2] "{rsi}" (arg2), |
| 80 | 80 | [arg3] "{rdx}" (arg3), |
| 81 | 81 | [arg4] "{r10}" (arg4), |
| 82 | 82 | [arg5] "{r8}" (arg5), |
| 83 | [arg6] "{r9}" (arg6) | |
| 83 | [arg6] "{r9}" (arg6), | |
| 84 | 84 | : "rcx", "r11", "memory" |
| 85 | 85 | ); |
| 86 | 86 | } |
| ... | ... | @@ -93,7 +93,7 @@ pub const restore = restore_rt; |
| 93 | 93 | pub fn restore_rt() callconv(.Naked) void { |
| 94 | 94 | return asm volatile ("syscall" |
| 95 | 95 | : |
| 96 | : [number] "{rax}" (@enumToInt(SYS.rt_sigreturn)) | |
| 96 | : [number] "{rax}" (@enumToInt(SYS.rt_sigreturn)), | |
| 97 | 97 | : "rcx", "r11", "memory" |
| 98 | 98 | ); |
| 99 | 99 | } |
lib/std/os/windows.zig+3-3| ... | ... | @@ -1723,15 +1723,15 @@ pub fn teb() *TEB { |
| 1723 | 1723 | return switch (builtin.target.cpu.arch) { |
| 1724 | 1724 | .i386 => asm volatile ( |
| 1725 | 1725 | \\ movl %%fs:0x18, %[ptr] |
| 1726 | : [ptr] "=r" (-> *TEB) | |
| 1726 | : [ptr] "=r" (-> *TEB), | |
| 1727 | 1727 | ), |
| 1728 | 1728 | .x86_64 => asm volatile ( |
| 1729 | 1729 | \\ movq %%gs:0x30, %[ptr] |
| 1730 | : [ptr] "=r" (-> *TEB) | |
| 1730 | : [ptr] "=r" (-> *TEB), | |
| 1731 | 1731 | ), |
| 1732 | 1732 | .aarch64 => asm volatile ( |
| 1733 | 1733 | \\ mov %[ptr], x18 |
| 1734 | : [ptr] "=r" (-> *TEB) | |
| 1734 | : [ptr] "=r" (-> *TEB), | |
| 1735 | 1735 | ), |
| 1736 | 1736 | else => @compileError("unsupported arch"), |
| 1737 | 1737 | }; |
lib/std/special/build_runner.zig+7| ... | ... | @@ -245,6 +245,13 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void |
| 245 | 245 | }); |
| 246 | 246 | defer allocator.free(name); |
| 247 | 247 | try out_stream.print("{s:<30} {s}\n", .{ name, option.description }); |
| 248 | if (option.enum_options) |enum_options| { | |
| 249 | const padding = " " ** 33; | |
| 250 | try out_stream.writeAll(padding ++ "Supported Values:\n"); | |
| 251 | for (enum_options) |enum_option| { | |
| 252 | try out_stream.print(padding ++ " {s}\n", .{enum_option}); | |
| 253 | } | |
| 254 | } | |
| 248 | 255 | } |
| 249 | 256 | } |
| 250 | 257 |
lib/std/special/compiler_rt/clear_cache.zig+3-3| ... | ... | @@ -88,7 +88,7 @@ pub fn clear_cache(start: usize, end: usize) callconv(.C) void { |
| 88 | 88 | asm volatile ( |
| 89 | 89 | \\mrs %[x], ctr_el0 |
| 90 | 90 | \\ |
| 91 | : [x] "=r" (ctr_el0) | |
| 91 | : [x] "=r" (ctr_el0), | |
| 92 | 92 | ); |
| 93 | 93 | // The DC and IC instructions must use 64-bit registers so we don't use |
| 94 | 94 | // uintptr_t in case this runs in an IPL32 environment. |
| ... | ... | @@ -101,7 +101,7 @@ pub fn clear_cache(start: usize, end: usize) callconv(.C) void { |
| 101 | 101 | while (addr < end) : (addr += dcache_line_size) { |
| 102 | 102 | asm volatile ("dc cvau, %[addr]" |
| 103 | 103 | : |
| 104 | : [addr] "r" (addr) | |
| 104 | : [addr] "r" (addr), | |
| 105 | 105 | ); |
| 106 | 106 | } |
| 107 | 107 | } |
| ... | ... | @@ -114,7 +114,7 @@ pub fn clear_cache(start: usize, end: usize) callconv(.C) void { |
| 114 | 114 | while (addr < end) : (addr += icache_line_size) { |
| 115 | 115 | asm volatile ("ic ivau, %[addr]" |
| 116 | 116 | : |
| 117 | : [addr] "r" (addr) | |
| 117 | : [addr] "r" (addr), | |
| 118 | 118 | ); |
| 119 | 119 | } |
| 120 | 120 | } |
lib/std/start.zig+13-13| ... | ... | @@ -98,7 +98,7 @@ fn exit2(code: usize) noreturn { |
| 98 | 98 | asm volatile ("syscall" |
| 99 | 99 | : |
| 100 | 100 | : [number] "{rax}" (231), |
| 101 | [arg1] "{rdi}" (code) | |
| 101 | [arg1] "{rdi}" (code), | |
| 102 | 102 | : "rcx", "r11", "memory" |
| 103 | 103 | ); |
| 104 | 104 | }, |
| ... | ... | @@ -106,7 +106,7 @@ fn exit2(code: usize) noreturn { |
| 106 | 106 | asm volatile ("svc #0" |
| 107 | 107 | : |
| 108 | 108 | : [number] "{r7}" (1), |
| 109 | [arg1] "{r0}" (code) | |
| 109 | [arg1] "{r0}" (code), | |
| 110 | 110 | : "memory" |
| 111 | 111 | ); |
| 112 | 112 | }, |
| ... | ... | @@ -114,7 +114,7 @@ fn exit2(code: usize) noreturn { |
| 114 | 114 | asm volatile ("svc #0" |
| 115 | 115 | : |
| 116 | 116 | : [number] "{x8}" (93), |
| 117 | [arg1] "{x0}" (code) | |
| 117 | [arg1] "{x0}" (code), | |
| 118 | 118 | : "memory", "cc" |
| 119 | 119 | ); |
| 120 | 120 | }, |
| ... | ... | @@ -128,7 +128,7 @@ fn exit2(code: usize) noreturn { |
| 128 | 128 | \\push $0 |
| 129 | 129 | \\syscall |
| 130 | 130 | : |
| 131 | : [syscall_number] "{rbp}" (8) | |
| 131 | : [syscall_number] "{rbp}" (8), | |
| 132 | 132 | : "rcx", "r11", "memory" |
| 133 | 133 | ); |
| 134 | 134 | }, |
| ... | ... | @@ -137,7 +137,7 @@ fn exit2(code: usize) noreturn { |
| 137 | 137 | .aarch64 => { |
| 138 | 138 | asm volatile ("svc #0" |
| 139 | 139 | : |
| 140 | : [exit] "{x0}" (0x08) | |
| 140 | : [exit] "{x0}" (0x08), | |
| 141 | 141 | : "memory", "cc" |
| 142 | 142 | ); |
| 143 | 143 | }, |
| ... | ... | @@ -208,34 +208,34 @@ fn _start() callconv(.Naked) noreturn { |
| 208 | 208 | .x86_64 => { |
| 209 | 209 | argc_argv_ptr = asm volatile ( |
| 210 | 210 | \\ xor %%rbp, %%rbp |
| 211 | : [argc] "={rsp}" (-> [*]usize) | |
| 211 | : [argc] "={rsp}" (-> [*]usize), | |
| 212 | 212 | ); |
| 213 | 213 | }, |
| 214 | 214 | .i386 => { |
| 215 | 215 | argc_argv_ptr = asm volatile ( |
| 216 | 216 | \\ xor %%ebp, %%ebp |
| 217 | : [argc] "={esp}" (-> [*]usize) | |
| 217 | : [argc] "={esp}" (-> [*]usize), | |
| 218 | 218 | ); |
| 219 | 219 | }, |
| 220 | 220 | .aarch64, .aarch64_be, .arm, .armeb, .thumb => { |
| 221 | 221 | argc_argv_ptr = asm volatile ( |
| 222 | 222 | \\ mov fp, #0 |
| 223 | 223 | \\ mov lr, #0 |
| 224 | : [argc] "={sp}" (-> [*]usize) | |
| 224 | : [argc] "={sp}" (-> [*]usize), | |
| 225 | 225 | ); |
| 226 | 226 | }, |
| 227 | 227 | .riscv64 => { |
| 228 | 228 | argc_argv_ptr = asm volatile ( |
| 229 | 229 | \\ li s0, 0 |
| 230 | 230 | \\ li ra, 0 |
| 231 | : [argc] "={sp}" (-> [*]usize) | |
| 231 | : [argc] "={sp}" (-> [*]usize), | |
| 232 | 232 | ); |
| 233 | 233 | }, |
| 234 | 234 | .mips, .mipsel => { |
| 235 | 235 | // The lr is already zeroed on entry, as specified by the ABI. |
| 236 | 236 | argc_argv_ptr = asm volatile ( |
| 237 | 237 | \\ move $fp, $0 |
| 238 | : [argc] "={sp}" (-> [*]usize) | |
| 238 | : [argc] "={sp}" (-> [*]usize), | |
| 239 | 239 | ); |
| 240 | 240 | }, |
| 241 | 241 | .powerpc => { |
| ... | ... | @@ -246,7 +246,7 @@ fn _start() callconv(.Naked) noreturn { |
| 246 | 246 | \\ stwu 1,-16(1) |
| 247 | 247 | \\ stw 0, 0(1) |
| 248 | 248 | \\ mtlr 0 |
| 249 | : [argc] "={r4}" (-> [*]usize) | |
| 249 | : [argc] "={r4}" (-> [*]usize), | |
| 250 | 250 | : |
| 251 | 251 | : "r0" |
| 252 | 252 | ); |
| ... | ... | @@ -259,7 +259,7 @@ fn _start() callconv(.Naked) noreturn { |
| 259 | 259 | \\ li 0, 0 |
| 260 | 260 | \\ stdu 0, -32(1) |
| 261 | 261 | \\ mtlr 0 |
| 262 | : [argc] "={r4}" (-> [*]usize) | |
| 262 | : [argc] "={r4}" (-> [*]usize), | |
| 263 | 263 | : |
| 264 | 264 | : "r0" |
| 265 | 265 | ); |
| ... | ... | @@ -269,7 +269,7 @@ fn _start() callconv(.Naked) noreturn { |
| 269 | 269 | argc_argv_ptr = asm ( |
| 270 | 270 | \\ mov %%g0, %%i6 |
| 271 | 271 | \\ add %%o6, 2175, %[argc] |
| 272 | : [argc] "=r" (-> [*]usize) | |
| 272 | : [argc] "=r" (-> [*]usize), | |
| 273 | 273 | ); |
| 274 | 274 | }, |
| 275 | 275 | else => @compileError("unsupported arch"), |
lib/std/valgrind.zig+4-4| ... | ... | @@ -13,9 +13,9 @@ pub fn doClientRequest(default: usize, request: usize, a1: usize, a2: usize, a3: |
| 13 | 13 | \\ roll $3, %%edi ; roll $13, %%edi |
| 14 | 14 | \\ roll $29, %%edi ; roll $19, %%edi |
| 15 | 15 | \\ xchgl %%ebx,%%ebx |
| 16 | : [_] "={edx}" (-> usize) | |
| 16 | : [_] "={edx}" (-> usize), | |
| 17 | 17 | : [_] "{eax}" (&[_]usize{ request, a1, a2, a3, a4, a5 }), |
| 18 | [_] "0" (default) | |
| 18 | [_] "0" (default), | |
| 19 | 19 | : "cc", "memory" |
| 20 | 20 | ); |
| 21 | 21 | }, |
| ... | ... | @@ -24,9 +24,9 @@ pub fn doClientRequest(default: usize, request: usize, a1: usize, a2: usize, a3: |
| 24 | 24 | \\ rolq $3, %%rdi ; rolq $13, %%rdi |
| 25 | 25 | \\ rolq $61, %%rdi ; rolq $51, %%rdi |
| 26 | 26 | \\ xchgq %%rbx,%%rbx |
| 27 | : [_] "={rdx}" (-> usize) | |
| 27 | : [_] "={rdx}" (-> usize), | |
| 28 | 28 | : [_] "{rax}" (&[_]usize{ request, a1, a2, a3, a4, a5 }), |
| 29 | [_] "0" (default) | |
| 29 | [_] "0" (default), | |
| 30 | 30 | : "cc", "memory" |
| 31 | 31 | ); |
| 32 | 32 | }, |
lib/std/zig/parser_test.zig+15-29| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | test "zig fmt: preserves clobbers in inline asm with stray comma" { |
| 2 | try testTransform( | |
| 2 | try testCanonical( | |
| 3 | 3 | \\fn foo() void { |
| 4 | 4 | \\ asm volatile ("" |
| 5 | 5 | \\ : [_] "" (-> type), |
| ... | ... | @@ -13,20 +13,6 @@ test "zig fmt: preserves clobbers in inline asm with stray comma" { |
| 13 | 13 | \\ ); |
| 14 | 14 | \\} |
| 15 | 15 | \\ |
| 16 | , | |
| 17 | \\fn foo() void { | |
| 18 | \\ asm volatile ("" | |
| 19 | \\ : [_] "" (-> type) | |
| 20 | \\ : | |
| 21 | \\ : "clobber" | |
| 22 | \\ ); | |
| 23 | \\ asm volatile ("" | |
| 24 | \\ : | |
| 25 | \\ : [_] "" (type) | |
| 26 | \\ : "clobber" | |
| 27 | \\ ); | |
| 28 | \\} | |
| 29 | \\ | |
| 30 | 16 | ); |
| 31 | 17 | } |
| 32 | 18 | |
| ... | ... | @@ -508,15 +494,15 @@ test "zig fmt: asm expression with comptime content" { |
| 508 | 494 | \\pub fn main() void { |
| 509 | 495 | \\ asm volatile ("foo" ++ "bar"); |
| 510 | 496 | \\ asm volatile ("foo" ++ "bar" |
| 511 | \\ : [_] "" (x) | |
| 497 | \\ : [_] "" (x), | |
| 512 | 498 | \\ ); |
| 513 | 499 | \\ asm volatile ("foo" ++ "bar" |
| 514 | \\ : [_] "" (x) | |
| 515 | \\ : [_] "" (y) | |
| 500 | \\ : [_] "" (x), | |
| 501 | \\ : [_] "" (y), | |
| 516 | 502 | \\ ); |
| 517 | 503 | \\ asm volatile ("foo" ++ "bar" |
| 518 | \\ : [_] "" (x) | |
| 519 | \\ : [_] "" (y) | |
| 504 | \\ : [_] "" (x), | |
| 505 | \\ : [_] "" (y), | |
| 520 | 506 | \\ : "h", "e", "l", "l", "o" |
| 521 | 507 | \\ ); |
| 522 | 508 | \\} |
| ... | ... | @@ -2058,11 +2044,11 @@ test "zig fmt: simple asm" { |
| 2058 | 2044 | \\ ); |
| 2059 | 2045 | \\ |
| 2060 | 2046 | \\ asm ("not real assembly" |
| 2061 | \\ : [a] "x" (x) | |
| 2047 | \\ : [a] "x" (x), | |
| 2062 | 2048 | \\ ); |
| 2063 | 2049 | \\ asm ("not real assembly" |
| 2064 | \\ : [a] "x" (-> i32) | |
| 2065 | \\ : [a] "x" (1) | |
| 2050 | \\ : [a] "x" (-> i32), | |
| 2051 | \\ : [a] "x" (1), | |
| 2066 | 2052 | \\ ); |
| 2067 | 2053 | \\ asm ("still not real assembly" ::: "a", "b"); |
| 2068 | 2054 | \\} |
| ... | ... | @@ -3712,9 +3698,9 @@ test "zig fmt: inline asm" { |
| 3712 | 3698 | try testCanonical( |
| 3713 | 3699 | \\pub fn syscall1(number: usize, arg1: usize) usize { |
| 3714 | 3700 | \\ return asm volatile ("syscall" |
| 3715 | \\ : [ret] "={rax}" (-> usize) | |
| 3701 | \\ : [ret] "={rax}" (-> usize), | |
| 3716 | 3702 | \\ : [number] "{rax}" (number), |
| 3717 | \\ [arg1] "{rdi}" (arg1) | |
| 3703 | \\ [arg1] "{rdi}" (arg1), | |
| 3718 | 3704 | \\ : "rcx", "r11" |
| 3719 | 3705 | \\ ); |
| 3720 | 3706 | \\} |
| ... | ... | @@ -3817,14 +3803,14 @@ test "zig fmt: inline asm parameter alignment" { |
| 3817 | 3803 | \\ \\ foo |
| 3818 | 3804 | \\ \\ bar |
| 3819 | 3805 | \\ : [_] "" (-> usize), |
| 3820 | \\ [_] "" (-> usize) | |
| 3806 | \\ [_] "" (-> usize), | |
| 3821 | 3807 | \\ ); |
| 3822 | 3808 | \\ asm volatile ( |
| 3823 | 3809 | \\ \\ foo |
| 3824 | 3810 | \\ \\ bar |
| 3825 | 3811 | \\ : |
| 3826 | 3812 | \\ : [_] "" (0), |
| 3827 | \\ [_] "" (0) | |
| 3813 | \\ [_] "" (0), | |
| 3828 | 3814 | \\ ); |
| 3829 | 3815 | \\ asm volatile ( |
| 3830 | 3816 | \\ \\ foo |
| ... | ... | @@ -3834,9 +3820,9 @@ test "zig fmt: inline asm parameter alignment" { |
| 3834 | 3820 | \\ \\ foo |
| 3835 | 3821 | \\ \\ bar |
| 3836 | 3822 | \\ : [_] "" (-> usize), |
| 3837 | \\ [_] "" (-> usize) | |
| 3823 | \\ [_] "" (-> usize), | |
| 3838 | 3824 | \\ : [_] "" (0), |
| 3839 | \\ [_] "" (0) | |
| 3825 | \\ [_] "" (0), | |
| 3840 | 3826 | \\ : "", "" |
| 3841 | 3827 | \\ ); |
| 3842 | 3828 | \\} |
lib/std/zig/render.zig+4-4| ... | ... | @@ -1944,13 +1944,13 @@ fn renderAsm( |
| 1944 | 1944 | try renderToken(ais, tree, comma, .newline); // , |
| 1945 | 1945 | try renderExtraNewlineToken(ais, tree, tree.firstToken(next_asm_output)); |
| 1946 | 1946 | } else if (asm_node.inputs.len == 0 and asm_node.first_clobber == null) { |
| 1947 | try renderAsmOutput(gpa, ais, tree, asm_output, .newline); | |
| 1947 | try renderAsmOutput(gpa, ais, tree, asm_output, .comma); | |
| 1948 | 1948 | ais.popIndent(); |
| 1949 | 1949 | ais.setIndentDelta(indent_delta); |
| 1950 | 1950 | ais.popIndent(); |
| 1951 | 1951 | return renderToken(ais, tree, asm_node.ast.rparen, space); // rparen |
| 1952 | 1952 | } else { |
| 1953 | try renderAsmOutput(gpa, ais, tree, asm_output, .newline); | |
| 1953 | try renderAsmOutput(gpa, ais, tree, asm_output, .comma); | |
| 1954 | 1954 | const comma_or_colon = tree.lastToken(asm_output) + 1; |
| 1955 | 1955 | ais.popIndent(); |
| 1956 | 1956 | break :colon2 switch (token_tags[comma_or_colon]) { |
| ... | ... | @@ -1976,13 +1976,13 @@ fn renderAsm( |
| 1976 | 1976 | try renderToken(ais, tree, first_token - 1, .newline); // , |
| 1977 | 1977 | try renderExtraNewlineToken(ais, tree, first_token); |
| 1978 | 1978 | } else if (asm_node.first_clobber == null) { |
| 1979 | try renderAsmInput(gpa, ais, tree, asm_input, .newline); | |
| 1979 | try renderAsmInput(gpa, ais, tree, asm_input, .comma); | |
| 1980 | 1980 | ais.popIndent(); |
| 1981 | 1981 | ais.setIndentDelta(indent_delta); |
| 1982 | 1982 | ais.popIndent(); |
| 1983 | 1983 | return renderToken(ais, tree, asm_node.ast.rparen, space); // rparen |
| 1984 | 1984 | } else { |
| 1985 | try renderAsmInput(gpa, ais, tree, asm_input, .newline); | |
| 1985 | try renderAsmInput(gpa, ais, tree, asm_input, .comma); | |
| 1986 | 1986 | const comma_or_colon = tree.lastToken(asm_input) + 1; |
| 1987 | 1987 | ais.popIndent(); |
| 1988 | 1988 | break :colon3 switch (token_tags[comma_or_colon]) { |
lib/std/zig/system/x86.zig+2-2| ... | ... | @@ -543,7 +543,7 @@ fn cpuid(leaf_id: u32, subid: u32) CpuidLeaf { |
| 543 | 543 | : |
| 544 | 544 | : [leaf_id] "{eax}" (leaf_id), |
| 545 | 545 | [subid] "{ecx}" (subid), |
| 546 | [leaf_ptr] "r" (&cpuid_leaf) | |
| 546 | [leaf_ptr] "r" (&cpuid_leaf), | |
| 547 | 547 | : "eax", "ebx", "ecx", "edx" |
| 548 | 548 | ); |
| 549 | 549 | |
| ... | ... | @@ -555,7 +555,7 @@ fn getXCR0() u32 { |
| 555 | 555 | return asm volatile ( |
| 556 | 556 | \\ xor %%ecx, %%ecx |
| 557 | 557 | \\ xgetbv |
| 558 | : [ret] "={eax}" (-> u32) | |
| 558 | : [ret] "={eax}" (-> u32), | |
| 559 | 559 | : |
| 560 | 560 | : "eax", "edx", "ecx" |
| 561 | 561 | ); |
src/AstGen.zig+143-134| ... | ... | @@ -2883,8 +2883,6 @@ fn fnDecl( |
| 2883 | 2883 | }; |
| 2884 | 2884 | const fn_name_str_index = try astgen.identAsString(fn_name_token); |
| 2885 | 2885 | |
| 2886 | try astgen.declareNewName(scope, fn_name_str_index, decl_node, fn_name_token); | |
| 2887 | ||
| 2888 | 2886 | // We insert this at the beginning so that its instruction index marks the |
| 2889 | 2887 | // start of the top level declaration. |
| 2890 | 2888 | const block_inst = try gz.addBlock(.block_inline, fn_proto.ast.proto_node); |
| ... | ... | @@ -3153,8 +3151,6 @@ fn globalVarDecl( |
| 3153 | 3151 | const name_token = var_decl.ast.mut_token + 1; |
| 3154 | 3152 | const name_str_index = try astgen.identAsString(name_token); |
| 3155 | 3153 | |
| 3156 | try astgen.declareNewName(scope, name_str_index, node, name_token); | |
| 3157 | ||
| 3158 | 3154 | var block_scope: GenZir = .{ |
| 3159 | 3155 | .parent = scope, |
| 3160 | 3156 | .decl_node_index = node, |
| ... | ... | @@ -3509,9 +3505,11 @@ fn structDeclInner( |
| 3509 | 3505 | }; |
| 3510 | 3506 | defer block_scope.instructions.deinit(gpa); |
| 3511 | 3507 | |
| 3512 | var namespace: Scope.Namespace = .{ .parent = scope }; | |
| 3508 | var namespace: Scope.Namespace = .{ .parent = scope, .node = node }; | |
| 3513 | 3509 | defer namespace.decls.deinit(gpa); |
| 3514 | 3510 | |
| 3511 | try astgen.scanDecls(&namespace, container_decl.ast.members); | |
| 3512 | ||
| 3515 | 3513 | var wip_decls: WipDecls = .{}; |
| 3516 | 3514 | defer wip_decls.deinit(gpa); |
| 3517 | 3515 | |
| ... | ... | @@ -3671,7 +3669,7 @@ fn structDeclInner( |
| 3671 | 3669 | const field_type: Zir.Inst.Ref = if (node_tags[member.ast.type_expr] == .@"anytype") |
| 3672 | 3670 | .none |
| 3673 | 3671 | else |
| 3674 | try typeExpr(&block_scope, &block_scope.base, member.ast.type_expr); | |
| 3672 | try typeExpr(&block_scope, &namespace.base, member.ast.type_expr); | |
| 3675 | 3673 | fields_data.appendAssumeCapacity(@enumToInt(field_type)); |
| 3676 | 3674 | |
| 3677 | 3675 | known_has_bits = known_has_bits or nodeImpliesRuntimeBits(tree, member.ast.type_expr); |
| ... | ... | @@ -3687,13 +3685,13 @@ fn structDeclInner( |
| 3687 | 3685 | (@as(u32, @boolToInt(unused)) << 31); |
| 3688 | 3686 | |
| 3689 | 3687 | if (have_align) { |
| 3690 | const align_inst = try expr(&block_scope, &block_scope.base, align_rl, member.ast.align_expr); | |
| 3688 | const align_inst = try expr(&block_scope, &namespace.base, align_rl, member.ast.align_expr); | |
| 3691 | 3689 | fields_data.appendAssumeCapacity(@enumToInt(align_inst)); |
| 3692 | 3690 | } |
| 3693 | 3691 | if (have_value) { |
| 3694 | 3692 | const rl: ResultLoc = if (field_type == .none) .none else .{ .ty = field_type }; |
| 3695 | 3693 | |
| 3696 | const default_inst = try expr(&block_scope, &block_scope.base, rl, member.ast.value_expr); | |
| 3694 | const default_inst = try expr(&block_scope, &namespace.base, rl, member.ast.value_expr); | |
| 3697 | 3695 | fields_data.appendAssumeCapacity(@enumToInt(default_inst)); |
| 3698 | 3696 | } else if (member.comptime_token) |comptime_token| { |
| 3699 | 3697 | return astgen.failTok(comptime_token, "comptime field without default initialization value", .{}); |
| ... | ... | @@ -3756,7 +3754,7 @@ fn unionDeclInner( |
| 3756 | 3754 | node: ast.Node.Index, |
| 3757 | 3755 | members: []const ast.Node.Index, |
| 3758 | 3756 | layout: std.builtin.TypeInfo.ContainerLayout, |
| 3759 | arg_inst: Zir.Inst.Ref, | |
| 3757 | arg_node: ast.Node.Index, | |
| 3760 | 3758 | have_auto_enum: bool, |
| 3761 | 3759 | ) InnerError!Zir.Inst.Ref { |
| 3762 | 3760 | const astgen = gz.astgen; |
| ... | ... | @@ -3778,9 +3776,16 @@ fn unionDeclInner( |
| 3778 | 3776 | }; |
| 3779 | 3777 | defer block_scope.instructions.deinit(gpa); |
| 3780 | 3778 | |
| 3781 | var namespace: Scope.Namespace = .{ .parent = scope }; | |
| 3779 | var namespace: Scope.Namespace = .{ .parent = scope, .node = node }; | |
| 3782 | 3780 | defer namespace.decls.deinit(gpa); |
| 3783 | 3781 | |
| 3782 | try astgen.scanDecls(&namespace, members); | |
| 3783 | ||
| 3784 | const arg_inst: Zir.Inst.Ref = if (arg_node != 0) | |
| 3785 | try typeExpr(gz, &namespace.base, arg_node) | |
| 3786 | else | |
| 3787 | .none; | |
| 3788 | ||
| 3784 | 3789 | var wip_decls: WipDecls = .{}; |
| 3785 | 3790 | defer wip_decls.deinit(gpa); |
| 3786 | 3791 | |
| ... | ... | @@ -3946,7 +3951,7 @@ fn unionDeclInner( |
| 3946 | 3951 | (@as(u32, @boolToInt(unused)) << 31); |
| 3947 | 3952 | |
| 3948 | 3953 | if (have_type and node_tags[member.ast.type_expr] != .@"anytype") { |
| 3949 | const field_type = try typeExpr(&block_scope, &block_scope.base, member.ast.type_expr); | |
| 3954 | const field_type = try typeExpr(&block_scope, &namespace.base, member.ast.type_expr); | |
| 3950 | 3955 | fields_data.appendAssumeCapacity(@enumToInt(field_type)); |
| 3951 | 3956 | } |
| 3952 | 3957 | if (have_align) { |
| ... | ... | @@ -4046,11 +4051,6 @@ fn containerDecl( |
| 4046 | 4051 | // We must not create any types until Sema. Here the goal is only to generate |
| 4047 | 4052 | // ZIR for all the field types, alignments, and default value expressions. |
| 4048 | 4053 | |
| 4049 | const arg_inst: Zir.Inst.Ref = if (container_decl.ast.arg != 0) | |
| 4050 | try comptimeExpr(gz, scope, .{ .ty = .type_type }, container_decl.ast.arg) | |
| 4051 | else | |
| 4052 | .none; | |
| 4053 | ||
| 4054 | 4054 | switch (token_tags[container_decl.ast.main_token]) { |
| 4055 | 4055 | .keyword_struct => { |
| 4056 | 4056 | const layout = if (container_decl.layout_token) |t| switch (token_tags[t]) { |
| ... | ... | @@ -4059,7 +4059,7 @@ fn containerDecl( |
| 4059 | 4059 | else => unreachable, |
| 4060 | 4060 | } else std.builtin.TypeInfo.ContainerLayout.Auto; |
| 4061 | 4061 | |
| 4062 | assert(arg_inst == .none); | |
| 4062 | assert(container_decl.ast.arg == 0); | |
| 4063 | 4063 | |
| 4064 | 4064 | const result = try structDeclInner(gz, scope, node, container_decl, layout); |
| 4065 | 4065 | return rvalue(gz, rl, result, node); |
| ... | ... | @@ -4073,7 +4073,7 @@ fn containerDecl( |
| 4073 | 4073 | |
| 4074 | 4074 | const have_auto_enum = container_decl.ast.enum_token != null; |
| 4075 | 4075 | |
| 4076 | const result = try unionDeclInner(gz, scope, node, container_decl.ast.members, layout, arg_inst, have_auto_enum); | |
| 4076 | const result = try unionDeclInner(gz, scope, node, container_decl.ast.members, layout, container_decl.ast.arg, have_auto_enum); | |
| 4077 | 4077 | return rvalue(gz, rl, result, node); |
| 4078 | 4078 | }, |
| 4079 | 4079 | .keyword_enum => { |
| ... | ... | @@ -4140,7 +4140,7 @@ fn containerDecl( |
| 4140 | 4140 | } |
| 4141 | 4141 | total_fields += 1; |
| 4142 | 4142 | if (member.ast.value_expr != 0) { |
| 4143 | if (arg_inst == .none) { | |
| 4143 | if (container_decl.ast.arg == 0) { | |
| 4144 | 4144 | return astgen.failNode(member.ast.value_expr, "value assigned to enum tag with inferred tag type", .{}); |
| 4145 | 4145 | } |
| 4146 | 4146 | values += 1; |
| ... | ... | @@ -4159,7 +4159,7 @@ fn containerDecl( |
| 4159 | 4159 | // must be at least one tag. |
| 4160 | 4160 | return astgen.failNode(node, "enum declarations must have at least one tag", .{}); |
| 4161 | 4161 | } |
| 4162 | if (counts.nonexhaustive_node != 0 and arg_inst == .none) { | |
| 4162 | if (counts.nonexhaustive_node != 0 and container_decl.ast.arg == 0) { | |
| 4163 | 4163 | return astgen.failNodeNotes( |
| 4164 | 4164 | node, |
| 4165 | 4165 | "non-exhaustive enum missing integer tag type", |
| ... | ... | @@ -4189,9 +4189,16 @@ fn containerDecl( |
| 4189 | 4189 | }; |
| 4190 | 4190 | defer block_scope.instructions.deinit(gpa); |
| 4191 | 4191 | |
| 4192 | var namespace: Scope.Namespace = .{ .parent = scope }; | |
| 4192 | var namespace: Scope.Namespace = .{ .parent = scope, .node = node }; | |
| 4193 | 4193 | defer namespace.decls.deinit(gpa); |
| 4194 | 4194 | |
| 4195 | try astgen.scanDecls(&namespace, container_decl.ast.members); | |
| 4196 | ||
| 4197 | const arg_inst: Zir.Inst.Ref = if (container_decl.ast.arg != 0) | |
| 4198 | try comptimeExpr(gz, &namespace.base, .{ .ty = .type_type }, container_decl.ast.arg) | |
| 4199 | else | |
| 4200 | .none; | |
| 4201 | ||
| 4195 | 4202 | var wip_decls: WipDecls = .{}; |
| 4196 | 4203 | defer wip_decls.deinit(gpa); |
| 4197 | 4204 | |
| ... | ... | @@ -4364,7 +4371,7 @@ fn containerDecl( |
| 4364 | 4371 | }, |
| 4365 | 4372 | ); |
| 4366 | 4373 | } |
| 4367 | const tag_value_inst = try expr(&block_scope, &block_scope.base, .{ .ty = arg_inst }, member.ast.value_expr); | |
| 4374 | const tag_value_inst = try expr(&block_scope, &namespace.base, .{ .ty = arg_inst }, member.ast.value_expr); | |
| 4368 | 4375 | fields_data.appendAssumeCapacity(@enumToInt(tag_value_inst)); |
| 4369 | 4376 | } |
| 4370 | 4377 | |
| ... | ... | @@ -4416,9 +4423,13 @@ fn containerDecl( |
| 4416 | 4423 | return rvalue(gz, rl, indexToRef(decl_inst), node); |
| 4417 | 4424 | }, |
| 4418 | 4425 | .keyword_opaque => { |
| 4419 | var namespace: Scope.Namespace = .{ .parent = scope }; | |
| 4426 | assert(container_decl.ast.arg == 0); | |
| 4427 | ||
| 4428 | var namespace: Scope.Namespace = .{ .parent = scope, .node = node }; | |
| 4420 | 4429 | defer namespace.decls.deinit(gpa); |
| 4421 | 4430 | |
| 4431 | try astgen.scanDecls(&namespace, container_decl.ast.members); | |
| 4432 | ||
| 4422 | 4433 | var wip_decls: WipDecls = .{}; |
| 4423 | 4434 | defer wip_decls.deinit(gpa); |
| 4424 | 4435 | |
| ... | ... | @@ -6352,73 +6363,63 @@ fn identifier( |
| 6352 | 6363 | |
| 6353 | 6364 | // Local variables, including function parameters. |
| 6354 | 6365 | const name_str_index = try astgen.identAsString(ident_token); |
| 6355 | { | |
| 6356 | var s = scope; | |
| 6357 | var found_already: ?ast.Node.Index = null; // we have found a decl with the same name already | |
| 6358 | var hit_namespace = false; | |
| 6359 | while (true) switch (s.tag) { | |
| 6360 | .local_val => { | |
| 6361 | const local_val = s.cast(Scope.LocalVal).?; | |
| 6362 | ||
| 6363 | if (local_val.name == name_str_index) { | |
| 6364 | local_val.used = true; | |
| 6365 | // Captures of non-locals need to be emitted as decl_val or decl_ref. | |
| 6366 | // This *might* be capturable depending on if it is comptime known. | |
| 6367 | if (!hit_namespace) { | |
| 6368 | return rvalue(gz, rl, local_val.inst, ident); | |
| 6369 | } | |
| 6366 | var s = scope; | |
| 6367 | var found_already: ?ast.Node.Index = null; // we have found a decl with the same name already | |
| 6368 | var hit_namespace: ast.Node.Index = 0; | |
| 6369 | while (true) switch (s.tag) { | |
| 6370 | .local_val => { | |
| 6371 | const local_val = s.cast(Scope.LocalVal).?; | |
| 6372 | ||
| 6373 | if (local_val.name == name_str_index) { | |
| 6374 | local_val.used = true; | |
| 6375 | // Locals cannot shadow anything, so we do not need to look for ambiguous | |
| 6376 | // references in this case. | |
| 6377 | return rvalue(gz, rl, local_val.inst, ident); | |
| 6378 | } | |
| 6379 | s = local_val.parent; | |
| 6380 | }, | |
| 6381 | .local_ptr => { | |
| 6382 | const local_ptr = s.cast(Scope.LocalPtr).?; | |
| 6383 | if (local_ptr.name == name_str_index) { | |
| 6384 | local_ptr.used = true; | |
| 6385 | if (hit_namespace != 0 and !local_ptr.maybe_comptime) { | |
| 6386 | return astgen.failNodeNotes(ident, "mutable '{s}' not accessible from here", .{ident_name}, &.{ | |
| 6387 | try astgen.errNoteTok(local_ptr.token_src, "declared mutable here", .{}), | |
| 6388 | try astgen.errNoteNode(hit_namespace, "crosses namespace boundary here", .{}), | |
| 6389 | }); | |
| 6370 | 6390 | } |
| 6371 | s = local_val.parent; | |
| 6372 | }, | |
| 6373 | .local_ptr => { | |
| 6374 | const local_ptr = s.cast(Scope.LocalPtr).?; | |
| 6375 | if (local_ptr.name == name_str_index) { | |
| 6376 | local_ptr.used = true; | |
| 6377 | if (hit_namespace) { | |
| 6378 | if (local_ptr.maybe_comptime) | |
| 6379 | break | |
| 6380 | else | |
| 6381 | return astgen.failNodeNotes(ident, "'{s}' not accessible from inner function", .{ident_name}, &.{ | |
| 6382 | try astgen.errNoteTok(local_ptr.token_src, "declared here", .{}), | |
| 6383 | // TODO add crossed function definition here note. | |
| 6384 | // Maybe add a note to the error about it being because of the var, | |
| 6385 | // maybe recommend copying it into a const variable. -SpexGuy | |
| 6386 | }); | |
| 6387 | } | |
| 6388 | switch (rl) { | |
| 6389 | .ref, .none_or_ref => return local_ptr.ptr, | |
| 6390 | else => { | |
| 6391 | const loaded = try gz.addUnNode(.load, local_ptr.ptr, ident); | |
| 6392 | return rvalue(gz, rl, loaded, ident); | |
| 6393 | }, | |
| 6394 | } | |
| 6391 | switch (rl) { | |
| 6392 | .ref, .none_or_ref => return local_ptr.ptr, | |
| 6393 | else => { | |
| 6394 | const loaded = try gz.addUnNode(.load, local_ptr.ptr, ident); | |
| 6395 | return rvalue(gz, rl, loaded, ident); | |
| 6396 | }, | |
| 6395 | 6397 | } |
| 6396 | s = local_ptr.parent; | |
| 6397 | }, | |
| 6398 | .gen_zir => s = s.cast(GenZir).?.parent, | |
| 6399 | .defer_normal, .defer_error => s = s.cast(Scope.Defer).?.parent, | |
| 6400 | // look for ambiguous references to decls | |
| 6401 | .namespace => { | |
| 6402 | const ns = s.cast(Scope.Namespace).?; | |
| 6403 | if (ns.decls.get(name_str_index)) |i| { | |
| 6404 | if (found_already) |f| | |
| 6405 | return astgen.failNodeNotes(ident, "ambiguous reference", .{}, &.{ | |
| 6406 | try astgen.errNoteNode(i, "declared here", .{}), | |
| 6407 | try astgen.errNoteNode(f, "also declared here", .{}), | |
| 6408 | }) | |
| 6409 | else | |
| 6410 | found_already = i; | |
| 6398 | } | |
| 6399 | s = local_ptr.parent; | |
| 6400 | }, | |
| 6401 | .gen_zir => s = s.cast(GenZir).?.parent, | |
| 6402 | .defer_normal, .defer_error => s = s.cast(Scope.Defer).?.parent, | |
| 6403 | .namespace => { | |
| 6404 | const ns = s.cast(Scope.Namespace).?; | |
| 6405 | if (ns.decls.get(name_str_index)) |i| { | |
| 6406 | if (found_already) |f| { | |
| 6407 | return astgen.failNodeNotes(ident, "ambiguous reference", .{}, &.{ | |
| 6408 | try astgen.errNoteNode(f, "declared here", .{}), | |
| 6409 | try astgen.errNoteNode(i, "also declared here", .{}), | |
| 6410 | }); | |
| 6411 | 6411 | } |
| 6412 | hit_namespace = true; | |
| 6413 | s = ns.parent; | |
| 6414 | }, | |
| 6415 | .top => break, | |
| 6416 | }; | |
| 6417 | } | |
| 6412 | // We found a match but must continue looking for ambiguous references to decls. | |
| 6413 | found_already = i; | |
| 6414 | } | |
| 6415 | hit_namespace = ns.node; | |
| 6416 | s = ns.parent; | |
| 6417 | }, | |
| 6418 | .top => break, | |
| 6419 | }; | |
| 6418 | 6420 | |
| 6419 | // We can't look up Decls until Sema because the same ZIR code is supposed to be | |
| 6420 | // used for multiple generic instantiations, and this may refer to a different Decl | |
| 6421 | // depending on the scope, determined by the generic instantiation. | |
| 6421 | // Decl references happen by name rather than ZIR index so that when unrelated | |
| 6422 | // decls are modified, ZIR code containing references to them can be unmodified. | |
| 6422 | 6423 | switch (rl) { |
| 6423 | 6424 | .ref, .none_or_ref => return gz.addStrTok(.decl_ref, name_str_index, ident_token), |
| 6424 | 6425 | else => { |
| ... | ... | @@ -8383,7 +8384,7 @@ fn nodeImpliesRuntimeBits(tree: *const ast.Tree, start_node: ast.Node.Index) boo |
| 8383 | 8384 | } |
| 8384 | 8385 | } |
| 8385 | 8386 | |
| 8386 | /// Applies `rl` semantics to `inst`. Expressions which do not do their own handling of | |
| 8387 | /// Applies `rl` semantics to `result`. Expressions which do not do their own handling of | |
| 8387 | 8388 | /// result locations must call this function on their result. |
| 8388 | 8389 | /// As an example, if the `ResultLoc` is `ptr`, it will write the result to the pointer. |
| 8389 | 8390 | /// If the `ResultLoc` is `ty`, it will coerce the result to the type. |
| ... | ... | @@ -8393,6 +8394,7 @@ fn rvalue( |
| 8393 | 8394 | result: Zir.Inst.Ref, |
| 8394 | 8395 | src_node: ast.Node.Index, |
| 8395 | 8396 | ) InnerError!Zir.Inst.Ref { |
| 8397 | if (gz.endsWithNoReturn()) return result; | |
| 8396 | 8398 | switch (rl) { |
| 8397 | 8399 | .none, .none_or_ref, .coerced_ty => return result, |
| 8398 | 8400 | .discard => { |
| ... | ... | @@ -8941,6 +8943,7 @@ const Scope = struct { |
| 8941 | 8943 | /// Maps string table index to the source location of declaration, |
| 8942 | 8944 | /// for the purposes of reporting name shadowing compile errors. |
| 8943 | 8945 | decls: std.AutoHashMapUnmanaged(u32, ast.Node.Index) = .{}, |
| 8946 | node: ast.Node.Index, | |
| 8944 | 8947 | }; |
| 8945 | 8948 | |
| 8946 | 8949 | const Top = struct { |
| ... | ... | @@ -10014,53 +10017,6 @@ fn nullTerminatedString(astgen: AstGen, index: usize) [*:0]const u8 { |
| 10014 | 10017 | return @ptrCast([*:0]const u8, astgen.string_bytes.items.ptr) + index; |
| 10015 | 10018 | } |
| 10016 | 10019 | |
| 10017 | fn declareNewName( | |
| 10018 | astgen: *AstGen, | |
| 10019 | start_scope: *Scope, | |
| 10020 | name_index: u32, | |
| 10021 | node: ast.Node.Index, | |
| 10022 | name_token: ast.TokenIndex, | |
| 10023 | ) !void { | |
| 10024 | const gpa = astgen.gpa; | |
| 10025 | ||
| 10026 | const token_bytes = astgen.tree.tokenSlice(name_token); | |
| 10027 | if (token_bytes[0] != '@' and isPrimitive(token_bytes)) { | |
| 10028 | return astgen.failTokNotes(name_token, "name shadows primitive '{s}'", .{ | |
| 10029 | token_bytes, | |
| 10030 | }, &[_]u32{ | |
| 10031 | try astgen.errNoteTok(name_token, "consider using @\"{s}\" to disambiguate", .{ | |
| 10032 | token_bytes, | |
| 10033 | }), | |
| 10034 | }); | |
| 10035 | } | |
| 10036 | ||
| 10037 | var scope = start_scope; | |
| 10038 | while (true) { | |
| 10039 | switch (scope.tag) { | |
| 10040 | .gen_zir => scope = scope.cast(GenZir).?.parent, | |
| 10041 | .local_val => scope = scope.cast(Scope.LocalVal).?.parent, | |
| 10042 | .local_ptr => scope = scope.cast(Scope.LocalPtr).?.parent, | |
| 10043 | .defer_normal, .defer_error => scope = scope.cast(Scope.Defer).?.parent, | |
| 10044 | .namespace => { | |
| 10045 | const ns = scope.cast(Scope.Namespace).?; | |
| 10046 | const gop = try ns.decls.getOrPut(gpa, name_index); | |
| 10047 | if (gop.found_existing) { | |
| 10048 | const name = try gpa.dupe(u8, mem.span(astgen.nullTerminatedString(name_index))); | |
| 10049 | defer gpa.free(name); | |
| 10050 | return astgen.failNodeNotes(node, "redeclaration of '{s}'", .{ | |
| 10051 | name, | |
| 10052 | }, &[_]u32{ | |
| 10053 | try astgen.errNoteNode(gop.value_ptr.*, "other declaration here", .{}), | |
| 10054 | }); | |
| 10055 | } | |
| 10056 | gop.value_ptr.* = node; | |
| 10057 | break; | |
| 10058 | }, | |
| 10059 | .top => break, | |
| 10060 | } | |
| 10061 | } | |
| 10062 | } | |
| 10063 | ||
| 10064 | 10020 | fn isPrimitive(name: []const u8) bool { |
| 10065 | 10021 | if (simple_types.get(name) != null) return true; |
| 10066 | 10022 | if (name.len < 2) return false; |
| ... | ... | @@ -10183,3 +10139,56 @@ fn refToIndex(inst: Zir.Inst.Ref) ?Zir.Inst.Index { |
| 10183 | 10139 | return null; |
| 10184 | 10140 | } |
| 10185 | 10141 | } |
| 10142 | ||
| 10143 | fn scanDecls(astgen: *AstGen, namespace: *Scope.Namespace, members: []const ast.Node.Index) !void { | |
| 10144 | const gpa = astgen.gpa; | |
| 10145 | const tree = astgen.tree; | |
| 10146 | const node_tags = tree.nodes.items(.tag); | |
| 10147 | const main_tokens = tree.nodes.items(.main_token); | |
| 10148 | for (members) |member_node| { | |
| 10149 | const name_token = switch (node_tags[member_node]) { | |
| 10150 | .fn_decl, | |
| 10151 | .fn_proto_simple, | |
| 10152 | .fn_proto_multi, | |
| 10153 | .fn_proto_one, | |
| 10154 | .fn_proto, | |
| 10155 | .global_var_decl, | |
| 10156 | .local_var_decl, | |
| 10157 | .simple_var_decl, | |
| 10158 | .aligned_var_decl, | |
| 10159 | => main_tokens[member_node] + 1, | |
| 10160 | ||
| 10161 | else => continue, | |
| 10162 | }; | |
| 10163 | ||
| 10164 | const token_bytes = astgen.tree.tokenSlice(name_token); | |
| 10165 | if (token_bytes[0] != '@' and isPrimitive(token_bytes)) { | |
| 10166 | switch (astgen.failTokNotes(name_token, "name shadows primitive '{s}'", .{ | |
| 10167 | token_bytes, | |
| 10168 | }, &[_]u32{ | |
| 10169 | try astgen.errNoteTok(name_token, "consider using @\"{s}\" to disambiguate", .{ | |
| 10170 | token_bytes, | |
| 10171 | }), | |
| 10172 | })) { | |
| 10173 | error.AnalysisFail => continue, | |
| 10174 | error.OutOfMemory => return error.OutOfMemory, | |
| 10175 | } | |
| 10176 | } | |
| 10177 | ||
| 10178 | const name_str_index = try astgen.identAsString(name_token); | |
| 10179 | const gop = try namespace.decls.getOrPut(gpa, name_str_index); | |
| 10180 | if (gop.found_existing) { | |
| 10181 | const name = try gpa.dupe(u8, mem.span(astgen.nullTerminatedString(name_str_index))); | |
| 10182 | defer gpa.free(name); | |
| 10183 | switch (astgen.failNodeNotes(member_node, "redeclaration of '{s}'", .{ | |
| 10184 | name, | |
| 10185 | }, &[_]u32{ | |
| 10186 | try astgen.errNoteNode(gop.value_ptr.*, "other declaration here", .{}), | |
| 10187 | })) { | |
| 10188 | error.AnalysisFail => continue, | |
| 10189 | error.OutOfMemory => return error.OutOfMemory, | |
| 10190 | } | |
| 10191 | } | |
| 10192 | gop.value_ptr.* = member_node; | |
| 10193 | } | |
| 10194 | } |
src/Module.zig+4-1| ... | ... | @@ -2648,7 +2648,10 @@ pub fn astGenFile(mod: *Module, file: *Scope.File) !void { |
| 2648 | 2648 | undefined; |
| 2649 | 2649 | defer if (data_has_safety_tag) gpa.free(safety_buffer); |
| 2650 | 2650 | const data_ptr = if (data_has_safety_tag) |
| 2651 | @ptrCast([*]const u8, safety_buffer.ptr) | |
| 2651 | if (file.zir.instructions.len == 0) | |
| 2652 | @as([*]const u8, undefined) | |
| 2653 | else | |
| 2654 | @ptrCast([*]const u8, safety_buffer.ptr) | |
| 2652 | 2655 | else |
| 2653 | 2656 | @ptrCast([*]const u8, file.zir.instructions.items(.data).ptr); |
| 2654 | 2657 | if (data_has_safety_tag) { |
src/codegen.zig+50-16| ... | ... | @@ -5210,25 +5210,59 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 5210 | 5210 | return error.CodegenFail; |
| 5211 | 5211 | } |
| 5212 | 5212 | |
| 5213 | usingnamespace switch (arch) { | |
| 5214 | .i386 => @import("codegen/x86.zig"), | |
| 5215 | .x86_64 => @import("codegen/x86_64.zig"), | |
| 5216 | .riscv64 => @import("codegen/riscv64.zig"), | |
| 5217 | .arm, .armeb => @import("codegen/arm.zig"), | |
| 5218 | .aarch64, .aarch64_be, .aarch64_32 => @import("codegen/aarch64.zig"), | |
| 5219 | else => struct { | |
| 5220 | pub const Register = enum { | |
| 5221 | dummy, | |
| 5222 | ||
| 5223 | pub fn allocIndex(self: Register) ?u4 { | |
| 5224 | _ = self; | |
| 5225 | return null; | |
| 5226 | } | |
| 5227 | }; | |
| 5228 | pub const callee_preserved_regs = [_]Register{}; | |
| 5213 | const Register = switch (arch) { | |
| 5214 | .i386 => @import("codegen/x86.zig").Register, | |
| 5215 | .x86_64 => @import("codegen/x86_64.zig").Register, | |
| 5216 | .riscv64 => @import("codegen/riscv64.zig").Register, | |
| 5217 | .arm, .armeb => @import("codegen/arm.zig").Register, | |
| 5218 | .aarch64, .aarch64_be, .aarch64_32 => @import("codegen/aarch64.zig").Register, | |
| 5219 | else => enum { | |
| 5220 | dummy, | |
| 5221 | ||
| 5222 | pub fn allocIndex(self: Register) ?u4 { | |
| 5223 | _ = self; | |
| 5224 | return null; | |
| 5225 | } | |
| 5229 | 5226 | }, |
| 5230 | 5227 | }; |
| 5231 | 5228 | |
| 5229 | const Instruction = switch (arch) { | |
| 5230 | .riscv64 => @import("codegen/riscv64.zig").Instruction, | |
| 5231 | .arm, .armeb => @import("codegen/arm.zig").Instruction, | |
| 5232 | .aarch64, .aarch64_be, .aarch64_32 => @import("codegen/aarch64.zig").Instruction, | |
| 5233 | else => void, | |
| 5234 | }; | |
| 5235 | ||
| 5236 | const Condition = switch (arch) { | |
| 5237 | .arm, .armeb => @import("codegen/arm.zig").Condition, | |
| 5238 | else => void, | |
| 5239 | }; | |
| 5240 | ||
| 5241 | const callee_preserved_regs = switch (arch) { | |
| 5242 | .i386 => @import("codegen/x86.zig").callee_preserved_regs, | |
| 5243 | .x86_64 => @import("codegen/x86_64.zig").callee_preserved_regs, | |
| 5244 | .riscv64 => @import("codegen/riscv64.zig").callee_preserved_regs, | |
| 5245 | .arm, .armeb => @import("codegen/arm.zig").callee_preserved_regs, | |
| 5246 | .aarch64, .aarch64_be, .aarch64_32 => @import("codegen/aarch64.zig").callee_preserved_regs, | |
| 5247 | else => [_]Register{}, | |
| 5248 | }; | |
| 5249 | ||
| 5250 | const c_abi_int_param_regs = switch (arch) { | |
| 5251 | .i386 => @import("codegen/x86.zig").c_abi_int_param_regs, | |
| 5252 | .x86_64 => @import("codegen/x86_64.zig").c_abi_int_param_regs, | |
| 5253 | .arm, .armeb => @import("codegen/arm.zig").c_abi_int_param_regs, | |
| 5254 | .aarch64, .aarch64_be, .aarch64_32 => @import("codegen/aarch64.zig").c_abi_int_param_regs, | |
| 5255 | else => [_]Register{}, | |
| 5256 | }; | |
| 5257 | ||
| 5258 | const c_abi_int_return_regs = switch (arch) { | |
| 5259 | .i386 => @import("codegen/x86.zig").c_abi_int_return_regs, | |
| 5260 | .x86_64 => @import("codegen/x86_64.zig").c_abi_int_return_regs, | |
| 5261 | .arm, .armeb => @import("codegen/arm.zig").c_abi_int_return_regs, | |
| 5262 | .aarch64, .aarch64_be, .aarch64_32 => @import("codegen/aarch64.zig").c_abi_int_return_regs, | |
| 5263 | else => [_]Register{}, | |
| 5264 | }; | |
| 5265 | ||
| 5232 | 5266 | fn parseRegName(name: []const u8) ?Register { |
| 5233 | 5267 | if (@hasDecl(Register, "parseRegName")) { |
| 5234 | 5268 | return Register.parseRegName(name); |
src/codegen/arm.zig+2-2| ... | ... | @@ -886,11 +886,11 @@ pub const Instruction = union(enum) { |
| 886 | 886 | return dataProcessing(cond, .mov, 1, rd, .r0, op2); |
| 887 | 887 | } |
| 888 | 888 | |
| 889 | pub fn bic(cond: Condition, rd: Register, op2: Operand) Instruction { | |
| 889 | pub fn bic(cond: Condition, rd: Register, rn: Register, op2: Operand) Instruction { | |
| 890 | 890 | return dataProcessing(cond, .bic, 0, rd, rn, op2); |
| 891 | 891 | } |
| 892 | 892 | |
| 893 | pub fn bics(cond: Condition, rd: Register, op2: Operand) Instruction { | |
| 893 | pub fn bics(cond: Condition, rd: Register, rn: Register, op2: Operand) Instruction { | |
| 894 | 894 | return dataProcessing(cond, .bic, 1, rd, rn, op2); |
| 895 | 895 | } |
| 896 | 896 |
src/codegen/llvm.zig+142-9| ... | ... | @@ -169,7 +169,7 @@ pub const Object = struct { |
| 169 | 169 | const context = llvm.Context.create(); |
| 170 | 170 | errdefer context.dispose(); |
| 171 | 171 | |
| 172 | initializeLLVMTargets(); | |
| 172 | initializeLLVMTarget(options.target.cpu.arch); | |
| 173 | 173 | |
| 174 | 174 | const root_nameZ = try gpa.dupeZ(u8, options.root_name); |
| 175 | 175 | defer gpa.free(root_nameZ); |
| ... | ... | @@ -258,14 +258,6 @@ pub const Object = struct { |
| 258 | 258 | gpa.destroy(self); |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | fn initializeLLVMTargets() void { | |
| 262 | llvm.initializeAllTargets(); | |
| 263 | llvm.initializeAllTargetInfos(); | |
| 264 | llvm.initializeAllTargetMCs(); | |
| 265 | llvm.initializeAllAsmPrinters(); | |
| 266 | llvm.initializeAllAsmParsers(); | |
| 267 | } | |
| 268 | ||
| 269 | 261 | fn locPath( |
| 270 | 262 | arena: *Allocator, |
| 271 | 263 | opt_loc: ?Compilation.EmitLoc, |
| ... | ... | @@ -1960,3 +1952,144 @@ pub const FuncGen = struct { |
| 1960 | 1952 | return self.llvmModule().getIntrinsicDeclaration(id, null, 0); |
| 1961 | 1953 | } |
| 1962 | 1954 | }; |
| 1955 | ||
| 1956 | fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void { | |
| 1957 | switch (arch) { | |
| 1958 | .aarch64, .aarch64_be, .aarch64_32 => { | |
| 1959 | llvm.LLVMInitializeAArch64Target(); | |
| 1960 | llvm.LLVMInitializeAArch64TargetInfo(); | |
| 1961 | llvm.LLVMInitializeAArch64TargetMC(); | |
| 1962 | llvm.LLVMInitializeAArch64AsmPrinter(); | |
| 1963 | llvm.LLVMInitializeAArch64AsmParser(); | |
| 1964 | }, | |
| 1965 | .amdgcn => { | |
| 1966 | llvm.LLVMInitializeAMDGPUTarget(); | |
| 1967 | llvm.LLVMInitializeAMDGPUTargetInfo(); | |
| 1968 | llvm.LLVMInitializeAMDGPUTargetMC(); | |
| 1969 | llvm.LLVMInitializeAMDGPUAsmPrinter(); | |
| 1970 | llvm.LLVMInitializeAMDGPUAsmParser(); | |
| 1971 | }, | |
| 1972 | .arm, .armeb => { | |
| 1973 | llvm.LLVMInitializeARMTarget(); | |
| 1974 | llvm.LLVMInitializeARMTargetInfo(); | |
| 1975 | llvm.LLVMInitializeARMTargetMC(); | |
| 1976 | llvm.LLVMInitializeARMAsmPrinter(); | |
| 1977 | llvm.LLVMInitializeARMAsmParser(); | |
| 1978 | }, | |
| 1979 | .avr => { | |
| 1980 | llvm.LLVMInitializeAVRTarget(); | |
| 1981 | llvm.LLVMInitializeAVRTargetInfo(); | |
| 1982 | llvm.LLVMInitializeAVRTargetMC(); | |
| 1983 | llvm.LLVMInitializeAVRAsmPrinter(); | |
| 1984 | llvm.LLVMInitializeAVRAsmParser(); | |
| 1985 | }, | |
| 1986 | .bpfel, .bpfeb => { | |
| 1987 | llvm.LLVMInitializeBPFTarget(); | |
| 1988 | llvm.LLVMInitializeBPFTargetInfo(); | |
| 1989 | llvm.LLVMInitializeBPFTargetMC(); | |
| 1990 | llvm.LLVMInitializeBPFAsmPrinter(); | |
| 1991 | llvm.LLVMInitializeBPFAsmParser(); | |
| 1992 | }, | |
| 1993 | .hexagon => { | |
| 1994 | llvm.LLVMInitializeHexagonTarget(); | |
| 1995 | llvm.LLVMInitializeHexagonTargetInfo(); | |
| 1996 | llvm.LLVMInitializeHexagonTargetMC(); | |
| 1997 | llvm.LLVMInitializeHexagonAsmPrinter(); | |
| 1998 | llvm.LLVMInitializeHexagonAsmParser(); | |
| 1999 | }, | |
| 2000 | .lanai => { | |
| 2001 | llvm.LLVMInitializeLanaiTarget(); | |
| 2002 | llvm.LLVMInitializeLanaiTargetInfo(); | |
| 2003 | llvm.LLVMInitializeLanaiTargetMC(); | |
| 2004 | llvm.LLVMInitializeLanaiAsmPrinter(); | |
| 2005 | llvm.LLVMInitializeLanaiAsmParser(); | |
| 2006 | }, | |
| 2007 | .mips, .mipsel, .mips64, .mips64el => { | |
| 2008 | llvm.LLVMInitializeMipsTarget(); | |
| 2009 | llvm.LLVMInitializeMipsTargetInfo(); | |
| 2010 | llvm.LLVMInitializeMipsTargetMC(); | |
| 2011 | llvm.LLVMInitializeMipsAsmPrinter(); | |
| 2012 | llvm.LLVMInitializeMipsAsmParser(); | |
| 2013 | }, | |
| 2014 | .msp430 => { | |
| 2015 | llvm.LLVMInitializeMSP430Target(); | |
| 2016 | llvm.LLVMInitializeMSP430TargetInfo(); | |
| 2017 | llvm.LLVMInitializeMSP430TargetMC(); | |
| 2018 | llvm.LLVMInitializeMSP430AsmPrinter(); | |
| 2019 | llvm.LLVMInitializeMSP430AsmParser(); | |
| 2020 | }, | |
| 2021 | .nvptx, .nvptx64 => { | |
| 2022 | llvm.LLVMInitializeNVPTXTarget(); | |
| 2023 | llvm.LLVMInitializeNVPTXTargetInfo(); | |
| 2024 | llvm.LLVMInitializeNVPTXTargetMC(); | |
| 2025 | llvm.LLVMInitializeNVPTXAsmPrinter(); | |
| 2026 | // There is no LLVMInitializeNVPTXAsmParser function available. | |
| 2027 | }, | |
| 2028 | .powerpc, .powerpcle, .powerpc64, .powerpc64le => { | |
| 2029 | llvm.LLVMInitializePowerPCTarget(); | |
| 2030 | llvm.LLVMInitializePowerPCTargetInfo(); | |
| 2031 | llvm.LLVMInitializePowerPCTargetMC(); | |
| 2032 | llvm.LLVMInitializePowerPCAsmPrinter(); | |
| 2033 | llvm.LLVMInitializePowerPCAsmParser(); | |
| 2034 | }, | |
| 2035 | .riscv32, .riscv64 => { | |
| 2036 | llvm.LLVMInitializeRISCVTarget(); | |
| 2037 | llvm.LLVMInitializeRISCVTargetInfo(); | |
| 2038 | llvm.LLVMInitializeRISCVTargetMC(); | |
| 2039 | llvm.LLVMInitializeRISCVAsmPrinter(); | |
| 2040 | llvm.LLVMInitializeRISCVAsmParser(); | |
| 2041 | }, | |
| 2042 | .sparc, .sparcv9, .sparcel => { | |
| 2043 | llvm.LLVMInitializeSparcTarget(); | |
| 2044 | llvm.LLVMInitializeSparcTargetInfo(); | |
| 2045 | llvm.LLVMInitializeSparcTargetMC(); | |
| 2046 | llvm.LLVMInitializeSparcAsmPrinter(); | |
| 2047 | llvm.LLVMInitializeSparcAsmParser(); | |
| 2048 | }, | |
| 2049 | .s390x => { | |
| 2050 | llvm.LLVMInitializeSystemZTarget(); | |
| 2051 | llvm.LLVMInitializeSystemZTargetInfo(); | |
| 2052 | llvm.LLVMInitializeSystemZTargetMC(); | |
| 2053 | llvm.LLVMInitializeSystemZAsmPrinter(); | |
| 2054 | llvm.LLVMInitializeSystemZAsmParser(); | |
| 2055 | }, | |
| 2056 | .wasm32, .wasm64 => { | |
| 2057 | llvm.LLVMInitializeWebAssemblyTarget(); | |
| 2058 | llvm.LLVMInitializeWebAssemblyTargetInfo(); | |
| 2059 | llvm.LLVMInitializeWebAssemblyTargetMC(); | |
| 2060 | llvm.LLVMInitializeWebAssemblyAsmPrinter(); | |
| 2061 | llvm.LLVMInitializeWebAssemblyAsmParser(); | |
| 2062 | }, | |
| 2063 | .i386, .x86_64 => { | |
| 2064 | llvm.LLVMInitializeX86Target(); | |
| 2065 | llvm.LLVMInitializeX86TargetInfo(); | |
| 2066 | llvm.LLVMInitializeX86TargetMC(); | |
| 2067 | llvm.LLVMInitializeX86AsmPrinter(); | |
| 2068 | llvm.LLVMInitializeX86AsmParser(); | |
| 2069 | }, | |
| 2070 | .xcore => { | |
| 2071 | llvm.LLVMInitializeXCoreTarget(); | |
| 2072 | llvm.LLVMInitializeXCoreTargetInfo(); | |
| 2073 | llvm.LLVMInitializeXCoreTargetMC(); | |
| 2074 | llvm.LLVMInitializeXCoreAsmPrinter(); | |
| 2075 | // There is no LLVMInitializeXCoreAsmParser function available. | |
| 2076 | }, | |
| 2077 | .arc => {}, | |
| 2078 | .csky => {}, | |
| 2079 | .r600 => {}, | |
| 2080 | .tce, .tcele => {}, | |
| 2081 | .thumb, .thumbeb => {}, | |
| 2082 | .le32, .le64 => {}, | |
| 2083 | .amdil, .amdil64 => {}, | |
| 2084 | .hsail, .hsail64 => {}, | |
| 2085 | .spir, .spir64 => {}, | |
| 2086 | .kalimba => {}, | |
| 2087 | .shave => {}, | |
| 2088 | .renderscript32 => {}, | |
| 2089 | .renderscript64 => {}, | |
| 2090 | .ve => {}, | |
| 2091 | .spu_2 => {}, | |
| 2092 | .spirv32 => {}, | |
| 2093 | .spirv64 => {}, | |
| 2094 | } | |
| 2095 | } |
src/codegen/llvm/bindings.zig+87-182| ... | ... | @@ -597,188 +597,93 @@ pub const Target = opaque { |
| 597 | 597 | extern fn LLVMGetTargetFromTriple(Triple: [*:0]const u8, T: **const Target, ErrorMessage: *[*:0]const u8) Bool; |
| 598 | 598 | }; |
| 599 | 599 | |
| 600 | extern fn LLVMInitializeAArch64TargetInfo() void; | |
| 601 | extern fn LLVMInitializeAMDGPUTargetInfo() void; | |
| 602 | extern fn LLVMInitializeARMTargetInfo() void; | |
| 603 | extern fn LLVMInitializeAVRTargetInfo() void; | |
| 604 | extern fn LLVMInitializeBPFTargetInfo() void; | |
| 605 | extern fn LLVMInitializeHexagonTargetInfo() void; | |
| 606 | extern fn LLVMInitializeLanaiTargetInfo() void; | |
| 607 | extern fn LLVMInitializeMipsTargetInfo() void; | |
| 608 | extern fn LLVMInitializeMSP430TargetInfo() void; | |
| 609 | extern fn LLVMInitializeNVPTXTargetInfo() void; | |
| 610 | extern fn LLVMInitializePowerPCTargetInfo() void; | |
| 611 | extern fn LLVMInitializeRISCVTargetInfo() void; | |
| 612 | extern fn LLVMInitializeSparcTargetInfo() void; | |
| 613 | extern fn LLVMInitializeSystemZTargetInfo() void; | |
| 614 | extern fn LLVMInitializeWebAssemblyTargetInfo() void; | |
| 615 | extern fn LLVMInitializeX86TargetInfo() void; | |
| 616 | extern fn LLVMInitializeXCoreTargetInfo() void; | |
| 617 | extern fn LLVMInitializeAArch64Target() void; | |
| 618 | extern fn LLVMInitializeAMDGPUTarget() void; | |
| 619 | extern fn LLVMInitializeARMTarget() void; | |
| 620 | extern fn LLVMInitializeAVRTarget() void; | |
| 621 | extern fn LLVMInitializeBPFTarget() void; | |
| 622 | extern fn LLVMInitializeHexagonTarget() void; | |
| 623 | extern fn LLVMInitializeLanaiTarget() void; | |
| 624 | extern fn LLVMInitializeMipsTarget() void; | |
| 625 | extern fn LLVMInitializeMSP430Target() void; | |
| 626 | extern fn LLVMInitializeNVPTXTarget() void; | |
| 627 | extern fn LLVMInitializePowerPCTarget() void; | |
| 628 | extern fn LLVMInitializeRISCVTarget() void; | |
| 629 | extern fn LLVMInitializeSparcTarget() void; | |
| 630 | extern fn LLVMInitializeSystemZTarget() void; | |
| 631 | extern fn LLVMInitializeWebAssemblyTarget() void; | |
| 632 | extern fn LLVMInitializeX86Target() void; | |
| 633 | extern fn LLVMInitializeXCoreTarget() void; | |
| 634 | extern fn LLVMInitializeAArch64TargetMC() void; | |
| 635 | extern fn LLVMInitializeAMDGPUTargetMC() void; | |
| 636 | extern fn LLVMInitializeARMTargetMC() void; | |
| 637 | extern fn LLVMInitializeAVRTargetMC() void; | |
| 638 | extern fn LLVMInitializeBPFTargetMC() void; | |
| 639 | extern fn LLVMInitializeHexagonTargetMC() void; | |
| 640 | extern fn LLVMInitializeLanaiTargetMC() void; | |
| 641 | extern fn LLVMInitializeMipsTargetMC() void; | |
| 642 | extern fn LLVMInitializeMSP430TargetMC() void; | |
| 643 | extern fn LLVMInitializeNVPTXTargetMC() void; | |
| 644 | extern fn LLVMInitializePowerPCTargetMC() void; | |
| 645 | extern fn LLVMInitializeRISCVTargetMC() void; | |
| 646 | extern fn LLVMInitializeSparcTargetMC() void; | |
| 647 | extern fn LLVMInitializeSystemZTargetMC() void; | |
| 648 | extern fn LLVMInitializeWebAssemblyTargetMC() void; | |
| 649 | extern fn LLVMInitializeX86TargetMC() void; | |
| 650 | extern fn LLVMInitializeXCoreTargetMC() void; | |
| 651 | extern fn LLVMInitializeAArch64AsmPrinter() void; | |
| 652 | extern fn LLVMInitializeAMDGPUAsmPrinter() void; | |
| 653 | extern fn LLVMInitializeARMAsmPrinter() void; | |
| 654 | extern fn LLVMInitializeAVRAsmPrinter() void; | |
| 655 | extern fn LLVMInitializeBPFAsmPrinter() void; | |
| 656 | extern fn LLVMInitializeHexagonAsmPrinter() void; | |
| 657 | extern fn LLVMInitializeLanaiAsmPrinter() void; | |
| 658 | extern fn LLVMInitializeMipsAsmPrinter() void; | |
| 659 | extern fn LLVMInitializeMSP430AsmPrinter() void; | |
| 660 | extern fn LLVMInitializeNVPTXAsmPrinter() void; | |
| 661 | extern fn LLVMInitializePowerPCAsmPrinter() void; | |
| 662 | extern fn LLVMInitializeRISCVAsmPrinter() void; | |
| 663 | extern fn LLVMInitializeSparcAsmPrinter() void; | |
| 664 | extern fn LLVMInitializeSystemZAsmPrinter() void; | |
| 665 | extern fn LLVMInitializeWebAssemblyAsmPrinter() void; | |
| 666 | extern fn LLVMInitializeX86AsmPrinter() void; | |
| 667 | extern fn LLVMInitializeXCoreAsmPrinter() void; | |
| 668 | extern fn LLVMInitializeAArch64AsmParser() void; | |
| 669 | extern fn LLVMInitializeAMDGPUAsmParser() void; | |
| 670 | extern fn LLVMInitializeARMAsmParser() void; | |
| 671 | extern fn LLVMInitializeAVRAsmParser() void; | |
| 672 | extern fn LLVMInitializeBPFAsmParser() void; | |
| 673 | extern fn LLVMInitializeHexagonAsmParser() void; | |
| 674 | extern fn LLVMInitializeLanaiAsmParser() void; | |
| 675 | extern fn LLVMInitializeMipsAsmParser() void; | |
| 676 | extern fn LLVMInitializeMSP430AsmParser() void; | |
| 677 | extern fn LLVMInitializePowerPCAsmParser() void; | |
| 678 | extern fn LLVMInitializeRISCVAsmParser() void; | |
| 679 | extern fn LLVMInitializeSparcAsmParser() void; | |
| 680 | extern fn LLVMInitializeSystemZAsmParser() void; | |
| 681 | extern fn LLVMInitializeWebAssemblyAsmParser() void; | |
| 682 | extern fn LLVMInitializeX86AsmParser() void; | |
| 683 | ||
| 684 | pub const initializeAllTargetInfos = LLVMInitializeAllTargetInfos; | |
| 685 | fn LLVMInitializeAllTargetInfos() callconv(.C) void { | |
| 686 | LLVMInitializeAArch64TargetInfo(); | |
| 687 | LLVMInitializeAMDGPUTargetInfo(); | |
| 688 | LLVMInitializeARMTargetInfo(); | |
| 689 | LLVMInitializeAVRTargetInfo(); | |
| 690 | LLVMInitializeBPFTargetInfo(); | |
| 691 | LLVMInitializeHexagonTargetInfo(); | |
| 692 | LLVMInitializeLanaiTargetInfo(); | |
| 693 | LLVMInitializeMipsTargetInfo(); | |
| 694 | LLVMInitializeMSP430TargetInfo(); | |
| 695 | LLVMInitializeNVPTXTargetInfo(); | |
| 696 | LLVMInitializePowerPCTargetInfo(); | |
| 697 | LLVMInitializeRISCVTargetInfo(); | |
| 698 | LLVMInitializeSparcTargetInfo(); | |
| 699 | LLVMInitializeSystemZTargetInfo(); | |
| 700 | LLVMInitializeWebAssemblyTargetInfo(); | |
| 701 | LLVMInitializeX86TargetInfo(); | |
| 702 | LLVMInitializeXCoreTargetInfo(); | |
| 703 | } | |
| 704 | pub const initializeAllTargets = LLVMInitializeAllTargets; | |
| 705 | fn LLVMInitializeAllTargets() callconv(.C) void { | |
| 706 | LLVMInitializeAArch64Target(); | |
| 707 | LLVMInitializeAMDGPUTarget(); | |
| 708 | LLVMInitializeARMTarget(); | |
| 709 | LLVMInitializeAVRTarget(); | |
| 710 | LLVMInitializeBPFTarget(); | |
| 711 | LLVMInitializeHexagonTarget(); | |
| 712 | LLVMInitializeLanaiTarget(); | |
| 713 | LLVMInitializeMipsTarget(); | |
| 714 | LLVMInitializeMSP430Target(); | |
| 715 | LLVMInitializeNVPTXTarget(); | |
| 716 | LLVMInitializePowerPCTarget(); | |
| 717 | LLVMInitializeRISCVTarget(); | |
| 718 | LLVMInitializeSparcTarget(); | |
| 719 | LLVMInitializeSystemZTarget(); | |
| 720 | LLVMInitializeWebAssemblyTarget(); | |
| 721 | LLVMInitializeX86Target(); | |
| 722 | LLVMInitializeXCoreTarget(); | |
| 723 | } | |
| 724 | pub const initializeAllTargetMCs = LLVMInitializeAllTargetMCs; | |
| 725 | fn LLVMInitializeAllTargetMCs() callconv(.C) void { | |
| 726 | LLVMInitializeAArch64TargetMC(); | |
| 727 | LLVMInitializeAMDGPUTargetMC(); | |
| 728 | LLVMInitializeARMTargetMC(); | |
| 729 | LLVMInitializeAVRTargetMC(); | |
| 730 | LLVMInitializeBPFTargetMC(); | |
| 731 | LLVMInitializeHexagonTargetMC(); | |
| 732 | LLVMInitializeLanaiTargetMC(); | |
| 733 | LLVMInitializeMipsTargetMC(); | |
| 734 | LLVMInitializeMSP430TargetMC(); | |
| 735 | LLVMInitializeNVPTXTargetMC(); | |
| 736 | LLVMInitializePowerPCTargetMC(); | |
| 737 | LLVMInitializeRISCVTargetMC(); | |
| 738 | LLVMInitializeSparcTargetMC(); | |
| 739 | LLVMInitializeSystemZTargetMC(); | |
| 740 | LLVMInitializeWebAssemblyTargetMC(); | |
| 741 | LLVMInitializeX86TargetMC(); | |
| 742 | LLVMInitializeXCoreTargetMC(); | |
| 743 | } | |
| 744 | pub const initializeAllAsmPrinters = LLVMInitializeAllAsmPrinters; | |
| 745 | fn LLVMInitializeAllAsmPrinters() callconv(.C) void { | |
| 746 | LLVMInitializeAArch64AsmPrinter(); | |
| 747 | LLVMInitializeAMDGPUAsmPrinter(); | |
| 748 | LLVMInitializeARMAsmPrinter(); | |
| 749 | LLVMInitializeAVRAsmPrinter(); | |
| 750 | LLVMInitializeBPFAsmPrinter(); | |
| 751 | LLVMInitializeHexagonAsmPrinter(); | |
| 752 | LLVMInitializeLanaiAsmPrinter(); | |
| 753 | LLVMInitializeMipsAsmPrinter(); | |
| 754 | LLVMInitializeMSP430AsmPrinter(); | |
| 755 | LLVMInitializeNVPTXAsmPrinter(); | |
| 756 | LLVMInitializePowerPCAsmPrinter(); | |
| 757 | LLVMInitializeRISCVAsmPrinter(); | |
| 758 | LLVMInitializeSparcAsmPrinter(); | |
| 759 | LLVMInitializeSystemZAsmPrinter(); | |
| 760 | LLVMInitializeWebAssemblyAsmPrinter(); | |
| 761 | LLVMInitializeX86AsmPrinter(); | |
| 762 | LLVMInitializeXCoreAsmPrinter(); | |
| 763 | } | |
| 764 | pub const initializeAllAsmParsers = LLVMInitializeAllAsmParsers; | |
| 765 | fn LLVMInitializeAllAsmParsers() callconv(.C) void { | |
| 766 | LLVMInitializeAArch64AsmParser(); | |
| 767 | LLVMInitializeAMDGPUAsmParser(); | |
| 768 | LLVMInitializeARMAsmParser(); | |
| 769 | LLVMInitializeAVRAsmParser(); | |
| 770 | LLVMInitializeBPFAsmParser(); | |
| 771 | LLVMInitializeHexagonAsmParser(); | |
| 772 | LLVMInitializeLanaiAsmParser(); | |
| 773 | LLVMInitializeMipsAsmParser(); | |
| 774 | LLVMInitializeMSP430AsmParser(); | |
| 775 | LLVMInitializePowerPCAsmParser(); | |
| 776 | LLVMInitializeRISCVAsmParser(); | |
| 777 | LLVMInitializeSparcAsmParser(); | |
| 778 | LLVMInitializeSystemZAsmParser(); | |
| 779 | LLVMInitializeWebAssemblyAsmParser(); | |
| 780 | LLVMInitializeX86AsmParser(); | |
| 781 | } | |
| 600 | pub extern fn LLVMInitializeAArch64TargetInfo() void; | |
| 601 | pub extern fn LLVMInitializeAMDGPUTargetInfo() void; | |
| 602 | pub extern fn LLVMInitializeARMTargetInfo() void; | |
| 603 | pub extern fn LLVMInitializeAVRTargetInfo() void; | |
| 604 | pub extern fn LLVMInitializeBPFTargetInfo() void; | |
| 605 | pub extern fn LLVMInitializeHexagonTargetInfo() void; | |
| 606 | pub extern fn LLVMInitializeLanaiTargetInfo() void; | |
| 607 | pub extern fn LLVMInitializeMipsTargetInfo() void; | |
| 608 | pub extern fn LLVMInitializeMSP430TargetInfo() void; | |
| 609 | pub extern fn LLVMInitializeNVPTXTargetInfo() void; | |
| 610 | pub extern fn LLVMInitializePowerPCTargetInfo() void; | |
| 611 | pub extern fn LLVMInitializeRISCVTargetInfo() void; | |
| 612 | pub extern fn LLVMInitializeSparcTargetInfo() void; | |
| 613 | pub extern fn LLVMInitializeSystemZTargetInfo() void; | |
| 614 | pub extern fn LLVMInitializeWebAssemblyTargetInfo() void; | |
| 615 | pub extern fn LLVMInitializeX86TargetInfo() void; | |
| 616 | pub extern fn LLVMInitializeXCoreTargetInfo() void; | |
| 617 | ||
| 618 | pub extern fn LLVMInitializeAArch64Target() void; | |
| 619 | pub extern fn LLVMInitializeAMDGPUTarget() void; | |
| 620 | pub extern fn LLVMInitializeARMTarget() void; | |
| 621 | pub extern fn LLVMInitializeAVRTarget() void; | |
| 622 | pub extern fn LLVMInitializeBPFTarget() void; | |
| 623 | pub extern fn LLVMInitializeHexagonTarget() void; | |
| 624 | pub extern fn LLVMInitializeLanaiTarget() void; | |
| 625 | pub extern fn LLVMInitializeMipsTarget() void; | |
| 626 | pub extern fn LLVMInitializeMSP430Target() void; | |
| 627 | pub extern fn LLVMInitializeNVPTXTarget() void; | |
| 628 | pub extern fn LLVMInitializePowerPCTarget() void; | |
| 629 | pub extern fn LLVMInitializeRISCVTarget() void; | |
| 630 | pub extern fn LLVMInitializeSparcTarget() void; | |
| 631 | pub extern fn LLVMInitializeSystemZTarget() void; | |
| 632 | pub extern fn LLVMInitializeWebAssemblyTarget() void; | |
| 633 | pub extern fn LLVMInitializeX86Target() void; | |
| 634 | pub extern fn LLVMInitializeXCoreTarget() void; | |
| 635 | ||
| 636 | pub extern fn LLVMInitializeAArch64TargetMC() void; | |
| 637 | pub extern fn LLVMInitializeAMDGPUTargetMC() void; | |
| 638 | pub extern fn LLVMInitializeARMTargetMC() void; | |
| 639 | pub extern fn LLVMInitializeAVRTargetMC() void; | |
| 640 | pub extern fn LLVMInitializeBPFTargetMC() void; | |
| 641 | pub extern fn LLVMInitializeHexagonTargetMC() void; | |
| 642 | pub extern fn LLVMInitializeLanaiTargetMC() void; | |
| 643 | pub extern fn LLVMInitializeMipsTargetMC() void; | |
| 644 | pub extern fn LLVMInitializeMSP430TargetMC() void; | |
| 645 | pub extern fn LLVMInitializeNVPTXTargetMC() void; | |
| 646 | pub extern fn LLVMInitializePowerPCTargetMC() void; | |
| 647 | pub extern fn LLVMInitializeRISCVTargetMC() void; | |
| 648 | pub extern fn LLVMInitializeSparcTargetMC() void; | |
| 649 | pub extern fn LLVMInitializeSystemZTargetMC() void; | |
| 650 | pub extern fn LLVMInitializeWebAssemblyTargetMC() void; | |
| 651 | pub extern fn LLVMInitializeX86TargetMC() void; | |
| 652 | pub extern fn LLVMInitializeXCoreTargetMC() void; | |
| 653 | ||
| 654 | pub extern fn LLVMInitializeAArch64AsmPrinter() void; | |
| 655 | pub extern fn LLVMInitializeAMDGPUAsmPrinter() void; | |
| 656 | pub extern fn LLVMInitializeARMAsmPrinter() void; | |
| 657 | pub extern fn LLVMInitializeAVRAsmPrinter() void; | |
| 658 | pub extern fn LLVMInitializeBPFAsmPrinter() void; | |
| 659 | pub extern fn LLVMInitializeHexagonAsmPrinter() void; | |
| 660 | pub extern fn LLVMInitializeLanaiAsmPrinter() void; | |
| 661 | pub extern fn LLVMInitializeMipsAsmPrinter() void; | |
| 662 | pub extern fn LLVMInitializeMSP430AsmPrinter() void; | |
| 663 | pub extern fn LLVMInitializeNVPTXAsmPrinter() void; | |
| 664 | pub extern fn LLVMInitializePowerPCAsmPrinter() void; | |
| 665 | pub extern fn LLVMInitializeRISCVAsmPrinter() void; | |
| 666 | pub extern fn LLVMInitializeSparcAsmPrinter() void; | |
| 667 | pub extern fn LLVMInitializeSystemZAsmPrinter() void; | |
| 668 | pub extern fn LLVMInitializeWebAssemblyAsmPrinter() void; | |
| 669 | pub extern fn LLVMInitializeX86AsmPrinter() void; | |
| 670 | pub extern fn LLVMInitializeXCoreAsmPrinter() void; | |
| 671 | ||
| 672 | pub extern fn LLVMInitializeAArch64AsmParser() void; | |
| 673 | pub extern fn LLVMInitializeAMDGPUAsmParser() void; | |
| 674 | pub extern fn LLVMInitializeARMAsmParser() void; | |
| 675 | pub extern fn LLVMInitializeAVRAsmParser() void; | |
| 676 | pub extern fn LLVMInitializeBPFAsmParser() void; | |
| 677 | pub extern fn LLVMInitializeHexagonAsmParser() void; | |
| 678 | pub extern fn LLVMInitializeLanaiAsmParser() void; | |
| 679 | pub extern fn LLVMInitializeMipsAsmParser() void; | |
| 680 | pub extern fn LLVMInitializeMSP430AsmParser() void; | |
| 681 | pub extern fn LLVMInitializePowerPCAsmParser() void; | |
| 682 | pub extern fn LLVMInitializeRISCVAsmParser() void; | |
| 683 | pub extern fn LLVMInitializeSparcAsmParser() void; | |
| 684 | pub extern fn LLVMInitializeSystemZAsmParser() void; | |
| 685 | pub extern fn LLVMInitializeWebAssemblyAsmParser() void; | |
| 686 | pub extern fn LLVMInitializeX86AsmParser() void; | |
| 782 | 687 | |
| 783 | 688 | extern fn ZigLLDLinkCOFF(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int; |
| 784 | 689 | extern fn ZigLLDLinkELF(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int; |
src/link/MachO.zig+15-11| ... | ... | @@ -148,7 +148,7 @@ globals_free_list: std.ArrayListUnmanaged(u32) = .{}, |
| 148 | 148 | stub_helper_stubs_start_off: ?u64 = null, |
| 149 | 149 | |
| 150 | 150 | strtab: std.ArrayListUnmanaged(u8) = .{}, |
| 151 | strtab_dir: std.HashMapUnmanaged(u32, u32, StringIndexContext, std.hash_map.default_max_load_percentage) = .{}, | |
| 151 | strtab_dir: std.HashMapUnmanaged(u32, void, StringIndexContext, std.hash_map.default_max_load_percentage) = .{}, | |
| 152 | 152 | |
| 153 | 153 | got_entries: std.ArrayListUnmanaged(GotIndirectionKey) = .{}, |
| 154 | 154 | got_entries_map: std.AutoHashMapUnmanaged(GotIndirectionKey, u32) = .{}, |
| ... | ... | @@ -938,7 +938,7 @@ fn linkWithZld(self: *MachO, comp: *Compilation) !void { |
| 938 | 938 | |
| 939 | 939 | { |
| 940 | 940 | // Add dyld_stub_binder as the final GOT entry. |
| 941 | const n_strx = self.strtab_dir.getAdapted(@as([]const u8, "dyld_stub_binder"), StringSliceAdapter{ | |
| 941 | const n_strx = self.strtab_dir.getKeyAdapted(@as([]const u8, "dyld_stub_binder"), StringSliceAdapter{ | |
| 942 | 942 | .strtab = &self.strtab, |
| 943 | 943 | }) orelse unreachable; |
| 944 | 944 | const resolv = self.symbol_resolver.get(n_strx) orelse unreachable; |
| ... | ... | @@ -1966,7 +1966,7 @@ fn writeStubHelperCommon(self: *MachO) !void { |
| 1966 | 1966 | code[9] = 0xff; |
| 1967 | 1967 | code[10] = 0x25; |
| 1968 | 1968 | { |
| 1969 | const n_strx = self.strtab_dir.getAdapted(@as([]const u8, "dyld_stub_binder"), StringSliceAdapter{ | |
| 1969 | const n_strx = self.strtab_dir.getKeyAdapted(@as([]const u8, "dyld_stub_binder"), StringSliceAdapter{ | |
| 1970 | 1970 | .strtab = &self.strtab, |
| 1971 | 1971 | }) orelse unreachable; |
| 1972 | 1972 | const resolv = self.symbol_resolver.get(n_strx) orelse unreachable; |
| ... | ... | @@ -2017,7 +2017,7 @@ fn writeStubHelperCommon(self: *MachO) !void { |
| 2017 | 2017 | code[10] = 0xbf; |
| 2018 | 2018 | code[11] = 0xa9; |
| 2019 | 2019 | binder_blk_outer: { |
| 2020 | const n_strx = self.strtab_dir.getAdapted(@as([]const u8, "dyld_stub_binder"), StringSliceAdapter{ | |
| 2020 | const n_strx = self.strtab_dir.getKeyAdapted(@as([]const u8, "dyld_stub_binder"), StringSliceAdapter{ | |
| 2021 | 2021 | .strtab = &self.strtab, |
| 2022 | 2022 | }) orelse unreachable; |
| 2023 | 2023 | const resolv = self.symbol_resolver.get(n_strx) orelse unreachable; |
| ... | ... | @@ -2435,7 +2435,7 @@ fn resolveSymbols(self: *MachO) !void { |
| 2435 | 2435 | } |
| 2436 | 2436 | |
| 2437 | 2437 | // Fourth pass, handle synthetic symbols and flag any undefined references. |
| 2438 | if (self.strtab_dir.getAdapted(@as([]const u8, "___dso_handle"), StringSliceAdapter{ | |
| 2438 | if (self.strtab_dir.getKeyAdapted(@as([]const u8, "___dso_handle"), StringSliceAdapter{ | |
| 2439 | 2439 | .strtab = &self.strtab, |
| 2440 | 2440 | })) |n_strx| blk: { |
| 2441 | 2441 | const resolv = self.symbol_resolver.getPtr(n_strx) orelse break :blk; |
| ... | ... | @@ -2985,7 +2985,7 @@ fn setEntryPoint(self: *MachO) !void { |
| 2985 | 2985 | // TODO we should respect the -entry flag passed in by the user to set a custom |
| 2986 | 2986 | // entrypoint. For now, assume default of `_main`. |
| 2987 | 2987 | const seg = self.load_commands.items[self.text_segment_cmd_index.?].Segment; |
| 2988 | const n_strx = self.strtab_dir.getAdapted(@as([]const u8, "_main"), StringSliceAdapter{ | |
| 2988 | const n_strx = self.strtab_dir.getKeyAdapted(@as([]const u8, "_main"), StringSliceAdapter{ | |
| 2989 | 2989 | .strtab = &self.strtab, |
| 2990 | 2990 | }) orelse { |
| 2991 | 2991 | log.err("'_main' export not found", .{}); |
| ... | ... | @@ -4616,7 +4616,7 @@ pub fn addExternFn(self: *MachO, name: []const u8) !u32 { |
| 4616 | 4616 | const sym_name = try std.fmt.allocPrint(self.base.allocator, "_{s}", .{name}); |
| 4617 | 4617 | defer self.base.allocator.free(sym_name); |
| 4618 | 4618 | |
| 4619 | if (self.strtab_dir.getAdapted(@as([]const u8, sym_name), StringSliceAdapter{ | |
| 4619 | if (self.strtab_dir.getKeyAdapted(@as([]const u8, sym_name), StringSliceAdapter{ | |
| 4620 | 4620 | .strtab = &self.strtab, |
| 4621 | 4621 | })) |n_strx| { |
| 4622 | 4622 | const resolv = self.symbol_resolver.get(n_strx) orelse unreachable; |
| ... | ... | @@ -5858,7 +5858,13 @@ pub fn padToIdeal(actual_size: anytype) @TypeOf(actual_size) { |
| 5858 | 5858 | } |
| 5859 | 5859 | |
| 5860 | 5860 | pub fn makeString(self: *MachO, string: []const u8) !u32 { |
| 5861 | if (self.strtab_dir.getAdapted(@as([]const u8, string), StringSliceAdapter{ .strtab = &self.strtab })) |off| { | |
| 5861 | const gop = try self.strtab_dir.getOrPutContextAdapted(self.base.allocator, @as([]const u8, string), StringSliceAdapter{ | |
| 5862 | .strtab = &self.strtab, | |
| 5863 | }, StringIndexContext{ | |
| 5864 | .strtab = &self.strtab, | |
| 5865 | }); | |
| 5866 | if (gop.found_existing) { | |
| 5867 | const off = gop.key_ptr.*; | |
| 5862 | 5868 | log.debug("reusing string '{s}' at offset 0x{x}", .{ string, off }); |
| 5863 | 5869 | return off; |
| 5864 | 5870 | } |
| ... | ... | @@ -5871,9 +5877,7 @@ pub fn makeString(self: *MachO, string: []const u8) !u32 { |
| 5871 | 5877 | self.strtab.appendSliceAssumeCapacity(string); |
| 5872 | 5878 | self.strtab.appendAssumeCapacity(0); |
| 5873 | 5879 | |
| 5874 | try self.strtab_dir.putContext(self.base.allocator, new_off, new_off, StringIndexContext{ | |
| 5875 | .strtab = &self.strtab, | |
| 5876 | }); | |
| 5880 | gop.key_ptr.* = new_off; | |
| 5877 | 5881 | |
| 5878 | 5882 | return new_off; |
| 5879 | 5883 | } |
src/link/MachO/TextBlock.zig+2-2| ... | ... | @@ -656,7 +656,7 @@ fn initRelocFromObject(rel: macho.relocation_info, context: RelocContext) !Reloc |
| 656 | 656 | parsed_rel.where = .local; |
| 657 | 657 | parsed_rel.where_index = where_index; |
| 658 | 658 | } else { |
| 659 | const n_strx = context.macho_file.strtab_dir.getAdapted(@as([]const u8, sym_name), MachO.StringSliceAdapter{ | |
| 659 | const n_strx = context.macho_file.strtab_dir.getKeyAdapted(@as([]const u8, sym_name), MachO.StringSliceAdapter{ | |
| 660 | 660 | .strtab = &context.macho_file.strtab, |
| 661 | 661 | }) orelse unreachable; |
| 662 | 662 | const resolv = context.macho_file.symbol_resolver.get(n_strx) orelse unreachable; |
| ... | ... | @@ -717,7 +717,7 @@ pub fn parseRelocs(self: *TextBlock, relocs: []macho.relocation_info, context: R |
| 717 | 717 | const where_index = context.object.symbol_mapping.get(rel.r_symbolnum) orelse unreachable; |
| 718 | 718 | subtractor = where_index; |
| 719 | 719 | } else { |
| 720 | const n_strx = context.macho_file.strtab_dir.getAdapted(@as([]const u8, sym_name), MachO.StringSliceAdapter{ | |
| 720 | const n_strx = context.macho_file.strtab_dir.getKeyAdapted(@as([]const u8, sym_name), MachO.StringSliceAdapter{ | |
| 721 | 721 | .strtab = &context.macho_file.strtab, |
| 722 | 722 | }) orelse unreachable; |
| 723 | 723 | const resolv = context.macho_file.symbol_resolver.get(n_strx) orelse unreachable; |
src/translate_c.zig+24-49| ... | ... | @@ -203,9 +203,7 @@ const Scope = struct { |
| 203 | 203 | /// Check if the global scope contains this name, without looking into the "future", e.g. |
| 204 | 204 | /// ignore the preprocessed decl and macro names. |
| 205 | 205 | fn containsNow(scope: *Root, name: []const u8) bool { |
| 206 | return isZigPrimitiveType(name) or | |
| 207 | scope.sym_table.contains(name) or | |
| 208 | scope.macro_table.contains(name); | |
| 206 | return scope.sym_table.contains(name) or scope.macro_table.contains(name); | |
| 209 | 207 | } |
| 210 | 208 | |
| 211 | 209 | /// Check if the global scope contains the name, includes all decls that haven't been translated yet. |
| ... | ... | @@ -495,19 +493,17 @@ fn declVisitorNamesOnly(c: *Context, decl: *const clang.Decl) Error!void { |
| 495 | 493 | }, |
| 496 | 494 | else => return, |
| 497 | 495 | } else unreachable; |
| 498 | // TODO https://github.com/ziglang/zig/issues/3756 | |
| 499 | // TODO https://github.com/ziglang/zig/issues/1802 | |
| 500 | const name = if (isZigPrimitiveType(decl_name)) try std.fmt.allocPrint(c.arena, "{s}_{d}", .{ decl_name, c.getMangle() }) else decl_name; | |
| 496 | ||
| 501 | 497 | const result = try c.unnamed_typedefs.getOrPut(c.gpa, addr); |
| 502 | 498 | if (result.found_existing) { |
| 503 | 499 | // One typedef can declare multiple names. |
| 504 | 500 | // Don't put this one in `decl_table` so it's processed later. |
| 505 | 501 | return; |
| 506 | 502 | } |
| 507 | result.value_ptr.* = name; | |
| 503 | result.value_ptr.* = decl_name; | |
| 508 | 504 | // Put this typedef in the decl_table to avoid redefinitions. |
| 509 | try c.decl_table.putNoClobber(c.gpa, @ptrToInt(typedef_decl.getCanonicalDecl()), name); | |
| 510 | try c.typedefs.put(c.gpa, name, {}); | |
| 505 | try c.decl_table.putNoClobber(c.gpa, @ptrToInt(typedef_decl.getCanonicalDecl()), decl_name); | |
| 506 | try c.typedefs.put(c.gpa, decl_name, {}); | |
| 511 | 507 | } |
| 512 | 508 | } |
| 513 | 509 | } |
| ... | ... | @@ -752,10 +748,6 @@ fn visitVarDecl(c: *Context, var_decl: *const clang.VarDecl, mangled_name: ?[]co |
| 752 | 748 | const is_pub = mangled_name == null; |
| 753 | 749 | const is_threadlocal = var_decl.getTLSKind() != .None; |
| 754 | 750 | const scope = &c.global_scope.base; |
| 755 | ||
| 756 | // TODO https://github.com/ziglang/zig/issues/3756 | |
| 757 | // TODO https://github.com/ziglang/zig/issues/1802 | |
| 758 | const checked_name = if (isZigPrimitiveType(var_name)) try std.fmt.allocPrint(c.arena, "{s}_{d}", .{ var_name, c.getMangle() }) else var_name; | |
| 759 | 751 | const var_decl_loc = var_decl.getLocation(); |
| 760 | 752 | |
| 761 | 753 | const qual_type = var_decl.getTypeSourceInfo_getType(); |
| ... | ... | @@ -774,7 +766,7 @@ fn visitVarDecl(c: *Context, var_decl: *const clang.VarDecl, mangled_name: ?[]co |
| 774 | 766 | |
| 775 | 767 | const type_node = transQualTypeMaybeInitialized(c, scope, qual_type, decl_init, var_decl_loc) catch |err| switch (err) { |
| 776 | 768 | error.UnsupportedTranslation, error.UnsupportedType => { |
| 777 | return failDecl(c, var_decl_loc, checked_name, "unable to resolve variable type", .{}); | |
| 769 | return failDecl(c, var_decl_loc, var_name, "unable to resolve variable type", .{}); | |
| 778 | 770 | }, |
| 779 | 771 | error.OutOfMemory => |e| return e, |
| 780 | 772 | }; |
| ... | ... | @@ -833,11 +825,11 @@ fn visitVarDecl(c: *Context, var_decl: *const clang.VarDecl, mangled_name: ?[]co |
| 833 | 825 | .is_threadlocal = is_threadlocal, |
| 834 | 826 | .linksection_string = linksection_string, |
| 835 | 827 | .alignment = zigAlignment(var_decl.getAlignedAttribute(c.clang_context)), |
| 836 | .name = checked_name, | |
| 828 | .name = var_name, | |
| 837 | 829 | .type = type_node, |
| 838 | 830 | .init = init_node, |
| 839 | 831 | }); |
| 840 | return addTopLevelDecl(c, checked_name, node); | |
| 832 | return addTopLevelDecl(c, var_name, node); | |
| 841 | 833 | } |
| 842 | 834 | |
| 843 | 835 | const builtin_typedef_map = std.ComptimeStringMap([]const u8, .{ |
| ... | ... | @@ -861,11 +853,7 @@ fn transTypeDef(c: *Context, scope: *Scope, typedef_decl: *const clang.TypedefNa |
| 861 | 853 | const toplevel = scope.id == .root; |
| 862 | 854 | const bs: *Scope.Block = if (!toplevel) try scope.findBlockScope(c) else undefined; |
| 863 | 855 | |
| 864 | const bare_name = try c.str(@ptrCast(*const clang.NamedDecl, typedef_decl).getName_bytes_begin()); | |
| 865 | ||
| 866 | // TODO https://github.com/ziglang/zig/issues/3756 | |
| 867 | // TODO https://github.com/ziglang/zig/issues/1802 | |
| 868 | var name: []const u8 = if (isZigPrimitiveType(bare_name)) try std.fmt.allocPrint(c.arena, "{s}_{d}", .{ bare_name, c.getMangle() }) else bare_name; | |
| 856 | var name: []const u8 = try c.str(@ptrCast(*const clang.NamedDecl, typedef_decl).getName_bytes_begin()); | |
| 869 | 857 | try c.typedefs.put(c.gpa, name, {}); |
| 870 | 858 | |
| 871 | 859 | if (builtin_typedef_map.get(name)) |builtin| { |
| ... | ... | @@ -1535,12 +1523,12 @@ fn transOffsetOfExpr( |
| 1535 | 1523 | /// node -> @bitCast(usize, @intCast(isize, node)) |
| 1536 | 1524 | fn usizeCastForWrappingPtrArithmetic(gpa: *mem.Allocator, node: Node) TransError!Node { |
| 1537 | 1525 | const intcast_node = try Tag.int_cast.create(gpa, .{ |
| 1538 | .lhs = try Tag.identifier.create(gpa, "isize"), | |
| 1526 | .lhs = try Tag.type.create(gpa, "isize"), | |
| 1539 | 1527 | .rhs = node, |
| 1540 | 1528 | }); |
| 1541 | 1529 | |
| 1542 | 1530 | return Tag.bit_cast.create(gpa, .{ |
| 1543 | .lhs = try Tag.identifier.create(gpa, "usize"), | |
| 1531 | .lhs = try Tag.type.create(gpa, "usize"), | |
| 1544 | 1532 | .rhs = intcast_node, |
| 1545 | 1533 | }); |
| 1546 | 1534 | } |
| ... | ... | @@ -3345,7 +3333,7 @@ fn transSignedArrayAccess( |
| 3345 | 3333 | const then_value = try Tag.add.create(c.arena, .{ |
| 3346 | 3334 | .lhs = container_node, |
| 3347 | 3335 | .rhs = try Tag.int_cast.create(c.arena, .{ |
| 3348 | .lhs = try Tag.identifier.create(c.arena, "usize"), | |
| 3336 | .lhs = try Tag.type.create(c.arena, "usize"), | |
| 3349 | 3337 | .rhs = tmp_ref, |
| 3350 | 3338 | }), |
| 3351 | 3339 | }); |
| ... | ... | @@ -3357,7 +3345,7 @@ fn transSignedArrayAccess( |
| 3357 | 3345 | |
| 3358 | 3346 | const minuend = container_node; |
| 3359 | 3347 | const signed_size = try Tag.int_cast.create(c.arena, .{ |
| 3360 | .lhs = try Tag.identifier.create(c.arena, "isize"), | |
| 3348 | .lhs = try Tag.type.create(c.arena, "isize"), | |
| 3361 | 3349 | .rhs = tmp_ref, |
| 3362 | 3350 | }); |
| 3363 | 3351 | const to_cast = try Tag.add_wrap.create(c.arena, .{ |
| ... | ... | @@ -3365,7 +3353,7 @@ fn transSignedArrayAccess( |
| 3365 | 3353 | .rhs = try Tag.negate.create(c.arena, Tag.one_literal.init()), |
| 3366 | 3354 | }); |
| 3367 | 3355 | const bitcast_node = try Tag.bit_cast.create(c.arena, .{ |
| 3368 | .lhs = try Tag.identifier.create(c.arena, "usize"), | |
| 3356 | .lhs = try Tag.type.create(c.arena, "usize"), | |
| 3369 | 3357 | .rhs = to_cast, |
| 3370 | 3358 | }); |
| 3371 | 3359 | const subtrahend = try Tag.bit_not.create(c.arena, bitcast_node); |
| ... | ... | @@ -3421,7 +3409,7 @@ fn transArrayAccess(c: *Context, scope: *Scope, stmt: *const clang.ArraySubscrip |
| 3421 | 3409 | const container_node = try transExpr(c, scope, unwrapped_base, .used); |
| 3422 | 3410 | const rhs = if (is_longlong or is_signed) blk: { |
| 3423 | 3411 | // check if long long first so that signed long long doesn't just become unsigned long long |
| 3424 | const typeid_node = if (is_longlong) try Tag.identifier.create(c.arena, "usize") else try transQualTypeIntWidthOf(c, subscr_qt, false); | |
| 3412 | const typeid_node = if (is_longlong) try Tag.type.create(c.arena, "usize") else try transQualTypeIntWidthOf(c, subscr_qt, false); | |
| 3425 | 3413 | break :blk try Tag.int_cast.create(c.arena, .{ .lhs = typeid_node, .rhs = try transExpr(c, scope, subscr_expr, .used) }); |
| 3426 | 3414 | } else try transExpr(c, scope, subscr_expr, .used); |
| 3427 | 3415 | |
| ... | ... | @@ -3953,7 +3941,7 @@ fn transFloatingLiteral(c: *Context, scope: *Scope, expr: *const clang.FloatingL |
| 3953 | 3941 | |
| 3954 | 3942 | fn transBinaryConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang.BinaryConditionalOperator, used: ResultUsed) TransError!Node { |
| 3955 | 3943 | // GNU extension of the ternary operator where the middle expression is |
| 3956 | // omitted, the conditition itself is returned if it evaluates to true | |
| 3944 | // omitted, the condition itself is returned if it evaluates to true | |
| 3957 | 3945 | const qt = @ptrCast(*const clang.Expr, stmt).getType(); |
| 3958 | 3946 | const res_is_bool = qualTypeIsBoolean(qt); |
| 3959 | 3947 | const casted_stmt = @ptrCast(*const clang.AbstractConditionalOperator, stmt); |
| ... | ... | @@ -4040,7 +4028,7 @@ fn transConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang.Condi |
| 4040 | 4028 | .then = then_body, |
| 4041 | 4029 | .@"else" = else_body, |
| 4042 | 4030 | }); |
| 4043 | // Clang inserts ImplicitCast(ToVoid)'s to both rhs and lhs so we don't need to supress the result here. | |
| 4031 | // Clang inserts ImplicitCast(ToVoid)'s to both rhs and lhs so we don't need to suppress the result here. | |
| 4044 | 4032 | return if_node; |
| 4045 | 4033 | } |
| 4046 | 4034 | |
| ... | ... | @@ -4671,6 +4659,7 @@ fn transType(c: *Context, scope: *Scope, ty: *const clang.Type, source_loc: clan |
| 4671 | 4659 | if (@ptrCast(*const clang.Decl, typedef_decl).castToNamedDecl()) |named_decl| { |
| 4672 | 4660 | const decl_name = try c.str(named_decl.getName_bytes_begin()); |
| 4673 | 4661 | if (c.global_names.get(decl_name)) |_| trans_scope = &c.global_scope.base; |
| 4662 | if (builtin_typedef_map.get(decl_name)) |builtin| return Tag.type.create(c.arena, builtin); | |
| 4674 | 4663 | } |
| 4675 | 4664 | try transTypeDef(c, trans_scope, typedef_decl); |
| 4676 | 4665 | const name = c.decl_table.get(@ptrToInt(typedef_decl.getCanonicalDecl())).?; |
| ... | ... | @@ -4994,19 +4983,6 @@ pub fn freeErrors(errors: []ClangErrMsg) void { |
| 4994 | 4983 | errors.ptr.delete(errors.len); |
| 4995 | 4984 | } |
| 4996 | 4985 | |
| 4997 | fn isZigPrimitiveType(name: []const u8) bool { | |
| 4998 | if (name.len > 1 and (name[0] == 'u' or name[0] == 'i')) { | |
| 4999 | for (name[1..]) |c| { | |
| 5000 | switch (c) { | |
| 5001 | '0'...'9' => {}, | |
| 5002 | else => return false, | |
| 5003 | } | |
| 5004 | } | |
| 5005 | return true; | |
| 5006 | } | |
| 5007 | return @import("AstGen.zig").simple_types.has(name); | |
| 5008 | } | |
| 5009 | ||
| 5010 | 4986 | const PatternList = struct { |
| 5011 | 4987 | patterns: []Pattern, |
| 5012 | 4988 | |
| ... | ... | @@ -5311,10 +5287,7 @@ fn transPreprocessorEntities(c: *Context, unit: *clang.ASTUnit) Error!void { |
| 5311 | 5287 | const end_loc = clang.Lexer.getLocForEndOfToken(macro.getSourceRange_getEnd(), c.source_manager, unit); |
| 5312 | 5288 | |
| 5313 | 5289 | const name = try c.str(raw_name); |
| 5314 | // TODO https://github.com/ziglang/zig/issues/3756 | |
| 5315 | // TODO https://github.com/ziglang/zig/issues/1802 | |
| 5316 | const mangled_name = if (isZigPrimitiveType(name)) try std.fmt.allocPrint(c.arena, "{s}_{d}", .{ name, c.getMangle() }) else name; | |
| 5317 | if (scope.containsNow(mangled_name)) { | |
| 5290 | if (scope.containsNow(name)) { | |
| 5318 | 5291 | continue; |
| 5319 | 5292 | } |
| 5320 | 5293 | |
| ... | ... | @@ -5328,7 +5301,7 @@ fn transPreprocessorEntities(c: *Context, unit: *clang.ASTUnit) Error!void { |
| 5328 | 5301 | var macro_ctx = MacroCtx{ |
| 5329 | 5302 | .source = slice, |
| 5330 | 5303 | .list = tok_list.items, |
| 5331 | .name = mangled_name, | |
| 5304 | .name = name, | |
| 5332 | 5305 | .loc = begin_loc, |
| 5333 | 5306 | }; |
| 5334 | 5307 | assert(mem.eql(u8, macro_ctx.slice(), name)); |
| ... | ... | @@ -5766,7 +5739,8 @@ fn parseCPrimaryExprInner(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!N |
| 5766 | 5739 | try m.fail(c, "TODO implement function '{s}' in std.zig.c_builtins", .{mangled_name}); |
| 5767 | 5740 | return error.ParseError; |
| 5768 | 5741 | } |
| 5769 | const identifier = try Tag.identifier.create(c.arena, builtin_typedef_map.get(mangled_name) orelse mangled_name); | |
| 5742 | if (builtin_typedef_map.get(mangled_name)) |ty| return Tag.type.create(c.arena, ty); | |
| 5743 | const identifier = try Tag.identifier.create(c.arena, mangled_name); | |
| 5770 | 5744 | scope.skipVariableDiscard(identifier.castTag(.identifier).?.data); |
| 5771 | 5745 | return identifier; |
| 5772 | 5746 | }, |
| ... | ... | @@ -6055,7 +6029,8 @@ fn parseCSpecifierQualifierList(c: *Context, m: *MacroCtx, scope: *Scope, allow_ |
| 6055 | 6029 | .Identifier => { |
| 6056 | 6030 | const mangled_name = scope.getAlias(m.slice()); |
| 6057 | 6031 | if (!allow_fail or c.typedefs.contains(mangled_name)) { |
| 6058 | return try Tag.identifier.create(c.arena, builtin_typedef_map.get(mangled_name) orelse mangled_name); | |
| 6032 | if (builtin_typedef_map.get(mangled_name)) |ty| return try Tag.type.create(c.arena, ty); | |
| 6033 | return try Tag.identifier.create(c.arena, mangled_name); | |
| 6059 | 6034 | } |
| 6060 | 6035 | }, |
| 6061 | 6036 | .Keyword_void => return try Tag.type.create(c.arena, "c_void"), |
src/translate_c/ast.zig+19-4| ... | ... | @@ -801,11 +801,26 @@ const Context = struct { |
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | fn addToken(c: *Context, tag: TokenTag, bytes: []const u8) Allocator.Error!TokenIndex { |
| 804 | return addTokenFmt(c, tag, "{s}", .{bytes}); | |
| 804 | return c.addTokenFmt(tag, "{s}", .{bytes}); | |
| 805 | } | |
| 806 | ||
| 807 | fn isZigPrimitiveType(name: []const u8) bool { | |
| 808 | if (name.len > 1 and (name[0] == 'u' or name[0] == 'i')) { | |
| 809 | for (name[1..]) |c| { | |
| 810 | switch (c) { | |
| 811 | '0'...'9' => {}, | |
| 812 | else => return false, | |
| 813 | } | |
| 814 | } | |
| 815 | return true; | |
| 816 | } | |
| 817 | return @import("../AstGen.zig").simple_types.has(name); | |
| 805 | 818 | } |
| 806 | 819 | |
| 807 | 820 | fn addIdentifier(c: *Context, bytes: []const u8) Allocator.Error!TokenIndex { |
| 808 | return addTokenFmt(c, .identifier, "{s}", .{std.zig.fmtId(bytes)}); | |
| 821 | if (isZigPrimitiveType(bytes)) | |
| 822 | return c.addTokenFmt(.identifier, "@\"{s}\"", .{bytes}); | |
| 823 | return c.addTokenFmt(.identifier, "{s}", .{std.zig.fmtId(bytes)}); | |
| 809 | 824 | } |
| 810 | 825 | |
| 811 | 826 | fn listToSpan(c: *Context, list: []const NodeIndex) Allocator.Error!NodeSubRange { |
| ... | ... | @@ -1999,7 +2014,7 @@ fn renderRecord(c: *Context, node: Node) !NodeIndex { |
| 1999 | 2014 | members[1] = 0; |
| 2000 | 2015 | |
| 2001 | 2016 | for (payload.fields) |field, i| { |
| 2002 | const name_tok = try c.addIdentifier(field.name); | |
| 2017 | const name_tok = try c.addTokenFmt(.identifier, "{s}", .{std.zig.fmtId(field.name)}); | |
| 2003 | 2018 | _ = try c.addToken(.colon, ":"); |
| 2004 | 2019 | const type_expr = try renderNode(c, field.type); |
| 2005 | 2020 | |
| ... | ... | @@ -2079,7 +2094,7 @@ fn renderFieldAccess(c: *Context, lhs: NodeIndex, field_name: []const u8) !NodeI |
| 2079 | 2094 | .main_token = try c.addToken(.period, "."), |
| 2080 | 2095 | .data = .{ |
| 2081 | 2096 | .lhs = lhs, |
| 2082 | .rhs = try c.addIdentifier(field_name), | |
| 2097 | .rhs = try c.addTokenFmt(.identifier, "{s}", .{std.zig.fmtId(field_name)}), | |
| 2083 | 2098 | }, |
| 2084 | 2099 | }); |
| 2085 | 2100 | } |
test/behavior.zig+2| ... | ... | @@ -89,6 +89,8 @@ test { |
| 89 | 89 | _ = @import("behavior/byval_arg_var.zig"); |
| 90 | 90 | _ = @import("behavior/call.zig"); |
| 91 | 91 | _ = @import("behavior/cast_stage1.zig"); |
| 92 | // When these tests pass, #9646 can be closed. | |
| 93 | // _ = @import("behavior/comptime_memory.zig"); | |
| 92 | 94 | _ = @import("behavior/const_slice_child.zig"); |
| 93 | 95 | _ = @import("behavior/defer.zig"); |
| 94 | 96 | _ = @import("behavior/enum.zig"); |
test/behavior/asm.zig+15-15| ... | ... | @@ -23,12 +23,12 @@ test "output constraint modifiers" { |
| 23 | 23 | // This is only testing compilation. |
| 24 | 24 | var a: u32 = 3; |
| 25 | 25 | asm volatile ("" |
| 26 | : [_] "=m,r" (a) | |
| 26 | : [_] "=m,r" (a), | |
| 27 | 27 | : |
| 28 | 28 | : "" |
| 29 | 29 | ); |
| 30 | 30 | asm volatile ("" |
| 31 | : [_] "=r,m" (a) | |
| 31 | : [_] "=r,m" (a), | |
| 32 | 32 | : |
| 33 | 33 | : "" |
| 34 | 34 | ); |
| ... | ... | @@ -38,8 +38,8 @@ test "alternative constraints" { |
| 38 | 38 | // Make sure we allow commas as a separator for alternative constraints. |
| 39 | 39 | var a: u32 = 3; |
| 40 | 40 | asm volatile ("" |
| 41 | : [_] "=r,m" (a) | |
| 42 | : [_] "r,m" (a) | |
| 41 | : [_] "=r,m" (a), | |
| 42 | : [_] "r,m" (a), | |
| 43 | 43 | : "" |
| 44 | 44 | ); |
| 45 | 45 | } |
| ... | ... | @@ -47,42 +47,42 @@ test "alternative constraints" { |
| 47 | 47 | test "sized integer/float in asm input" { |
| 48 | 48 | asm volatile ("" |
| 49 | 49 | : |
| 50 | : [_] "m" (@as(usize, 3)) | |
| 50 | : [_] "m" (@as(usize, 3)), | |
| 51 | 51 | : "" |
| 52 | 52 | ); |
| 53 | 53 | asm volatile ("" |
| 54 | 54 | : |
| 55 | : [_] "m" (@as(i15, -3)) | |
| 55 | : [_] "m" (@as(i15, -3)), | |
| 56 | 56 | : "" |
| 57 | 57 | ); |
| 58 | 58 | asm volatile ("" |
| 59 | 59 | : |
| 60 | : [_] "m" (@as(u3, 3)) | |
| 60 | : [_] "m" (@as(u3, 3)), | |
| 61 | 61 | : "" |
| 62 | 62 | ); |
| 63 | 63 | asm volatile ("" |
| 64 | 64 | : |
| 65 | : [_] "m" (@as(i3, 3)) | |
| 65 | : [_] "m" (@as(i3, 3)), | |
| 66 | 66 | : "" |
| 67 | 67 | ); |
| 68 | 68 | asm volatile ("" |
| 69 | 69 | : |
| 70 | : [_] "m" (@as(u121, 3)) | |
| 70 | : [_] "m" (@as(u121, 3)), | |
| 71 | 71 | : "" |
| 72 | 72 | ); |
| 73 | 73 | asm volatile ("" |
| 74 | 74 | : |
| 75 | : [_] "m" (@as(i121, 3)) | |
| 75 | : [_] "m" (@as(i121, 3)), | |
| 76 | 76 | : "" |
| 77 | 77 | ); |
| 78 | 78 | asm volatile ("" |
| 79 | 79 | : |
| 80 | : [_] "m" (@as(f32, 3.17)) | |
| 80 | : [_] "m" (@as(f32, 3.17)), | |
| 81 | 81 | : "" |
| 82 | 82 | ); |
| 83 | 83 | asm volatile ("" |
| 84 | 84 | : |
| 85 | : [_] "m" (@as(f64, 3.17)) | |
| 85 | : [_] "m" (@as(f64, 3.17)), | |
| 86 | 86 | : "" |
| 87 | 87 | ); |
| 88 | 88 | } |
| ... | ... | @@ -90,15 +90,15 @@ test "sized integer/float in asm input" { |
| 90 | 90 | test "struct/array/union types as input values" { |
| 91 | 91 | asm volatile ("" |
| 92 | 92 | : |
| 93 | : [_] "m" (@as([1]u32, undefined)) | |
| 93 | : [_] "m" (@as([1]u32, undefined)), | |
| 94 | 94 | ); // fails |
| 95 | 95 | asm volatile ("" |
| 96 | 96 | : |
| 97 | : [_] "m" (@as(struct { x: u32, y: u8 }, undefined)) | |
| 97 | : [_] "m" (@as(struct { x: u32, y: u8 }, undefined)), | |
| 98 | 98 | ); // fails |
| 99 | 99 | asm volatile ("" |
| 100 | 100 | : |
| 101 | : [_] "m" (@as(union { x: u32, y: u8 }, undefined)) | |
| 101 | : [_] "m" (@as(union { x: u32, y: u8 }, undefined)), | |
| 102 | 102 | ); // fails |
| 103 | 103 | } |
| 104 | 104 |
test/behavior/comptime_memory.zig created+317| ... | ... | @@ -0,0 +1,317 @@ |
| 1 | const endian = @import("builtin").cpu.arch.endian(); | |
| 2 | const testing = @import("std").testing; | |
| 3 | const ptr_size = @sizeOf(usize); | |
| 4 | ||
| 5 | test "type pun signed and unsigned as single pointer" { | |
| 6 | comptime { | |
| 7 | var x: u32 = 0; | |
| 8 | const y = @ptrCast(*i32, &x); | |
| 9 | y.* = -1; | |
| 10 | try testing.expectEqual(@as(u32, 0xFFFFFFFF), x); | |
| 11 | } | |
| 12 | } | |
| 13 | ||
| 14 | test "type pun signed and unsigned as many pointer" { | |
| 15 | comptime { | |
| 16 | var x: u32 = 0; | |
| 17 | const y = @ptrCast([*]i32, &x); | |
| 18 | y[0] = -1; | |
| 19 | try testing.expectEqual(@as(u32, 0xFFFFFFFF), x); | |
| 20 | } | |
| 21 | } | |
| 22 | ||
| 23 | test "type pun signed and unsigned as array pointer" { | |
| 24 | comptime { | |
| 25 | var x: u32 = 0; | |
| 26 | const y = @ptrCast(*[1]i32, &x); | |
| 27 | y[0] = -1; | |
| 28 | try testing.expectEqual(@as(u32, 0xFFFFFFFF), x); | |
| 29 | } | |
| 30 | } | |
| 31 | ||
| 32 | test "type pun signed and unsigned as offset many pointer" { | |
| 33 | comptime { | |
| 34 | var x: u32 = 0; | |
| 35 | var y = @ptrCast([*]i32, &x); | |
| 36 | y -= 10; | |
| 37 | y[10] = -1; | |
| 38 | try testing.expectEqual(@as(u32, 0xFFFFFFFF), x); | |
| 39 | } | |
| 40 | } | |
| 41 | ||
| 42 | test "type pun signed and unsigned as array pointer" { | |
| 43 | comptime { | |
| 44 | var x: u32 = 0; | |
| 45 | const y = @ptrCast([*]i32, &x) - 10; | |
| 46 | const z: *[15]i32 = y[0..15]; | |
| 47 | z[10] = -1; | |
| 48 | try testing.expectEqual(@as(u32, 0xFFFFFFFF), x); | |
| 49 | } | |
| 50 | } | |
| 51 | ||
| 52 | test "type pun value and struct" { | |
| 53 | comptime { | |
| 54 | const StructOfU32 = extern struct { x: u32 }; | |
| 55 | var inst: StructOfU32 = .{ .x = 0 }; | |
| 56 | @ptrCast(*i32, &inst.x).* = -1; | |
| 57 | try testing.expectEqual(@as(u32, 0xFFFFFFFF), inst.x); | |
| 58 | @ptrCast(*i32, &inst).* = -2; | |
| 59 | try testing.expectEqual(@as(u32, 0xFFFFFFFE), inst.x); | |
| 60 | } | |
| 61 | } | |
| 62 | ||
| 63 | fn bigToNativeEndian(comptime T: type, v: T) T { | |
| 64 | return if (endian == .Big) v else @byteSwap(T, v); | |
| 65 | } | |
| 66 | test "type pun endianness" { | |
| 67 | comptime { | |
| 68 | const StructOfBytes = extern struct { x: [4]u8 }; | |
| 69 | var inst: StructOfBytes = .{ .x = [4]u8{ 0, 0, 0, 0 } }; | |
| 70 | const structPtr = @ptrCast(*align(1) u32, &inst); | |
| 71 | const arrayPtr = @ptrCast(*align(1) u32, &inst.x); | |
| 72 | inst.x[0] = 0xFE; | |
| 73 | inst.x[2] = 0xBE; | |
| 74 | try testing.expectEqual(bigToNativeEndian(u32, 0xFE00BE00), structPtr.*); | |
| 75 | try testing.expectEqual(bigToNativeEndian(u32, 0xFE00BE00), arrayPtr.*); | |
| 76 | structPtr.* = bigToNativeEndian(u32, 0xDEADF00D); | |
| 77 | try testing.expectEqual(bigToNativeEndian(u32, 0xDEADF00D), structPtr.*); | |
| 78 | try testing.expectEqual(bigToNativeEndian(u32, 0xDEADF00D), arrayPtr.*); | |
| 79 | try testing.expectEqual(@as(u8, 0xDE), inst.x[0]); | |
| 80 | try testing.expectEqual(@as(u8, 0xAD), inst.x[1]); | |
| 81 | try testing.expectEqual(@as(u8, 0xF0), inst.x[2]); | |
| 82 | try testing.expectEqual(@as(u8, 0x0D), inst.x[3]); | |
| 83 | } | |
| 84 | } | |
| 85 | ||
| 86 | const Bits = packed struct { | |
| 87 | // Note: This struct has only single byte words so it | |
| 88 | // doesn't need to be byte swapped. | |
| 89 | p0: u1, | |
| 90 | p1: u4, | |
| 91 | p2: u3, | |
| 92 | p3: u2, | |
| 93 | p4: u6, | |
| 94 | p5: u8, | |
| 95 | p6: u7, | |
| 96 | p7: u1, | |
| 97 | }; | |
| 98 | const ShuffledBits = packed struct { | |
| 99 | p1: u4, | |
| 100 | p3: u2, | |
| 101 | p7: u1, | |
| 102 | p0: u1, | |
| 103 | p5: u8, | |
| 104 | p2: u3, | |
| 105 | p6: u7, | |
| 106 | p4: u6, | |
| 107 | }; | |
| 108 | fn shuffle(ptr: usize, comptime From: type, comptime To: type) usize { | |
| 109 | if (@sizeOf(From) != @sizeOf(To)) | |
| 110 | @compileError("Mismatched sizes! " ++ @typeName(From) ++ " and " ++ @typeName(To) ++ " must have the same size!"); | |
| 111 | const array_len = @divExact(ptr_size, @sizeOf(From)); | |
| 112 | var result: usize = 0; | |
| 113 | const pSource = @ptrCast(*align(1) const [array_len]From, &ptr); | |
| 114 | const pResult = @ptrCast(*align(1) [array_len]To, &result); | |
| 115 | var i: usize = 0; | |
| 116 | while (i < array_len) : (i += 1) { | |
| 117 | inline for (@typeInfo(To).Struct.fields) |f| { | |
| 118 | @field(pResult[i], f.name) = @field(pSource[i], f.name); | |
| 119 | } | |
| 120 | } | |
| 121 | return result; | |
| 122 | } | |
| 123 | ||
| 124 | fn doTypePunBitsTest(as_bits: *Bits) !void { | |
| 125 | const as_u32 = @ptrCast(*align(1) u32, as_bits); | |
| 126 | const as_bytes = @ptrCast(*[4]u8, as_bits); | |
| 127 | as_u32.* = bigToNativeEndian(u32, 0xB0A7DEED); | |
| 128 | try testing.expectEqual(@as(u1, 0x00), as_bits.p0); | |
| 129 | try testing.expectEqual(@as(u4, 0x08), as_bits.p1); | |
| 130 | try testing.expectEqual(@as(u3, 0x05), as_bits.p2); | |
| 131 | try testing.expectEqual(@as(u2, 0x03), as_bits.p3); | |
| 132 | try testing.expectEqual(@as(u6, 0x29), as_bits.p4); | |
| 133 | try testing.expectEqual(@as(u8, 0xDE), as_bits.p5); | |
| 134 | try testing.expectEqual(@as(u7, 0x6D), as_bits.p6); | |
| 135 | try testing.expectEqual(@as(u1, 0x01), as_bits.p7); | |
| 136 | ||
| 137 | as_bits.p6 = 0x2D; | |
| 138 | as_bits.p1 = 0x0F; | |
| 139 | try testing.expectEqual(bigToNativeEndian(u32, 0xBEA7DEAD), as_u32.*); | |
| 140 | ||
| 141 | // clobbering one bit doesn't clobber the word | |
| 142 | as_bits.p7 = undefined; | |
| 143 | try testing.expectEqual(@as(u7, 0x2D), as_bits.p6); | |
| 144 | // even when read as a whole | |
| 145 | const u = as_u32.*; | |
| 146 | _ = u; // u is undefined | |
| 147 | try testing.expectEqual(@as(u7, 0x2D), as_bits.p6); | |
| 148 | // or if a field which shares the byte is modified | |
| 149 | as_bits.p6 = 0x6D; | |
| 150 | try testing.expectEqual(@as(u7, 0x6D), as_bits.p6); | |
| 151 | ||
| 152 | // but overwriting the undefined will clear it | |
| 153 | as_bytes[3] = 0xAF; | |
| 154 | try testing.expectEqual(bigToNativeEndian(u32, 0xBEA7DEAF), as_u32.*); | |
| 155 | } | |
| 156 | ||
| 157 | test "type pun bits" { | |
| 158 | comptime { | |
| 159 | var v: u32 = undefined; | |
| 160 | try doTypePunBitsTest(@ptrCast(*Bits, &v)); | |
| 161 | } | |
| 162 | } | |
| 163 | ||
| 164 | const imports = struct { | |
| 165 | var global_u32: u32 = 0; | |
| 166 | }; | |
| 167 | ||
| 168 | // Make sure lazy values work on their own, before getting into more complex tests | |
| 169 | test "basic pointer preservation" { | |
| 170 | comptime { | |
| 171 | const lazy_address = @ptrToInt(&imports.global_u32); | |
| 172 | try testing.expectEqual(@ptrToInt(&imports.global_u32), lazy_address); | |
| 173 | try testing.expectEqual(&imports.global_u32, @intToPtr(*u32, lazy_address)); | |
| 174 | } | |
| 175 | } | |
| 176 | ||
| 177 | test "byte copy preserves linker value" { | |
| 178 | const ct_value = comptime blk: { | |
| 179 | const lazy = &imports.global_u32; | |
| 180 | var result: *u32 = undefined; | |
| 181 | const pSource = @ptrCast(*const [ptr_size]u8, &lazy); | |
| 182 | const pResult = @ptrCast(*[ptr_size]u8, &result); | |
| 183 | var i: usize = 0; | |
| 184 | while (i < ptr_size) : (i += 1) { | |
| 185 | pResult[i] = pSource[i]; | |
| 186 | try testing.expectEqual(pSource[i], pResult[i]); | |
| 187 | } | |
| 188 | try testing.expectEqual(&imports.global_u32, result); | |
| 189 | break :blk result; | |
| 190 | }; | |
| 191 | ||
| 192 | try testing.expectEqual(&imports.global_u32, ct_value); | |
| 193 | } | |
| 194 | ||
| 195 | test "unordered byte copy preserves linker value" { | |
| 196 | const ct_value = comptime blk: { | |
| 197 | const lazy = &imports.global_u32; | |
| 198 | var result: *u32 = undefined; | |
| 199 | const pSource = @ptrCast(*const [ptr_size]u8, &lazy); | |
| 200 | const pResult = @ptrCast(*[ptr_size]u8, &result); | |
| 201 | if (ptr_size > 8) @compileError("This array needs to be expanded for platform with very big pointers"); | |
| 202 | const shuffled_indices = [_]usize{ 4, 5, 2, 6, 1, 3, 0, 7 }; | |
| 203 | for (shuffled_indices) |i| { | |
| 204 | pResult[i] = pSource[i]; | |
| 205 | try testing.expectEqual(pSource[i], pResult[i]); | |
| 206 | } | |
| 207 | try testing.expectEqual(&imports.global_u32, result); | |
| 208 | break :blk result; | |
| 209 | }; | |
| 210 | ||
| 211 | try testing.expectEqual(&imports.global_u32, ct_value); | |
| 212 | } | |
| 213 | ||
| 214 | test "shuffle chunks of linker value" { | |
| 215 | const lazy_address = @ptrToInt(&imports.global_u32); | |
| 216 | const shuffled1_rt = shuffle(lazy_address, Bits, ShuffledBits); | |
| 217 | const unshuffled1_rt = shuffle(shuffled1_rt, ShuffledBits, Bits); | |
| 218 | try testing.expectEqual(lazy_address, unshuffled1_rt); | |
| 219 | const shuffled1_ct = comptime shuffle(lazy_address, Bits, ShuffledBits); | |
| 220 | const shuffled1_ct_2 = comptime shuffle(lazy_address, Bits, ShuffledBits); | |
| 221 | comptime try testing.expectEqual(shuffled1_ct, shuffled1_ct_2); | |
| 222 | const unshuffled1_ct = comptime shuffle(shuffled1_ct, ShuffledBits, Bits); | |
| 223 | comptime try testing.expectEqual(lazy_address, unshuffled1_ct); | |
| 224 | try testing.expectEqual(shuffled1_ct, shuffled1_rt); | |
| 225 | } | |
| 226 | ||
| 227 | test "dance on linker values" { | |
| 228 | comptime { | |
| 229 | var arr: [2]usize = undefined; | |
| 230 | arr[0] = @ptrToInt(&imports.global_u32); | |
| 231 | arr[1] = @ptrToInt(&imports.global_u32); | |
| 232 | ||
| 233 | const weird_ptr = @ptrCast([*]Bits, @ptrCast([*]u8, &arr) + @sizeOf(usize) - 3); | |
| 234 | try doTypePunBitsTest(&weird_ptr[0]); | |
| 235 | if (ptr_size > @sizeOf(Bits)) | |
| 236 | try doTypePunBitsTest(&weird_ptr[1]); | |
| 237 | ||
| 238 | var arr_bytes = @ptrCast(*[2][ptr_size]u8, &arr); | |
| 239 | ||
| 240 | var rebuilt_bytes: [ptr_size]u8 = undefined; | |
| 241 | var i: usize = 0; | |
| 242 | while (i < ptr_size - 3) : (i += 1) { | |
| 243 | rebuilt_bytes[i] = arr_bytes[0][i]; | |
| 244 | } | |
| 245 | while (i < ptr_size) : (i += 1) { | |
| 246 | rebuilt_bytes[i] = arr_bytes[1][i]; | |
| 247 | } | |
| 248 | ||
| 249 | try testing.expectEqual(&imports.global_u32, @intToPtr(*u32, @bitCast(usize, rebuilt_bytes))); | |
| 250 | } | |
| 251 | } | |
| 252 | ||
| 253 | test "offset array ptr by element size" { | |
| 254 | comptime { | |
| 255 | const VirtualStruct = struct { x: u32 }; | |
| 256 | var arr: [4]VirtualStruct = .{ | |
| 257 | .{ .x = bigToNativeEndian(u32, 0x0004080c) }, | |
| 258 | .{ .x = bigToNativeEndian(u32, 0x0105090d) }, | |
| 259 | .{ .x = bigToNativeEndian(u32, 0x02060a0e) }, | |
| 260 | .{ .x = bigToNativeEndian(u32, 0x03070b0f) }, | |
| 261 | }; | |
| 262 | ||
| 263 | const address = @ptrToInt(&arr); | |
| 264 | try testing.expectEqual(@ptrToInt(&arr[0]), address); | |
| 265 | try testing.expectEqual(@ptrToInt(&arr[0]) + 10, address + 10); | |
| 266 | try testing.expectEqual(@ptrToInt(&arr[1]), address + @sizeOf(VirtualStruct)); | |
| 267 | try testing.expectEqual(@ptrToInt(&arr[2]), address + 2 * @sizeOf(VirtualStruct)); | |
| 268 | try testing.expectEqual(@ptrToInt(&arr[3]), address + @sizeOf(VirtualStruct) * 3); | |
| 269 | ||
| 270 | const secondElement = @intToPtr(*VirtualStruct, @ptrToInt(&arr[0]) + 2 * @sizeOf(VirtualStruct)); | |
| 271 | try testing.expectEqual(bigToNativeEndian(u32, 0x02060a0e), secondElement.x); | |
| 272 | } | |
| 273 | } | |
| 274 | ||
| 275 | test "offset instance by field size" { | |
| 276 | comptime { | |
| 277 | const VirtualStruct = struct { x: u32, y: u32, z: u32, w: u32 }; | |
| 278 | var inst = VirtualStruct{ .x = 0, .y = 1, .z = 2, .w = 3 }; | |
| 279 | ||
| 280 | var ptr = @ptrToInt(&inst); | |
| 281 | ptr -= 4; | |
| 282 | ptr += @offsetOf(VirtualStruct, "x"); | |
| 283 | try testing.expectEqual(@as(u32, 0), @intToPtr([*]u32, ptr)[1]); | |
| 284 | ptr -= @offsetOf(VirtualStruct, "x"); | |
| 285 | ptr += @offsetOf(VirtualStruct, "y"); | |
| 286 | try testing.expectEqual(@as(u32, 1), @intToPtr([*]u32, ptr)[1]); | |
| 287 | ptr = ptr - @offsetOf(VirtualStruct, "y") + @offsetOf(VirtualStruct, "z"); | |
| 288 | try testing.expectEqual(@as(u32, 2), @intToPtr([*]u32, ptr)[1]); | |
| 289 | ptr = @ptrToInt(&inst.z) - 4 - @offsetOf(VirtualStruct, "z"); | |
| 290 | ptr += @offsetOf(VirtualStruct, "w"); | |
| 291 | try testing.expectEqual(@as(u32, 3), @intToPtr(*u32, ptr + 4).*); | |
| 292 | } | |
| 293 | } | |
| 294 | ||
| 295 | test "offset field ptr by enclosing array element size" { | |
| 296 | comptime { | |
| 297 | const VirtualStruct = struct { x: u32 }; | |
| 298 | var arr: [4]VirtualStruct = .{ | |
| 299 | .{ .x = bigToNativeEndian(u32, 0x0004080c) }, | |
| 300 | .{ .x = bigToNativeEndian(u32, 0x0105090d) }, | |
| 301 | .{ .x = bigToNativeEndian(u32, 0x02060a0e) }, | |
| 302 | .{ .x = bigToNativeEndian(u32, 0x03070b0f) }, | |
| 303 | }; | |
| 304 | ||
| 305 | var i: usize = 0; | |
| 306 | while (i < 4) : (i += 1) { | |
| 307 | var ptr: [*]u8 = @ptrCast([*]u8, &arr[0]); | |
| 308 | ptr += i; | |
| 309 | ptr += @offsetOf(VirtualStruct, "x"); | |
| 310 | var j: usize = 0; | |
| 311 | while (j < 4) : (j += 1) { | |
| 312 | const base = ptr + j * @sizeOf(VirtualStruct); | |
| 313 | try testing.expectEqual(@intCast(u8, i * 4 + j), base[0]); | |
| 314 | } | |
| 315 | } | |
| 316 | } | |
| 317 | } |
test/behavior/generics.zig+2-1| ... | ... | @@ -91,7 +91,8 @@ test "type constructed by comptime function call" { |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | fn SimpleList(comptime L: usize) type { |
| 94 | var T = u8; | |
| 94 | var mutable_T = u8; | |
| 95 | const T = mutable_T; | |
| 95 | 96 | return struct { |
| 96 | 97 | array: [L]T, |
| 97 | 98 | }; |
test/behavior/misc.zig+2-2| ... | ... | @@ -506,7 +506,7 @@ test "lazy typeInfo value as generic parameter" { |
| 506 | 506 | S.foo(@typeInfo(@TypeOf(.{}))); |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | fn A() type { | |
| 509 | fn ZA() type { | |
| 510 | 510 | return struct { |
| 511 | 511 | b: B(), |
| 512 | 512 | |
| ... | ... | @@ -520,7 +520,7 @@ fn A() type { |
| 520 | 520 | }; |
| 521 | 521 | } |
| 522 | 522 | test "non-ambiguous reference of shadowed decls" { |
| 523 | try expect(A().B().Self != A().Self); | |
| 523 | try expect(ZA().B().Self != ZA().Self); | |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | test "use of declaration with same name as primitive" { |
test/cases.zig+5-4| ... | ... | @@ -984,8 +984,8 @@ pub fn addCases(ctx: *TestContext) !void { |
| 984 | 984 | \\}; |
| 985 | 985 | , &.{ |
| 986 | 986 | ":4:17: error: ambiguous reference", |
| 987 | ":1:1: note: declared here", | |
| 988 | ":2:5: note: also declared here", | |
| 987 | ":2:5: note: declared here", | |
| 988 | ":1:1: note: also declared here", | |
| 989 | 989 | }); |
| 990 | 990 | |
| 991 | 991 | ctx.compileError("inner func accessing outer var", linux_x64, |
| ... | ... | @@ -999,8 +999,9 @@ pub fn addCases(ctx: *TestContext) !void { |
| 999 | 999 | \\ _ = S; |
| 1000 | 1000 | \\} |
| 1001 | 1001 | , &.{ |
| 1002 | ":5:20: error: 'bar' not accessible from inner function", | |
| 1003 | ":2:9: note: declared here", | |
| 1002 | ":5:20: error: mutable 'bar' not accessible from here", | |
| 1003 | ":2:9: note: declared mutable here", | |
| 1004 | ":3:15: note: crosses namespace boundary here", | |
| 1004 | 1005 | }); |
| 1005 | 1006 | |
| 1006 | 1007 | ctx.compileError("global variable redeclaration", linux_x64, |
test/compile_errors.zig+24| ... | ... | @@ -5342,6 +5342,17 @@ pub fn addCases(ctx: *TestContext) !void { |
| 5342 | 5342 | "tmp.zig:2:1: note: declared here", |
| 5343 | 5343 | }); |
| 5344 | 5344 | |
| 5345 | ctx.objErrStage1("local shadows global that occurs later", | |
| 5346 | \\pub fn main() void { | |
| 5347 | \\ var foo = true; | |
| 5348 | \\ _ = foo; | |
| 5349 | \\} | |
| 5350 | \\fn foo() void {} | |
| 5351 | , &[_][]const u8{ | |
| 5352 | "tmp.zig:2:9: error: local shadows declaration of 'foo'", | |
| 5353 | "tmp.zig:5:1: note: declared here", | |
| 5354 | }); | |
| 5355 | ||
| 5345 | 5356 | ctx.objErrStage1("switch expression - missing enumeration prong", |
| 5346 | 5357 | \\const Number = enum { |
| 5347 | 5358 | \\ One, |
| ... | ... | @@ -8814,4 +8825,17 @@ pub fn addCases(ctx: *TestContext) !void { |
| 8814 | 8825 | , &[_][]const u8{ |
| 8815 | 8826 | "error: Unsupported OS", |
| 8816 | 8827 | }); |
| 8828 | ||
| 8829 | ctx.objErrStage1("attempt to close over comptime variable from outer scope", | |
| 8830 | \\fn SimpleList(comptime L: usize) type { | |
| 8831 | \\ var T = u8; | |
| 8832 | \\ return struct { | |
| 8833 | \\ array: [L]T, | |
| 8834 | \\ }; | |
| 8835 | \\} | |
| 8836 | , &[_][]const u8{ | |
| 8837 | "tmp.zig:4:19: error: mutable 'T' not accessible from here", | |
| 8838 | "tmp.zig:2:9: note: declared mutable here", | |
| 8839 | "tmp.zig:3:12: note: crosses namespace boundary here", | |
| 8840 | }); | |
| 8817 | 8841 | } |
test/tests.zig+30-34| ... | ... | @@ -160,24 +160,22 @@ const test_targets = blk: { |
| 160 | 160 | // .link_libc = true, |
| 161 | 161 | //}, |
| 162 | 162 | |
| 163 | // https://github.com/ziglang/zig/issues/8155 | |
| 164 | //TestTarget{ | |
| 165 | // .target = .{ | |
| 166 | // .cpu_arch = .mips, | |
| 167 | // .os_tag = .linux, | |
| 168 | // .abi = .none, | |
| 169 | // }, | |
| 170 | //}, | |
| 163 | TestTarget{ | |
| 164 | .target = .{ | |
| 165 | .cpu_arch = .mips, | |
| 166 | .os_tag = .linux, | |
| 167 | .abi = .none, | |
| 168 | }, | |
| 169 | }, | |
| 171 | 170 | |
| 172 | // https://github.com/ziglang/zig/issues/8155 | |
| 173 | //TestTarget{ | |
| 174 | // .target = .{ | |
| 175 | // .cpu_arch = .mips, | |
| 176 | // .os_tag = .linux, | |
| 177 | // .abi = .musl, | |
| 178 | // }, | |
| 179 | // .link_libc = true, | |
| 180 | //}, | |
| 171 | TestTarget{ | |
| 172 | .target = .{ | |
| 173 | .cpu_arch = .mips, | |
| 174 | .os_tag = .linux, | |
| 175 | .abi = .musl, | |
| 176 | }, | |
| 177 | .link_libc = true, | |
| 178 | }, | |
| 181 | 179 | |
| 182 | 180 | // https://github.com/ziglang/zig/issues/4927 |
| 183 | 181 | //TestTarget{ |
| ... | ... | @@ -189,24 +187,22 @@ const test_targets = blk: { |
| 189 | 187 | // .link_libc = true, |
| 190 | 188 | //}, |
| 191 | 189 | |
| 192 | // https://github.com/ziglang/zig/issues/8155 | |
| 193 | //TestTarget{ | |
| 194 | // .target = .{ | |
| 195 | // .cpu_arch = .mipsel, | |
| 196 | // .os_tag = .linux, | |
| 197 | // .abi = .none, | |
| 198 | // }, | |
| 199 | //}, | |
| 190 | TestTarget{ | |
| 191 | .target = .{ | |
| 192 | .cpu_arch = .mipsel, | |
| 193 | .os_tag = .linux, | |
| 194 | .abi = .none, | |
| 195 | }, | |
| 196 | }, | |
| 200 | 197 | |
| 201 | // https://github.com/ziglang/zig/issues/8155 | |
| 202 | //TestTarget{ | |
| 203 | // .target = .{ | |
| 204 | // .cpu_arch = .mipsel, | |
| 205 | // .os_tag = .linux, | |
| 206 | // .abi = .musl, | |
| 207 | // }, | |
| 208 | // .link_libc = true, | |
| 209 | //}, | |
| 198 | TestTarget{ | |
| 199 | .target = .{ | |
| 200 | .cpu_arch = .mipsel, | |
| 201 | .os_tag = .linux, | |
| 202 | .abi = .musl, | |
| 203 | }, | |
| 204 | .link_libc = true, | |
| 205 | }, | |
| 210 | 206 | |
| 211 | 207 | // https://github.com/ziglang/zig/issues/4927 |
| 212 | 208 | //TestTarget{ |
test/translate_c.zig+12-4| ... | ... | @@ -318,8 +318,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 318 | 318 | \\}; |
| 319 | 319 | \\pub const Color = struct_Color; |
| 320 | 320 | , |
| 321 | \\pub inline fn CLITERAL(type_1: anytype) @TypeOf(type_1) { | |
| 322 | \\ return type_1; | |
| 321 | \\pub inline fn CLITERAL(@"type": anytype) @TypeOf(@"type") { | |
| 322 | \\ return @"type"; | |
| 323 | 323 | \\} |
| 324 | 324 | , |
| 325 | 325 | \\pub const LIGHTGRAY = @import("std").mem.zeroInit(CLITERAL(Color), .{ @as(c_int, 200), @as(c_int, 200), @as(c_int, 200), @as(c_int, 255) }); |
| ... | ... | @@ -2031,10 +2031,18 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2031 | 2031 | cases.add("shadowing primitive types", |
| 2032 | 2032 | \\unsigned anyerror = 2; |
| 2033 | 2033 | \\#define noreturn _Noreturn |
| 2034 | \\typedef enum { | |
| 2035 | \\ f32, | |
| 2036 | \\ u32, | |
| 2037 | \\} BadEnum; | |
| 2034 | 2038 | , &[_][]const u8{ |
| 2035 | \\pub export var anyerror_1: c_uint = 2; | |
| 2039 | \\pub export var @"anyerror": c_uint = 2; | |
| 2040 | , | |
| 2041 | \\pub const @"noreturn" = @compileError("unable to translate C expr: unexpected token .Keyword_noreturn"); | |
| 2036 | 2042 | , |
| 2037 | \\pub const noreturn_2 = @compileError("unable to translate C expr: unexpected token .Keyword_noreturn"); | |
| 2043 | \\pub const @"f32": c_int = 0; | |
| 2044 | \\pub const @"u32": c_int = 1; | |
| 2045 | \\pub const BadEnum = c_uint; | |
| 2038 | 2046 | }); |
| 2039 | 2047 | |
| 2040 | 2048 | cases.add("floats", |