Commit graph

47 commits

Author SHA1 Message Date
Folkert
61aeaefc76
a start with 32-bit linux support 2022-03-30 23:55:34 +02:00
Folkert
d669b8c894
preparation for using argument_type_from_layout 2022-03-26 14:20:59 +01: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
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
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
92f2927046
initial implementation 2022-03-08 19:09:42 +01: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
0298013346 fix logical error 2022-01-26 17:03:49 +01: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
ayazhafiz
6da9a58b22 Remove some dead code 2021-12-29 17:55:21 -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
Folkert
a1fd34feef remove empty layout types (list,str,dict,set) 2021-11-27 14:05:16 +01:00
Folkert
dc44eaac97 cleanup 2021-11-21 14:11:18 +01:00
Folkert
123c963ff1 llvm build working 2021-11-21 00:23:59 +01:00
Folkert
c4ec9aa898 working mono 2021-11-20 23:25:30 +01:00
Folkert
bd0f02c542 another waypoint 2021-11-06 19:27:16 +01:00
Folkert
5cd232816b waypoint 2021-11-05 21:30:20 +01:00
Brendan Hansknecht
0c6f8f308f Remove f16. It is not really supported by modern CPU hardware. 2021-09-21 16:51:47 -07:00
Folkert
350891468a add LambdaSet layout variant 2021-09-12 17:00:09 +02:00
Folkert
f04ad1643f fix some things 2021-08-25 20:54:34 +02:00
Folkert
c09b3b89f3 test_gen works again 2021-08-18 13:46:09 +02:00
Folkert
e0648d348d new formatting 2021-07-30 17:13:50 +02:00
Folkert
899cbeabd7 fix extra ampersands 2021-07-29 17:32:08 +02:00
Folkert
23ea151d5f make decimal math ops correctly report overflow 2021-07-18 22:04:32 +02:00
Folkert
cb42f0c039 Merge remote-tracking branch 'origin/trunk' into add-dec-types 2021-07-18 16:54:38 +02:00
Folkert
5012b11129 fix oversight 2021-07-18 00:13:45 +02:00
Folkert
e19b03f290 WIP 2021-07-18 00:04:10 +02:00
Folkert
0171fd0959 remove Boxed 2021-07-14 15:33:59 +02:00
Folkert
09f01ba193 Boxed skeleton 2021-07-12 17:01:53 +02:00
Jared Ramirez
67eef2c97f Merge branch 'trunk' of https://github.com/rtfeldman/roc into add-dec-types 2021-07-08 16:47:42 -07:00
Folkert
978cea4b8a passing tests 2021-06-28 22:28:47 +02:00
Folkert
99d0d9c732 WIP 2021-06-27 13:49:49 +02:00
Folkert
8add147dcf change over nullable wrapped 2021-06-27 01:35:15 +02:00
Folkert
fd9b826398 fix the issues 2021-06-25 22:27:11 +02:00
Jared Ramirez
0827123c88 Adding Decimals work!! 2021-06-24 11:15:52 -07:00
Folkert
0eba188493 WIP 2021-06-24 20:12:37 +02:00
Jared Ramirez
4d6e5a1a4f [WIP] Add Dec/Decimal builtin types 2021-06-23 19:30:16 -07:00
Folkert
718aa34b19 clippy 2021-06-19 15:04:28 +02:00
Folkert
f2f9897187 remove FunctionPointer completely 2021-06-19 15:04:28 +02:00
Folkert
d894a06290 use toplevel more 2021-06-18 21:05:31 +02:00
Folkert
88f4b6bc9b remove more FunctionPointer 2021-06-18 21:00:27 +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
Renamed from compiler/gen/src/llvm/convert.rs (Browse further)