Commit Graph

73 Commits

Author SHA1 Message Date
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
Kartik Agaram a3443cac7d 5779
Snapshot with new skeleton for parsing function body.
New test still failing, but only in the one expected place.
2019-11-29 15:23:22 -08:00
Kartik Agaram 8d5437838b 5778 2019-11-29 01:27:39 -08:00
Kartik Agaram cc253a74a2 5777 2019-11-29 01:24:03 -08:00
Kartik Agaram 5da865c7fd 5776 2019-11-29 00:43:10 -08:00
Kartik Agaram 2bc11ffb97 5775 2019-11-29 00:31:29 -08:00
Kartik Agaram 65b26ea169 5774
Function headers seem to be parsing right.
2019-11-29 00:09:06 -08:00
Kartik Agaram 31ed455886 5773
Rudimentary support for parsing variable declarations.
2019-11-28 23:20:39 -08:00
Kartik Agaram 0c24aa334e 5772 2019-11-28 01:14:15 -08:00
Kartik Agaram 0546546c15 5770 2019-11-28 01:01:37 -08:00
Kartik Agaram 0d741834f3 5768 - start parsing fn headers 2019-11-27 19:14:42 -08:00
Kartik Agaram 703f6ab1ae 5767
Some groundwork for parsing.
2019-11-27 17:02:13 -08:00
Kartik Agaram 70187b1c01 5765
A couple more primitives now working. In the process I ran into an issue
with some buffer filling up when running ntranslate. Isolating it to survey.subx
was straightforward, but --trace ran out of RAM, and --trace --dump ran
out of (7GB of) disk. In the end what helped was just repeatedly inserting
exits at different points, and I realized there was a magic number that
hadn't been turned into a named constant.
2019-11-26 22:11:23 -08:00
Kartik Agaram b697b34318 5763 2019-11-26 18:07:55 -08:00
Kartik Agaram fee3e91d85 5762 2019-11-26 17:47:14 -08:00
Kartik Agaram 4d20c9ee94 5761 2019-11-26 17:41:25 -08:00
Kartik Agaram 28044a3bcb 5760 2019-11-25 21:07:30 -08:00
Kartik Agaram edce9c00ee 5759 - design statement data structure 2019-11-25 21:00:07 -08:00
Kartik Agaram 49ffb03084 5756 2019-11-18 17:36:59 -08:00
Kartik Agaram dd6c5fff9e 5755
Support function calls with literal arguments.
2019-11-18 17:29:50 -08:00
Kartik Agaram e9db8e1f25 5754
Support binary instructions with an immediate operand.
2019-11-18 16:30:30 -08:00
Kartik Agaram 442fdabe30 5752
Support binary operations with reg/mem and reg operands.

Everything is passing. However, the self-hosting translator now generates
some discrepancies compared to the C++ translator :(
2019-11-18 01:15:29 -08:00
Kartik Agaram 0ea0ebcf81 5751 - start of table of Mu primitives
So far this is just the same as our most recent tests. But now we have a
'DSL' for adding more primitives.
2019-11-18 00:24:24 -08:00
Kartik Agaram 3b40e3c331 5750
We can now compile primitive statements while selecting the right template
to code-gen each one from. Even when multiple templates have the same name.
2019-11-17 21:01:36 -08:00