Commit graph

56 commits

Author SHA1 Message Date
ayazhafiz
5e5eb6dca8 (llvm) Generate code for tag unions less than 64 bits in size correctly
Previously, we assumed that a union layout always lived on >= 1 64-bit
boundary when generating an LLVM type for it. For small tags unions,
like `[ Ok i8, Err ]` this need not be the case; indeed, a tag union
like that is actually only 2 bits - 1 bit for the "i8" data, and one bit
of the tag kind.

This led to a discrepancy between what the layout IR and generated LLVM
code would assume about the size of tag unions. In the case above, the
layout IR would assume the tag data is 2 bits wide, and the tag id is 1
bit into the data. But the LLVM code would generate a type that was 65
bits wide, the first 64 bits being for the "i8" data and the last 1 bit
being for the tag kind.

Usually, just running the LLVM-emitted code would not present a problem.
But it does present a problem when we use the layout IR to inspect the
result of LLVM-run code, in particular when we try to look up the tag
ID, as the repl does. This patch fixes that issue.

Note that this bug did not present itself in `test_gen` previously
because the data that most tests check against is stored in the front of
the representation.

Closes #2149
2021-12-26 11:45:02 -06:00
Folkert
acb26002c8 fix repl 2021-11-10 23:36:16 +01:00
Folkert
4152519bfb formatting & catch zig overflow error 2021-10-17 18:03:40 +02:00
Chelsea Troy
03295d4369 So far, add type for divCeil to the language 2021-10-17 09:29:11 -05:00
Folkert
ed52615d4c fix Foo Bar 2021-10-13 14:34:59 +02:00
Chelsea Troy
475326c005 cargo fmt 2021-10-11 20:48:19 -05:00
Chelsea Troy
051b511d87 Remove parentheses from unapplied tags 2021-10-11 20:42:07 -05:00
Folkert
34a25408c3 fix issue 2021-09-24 14:27:38 +02:00
Richard Feldman
57676057fa Rename gen to gen_llvm
This way, we have gen_dev and gen_llvm representing the two
different compiler backends.
2021-06-06 07:56:47 -04:00
Anton-4
d1948d99d0 Merge branch 'trunk' of github.com:rtfeldman/roc into benchmarks 2021-06-02 10:56:30 +02:00
Folkert
08a3b43649 remove inaccurate comments 2021-05-31 23:18:39 +02:00
Anton-4
8d0d1a0758 put cli helpers in cli_utils crate, added bench_utils.rs for sharing functions between benchmarks, added iai benchmarks 2021-05-18 18:48:59 +02:00
Anton-4
9a50ba37ce criterion benchmarks for examples/benchmarks, moved cli helpers 2021-05-17 17:15:10 +02:00
Richard Feldman
f1ddf775cb Use a constant for RocCallResult tag size 2021-04-11 09:44:59 -04:00
Folkert
ae17399741 fix issue 2021-04-11 15:29:51 +02:00
Folkert
a4d7e809d2 allow list of empty record in repl 2021-01-22 20:31:29 +01:00
Sébastien Besnier
fdc2b6ad86 add bitwise xor 2021-01-14 16:12:46 +01:00
rvcas
565cf21e1e fix(tests): need to adjust tests after changing builtin function types 2021-01-05 09:18:24 -05:00
rvcas
a123bfa3ee fix: tests compile and repl_eval 2021-01-04 09:46:10 -05:00
Richard Feldman
7a53003313
Merge pull request #826 from rtfeldman/bughunt
Throw on overflow in Num.neg/Num.abs & fix mono bug
2020-12-26 23:41:11 -05:00
Folkert
a760a41e1f repl: show error for partial application 2020-12-26 22:13:05 +01:00
Folkert
12c7b5435a generate more runtime errors 2020-12-26 21:30:25 +01:00
Folkert
3d1824c658 add test 2020-12-26 21:20:50 +01:00
Folkert
125146aac7 Merge remote-tracking branch 'origin/trunk' into bughunt 2020-12-26 00:51:22 +01:00
Folkert
917ec9c44c make List.first/List.last work 2020-12-24 01:00:37 +01:00
Celso Bonutti Filho
e118b9a1ed test: adds repl tests for Num checked operations 2020-12-23 13:44:02 -03:00
Celso Bonutti Filho
c98d554328 test: adds tests for mulCheck and mulWrap 2020-12-23 13:43:34 -03:00
Celso Bonutti Filho
313bc2ab86 adds tests for Num.subWrap and sub overflow 2020-12-22 22:18:00 -03:00
Celso Bonutti Filho
51a302957f adds List.last 2020-12-21 19:44:24 -03:00
Celso Bonutti Filho
0a24f3b4b4 adds Num.bitwiseAnd 2020-12-20 19:55:10 -03:00
rvcas
4987721154 feat(Num): rename Num.Int to Num.I64 2020-12-07 19:17:20 -05:00
Folkert
68c54b5327 display Result in the repl 2020-12-01 15:21:53 +01:00
rvcas
f7bd803509 feat(Num): rename Float to F64 2020-11-24 10:25:21 -05:00
rvcas
1c8bb74268 feat(List): add sum builtin 2020-11-15 11:08:27 -05:00
Folkert
aecf931305 tag in record 2020-11-11 18:19:28 +01:00
Folkert
51cd6cb925 implement byte enum in repl 2020-11-11 16:16:55 +01:00
Folkert
a94fcdb768 fix single tag multiple arguments case 2020-11-11 15:54:20 +01:00
lrosa007
2bbc2ebe6c use a loop on variables 2020-11-11 09:03:04 -05:00
lrosa007
147646b83e some formatting and ptr adjustment 2020-11-11 08:24:46 -05:00
Folkert
41c5101799 more tests 2020-11-09 14:28:31 +01:00
lrosa007
3ba6f2bf88 some improvements around tags in the repl 2020-11-08 20:07:34 -05:00
lrosa007
c0119514b0 fix(Str): countGraphemes repl_eval test 2020-11-07 18:34:18 -05:00
Jared Ramirez
14fed8e6a6 Fix cargo fmt 2020-11-06 17:03:21 -06:00
Jared Ramirez
e112a406a2 Fix countGrapheme wiring; Reorganize zig builtins; Streamline how we export zig function 2020-11-06 16:54:28 -06:00
lrosa007
4f5237fcd8 add repl_eval test 2020-11-05 08:31:33 -05:00
Folkert
ba99b96164 add repl test for type error 2020-10-14 20:53:19 +02:00
Folkert
be6752542b update to run on our fork of inkwell again 2020-09-19 21:50:33 +02:00
Folkert
9a0a13646f fix repl 2020-09-19 01:46:14 +02:00
Folkert
ee017084f7 return 3-element records 2020-09-14 21:56:57 +02:00
Richard Feldman
7682e09b0a Fix some fmt stuff 2020-08-31 23:13:50 -04:00