Commit graph

364 commits

Author SHA1 Message Date
Brendan Hansknecht
39d070e543 flip platform flag to be default 2022-02-25 20:10:36 -08:00
ayazhafiz
e52d427ac8 Hash record field name order in generated layouts
Closes #2535

See the referenced issue for longer discussion - here's the synopsis.
Consider this program

```
app "test" provides [ nums ] to "./platform"

alpha = { a: 1, b: 2 }

nums : List U8
nums =
    [
        alpha.a,
        alpha.b,
    ]
```

Here's its IR:

```
procedure : `#UserApp.alpha` {I64, U8}
procedure = `#UserApp.alpha` ():
    let `#UserApp.5` : Builtin(Int(I64)) = 1i64;
    let `#UserApp.6` : Builtin(Int(U8)) = 2i64;
    let `#UserApp.4` : Struct([Builtin(Int(I64)), Builtin(Int(U8))]) = Struct {`#UserApp.5`, `#UserApp.6`};
    ret `#UserApp.4`;

procedure : `#UserApp.nums` List U8
procedure = `#UserApp.nums` ():
    let `#UserApp.7` : Struct([Builtin(Int(I64)), Builtin(Int(U8))]) = CallByName `#UserApp.alpha`;
    let `#UserApp.1` : Builtin(Int(U8)) = StructAtIndex 1 `#UserApp.7`;
    let `#UserApp.3` : Struct([Builtin(Int(I64)), Builtin(Int(U8))]) = CallByName `#UserApp.alpha`;
    let `#UserApp.2` : Builtin(Int(U8)) = StructAtIndex 1 `#UserApp.3`;
    let `#UserApp.0` : Builtin(List(Builtin(Int(U8)))) = Array [`#UserApp.1`, `#UserApp.2`];
    ret `#UserApp.0`;
