Commit graph

74 commits

Author SHA1 Message Date
Brendan Hansknecht
cdf19e3feb
Merge pull request #2698 from rtfeldman/i/2696
Make sure casting to unsigned types performs zero-extension
2022-03-10 20:10:33 -08:00
ayazhafiz
a90bba3d1d Make sure casting to unsigned types performs zero-extension
Closes #2696
2022-03-10 17:39:37 -06:00
Folkert
e90c12ba1f
Merge remote-tracking branch 'origin/trunk' into box-all-the-things 2022-03-10 18:01:09 +01:00
Folkert
29e053abf3
clarify basic_type_from_layout function 2022-03-09 19:01:03 +01:00
Folkert
5d15166bb5
rename 2022-03-09 16:33:36 +01:00
Folkert
4cca0b3b3c
llvm codegen 2022-03-08 22:21:03 +01:00
Folkert
92f2927046
initial implementation 2022-03-08 19:09:42 +01:00
ayazhafiz
148dbb4efe Unnecessary reference 2022-02-21 14:10:46 -05: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
Folkert
c663a35e16 final phase 2022-01-26 15:44:24 +01:00
Folkert
74932a4cab phase 2 2022-01-26 14:30:37 +01:00
Folkert
40246607aa update inkwell to ease the llvm13 transition 2021-12-08 19:36:29 +01:00
Brian Carroll
c8278dcb1c Add a comment on REFCOUNT_MAX 2021-11-30 09:57:00 +00:00
Richard Feldman
f80409800d
Merge pull request #2091 from rtfeldman/remove-empty-layouts
Remove empty layouts
2021-11-27 23:32:15 -05:00
Folkert
79d5c82dfb cleanup 2021-11-27 16:36:43 +01:00
Brian Carroll
a9456639c7 Fix a bug in LLVM backend refcounting 2021-11-27 00:10:54 +00:00
Folkert
dc44eaac97 cleanup 2021-11-21 14:11:18 +01:00
Joshua Warner
45f9f800ef Use Internal linkage instead of Private to keep roc function symbols in the final binary 2021-11-19 21:32:34 -08:00
Folkert
196538cc58 fix valgrind error, finally 2021-11-13 01:00:20 +01:00
Folkert
65a9febe7d clippy 2021-11-11 23:38:45 +01:00
Folkert
38da99b1ac make it work 2021-11-11 23:36:35 +01:00
Folkert
8266284567 clippy 2021-11-08 22:31:08 +01:00
Folkert
0e1e3381f0 Merge remote-tracking branch 'origin/trunk' into tag-union-imitate-rust 2021-11-07 15:29:55 +01:00
Folkert
180575852a all tests passing 2021-11-07 14:56:24 +01:00
Folkert
bd0f02c542 another waypoint 2021-11-06 19:27:16 +01:00
Kevin Sjöberg
f6d055dc62 Correct minor spelling mistakes 2021-11-06 15:29:08 +01:00
Folkert
5cd232816b waypoint 2021-11-05 21:30:20 +01:00
Folkert
28b15cdf67 prettier 2021-10-22 13:17:07 +02:00
Folkert
7d1bd0ffe7 make refcount take tag union by reference 2021-10-22 13:17:07 +02:00
Folkert
0a12ce896f Revert "make list inc/dec non-recursive (except when freeing the list)"
This reverts commit 19eadbfe70.
2021-10-21 20:28:32 +02:00
Folkert
03144f978f Revert "clippy"
This reverts commit 7773cf9b4d.
2021-10-21 20:28:18 +02:00
Folkert
7773cf9b4d clippy 2021-10-14 20:12:43 +02:00
Folkert
19eadbfe70 make list inc/dec non-recursive (except when freeing the list) 2021-10-14 19:57:23 +02:00
Folkert
350891468a add LambdaSet layout variant 2021-09-12 17:00:09 +02:00
Folkert
cf5bb7ae6e cleanup 2021-09-11 13:56:06 +02:00
Folkert
cd9b32ba65 fix list decref 2021-09-10 21:53:57 +02:00
Folkert
5e68d31afc expose decref_pointer_check_NULL 2021-09-10 20:42:25 +02:00
Folkert
ac75badbe4 refactor 2021-09-10 20:08:05 +02:00
Folkert
1d8a475ac6 un-pub function 2021-09-10 16:06:14 +02:00
Folkert
05ef6fdeb7 simplify 2021-09-10 15:47:16 +02:00
Folkert
770c8352e3 refactor 2021-09-10 15:29:28 +02:00
Folkert
7627e15266 remove dead code 2021-09-10 14:58:27 +02:00
Folkert
97577c92cf layout add allocation_alignment_bytes 2021-09-04 00:03:10 +02:00
Folkert
63c488acd8 check whether a pointer actually stores the tag id in the bits 2021-09-03 23:58:41 +02:00
Folkert
4e39543054 simplify/optimize decref logic 2021-09-01 23:07:56 +02:00
Folkert
85e4afefe8 quick fix for failing expects on wasm 2021-09-01 17:22:57 +02:00
Folkert
5cb7dbd3cc use zig's decref instead of an LLVM implementation 2021-09-01 16:58:05 +02:00
Folkert
a4475b7544 make TestBase64 compile 2021-08-25 20:47:03 +02:00
Folkert
08c24dde1b make refcount increment support 32-bit 2021-08-24 16:59:27 +02:00
Richard Feldman
f279485edf
Merge branch 'trunk' into roc_panic 2021-08-19 07:20:26 -04:00