David Given [Sat, 22 Sep 2018 15:30:52 +0000 (17:30 +0200)]
Merge pull request #133 from davidgiven/dtrg-mips
Allow constants >INT_MAX in mcg
David Given [Sat, 22 Sep 2018 10:45:59 +0000 (12:45 +0200)]
When parsing constants which don't fit into an arith, handle overflow properly
(and don't turn them all into INT_MAX...).
David Given [Sat, 22 Sep 2018 10:04:13 +0000 (11:04 +0100)]
Merge pull request #132 from davidgiven/dtrg-mips
Teach mcg how to merge pushes
David Given [Sat, 22 Sep 2018 09:49:13 +0000 (11:49 +0200)]
Teach the code generator about the zero register and how to efficiently access
the stack.
David Given [Sat, 22 Sep 2018 09:19:50 +0000 (11:19 +0200)]
Take hreg aliases into account when finding evicted registers and performing
the register shuffle dance.
David Given [Sat, 22 Sep 2018 09:19:00 +0000 (11:19 +0200)]
Add the OPTIONS clause to the mcgg grammar; add an optional pass which converts
sequences of PUSHes to a single STACKADJUST followed by STOREs. This should
dramatically improve code on stack-unfriendly architectures like MIPS.
David Given [Thu, 20 Sep 2018 22:05:55 +0000 (23:05 +0100)]
Merge pull request #131 from davidgiven/dtrg-mips
Add an mcg-based MIPS code generator.
David Given [Thu, 20 Sep 2018 21:30:38 +0000 (23:30 +0200)]
Remove some old, hopefully unused PowerPC code. Teach the code generator about
non-volatile long registers.
David Given [Thu, 20 Sep 2018 21:24:46 +0000 (23:24 +0200)]
Fix subtle register corruption bug where aliases weren't taken into account
when assigning input registers to phis, which could cause the same hreg to be
assigned to two vregs of different types. Also improve tracing.
David Given [Wed, 19 Sep 2018 22:49:31 +0000 (00:49 +0200)]
Create correctly sized csa descriptors in the Basic compiler.
David Given [Wed, 19 Sep 2018 22:39:13 +0000 (00:39 +0200)]
A few more minor optimisations.
David Given [Wed, 19 Sep 2018 22:12:03 +0000 (00:12 +0200)]
The approach I was taking to csa and csb turns out not to work --- critical
edge splitting can cause new basic blocks to be added to the graph, but while
the graph itself gets properly rewritten the descriptor tables can't be updated
to take these into account, so they end up pointing at the wrong blocks. This
causes really hard-to-debug problems.
The new approach is to parse the descriptor blocks and then generate a
comparison chain. Brute force, but much easier for the compiler to reason
about.
David Given [Wed, 19 Sep 2018 22:06:26 +0000 (00:06 +0200)]
Fix incorrect ori encoding.
David Given [Tue, 18 Sep 2018 22:09:50 +0000 (00:09 +0200)]
Remember to save longs and doubles. Yikes.
David Given [Tue, 18 Sep 2018 21:49:31 +0000 (23:49 +0200)]
Updated READMEs with the MIPS platform.
David Given [Tue, 18 Sep 2018 21:39:04 +0000 (23:39 +0200)]
Make the MIPS boot code produce correct code.
David Given [Tue, 18 Sep 2018 21:38:37 +0000 (23:38 +0200)]
Loads and stores (except longs, which are difficult) are now loaded with two
instructions rather than three.
David Given [Tue, 18 Sep 2018 21:32:53 +0000 (23:32 +0200)]
Fixed some bad mcg ir code generation: only nodes which have been appendir'd
may be used multiple times.
David Given [Mon, 17 Sep 2018 22:19:40 +0000 (00:19 +0200)]
Add unsigned comparison rules.
David Given [Mon, 17 Sep 2018 21:59:49 +0000 (23:59 +0200)]
Add extern declaration which I forget to check in.
David Given [Mon, 17 Sep 2018 21:53:18 +0000 (23:53 +0200)]
Add specialist rules for signed integer comparisons; much better code.
David Given [Mon, 17 Sep 2018 18:34:38 +0000 (19:34 +0100)]
Array descriptor ranges are inclusive; adjust aar and the tests to check for
this. All the tests except rotate build now!
David Given [Mon, 17 Sep 2018 17:44:17 +0000 (18:44 +0100)]
Fix lar and sar, which were horribly, horribly broken. Add tests.
David Given [Mon, 17 Sep 2018 15:59:45 +0000 (16:59 +0100)]
Fix aar; add test.
David Given [Mon, 17 Sep 2018 14:03:44 +0000 (15:03 +0100)]
ACK loi 1 and sti 1 load and store unsigned bytes. I think.
David Given [Mon, 17 Sep 2018 12:13:39 +0000 (13:13 +0100)]
rotate() now generates valid code.
David Given [Mon, 17 Sep 2018 11:53:27 +0000 (12:53 +0100)]
Fix bls4.
David Given [Mon, 17 Sep 2018 11:42:10 +0000 (12:42 +0100)]
Added cms, and a test for it.
David Given [Mon, 17 Sep 2018 11:16:17 +0000 (12:16 +0100)]
Add hacky 64-bit comparisons (used by M2).
David Given [Mon, 17 Sep 2018 10:56:15 +0000 (11:56 +0100)]
Added a test for set. Fix mips set implementation.
David Given [Fri, 14 Sep 2018 13:13:35 +0000 (14:13 +0100)]
Set fixes; also add discrete tests for and, ior, xor.
David Given [Fri, 14 Sep 2018 11:48:43 +0000 (13:48 +0200)]
Make inn work; fix broken 64-bit loads and stores.
David Given [Fri, 14 Sep 2018 10:26:27 +0000 (12:26 +0200)]
Implement a working .trp.
David Given [Fri, 14 Sep 2018 09:30:15 +0000 (11:30 +0200)]
Remove la; turns out that the assembler gets upset if you ask it to
generate more than one fixup per instruction (I think).
David Given [Fri, 14 Sep 2018 07:28:35 +0000 (09:28 +0200)]
Clang-format before editing.
David Given [Thu, 13 Sep 2018 22:38:31 +0000 (00:38 +0200)]
Bugfix rck.
David Given [Thu, 13 Sep 2018 22:15:43 +0000 (00:15 +0200)]
Fix csa and csb.
David Given [Thu, 13 Sep 2018 22:04:25 +0000 (00:04 +0200)]
Make work with clang.
David Given [Wed, 12 Sep 2018 21:59:09 +0000 (23:59 +0200)]
Fix an incorrect instruction, and incredibly broken li handling.
David Given [Wed, 12 Sep 2018 21:58:48 +0000 (23:58 +0200)]
Converting floats and doubles to integers now works, as much as these ever do
on MIPS; turns out that it can't (or at least can't in qemu) reliably turn
INT_MIN from a double to an int.
David Given [Wed, 12 Sep 2018 21:19:32 +0000 (23:19 +0200)]
mcg now uses dataf4 and dataf8 to emit floating point constants, and so doesn't
need flt_arith any more. (And also generates them correctly on little-endian
systems.) as now parses numbers properly, doesn't trash memory all over the
place, and can handle negative numbers.
David Given [Wed, 12 Sep 2018 20:28:40 +0000 (22:28 +0200)]
Make sure li works properly when loading fixed up values which end up as 0. Use
lui rather than li to load high values.
David Given [Wed, 12 Sep 2018 20:27:39 +0000 (22:27 +0200)]
Adding new tokens to the assembler isn't quite as easy as I thought: ensure
that NUMBERF is stored properly in the temporary file.
David Given [Tue, 11 Sep 2018 21:17:09 +0000 (23:17 +0200)]
Values are more useful shown in hex.
David Given [Tue, 11 Sep 2018 21:16:50 +0000 (23:16 +0200)]
Fix an unsubtle bug where subtractions were done backwards...
David Given [Tue, 11 Sep 2018 21:16:30 +0000 (23:16 +0200)]
Fix a subtle thinko which was causing bits 2-3 of jump targets to be reset.
David Given [Mon, 10 Sep 2018 21:40:03 +0000 (23:40 +0200)]
Add huge numbers of failing tests.
David Given [Mon, 10 Sep 2018 21:37:28 +0000 (23:37 +0200)]
Add the bitset helpers. We now have enough helpers for the tests to run (and
massively fail).
David Given [Mon, 10 Sep 2018 21:37:04 +0000 (23:37 +0200)]
Do some cleanup; ha16[] and friends can now be used with li.
David Given [Mon, 10 Sep 2018 21:21:54 +0000 (23:21 +0200)]
Replaced some incorrect hi16s with ha16s.
David Given [Mon, 10 Sep 2018 21:20:52 +0000 (23:20 +0200)]
Added some more very untested helper functions.
David Given [Mon, 10 Sep 2018 20:56:18 +0000 (22:56 +0200)]
Add the .dataf4 and .dataf8 directives to the assembler --- manually converting
floats and doubles to bytes is not fun. It might even work!
David Given [Mon, 10 Sep 2018 20:55:05 +0000 (22:55 +0200)]
Ansify.
David Given [Mon, 10 Sep 2018 20:42:30 +0000 (22:42 +0200)]
Clang-format before editing.
David Given [Mon, 10 Sep 2018 20:37:04 +0000 (22:37 +0200)]
Clang-format before editing.
David Given [Mon, 10 Sep 2018 20:25:14 +0000 (22:25 +0200)]
Clang-format before editing.
David Given [Sun, 9 Sep 2018 23:08:25 +0000 (01:08 +0200)]
Lots more untested helper functions.
David Given [Sun, 9 Sep 2018 22:21:16 +0000 (00:21 +0200)]
Added some more incredibly untested helper functions.
David Given [Sun, 9 Sep 2018 16:58:07 +0000 (18:58 +0200)]
Merge from default.
David Given [Sun, 9 Sep 2018 16:57:44 +0000 (18:57 +0200)]
Thinko fix.
David Given [Sun, 9 Sep 2018 16:57:35 +0000 (18:57 +0200)]
Use the correct ELF processor flags; align properly.
David Given [Sun, 9 Sep 2018 16:57:12 +0000 (18:57 +0200)]
Call proper Linux system calls proper-like.
David Given [Sun, 9 Sep 2018 16:53:49 +0000 (18:53 +0200)]
Remember to preserve input registers if we're going to be reading from them
after writing to the output register.
David Given [Sun, 9 Sep 2018 16:51:00 +0000 (18:51 +0200)]
Call atexit handlers properly, avoiding a NPE and seg fault every time a
program exits.
David Given [Sun, 9 Sep 2018 16:25:00 +0000 (18:25 +0200)]
Yikes! Turns out that FPU registers are only 32 bits wide, and doubles are
stored in pairs, just like on the PowerPC!
David Given [Sun, 9 Sep 2018 12:29:34 +0000 (14:29 +0200)]
Allow the ELF processor flags to be set. Generate MIPS ELF executables, not
PowerPC ones.
David Given [Sun, 9 Sep 2018 12:11:11 +0000 (14:11 +0200)]
Rework relocations again: add RELO2HI and RELO2HISAD for the high two bytes of
a word.
David Given [Sun, 9 Sep 2018 10:24:22 +0000 (12:24 +0200)]
Fix some niggling issues --- we have our first binary now!
David Given [Sun, 9 Sep 2018 10:23:59 +0000 (12:23 +0200)]
Simplify MIPS relocations. Add RELS2 (for generic high-word relocations). Add
support for MIPS branch-and-jump relocations.
David Given [Sun, 9 Sep 2018 10:22:59 +0000 (12:22 +0200)]
Warning fix.
David Given [Sat, 8 Sep 2018 21:12:57 +0000 (23:12 +0200)]
Added some very untested csa and csb implementations, based on the PowerPC
ones.
David Given [Sat, 8 Sep 2018 20:42:06 +0000 (22:42 +0200)]
Added hi[] and lo[] functions to the assembler; fix things enough that we now
get to the point of failing to link programs.
David Given [Sat, 8 Sep 2018 20:06:38 +0000 (22:06 +0200)]
Rework floating point conversion. Bash enough of the table into workingness
that the libraries build now.
David Given [Sat, 8 Sep 2018 16:59:55 +0000 (18:59 +0200)]
Precisely one stack hreg gets allocated for each vreg/congruence group for
eviction; this prevents us from having to worry about moving values from stack
slot to stack slot, which is hard.
David Given [Wed, 5 Sep 2018 21:53:38 +0000 (23:53 +0200)]
MIPS appears to hate converting unsigneds to floats and vice versa.
David Given [Wed, 5 Sep 2018 21:53:08 +0000 (23:53 +0200)]
(Slightly) better errors on phi congruence group mismatches.
David Given [Tue, 4 Sep 2018 22:13:01 +0000 (00:13 +0200)]
We attempt to compile the first library function; we fail.
David Given [Tue, 4 Sep 2018 22:07:07 +0000 (00:07 +0200)]
Added library skeletons.
David Given [Tue, 4 Sep 2018 22:00:13 +0000 (00:00 +0200)]
Added a boot.o based on the PowerPC one.
David Given [Tue, 4 Sep 2018 21:55:28 +0000 (23:55 +0200)]
The examples all compile now (probably incorrectly, and the libc doesn't
compile yet).
David Given [Tue, 4 Sep 2018 21:43:24 +0000 (23:43 +0200)]
Lots of assembler and rule bugfixing.
David Given [Mon, 3 Sep 2018 20:47:41 +0000 (22:47 +0200)]
Added li and la instructions.
David Given [Mon, 3 Sep 2018 20:06:05 +0000 (22:06 +0200)]
Add in floating point support to the code generator.
David Given [Mon, 3 Sep 2018 20:03:57 +0000 (22:03 +0200)]
mcgg now checks that registers have at most one type attribute set.
David Given [Sun, 2 Sep 2018 19:36:09 +0000 (21:36 +0200)]
Add some painfully untested FPU instructions.
David Given [Sun, 2 Sep 2018 16:57:25 +0000 (18:57 +0200)]
The MIPS backend is still full of holes, and cut-and-pasted PowerPC code, but
is beginning to look like an actual code generator.
David Given [Sun, 2 Sep 2018 16:55:44 +0000 (18:55 +0200)]
Better error reporting for unterminated strings.
David Given [Sun, 2 Sep 2018 11:15:11 +0000 (13:15 +0200)]
Merge pull request #120 from davidgiven/dtrg-no
Remove the built-in preprocessor in cemcom.ansi
David Given [Sun, 2 Sep 2018 10:54:53 +0000 (12:54 +0200)]
Remove stray #include.
David Given [Sun, 2 Sep 2018 10:50:50 +0000 (12:50 +0200)]
Rip out the built-in preprocessor from cemcom.ansi, now it's no longer used.
David Given [Sun, 2 Sep 2018 10:39:00 +0000 (12:39 +0200)]
Disable the built-in preprocessor in cemcom.ansi; the external preprocessor is
always run. Fix a bug in block skipping in the preprocessor.
David Given [Sun, 2 Sep 2018 10:14:59 +0000 (12:14 +0200)]
Implement single-line C++-style comments.
Fixes: #118
David Given [Sun, 2 Sep 2018 10:04:33 +0000 (12:04 +0200)]
Run through clang-format before editing.
David Given [Sun, 2 Sep 2018 09:49:40 +0000 (11:49 +0200)]
Run through clang-format before editing.
David Given [Sun, 2 Sep 2018 09:36:15 +0000 (11:36 +0200)]
Run files through clang-format before editing.
David Given [Sun, 2 Sep 2018 09:30:20 +0000 (11:30 +0200)]
Convert CRLF into LF on read; this should avoid problems with parsing CRLF files.
Fixes #117.
David Given [Sun, 2 Sep 2018 09:16:06 +0000 (11:16 +0200)]
Run files through clang-format before editing.
David Given [Sat, 1 Sep 2018 17:35:31 +0000 (19:35 +0200)]
Add a completely non-tested table-based MIPS assembler.
David Given [Sat, 1 Sep 2018 13:34:36 +0000 (15:34 +0200)]
Merge.
David Given [Sat, 1 Sep 2018 13:34:01 +0000 (15:34 +0200)]
The default installation location should be /usr/local.