```

What's happening is that we need to specialize `alpha` twice - once for the
type of a narrowed to a U8, another time for the type of b narrowed to a U8.

We do the specialization for alpha.b first - record fields are sorted by
layout, so we generate a record of type {i64, u8}. But then we go to
specialize alpha.a, but this has the same layout - {i64, u8} - so we reuse
the existing one! So (at least for records), we need to include record field
order associated with the sorted layout fields, so that we don't reuse
monomorphizations like this incorrectly!
2022-02-21 14:10:45 -05:00
Brendan Hansknecht
0dae9014fe Update comments 2022-02-19 10:59:32 -08:00
Brendan Hansknecht
4e4dcef1b9 fix missed register freeing 2022-02-18 22:55:19 -08:00
Brendan Hansknecht
6c0230ae4f fix typos 2022-02-18 22:10:15 -08:00
Brendan Hansknecht
427f3e2b68 fix typo 2022-02-18 21:35:30 -08:00
Brendan Hansknecht
b63d62418b clippy 2022-02-18 21:30:58 -08:00
Brendan Hansknecht
469ecbe6c5 remove todo and use doc comments in more places 2022-02-18 21:29:18 -08:00
Brendan Hansknecht
7df6b34a21 correct arg storing index 2022-02-18 21:25:09 -08:00
Brendan Hansknecht
99f6dd7e7b fully integrate storage manager removing old code 2022-02-18 21:14:01 -08:00
Brendan Hansknecht
f564514d9c stop trying to free symbols that don't exist due to being call args 2022-02-18 16:45:34 -08:00
Brendan Hansknecht
c81a1c7c2c remove redundant move 2022-02-18 16:34:07 -08:00
Brendan Hansknecht
f16c0f7db5 fix joinpoint and returning issues 2022-02-18 16:15:10 -08:00
Brendan Hansknecht
37afe28c98 fix join point param loading 2022-02-18 15:03:21 -08:00
Brendan Hansknecht
1f8ac3e150 refactor join points and jumps 2022-02-18 14:46:31 -08:00
Brendan Hansknecht
554db4556b refactor out loading values from storage or internal error 2022-02-18 13:25:39 -08:00
Brendan Hansknecht
b00ef5ea4f add JoinPointId tracking for parameters 2022-02-17 23:17:17 -08:00
Brendan Hansknecht
fb589f7dc5 removing owning symbol map, now delt with by storage manager 2022-02-17 23:06:55 -08:00
Brendan Hansknecht
b6a61aa1cd update todo 2022-02-17 22:46:41 -08:00
Brendan Hansknecht
9fa420f871 move storing args to use storage manager 2022-02-17 22:41:34 -08:00
Brendan Hansknecht
d578dae3ef fix empty struct bug 2022-02-17 22:12:54 -08:00
Brendan Hansknecht
25f232ae0f fix minor typo 2022-02-17 22:09:46 -08:00
Brendan Hansknecht
2bcbb19f07 enable loading aligned referenced primitives 2022-02-17 22:08:35 -08:00
Brendan Hansknecht
907050ceaa convert loading args to storage manager 2022-02-17 21:52:41 -08:00
Brendan Hansknecht
76f03c722f add alignment dbg assert 2022-02-17 21:22:03 -08:00
Brendan Hansknecht
8eb1b09ff9 remove returns via arg pointer from the callconv interface 2022-02-17 21:21:07 -08:00
Brendan Hansknecht
d65a971508 add returning str and list 2022-02-17 21:17:56 -08:00
Brendan Hansknecht
cb64543476 add basic returned value loading 2022-02-17 21:08:28 -08:00
Brendan Hansknecht
55c6c9abad fix wrong assumption 2022-02-17 20:49:27 -08:00
Brendan Hansknecht
77120cb063 enable returning basic symbols with storage manager 2022-02-17 20:46:36 -08:00
Brendan Hansknecht
bf6e825e25 make clippy happier 2022-02-17 17:55:29 -08:00
Brendan Hansknecht
e71da49dd1 re-add loading small string literals 2022-02-17 17:47:25 -08:00
Brendan Hansknecht
d33c02febd fix compilation bug and expand enum derives 2022-02-17 16:43:12 -08:00
Brendan Hansknecht
aa1c0c11b2 add referenced primitives and move loading struct fields to storage manager 2022-02-17 16:32:28 -08:00
Brendan Hansknecht
f4bb49427d remove refs to complex storage with todo to investigate later 2022-02-17 15:46:41 -08:00
Brendan Hansknecht
fa8d7f78b2 move freeing symbols to the storage manager 2022-02-17 15:28:54 -08:00
Brendan Hansknecht
89b6a6cf91 add todo 2022-02-17 15:11:24 -08:00
Brendan Hansknecht
895ed17776 add internal error 2022-02-17 14:58:09 -08:00
Brendan Hansknecht
c08b011875 move copy_symbol_to_stack_offset to storage manager 2022-02-17 14:55:49 -08:00
Brendan Hansknecht
dff1255fd3 properly get target_info and move claim stack fully to storage manager 2022-02-17 14:47:24 -08:00
Brendan Hansknecht
d7cac1a224 fix naming clippy warning 2022-02-16 23:37:28 -08:00
Brendan Hansknecht
b76052c91e swap to using storage manager for some core functions 2022-02-16 23:33:26 -08:00
Brendan Hansknecht
835d3980d5 add float methods to storage manager 2022-02-16 23:13:56 -08:00
Brendan Hansknecht
0d70a4f9f8 add symbol storage into generic64 backend 2022-02-16 23:06:31 -08:00
Brendan Hansknecht
6e10e00534 add core stack methods 2022-02-16 22:56:27 -08:00
Brendan Hansknecht
9e51148628 Add assembler and pass buffer through functions 2022-02-16 22:25:43 -08:00
Brendan Hansknecht
6025880e73 Move references out of storage and into own map 2022-02-16 22:17:02 -08:00
Brendan Hansknecht
1926c3e198 Add base general reg helpers 2022-02-16 21:18:52 -08:00
Brendan Hansknecht
1153e0833b Make symbols store as RCs 2022-02-16 20:59:51 -08:00
Brendan Hansknecht
d1bcc8d55b start storage rewrite 2022-02-16 19:19:35 -08:00