Commit Graph

96 Commits

Author SHA1 Message Date
Kartik Agaram 1a65c3af0f 5923 - start work on code-generation for 'var' 2020-01-27 00:20:21 -08:00
Kartik Agaram f39eeb3af3 5921 2020-01-26 23:44:40 -08:00
Kartik Agaram 0c1f023acf 5920 2020-01-26 15:09:57 -08:00
Kartik Agaram 9a4631af77 5919 2020-01-26 15:07:55 -08:00
Kartik Agaram d1b94adc39 5918 2020-01-26 15:05:12 -08:00
Kartik Agaram e4dec37372 5916 2020-01-22 23:47:24 -08:00
Kartik Agaram 6915c2774c 5913 2020-01-20 03:14:26 -08:00
Kartik Agaram 73e6c9a389 5911 - support for compound types 2020-01-20 03:09:01 -08:00
Kartik Agaram 9ed9188a39 5909
Draft 5.
2020-01-20 02:42:08 -08:00
Kartik Agaram ad1b89e280 5908
Now parse-type passes, but some outer test is failing. The result is not
being consumed right by `type-equal?`.
2020-01-20 02:27:07 -08:00
Kartik Agaram efd3681e19 5907
Draft 3.

Getting close. Now the tree structure seems right.
2020-01-20 02:21:56 -08:00
Kartik Agaram cad99482cc 5906
Draft 2.
2020-01-20 02:08:12 -08:00
Kartik Agaram f5387ede3a 5905
Draft of my first, incorrect attempt at parsing s-expressions.

No matter how many times I've done this, I never get it right the first
time.
2020-01-20 01:51:01 -08:00
Kartik Agaram 41e4cfc33f 5904 2020-01-19 23:38:06 -08:00
Kartik Agaram bd92759047 5902 2020-01-19 20:43:24 -08:00
Kartik Agaram 6070c23e5e 5897 - rename comparison instructions
Signed and unsigned don't quite capture the essence of what the different
combinations of x86 flags are doing for SubX. The crucial distinction is
that one set of comparison operators is for integers and the second is
for addresses.
2020-01-16 18:31:12 -08:00
Kartik Agaram 675fa93ded 5894 2020-01-16 18:10:42 -08:00
Kartik Agaram 271f26d791 5885
Finalize design for type trees.
2020-01-12 20:25:11 -08:00
Kartik Agaram f1eade7286 5883 - drop the `ref` keyword
When I created it I was conflating two things:
a) needing to refer to just the start, rather than the whole, and
b) counting indirections.

Both are kinda ill-posed. Now Mu will have just `addr` and `handle` types.
Normal types will translate implicitly to `addr` types, while `handle`
will always require explicit handling.
2020-01-12 14:49:35 -08:00
Kartik Agaram e064f1bbfd 5882 2020-01-10 10:35:48 -08:00
Kartik Agaram 0bcfe6e5cf 5880 2020-01-10 10:35:17 -08:00
Kartik Agaram a5010b1b37 5879 2020-01-10 10:35:13 -08:00
Kartik Agaram 68071dca1e 5877 2020-01-03 02:17:53 -08:00
Kartik Agaram 7e7a8a6eae 5876 - address -> addr 2020-01-03 01:36:34 -08:00
Kartik Agaram dafef4e30f 5849 - more integration testing of function calls
I can now run this program:

  fn main -> result/ebx: int {
    result <- do-add 3 4
  }

  fn do-add a: int, b: int -> result/ebx: int {
    result <- copy a
    result <- add b
  }

We still can't define local variables, but can write any programs involving
ints by passing in enough arguments for temporaries.
2020-01-01 15:55:12 -08:00
Kartik Agaram 6126361821 5848 2020-01-01 14:51:07 -08:00
Kartik Agaram a9baaac00b 5847 - literal inputs 2019-12-31 21:58:52 -08:00
Kartik Agaram f1344589da 5846 2019-12-30 01:34:39 -08:00
Kartik Agaram dcb20a225f 5845 2019-12-30 01:33:34 -08:00
Kartik Agaram 2b665cc552 5834
Bugfix.
2019-12-27 23:59:07 -08:00
Kartik Agaram 1d70540ab3 5833 2019-12-27 23:42:35 -08:00
Kartik Agaram 8961f4f0aa 5832 - support for function outputs
We haven't implemented it yet, but there's now a design for how we check
whether a function has written its output correctly. Functions must write
to each output at the top level at least once, and never overwrite an output
register in the top-level once it's been defined.

This is conservative (it can be perfectly reasonable for functions to write
the output, reuse the register for a temporary, and then write the output
again) but easy to check.
2019-12-27 22:38:06 -08:00
Kartik Agaram 80e0188214 5831 2019-12-27 20:00:30 -08:00
Kartik Agaram 8e8a38ea81 5830
Bugfix: statements defining a new register variable require an initializer
instruction.
2019-12-26 02:43:14 -08:00
Kartik Agaram bf03b1d9fa 5828 - copy (mov) instructions 2019-12-26 02:21:55 -08:00
Kartik Agaram 1210b77362 5827 - give primitives one more bit of metadata
Copy (mov) instructions are unlike instructions we've encoded so far, in
that their destination is not read.
2019-12-26 02:07:48 -08:00
Kartik Agaram eeac6cfddb 5826 - done with basic binary ops 2019-12-26 01:51:29 -08:00
Kartik Agaram 5573979f20 5825 - code-generation for add opcodes 2019-12-26 01:28:47 -08:00
Kartik Agaram c74e5009e0 5824 - code-generation for all inc/dec opcodes 2019-12-26 00:16:36 -08:00
Kartik Agaram 4ca4e94dce 5823 2019-12-22 23:43:45 -08:00
Kartik Agaram ce27f90f05 5821 - now translating function arguments
See test-convert-function-with-arg-and-body.
2019-12-22 23:20:44 -08:00
Kartik Agaram 40dbfe20d1 5820
One test failing. It took enough debugging just to get to the expected
failure that it seems worth saving this snapshot.

Saw some signs that I have to remember to zero-out allocated memory. We
need a scalable solution for this.

I think parse-var-with-type needs to be rewritten. Just added a test and
a hacky fix for now.
2019-12-22 08:20:20 -08:00
Kartik Agaram 2a2a5b1e43 5804
Try to make the comments consistent with the type system we'll eventually
have.
2019-12-08 23:31:05 -08:00
Kartik Agaram e9aee071f4 5795 2019-12-07 11:21:30 -08:00
Kartik Agaram 686a52bd2e 5790
Standardize conventions for labels within objects in the data segment.

We're going to use this in a new tool.
2019-12-05 22:57:51 -08:00
Kartik Agaram eb6e4a1339 5785 - initial skeleton for parsing fn bodies
All tests passing again. We have big gaping holes for type- and var-management.
We're going to work on the latter first.
2019-11-30 14:16:05 -08:00
Kartik Agaram ab752bc9ca 5784
Lots of debugging to add two curly braces. I need tests for populate-mu-function-body,
or even parse-mu-block.
2019-11-30 12:28:19 -08:00
Kartik Agaram 931b17daa0 5782 - fix a widespread bug with Heap-size 2019-11-30 11:14:49 -08:00
Kartik Agaram 1d4e6a76ef 5781
parse-mu-stmt now working, though we'll need to go back and stop creating
a new var for every instance of a variable in a scope.
2019-11-30 01:26:55 -08:00
Kartik Agaram f6ff6005f7 5780 2019-11-29 15:35:28 -08:00