Commit graph

7901 commits

Author SHA1 Message Date
David Given 79e7636537 Teach the code generator about the zero register and how to efficiently access
the stack.
2018-09-22 11:49:13 +02:00
David Given 99fcde69dc Take hreg aliases into account when finding evicted registers and performing
the register shuffle dance.
2018-09-22 11:19:50 +02:00
David Given bbb708717a 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.
2018-09-22 11:19:00 +02:00
David Given 8fd3e1f5ce
Merge pull request #131 from davidgiven/dtrg-mips
Add an mcg-based MIPS code generator.
2018-09-20 23:05:55 +01:00
David Given 985d3dc7d1 Remove some old, hopefully unused PowerPC code. Teach the code generator about
non-volatile long registers.
2018-09-20 23:30:38 +02:00
David Given 65a20ce2d6 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.
2018-09-20 23:24:46 +02:00
David Given 436d50b54c Create correctly sized csa descriptors in the Basic compiler. 2018-09-20 00:49:31 +02:00
David Given cb20856aea A few more minor optimisations. 2018-09-20 00:39:13 +02:00
David Given ac856f3b09 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.
2018-09-20 00:12:03 +02:00
David Given ac921080b7 Fix incorrect ori encoding. 2018-09-20 00:06:26 +02:00
David Given 8fda024ec8 Remember to save longs and doubles. Yikes. 2018-09-19 00:09:50 +02:00
David Given 365c89c9e7 Updated READMEs with the MIPS platform. 2018-09-18 23:49:31 +02:00
David Given 9333b323a5 Make the MIPS boot code produce correct code. 2018-09-18 23:39:04 +02:00
David Given d23d2dd1b3 Loads and stores (except longs, which are difficult) are now loaded with two
instructions rather than three.
2018-09-18 23:38:37 +02:00
David Given 52ee317878 Fixed some bad mcg ir code generation: only nodes which have been appendir'd
may be used multiple times.
2018-09-18 23:32:53 +02:00
David Given 692caa2b0a Add unsigned comparison rules. 2018-09-18 00:19:40 +02:00
David Given f362d12dee Add extern declaration which I forget to check in. 2018-09-17 23:59:49 +02:00
David Given fe177bd688 Add specialist rules for signed integer comparisons; much better code. 2018-09-17 23:53:18 +02:00
David Given ec0891469f Array descriptor ranges are inclusive; adjust aar and the tests to check for
this. All the tests except rotate build now!
2018-09-17 19:34:38 +01:00
David Given f61500c51b Fix lar and sar, which were horribly, horribly broken. Add tests. 2018-09-17 18:44:17 +01:00
David Given abb7e3e105 Fix aar; add test. 2018-09-17 16:59:45 +01:00
David Given b665efca04 ACK loi 1 and sti 1 load and store unsigned bytes. I think. 2018-09-17 15:03:44 +01:00
David Given c2dc1e184e rotate() now generates valid code. 2018-09-17 13:13:39 +01:00
David Given 0202ac8700 Fix bls4. 2018-09-17 12:53:27 +01:00
David Given 1e073e944a Added cms, and a test for it. 2018-09-17 12:42:10 +01:00
David Given 0b65591972 Add hacky 64-bit comparisons (used by M2). 2018-09-17 12:16:17 +01:00
David Given 15ae171aef Added a test for set. Fix mips set implementation. 2018-09-17 11:56:15 +01:00
David Given 7efb749003 Set fixes; also add discrete tests for and, ior, xor. 2018-09-14 14:13:35 +01:00
David Given 08b1e8d71b Make inn work; fix broken 64-bit loads and stores. 2018-09-14 13:48:43 +02:00
David Given 5d0876a30b Implement a working .trp. 2018-09-14 12:26:27 +02:00
David Given ba0849c87c Remove la; turns out that the assembler gets upset if you ask it to
generate more than one fixup per instruction (I think).
2018-09-14 11:30:15 +02:00
David Given ac33bdd031 Clang-format before editing. 2018-09-14 09:28:35 +02:00
David Given c4e3d0903e Bugfix rck. 2018-09-14 00:38:31 +02:00
David Given 8c0b2f8aee Fix csa and csb. 2018-09-14 00:15:43 +02:00
David Given 9b0a1c1c10 Make work with clang. 2018-09-14 00:04:25 +02:00
David Given 57338b1991 Fix an incorrect instruction, and incredibly broken li handling. 2018-09-12 23:59:09 +02:00
David Given ecb3395aba 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.
2018-09-12 23:58:48 +02:00
David Given 642956fa2f 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.
2018-09-12 23:19:32 +02:00
David Given 8105281534 Make sure li works properly when loading fixed up values which end up as 0. Use
lui rather than li to load high values.
2018-09-12 22:28:40 +02:00
David Given a8df9721d3 Adding new tokens to the assembler isn't quite as easy as I thought: ensure
that NUMBERF is stored properly in the temporary file.
2018-09-12 22:27:39 +02:00
David Given 5264db860d Values are more useful shown in hex. 2018-09-11 23:17:09 +02:00
David Given 8379969b6f Fix an unsubtle bug where subtractions were done backwards... 2018-09-11 23:16:50 +02:00
David Given 8230ec42ac Fix a subtle thinko which was causing bits 2-3 of jump targets to be reset. 2018-09-11 23:16:30 +02:00
David Given b81e060372 Add huge numbers of failing tests. 2018-09-10 23:40:03 +02:00
David Given 0ce368324e Add the bitset helpers. We now have enough helpers for the tests to run (and
massively fail).
2018-09-10 23:37:28 +02:00
David Given 2f8fe3ce6e Do some cleanup; ha16[] and friends can now be used with li. 2018-09-10 23:37:04 +02:00
David Given 3122946a6f Replaced some incorrect hi16s with ha16s. 2018-09-10 23:21:54 +02:00
David Given 008737ed19 Added some more very untested helper functions. 2018-09-10 23:20:52 +02:00
David Given a1747ac916 Add the .dataf4 and .dataf8 directives to the assembler --- manually converting
floats and doubles to bytes is not fun. It might even work!
2018-09-10 22:56:18 +02:00
David Given 53f7de794a Ansify. 2018-09-10 22:55:05 +02:00