Commit graph

11947 commits

Author SHA1 Message Date
Folkert
36700a0c70 shrink tag width on RocResult 2021-12-27 23:59:12 +01:00
Folkert
b924f7e329 use new header type in a spot we missed 2021-12-27 23:58:56 +01:00
Richard Feldman
554570a232
Merge pull request #2284 from rtfeldman/roc-std-result
add RocResult to roc_std rust crate
2021-12-27 17:43:22 -05:00
Folkert de Vries
249878cbd9
Merge pull request #2281 from rtfeldman/i/2149
(llvm) Generate code for tag unions less than 64 bits in size correctly
2021-12-27 22:38:08 +01:00
Folkert de Vries
bb935948aa
Merge pull request #2276 from rtfeldman/i/2265
Parse "as" aliases into tag/args rather than arbitrary annotations
2021-12-27 20:56:48 +01:00
Folkert de Vries
565809063b
Merge pull request #2283 from rtfeldman/eq-linked-list-tce
Tail-call elimination for equality on linked lists
2021-12-27 20:40:03 +01:00
Folkert de Vries
543dd83fd4
Merge pull request #2282 from rtfeldman/i/178
Parse destructured tag annotations as annotations rather than aliases
2021-12-27 20:18:01 +01:00
Folkert
007d777865 flesh out api for RocResult 2021-12-27 20:01:19 +01:00
Folkert
c2934a509a refactor unsafe RocResult to payload conversion 2021-12-27 19:31:22 +01:00
Brian Carroll
c67b9e7a6f clippy 2021-12-27 18:11:48 +00:00
Brian Carroll
0285cd88c5 Don't emit tail recursion loop for non-recursive unions 2021-12-27 18:08:43 +00:00
Brian Carroll
409a32b192 Test for equality on very long linked lists 2021-12-27 18:08:43 +00:00
Brian Carroll
0d8a2c8a49 Use tail call elimination where possible in == for tag unions 2021-12-27 18:08:43 +00:00
Brian Carroll
65a9464d98 Replace RecursivePointer todo with unreachable 2021-12-27 18:08:43 +00:00
Richard Feldman
f536eeb919 Add From<Result> to RocResult 2021-12-27 16:34:55 +01:00
Richard Feldman
c83a9b82e7 Fix RocResult double-free, add tests 2021-12-27 16:34:43 +01:00
Richard Feldman
d6fc4ac25f Make RocResult use unions under the hood 2021-12-27 16:34:36 +01:00
ayazhafiz
4631ff96f5 Initialize stack pointer when it doesn't exist
I'm not sure this is right, but we have to do it somewhere.. and here
seems reasonable?
2021-12-26 17:46:06 -06:00
ayazhafiz
326bfe9aa3 Ensure WASM code gen uses proper tag ID alignment
We should use the alignment of the tag ID layout, not the alignment of
the rest of the data in the tag union. The reason is that the tag ID may
be smaller than the data.
2021-12-26 17:45:05 -06:00
ayazhafiz
b3ddfa7515 Parse destructured tag annotations as annotations rather than aliases
Closes #178
2021-12-26 16:11:29 -06:00
ayazhafiz
235d6a9e88 Fix gen_tags tests 2021-12-26 15:49:54 -06:00
ayazhafiz
a03f7fa46c Update layout tests 2021-12-26 14:44:43 -06:00
Lucas
fe62e59e31
Merge pull request #2278 from rtfeldman/configure-zig-executable
use ROC_ZIG environment variable to configure which zig is used
2021-12-26 14:40:48 -05:00
ayazhafiz
c8ba554d8c Clippy warning 2021-12-26 11:58:50 -06:00
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
ayazhafiz
0b6d3d2c55 Promote parse tests 2021-12-26 11:35:10 -06:00
ayazhafiz
b66543dd95 into_iter -> iter 2021-12-26 09:55:27 -06:00
ayazhafiz
966198a6e7 Coalesce inline and normal alias headers
Unifies `As` annotations and `Alias` defs to use a common struct for
defining alias header information, i.e. the name and type variables of
the alias.
2021-12-26 09:37:56 -06:00
ayazhafiz
597a1cef3b Attach location to alias header name 2021-12-26 09:17:27 -06:00
ayazhafiz
11da888c07 Pull out alias header as its own struct 2021-12-26 09:07:12 -06:00
ayazhafiz
dae94f4aaa Improve error message 2021-12-26 08:51:35 -06:00
ayazhafiz
507f219d28 Satiate clippy 2021-12-26 08:44:10 -06:00
ayazhafiz
3b209b1164 Report type alias issues 2021-12-26 08:44:10 -06:00
ayazhafiz
2cd5bf8c03 Parse "as" aliases into tag/args rather than arbitrary annotations 2021-12-26 08:44:09 -06:00
Folkert de Vries
4ddb8e10fb
Merge pull request #2272 from rtfeldman/joshuawarner32/parser-benchmark
Add simple benchmark for the parser: parse false-interpreter
2021-12-26 14:38:07 +01:00
Folkert de Vries
b43a9b9556
Merge pull request #2280 from rtfeldman/wasm-eq-recursive-eager
Wasm: Equality on recursive tag unions
2021-12-26 14:36:01 +01:00
Brian Carroll
44b4d2b3c9 Enable remaining gen_compare tests for wasm 2021-12-26 10:45:23 +00:00
Brian Carroll
e54ce0c975 Ensure procs are in the same order as the Symbols 2021-12-26 10:45:23 +00:00
Brian Carroll
9fb7048de0 Rename rec_ptr_layout -> recursive_union
I kept thinking it was of type Layout but it's not
2021-12-26 10:45:23 +00:00
Brian Carroll
ab7867d233 Separate specializations from procs
This was causing issues with recursive procs.
We need to be able to look up the proc's symbol
before we have finished generating it.
2021-12-26 10:45:23 +00:00
Brian Carroll
e10acd59ee Debug config for Wasm backend 2021-12-26 10:45:18 +00:00
Brian Carroll
1f86ad3438 Fix Wasm function indices for generated helpers 2021-12-26 10:40:45 +00:00
Brian Carroll
d08b79295c Fix unique names 2021-12-26 10:40:45 +00:00
Brian Carroll
da4cf721cc Fix equality on empty structures 2021-12-26 10:40:45 +00:00
Brian Carroll
a0afb64cb0 Fix bug storing linker data for generated procs 2021-12-26 10:40:45 +00:00
Brian Carroll
0fbe49dce9 Shorten some variable names 2021-12-26 10:40:45 +00:00
Brian Carroll
ca501fdcf1 Restructure CodeGenHelp to generate IR immediately, in depth-first traversal 2021-12-26 10:40:45 +00:00
Folkert
022b1ca83a use ROC_ZIG environment variable to configure which zig is used 2021-12-25 22:27:52 +01:00
Richard Feldman
f314abfed9
Merge pull request #2274 from rtfeldman/alias-def-order
Fix type alias definition order
2021-12-24 16:32:31 -05:00
Folkert
d70e803dff add test 2021-12-24 21:19:09 +01:00