Commit graph

483 commits

Author SHA1 Message Date
Jan Van Bruggen
7d95d2b576 Fix shift filling by flipping inkwell sign_extend flags
See https://thedan64.github.io/inkwell/inkwell/builder/struct.Builder.html#method.build_right_shift

Before:
```
» Num.shiftRightBy 1 -8

9223372036854775804 : Int *

» Num.shiftRightZfBy 1 -8

-4 : Int *
```

After:
```
» Num.shiftRightBy 1 -8

-4 : Int *

» Num.shiftRightZfBy 1 -8

9223372036854775804 : Int *
```
2022-03-20 21:39:39 -06:00
ayazhafiz
530fa9943a Generate unsigned div and modulo correctly
Closes #2705
2022-03-13 18:44:38 -05:00
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
d222be95b3
fix another merge conflict 2022-03-10 21:38:31 +01:00
Folkert
be214b7931
fix merge conflict 2022-03-10 21:37:33 +01:00
Folkert
e90c12ba1f
Merge remote-tracking branch 'origin/trunk' into box-all-the-things 2022-03-10 18:01:09 +01:00
Folkert de Vries
7fc1272840
Merge pull request #2692 from rtfeldman/walk-return-tag
`List.walk` return tag
2022-03-10 10:12:42 +01:00
Folkert
f8ca0694e5
Revert "make type conversion work on 32-bit architectures"
This reverts commit 381ec9c01b.
2022-03-10 00:04:34 +01:00
Folkert
381ec9c01b
make type conversion work on 32-bit architectures 2022-03-09 23:10:07 +01:00
Folkert
de6349fbbd
don't double-alloca non-recursive tags 2022-03-09 22:54:56 +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
768703c5df
update reporting; suggestions now have Box in scope 2022-03-09 16:12:11 +01:00
Folkert
6543c9bbc6
Merge remote-tracking branch 'origin/trunk' into box-all-the-things 2022-03-09 00:00:15 +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
Derek Gustafson
78cf0b8d2e
Fix fmt. 2022-03-07 15:49:09 -05:00
Derek Gustafson
ba6b225761
Hide RocDec implemntation details. 2022-03-07 15:34:02 -05:00
Folkert
b3b3b8790c
add new Expr variants 2022-03-07 21:13:48 +01:00
Folkert
3510bad1d5
add scaffolding 2022-03-07 20:55:40 +01:00
Brian Carroll
f2adf71873 Move alias analysis to its own crate instead of roc_mono
Shrinks roc_repl_wasm by 400kB (~8%)
2022-03-04 14:50:02 +00:00
Brendan Hansknecht
2ca1ebdd2d appease the paperclip 2022-02-27 15:50:19 -08:00
Brendan Hansknecht
2e70bb8458 remove list set low level 2022-02-27 15:07:09 -08:00
Brendan Hansknecht
b802d681a3 Merge remote-tracking branch 'origin/trunk' into list-replace 2022-02-27 00:28:08 -08:00
Richard Feldman
d57334dd63
Merge pull request #2566 from rtfeldman/gui-example
GUI Example
2022-02-26 07:48:38 -05:00
Brendan Hansknecht
39d070e543 flip platform flag to be default 2022-02-25 20:10:36 -08:00
Brendan Hansknecht
7c6c9b52a9 Merge remote-tracking branch 'origin/trunk' into list-replace 2022-02-25 07:35:00 -08:00
Richard Feldman
a49b66e379
Merge branch 'trunk' into gui-example 2022-02-25 08:22:36 -05:00
Brendan Hansknecht
116b585cdc add more tests 2022-02-24 22:59:47 -08:00
Brendan Hansknecht
badad1c1ad get basic tests passing 2022-02-24 22:50:28 -08:00
Brendan Hansknecht
889b189191 fix list passing 2022-02-24 22:46:50 -08:00
Brendan Hansknecht
aff962809b call ListReplace and generate struct afterwards 2022-02-24 22:33:36 -08:00
Brendan Hansknecht
dddf8ff785 switch from pair to record and change name to ListReplaceUnsafe 2022-02-24 20:41:26 -08:00
Brendan Hansknecht
27b47713aa Add some comments and TODOs 2022-02-24 20:40:45 -08:00
Brendan Hansknecht
ba2e8cd32b Add base piping for list.Replace 2022-02-24 17:58:56 -08:00
Brendan Hansknecht
69b4e78ac7 Add --opt-size and compiling smaller binaries 2022-02-24 15:39:50 -08:00
Richard Feldman
655373dbe7
Merge remote-tracking branch 'origin/trunk' into gui-example 2022-02-23 21:25:01 -05:00
ayazhafiz
2151e715dd Fix rebased compile error 2022-02-21 14:12:49 -05: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
ayazhafiz
13067f2908 Implement Num.toNNNChecked
Closes #2411
2022-02-19 16:20:21 -05:00
ayazhafiz
d90915a8cd Implement Num.to* builtins
Just wrap over Num.intCast
2022-02-19 11:28:41 -05:00
Folkert
5582644166
use str/list helpers to prepare for adding capacity 2022-02-18 22:23:05 +01:00
hafiz
91483dbf55
Merge pull request #2471 from rtfeldman/fix_args_order
Swap arg order in `List` builtins to put the more-complex types first
2022-02-13 23:25:05 -05:00
ayazhafiz
886e4e07f6 Update alias analysis, implementation for List.mapWithIndex 2022-02-13 22:50:27 -05:00
ayazhafiz
6e5c1d5914 Specialize Num.toFloat for different target float types
Closes #2476
2022-02-13 20:20:25 -05:00
Richard Feldman
71f2444397
s/Int/Nat in a comment 2022-02-11 21:26:39 -05:00
Richard Feldman
e1cc4cbde6
Fix comment 2022-02-11 21:25:08 -05:00
Jan Van Bruggen
f47dbb5171
Swap List.mapWithIndex arg1 args order to put the element first 2022-02-11 16:10:29 -07:00