Commit graph

7876 commits

Author SHA1 Message Date
David Given 80bfbd17b7 Add missing file. 2019-02-07 23:01:10 +01:00
David Given 7473601172 Add the cpm emulator from Cowgol, modified to work with an 8080 emulator rather
than libz80ex; enable tests for cpm.
2019-02-07 22:39:57 +01:00
David Given a5bf2932c8 Add rst 1 to store frame variables. Reduces Star Trek from 42339 to 41821
bytes.
2019-02-07 09:31:38 +01:00
David Given 67a9be26d1 Fix warnings. 2019-02-07 09:09:31 +01:00
David Given 9d8ea79c7f rst 1 now takes an eight-bit parameter, not a 16 bit one. Reduces Star Trek
again from 43205 to 42339 bytes.
2019-02-07 08:45:20 +01:00
David Given 5ac280026e Experimentally use rst 1 to optimise frame variable loads. Reduces Star Trek
from 43892 to 43205 bytes.
2019-02-07 00:06:32 +01:00
David Given a6b8ae66d7
Merge pull request #144 from davidgiven/dtrg-arraysizes
i80: use a helper function for cai.
2019-02-06 21:31:29 +01:00
David Given 08b92153a0 Use a helper function for cai --- only saves two bytes per invocation, but is
much less embarassing.
2019-02-06 20:36:23 +01:00
David Given 3d5977b93b
Merge pull request #142 from davidgiven/dtrg-arraysizes
i80: factor out function prologue boilerplate
2019-02-06 16:15:53 +01:00
David Given 2b0629f87f Common out boilerplate function prologue code; shrinks Star Trek from 44256 to
43892 bytes.
2019-02-06 16:06:07 +01:00
David Given b77f616598 Run through clang-format before editing. 2019-02-06 11:50:05 +01:00
David Given 73fab341f5
Merge pull request #141 from davidgiven/dtrg-stray
Install the cpp.ansi man page.
2019-02-06 11:30:56 +01:00
David Given 7563ac46a7
Merge pull request #140 from davidgiven/dtrg-arraysizes
CPM: Move the standard ret boilerplate into a helper procedure.
2019-02-06 07:43:16 +00:00
David Given 02779325ab Move the standard ret boilerplate into a helper procedure, to save a little
space.
2019-02-06 08:08:11 +01:00
David Given 24ffbe086a Install the cpp.ansi man page. #82. 2018-12-22 23:47:49 +01:00
David Given 2e71c027a3
Merge pull request #136 from kernigh/kernigh-led-malloc
Fewer calls to brk() and sbrk()
2018-11-20 10:52:44 +01:00
George Koehler 33c0573598 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.
2018-11-14 16:13:54 -05:00
George Koehler 1c8434e33a 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.*).
2018-11-14 15:15:45 -05:00
George Koehler 4fdfa3177e 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.
2018-11-14 12:35:38 -05:00
George Koehler f09f14cd4d 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).
2018-11-14 12:33:25 -05:00
David Given c55ed2acfa
Merge pull request #135 from kernigh/kernigh-mv-int
Move int to $(INSDIR)/bin/int
2018-11-05 21:48:17 +01:00
George Koehler df855248a0 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
2018-11-05 15:14:29 -05:00
David Given 1b60af4f0b
Merge pull request #133 from davidgiven/dtrg-mips
Allow constants >INT_MAX in mcg
2018-09-22 17:30:52 +02:00
David Given ed91ea4371 When parsing constants which don't fit into an arith, handle overflow properly
(and don't turn them all into INT_MAX...).
2018-09-22 12:45:59 +02:00
David Given c6a1cf8de4
Merge pull request #132 from davidgiven/dtrg-mips
Teach mcg how to merge pushes
2018-09-22 11:04:13 +01:00
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