David Given [Wed, 6 Feb 2019 10:50:05 +0000 (11:50 +0100)]
Run through clang-format before editing.
David Given [Wed, 6 Feb 2019 10:30:56 +0000 (11:30 +0100)]
Merge pull request #141 from davidgiven/dtrg-stray
Install the cpp.ansi man page.
David Given [Wed, 6 Feb 2019 07:43:16 +0000 (07:43 +0000)]
Merge pull request #140 from davidgiven/dtrg-arraysizes
CPM: Move the standard ret boilerplate into a helper procedure.
David Given [Wed, 6 Feb 2019 07:08:11 +0000 (08:08 +0100)]
Move the standard ret boilerplate into a helper procedure, to save a little
space.
David Given [Sat, 22 Dec 2018 22:47:49 +0000 (23:47 +0100)]
Install the cpp.ansi man page. #82.
David Given [Tue, 20 Nov 2018 09:52:44 +0000 (10:52 +0100)]
Merge pull request #136 from kernigh/kernigh-led-malloc
Fewer calls to brk() and sbrk()
George Koehler [Wed, 14 Nov 2018 21:13:54 +0000 (16:13 -0500)]
Remove code to calculate memory usage with sbrk().
In many systems, malloc() can allocate outside the brk area. The
calculation with sbrk() misses those allocations. When LLgen or ncgg
reported the memory usage, the value was probably too low.
George Koehler [Tue, 13 Nov 2018 23:05:16 +0000 (18:05 -0500)]
Switch led to malloc() and realloc().
Add USEMALLOC and enable it by default. You can switch back to brk()
by removing `#define USEMALLOC` in memory.c.
USEMALLOC tells the allocator to use malloc() and realloc(), not
brk(). This might help systems where brk() doesn't work, or where
malloc() can allocate outside the brk area.
My build shows no changes in share/ack/examples (except hilo_bas.*).
George Koehler [Tue, 13 Nov 2018 03:46:26 +0000 (22:46 -0500)]
Fix em_led -u name when memory allocator moves ALLOMODL.
Option -u was passing an offset from modulptr(0) in ALLOMODL to the
string in argv. If entername() would move ALLOMODL to make room in
ALLOGCHR, then the offset would become invalid, so the string would
get lost. This fix copies the string into ALLOMODL.
This was often not a problem because the initial size of ALLOGCHR in
mach.h is probably large enough for -u. This became a problem when I
caused the initial allocations to fail, and then only because the B
runtime uses -u.
George Koehler [Mon, 12 Nov 2018 03:51:17 +0000 (22:51 -0500)]
Switch from long to size_t when allocating memory.
Also move the declarations of `incore` and `core_alloc` to "memory.h".
Also correct SYMDEBUG to SYMDBUG. (I don't know if SYMDBUG works
because our build system never defines it.)
ind_t becomes an alias of size_t. ind_t becomes unsigned, so I edit
some code that was using negative ind_t. Some casts disappear, like
(long)sizeof(...) because the size is already a size_t. There are
changes to overflow checks. Callers with a size too big for size_t
must check it before calling the memory allocator. An overflow check
of BASE + incr in memory.c sbreak() now happens on all platforms, not
only when a pointer is smaller than a long.
My build shows no changes in share/ack/examples (except hilo_bas.*
changing with every build).
David Given [Mon, 5 Nov 2018 20:48:17 +0000 (21:48 +0100)]
Merge pull request #135 from kernigh/kernigh-mv-int
Move int to $(INSDIR)/bin/int
George Koehler [Mon, 5 Nov 2018 20:14:29 +0000 (15:14 -0500)]
Move int to $(INSDIR)/bin/int
If $(INSDIR)/bin is in PATH, then the user can run both ack(1) and
int(1), like
$ ack -mem22 -o prog prog.c
$ int prog
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