| author | |
| committer | |
| log | 399bb2e154395f1f2372eccb10ea41d6ba5ef68f |
| tree | 91ca58a20bb65c8a404b74a130f06ab1cacbfce0 |
| parent | 31023de6c4b3957ef356be01b5454426844955a9 |
3 files changed, 36 insertions(+), 39 deletions(-)
BRANCH_TODO+1| ... | ... | @@ -20,6 +20,7 @@ Merge TODO list: |
| 20 | 20 | |
| 21 | 21 | Performance optimizations to look into: |
| 22 | 22 | * astgen: pass *GenZir as the first arg, not *Module |
| 23 | - point here is to avoid the unnecessary virtual call scope.getGenZir() | |
| 23 | 24 | * don't store end index for blocks; rely on last instruction being noreturn |
| 24 | 25 | * look into not storing the field name of field access as a string in zir |
| 25 | 26 | instructions. or, look into introducing interning to string_bytes (local |
src/astgen.zig+12-16| ... | ... | @@ -1838,25 +1838,21 @@ fn arrayAccess( |
| 1838 | 1838 | rl: ResultLoc, |
| 1839 | 1839 | node: ast.Node.Index, |
| 1840 | 1840 | ) InnerError!zir.Inst.Ref { |
| 1841 | if (true) @panic("TODO update for zir-memory-layout"); | |
| 1842 | const tree = scope.tree(); | |
| 1841 | const gz = scope.getGenZir(); | |
| 1842 | const tree = gz.tree(); | |
| 1843 | 1843 | const main_tokens = tree.nodes.items(.main_token); |
| 1844 | 1844 | const node_datas = tree.nodes.items(.data); |
| 1845 | ||
| 1846 | const usize_type = try addZIRInstConst(mod, scope, src, .{ | |
| 1847 | .ty = Type.initTag(.type), | |
| 1848 | .val = Value.initTag(.usize_type), | |
| 1849 | }); | |
| 1850 | const index_rl: ResultLoc = .{ .ty = usize_type }; | |
| 1851 | 1845 | switch (rl) { |
| 1852 | .ref => return addZirInstTag(mod, scope, src, .elem_ptr, .{ | |
| 1853 | .array = try expr(mod, scope, .ref, node_datas[node].lhs), | |
| 1854 | .index = try expr(mod, scope, index_rl, node_datas[node].rhs), | |
| 1855 | }), | |
| 1856 | else => return rvalue(mod, scope, rl, try addZirInstTag(mod, scope, src, .elem_val, .{ | |
| 1857 | .array = try expr(mod, scope, .none, node_datas[node].lhs), | |
| 1858 | .index = try expr(mod, scope, index_rl, node_datas[node].rhs), | |
| 1859 | })), | |
| 1846 | .ref => return gz.addBin( | |
| 1847 | .elem_ptr, | |
| 1848 | try expr(mod, scope, .ref, node_datas[node].lhs), | |
| 1849 | try expr(mod, scope, .{ .ty = .usize_type }, node_datas[node].rhs), | |
| 1850 | ), | |
| 1851 | else => return rvalue(mod, scope, rl, try gz.addBin( | |
| 1852 | .elem_val, | |
| 1853 | try expr(mod, scope, .none, node_datas[node].lhs), | |
| 1854 | try expr(mod, scope, .{ .ty = .usize_type }, node_datas[node].rhs), | |
| 1855 | ), node), | |
| 1860 | 1856 | } |
| 1861 | 1857 | } |
| 1862 | 1858 |
test/stage2/test.zig+23-23| ... | ... | @@ -917,29 +917,29 @@ pub fn addCases(ctx: *TestContext) !void { |
| 917 | 917 | ); |
| 918 | 918 | |
| 919 | 919 | // Array access. |
| 920 | //case.addCompareOutput( | |
| 921 | // \\export fn _start() noreturn { | |
| 922 | // \\ assert("hello"[0] == 'h'); | |
| 923 | // \\ | |
| 924 | // \\ exit(); | |
| 925 | // \\} | |
| 926 | // \\ | |
| 927 | // \\pub fn assert(ok: bool) void { | |
| 928 | // \\ if (!ok) unreachable; // assertion failure | |
| 929 | // \\} | |
| 930 | // \\ | |
| 931 | // \\fn exit() noreturn { | |
| 932 | // \\ asm volatile ("syscall" | |
| 933 | // \\ : | |
| 934 | // \\ : [number] "{rax}" (231), | |
| 935 | // \\ [arg1] "{rdi}" (0) | |
| 936 | // \\ : "rcx", "r11", "memory" | |
| 937 | // \\ ); | |
| 938 | // \\ unreachable; | |
| 939 | // \\} | |
| 940 | //, | |
| 941 | // "", | |
| 942 | //); | |
| 920 | case.addCompareOutput( | |
| 921 | \\export fn _start() noreturn { | |
| 922 | \\ assert("hello"[0] == 'h'); | |
| 923 | \\ | |
| 924 | \\ exit(); | |
| 925 | \\} | |
| 926 | \\ | |
| 927 | \\pub fn assert(ok: bool) void { | |
| 928 | \\ if (!ok) unreachable; // assertion failure | |
| 929 | \\} | |
| 930 | \\ | |
| 931 | \\fn exit() noreturn { | |
| 932 | \\ asm volatile ("syscall" | |
| 933 | \\ : | |
| 934 | \\ : [number] "{rax}" (231), | |
| 935 | \\ [arg1] "{rdi}" (0) | |
| 936 | \\ : "rcx", "r11", "memory" | |
| 937 | \\ ); | |
| 938 | \\ unreachable; | |
| 939 | \\} | |
| 940 | , | |
| 941 | "", | |
| 942 | ); | |
| 943 | 943 | |
| 944 | 944 | // 64bit set stack |
| 945 | 945 | case.addCompareOutput( |