Commit graph

1883 commits

Author SHA1 Message Date
David Given d5a83fd73e Clean up the led includes. 2017-01-18 19:55:56 +01:00
David Given 01a61e0708 Apply kernigh@'s fix to broken symbol tables in aelflod (via mailing list patch):
---snip---
The ELF spec at http://www.sco.com/developers/gabi/ says, "In each
symbol table, all symbols with STB_LOCAL binding precede the weak and
global symbols," and that sh_info is the index of the first non-local
symbol.

I was mixing local and global symbols and setting sh_info to zero. I
also forgot to set the type of the .shstrtab section.
---snip---
2017-01-18 00:06:14 +01:00
David Given b63a4513d5 Add missing header. 2017-01-15 12:04:47 +01:00
David Given 9a346c382d Turns out Apple's hi16/ha16 exactly match my ha16/has16, so renamed
accordingly. (Memo to self: read the docs *before* doing the work.)
2017-01-15 11:59:33 +01:00
David Given f80acfe9f5 Signed vs unsigned lower halves of powerpc fixups are now handled by having two
assembler directives, ha16() and has16(), for the upper half; has16() applies
the sign adjustment. .powerpcfixup is now gone, as we generate the relocation
in ha*() instead. Add special logic to the linker for undoing and redoing the
sign adjustment when reading/writing fixups. Tests still pass.
2017-01-15 11:51:37 +01:00
David Given 14aab21204 Revert change; addis/ori requires different handling to addis/lwz due to ori's
payload being unsigned while lwz's payload is signed.
2017-01-15 10:31:20 +01:00
David Given 8edbff9795 Add assembler support for fixing up arbitrary oris/addi pairs of instructions;
this should allow oris/lwz constant value loads, which will save an opcode.
2017-01-15 00:15:01 +01:00
David Given 62022c6f6b Don't print source file names during compilation (gcc stopped doing it years
ago).
2017-01-08 00:16:35 +01:00
David Given 4b7fc5e233 Run through clang-format. 2017-01-08 00:15:23 +01:00
David Given cca6171e55 Properly install man pages. 2017-01-07 22:38:30 +01:00
David Given 72766a02de Fix typo in the descr file which was stopping -B from working. Add B
documentation to the ack man page.
2017-01-04 13:28:40 +00:00
David Given aeb9d4952d Added an abmodules tool which detects B modules and generates an initialiser
function for them (in C, unfortunately).
2017-01-03 18:54:13 +00:00
David Given 52f82a76b6 Don't crash when using the -u option to enter undefined symbols. 2016-12-28 23:49:55 +00:00
David Given e50f4be710 Merge from default. 2016-12-26 19:44:48 +00:00
George Koehler 7e39a821f4 Update aelflod.1 to describe options, mention symbol table. 2016-12-13 17:22:45 -05:00
George Koehler 5cf2a68438 Teach aelflod to write the ELF symbol table.
Convert each ack.out symbol to ELF, preserving its name and value, and
some but not all other symbol info.  The ELF symbol table comes with
ELF section headers.  If the input file has no symbols (ack -Rled-s),
then the output file has no ELF section headers.

Append the symbol table and section headers to the ELF file.  Linux
ignores this appended info when it execs the file.  The info might
pollute the last page of the ELF segment, but Linux clears this
pollution.  Tools like nm and gdb can read the ELF symbol table.

I include code to translate debugger symbols to an ELF .stab section.
I did not test this code, because I did not find a platform that can
put S_STB symbols in the ack.out file.
2016-12-13 16:41:22 -05:00
George Koehler 8280ca8745 In aslod, remove some unused m68k2 stuff. 2016-12-13 16:02:38 -05:00
George Koehler 2874806048 Tweak man syntax in aelflod.1 and aslod.1
Put end of sentence at end of line.  This is roff(7) syntax so the
formatter can make spacing between sentences.

Use the macro .PP to break paragraphs.  Use bold for the command name
in SYNOPSIS, to match other ack manuals.
2016-12-13 15:54:38 -05:00
David Given 3cce93586f Merge branch 'pr-osx' of https://github.com/kernigh/ack into kernigh-pr-osx 2016-12-05 20:14:54 +01:00
David Given 07e654d6e3 Merge from default. 2016-12-02 00:25:50 +01:00
David Given 8c99e2b7ad Run all tests, even the ones which fail, and emit a test summary right at the
end of the build (and fail then).
2016-12-01 23:03:30 +01:00
David Given b7de58e34e Fix signal unsafety in testdriver.c. 2016-12-01 22:05:22 +01:00
David Given 90547157b4 Merge from default. 2016-11-30 22:07:29 +01:00
David Given 8ce3382996 Merge from default. 2016-11-30 22:04:11 +01:00
David Given d94c326465 Merge pull request #18 from kernigh/pr-util-ack
util/ack: use DEFAULT_PLATFORM, allow non-ASCII filenames, other changes
2016-11-30 22:00:55 +01:00
George Koehler 8ef7c31089 Write a powerpc.descr for ego and use it with osxppc.
No change to linuxppc and qemuppc.  They continue to run ego without
any descr file.

I copied m68020.descr to powerpc.descr and changed some numbers.  My
numbers are guesses; I know little about PowerPC cycle counts, and
almost nothing about ego.  This powerpc.descr causes most of the
example programs to shrink in size (without descr -> with descr):

  65429 -> 57237  hilo_b.osxppc        -8192
  36516 -> 32420  hilo_c.osxppc        -4096
  55782 -> 51686  hilo_mod.osxppc      -4096
  20096 -> 20096  hilo_p.osxppc            0
   8813 ->  8813  mandelbrot_c.osxppc      0
  93355 -> 89259  paranoia_c.osxppc    -4096
  92751 -> 84559  startrek_c.osxppc    -8192

(Each file has 2 Mach segments, then a symbol table.  Each segment
takes a multiple of 4096 bytes.  When the code shrinks, we lose a
multiple of 4096 bytes.)

I used "ack -mosxppc -O6 -c.so" to examine the assembly code for
hilo.mod and mandelbrot.c, both without and with descr.  This reveals
optimizations made only with descr, from 2 ego phases: SP (stack
pollution) and RA (register allocation).  In hilo.mod, SP deletes some
instructions that remove items from the stack.  These items get
removed when the function returns.  In both hilo.mod and mandelbrot.c,
RA moves some values into local variables, so ncg can make them into
register variables.  This shrinks code size, probably because register
variables get preserved across function calls.  More values stay in
registers, and ncg emits shorter code.

I believe that the ego descr file uses (time,space) tuples but the ncg
table uses (space,time) tuples.  This is confusing.  Perhaps I am
wrong, and some or all tuples are backwards.  My time values are the
cycle counts in latency from the MPC7450 Reference Manual (but not
including complications like "store serialization").

In powerpc.descr, I give the cost for saving and restoring registers
as if I was using chains of stw and lwz instructions.  Actually ncg
uses single stmw and lmw instructions with at least 2 instructions.
The (time,space) for stmw and lmw would be much less than the
(time,space) for chains of stw and lwz.  But this ignores the pipeline
of the MPC7450.  The chains of stw and lwz may run faster than stmw
and lmw in the pipeline, because the throughput may be better than the
latency.  By using the wrong values for (time,space), I'm trying to
tell ego that stmw and lmw are not better than chains of stw and lwz.
2016-11-30 15:29:19 -05:00
David Given 960584c0f3 Replace the hacky and broken pipeline in testdriver.sh with a custom-written
tool in C; much more robust and easier to understand, as well as avoiding the
dependency on timeout (which isn't Posix).
2016-11-29 20:59:43 +01:00
George Koehler ecdfb61c9d Merge branch 'default' into kernigh-osx
This brings in David Given's PowerPC changes, including the addition
of the modern code generator (mcg) for PowerPC.

Resolve minor conflicts in top build.lua and util/led/main.c
2016-11-28 16:20:56 -05:00
David Given 5bce5fc4da Change the extension used by Basic files for .b to .bas, to avoid conflicts
with B.
2016-11-27 20:38:33 +01:00
David Given 3e69d1185a Fix a whole lot more stray prototypes. 2016-11-24 21:47:40 +01:00
David Given 7435c06ff4 Non-standard stdlib prototypes are not our friend (and not OSX's friend, which
implements strcpy() &co as macros).
2016-11-24 20:48:51 +01:00
George Koehler 88c2ea63aa Use uint32_t in util/led/main.c
This uses uint32_t for the base, file offset, and alignment of each
section, to be consistent with the usage of uint32_t in h/out.h

Also declare setbit() as static.
2016-11-20 11:38:16 -05:00
David Given d5328492d7 Better handling of float conversions; more tests; converting to unsigned ints
works now.
2016-11-20 11:27:40 +01:00
David Given d31bc6a3f9 Made csa and csb work with mcg; adjust the libem functions and the
corresponding invocation in the ncg table so the same helpers can be used for
both mcg and ncg. Add a new IR opcode, FARJUMP, which jumps to a helper
function but saves volatile registers.
2016-11-19 10:55:41 +01:00
George Koehler 486c516242 Stop trying to remove core dumps.
unlink("core") doesn't work with OpenBSD, where core dumps have names
like "ncg.core".  Users who don't want core dumps can turn them off
with "ulimit -c 0" in sh(1).  Then the system doesn't write a core
dump.  That's better than writing core then unlinking it.
2016-11-15 11:58:13 -05:00
George Koehler 07b04c64c8 Let ack(1) compile files with non-ASCII names.
This commit changes how ack(1) parses backslashes in its descr files.
Before this commit, ack set the high bit of each character escaped by
a backslash, and later cleared all high bits in command arguments, but
this lost the high bits in non-ASCII filenames.  After this commit,
ack keeps backslashes in strings while processing them.  Functions
scanvars(), scanexpr(), doassign(), unravel(), addargs() now
understand backslashes.  I remove from ack_basename() the warning
about non-ASCII characters.

This commit makes some incompatible changes for backslashes in descr
files.  None of our descr files uses backslashes, except for those
backslashes that continue lines, and there are no changes for those
backslashes.  The problem with non-ASCII filenames had its cause in a
feature that we weren't using.

With this commit, ack now understands backslashes after the = sign in
both "var NAME=value" and "mapflag -flag NAME=value".  Before, ack
never scanned backslashes in "var" lines, so "var A=\{B}" failed to
prevent expansion of B.  Now it does.  Before, ack did scan for
backslashes in the "-flag NAME=" part of "mapflag" lines.  Now it
doesn't, so it is no longer possible to map a flag that contains a
literal space, tab, or star "*".

I removed the expansion of "{{" to "{".  One can use "\{" for a
literal "{", and "\{" now works in "var" lines.  Before and now, ack
never expanded "{" in flags for "mapflag", so the correct way to map a
literal flag "-{" remains "mapflag -{ ...", not "mapflag -{{ ...".
(The other way "mapflag -\{ ..." stops working with this commit.)

Backslashes in strange places, like "{NA\ME}", probably have different
behavior now.

Backslashes in "program" lines now work.  Before, ack scanned for
backslashes there but forgot to clear the high bits later.

Escaping < or > as \< or \> now works, and prevents substitution of
the input or output file paths.  Before, ack only expanded the first <
or > in each argument.  Now, it expands every unescaped < or > in an
argument, but this is an accident of how I rewrote the code.  I don't
suggest to put more than one each of < or > in a command.  The code no
longer optimizes away its recursive calls when the argument is "<".

The code continues to set or clear the high bit NO_SCAN on the first
characters of flags.  This doesn't seem to be a problem, because flags
usually begin with an ASCII hyphen '-'.
2016-11-15 11:33:35 -05:00
David Given 408b69b17d aelflod and aslod now default to not showing the memory dump. 2016-11-13 20:50:23 +01:00
George Koehler fafc8a0b8a Don't retry fork() in a loop.
If fork() fails, then report a fatal error.  Don't spin the cpu
retrying fork() until it succeeds.  It can fail when we reach a limit
on the number of processes.  Spinning on the cpu would slow down other
processes when we want them to exit.  This would get bad if we had a
parallel build with multiple ack processes spinning.
2016-11-13 12:45:01 -05:00
George Koehler e617f42503 Don't print a string after possibly freeing it.
new= newvar(name) takes ownership of the string and might free its
memory.  Don't print name.  Do print new->v_name.

Also #include <string.h> for strcmp().
2016-11-13 12:02:35 -05:00
George Koehler 65278bc9a9 In util/ack, add prototypes and static to functions.
Declare most functions before using them.  I declare some functions in
ack.h and some in trans.h (because trans.h declares type trf).  I
leave declarations of scanb() and scanvars() in .c files because they
need type growstring.  (I can't #include "grows.h" in another header
file as long as grows.h doesn't guard against multiple inclusion.)

Functions used within one file become static.  I remove a few tiny
functions.  I move a few functions or declarations to more convenient
places.  Some functions now return void instead of a garbage int.

I feel that keyword "register" is obsolete, so I removed it from where
I was editing.  This commit doesn't touch mktables.c
2016-11-12 21:12:45 -05:00
George Koehler 7b3f870f63 Don't build mktables.c in the ack binary.
It only worked by accident because main() in main.c was found before
main() in mktables.c.

Also add build dependencies on the local *.h files.
2016-11-11 17:06:25 -05:00
David Given 84ee75ec07 Merge from default. 2016-11-11 20:17:54 +01:00
David Given d82df74a7a Rename addr_t to address_t to avoid clashes with the system addr_t. 2016-11-11 20:17:10 +01:00
David Given fd91851005 Add enough return types to the K&R C that the ACK builds (on Linux) using clang
now.
2016-11-10 22:04:18 +01:00
David Given a8c4dac67c Merge from default (merging in George Koehler's PowerPC changes). 2016-10-29 22:40:40 +02:00
David Given a311e61360 Add support for preserved registers. 2016-10-29 20:22:44 +02:00
David Given 61349389fb More opcodes. sti can now cope with non-standard sizes (really need a better
fix for this). Hack in crude support for mismatched stack pushes and pops (ints
vs longs).
2016-10-29 12:48:05 +02:00
David Given 2cc2c0ae98 Lots more opcodes. Rearrange the stack layout so that fp->ab is a fixed value
(needed for CHAINFP and FPTOAB). Wire up lfrs to calls via a phi when
necessary, to allow call-bra-lfr chains.
2016-10-29 11:57:56 +02:00
David Given 9977ce841a Remove the bytes1, bytes2, bytes4, bytes8 attributes; remove the concept of a
register 'type'; now use int/float/long/double throughout to identify
registers. Lots of register allocator tweaks and table bugfixes --- we now get
through the dreading Mathlib.mod!
2016-10-25 23:04:20 +02:00
David Given abd0cedd61 Massive change to how IR types are handled; we use the type code for matching
rather than the size. Much cleaner and simpler.
2016-10-23 21:54:14 +02:00
David Given b1a3d76d6f Re-re-add the type inference layer, now I know more about how things work.
Remove that terrible float promotion code.
2016-10-22 23:04:13 +02:00
David Given 11b0bc1055 More opcodes. 2016-10-22 20:32:51 +02:00
David Given 2d52b1fdaa Remove GETRET; values are now returned directly by CALL. Fix a bug in
convertstackops which was resulting in duplicate IR groups.
2016-10-22 12:13:57 +02:00
David Given ceb938fb3c More opcodes. 2016-10-22 11:26:28 +02:00
David Given 7ae888b754 Hacky workaround the way the Modula-2 compiler generates non-standard sized
loads and saves. More opcodes; simplified table using macros.
2016-10-22 10:48:22 +02:00
David Given f851ab83af Better (and more correct) floating point conversions; fif; various new opcodes. 2016-10-22 00:48:26 +02:00
David Given 4db402f229 Add (pretty crummy) support for register aliases and static pairs of registers.
We should have enough functionality now for rather buggy 8-bit ints and
doubles. Rework the table and the platform.c to match.
2016-10-21 23:31:00 +02:00
David Given d6984d60ac Add parsing support for register aliases. 2016-10-20 21:47:28 +02:00
David Given e4fec71f9c Lots more opcodes; better eviction behaviour; better register moves. Lots more
PowerPC stuff (some working).
2016-10-19 23:29:05 +02:00
David Given d539389e81 Merge in the unfinished PowerPC branch. 2016-10-16 22:38:27 +02:00
David Given 6a06ce798b Add missing header that was causing builds to fail on Travis. 2016-10-16 17:58:01 +02:00
David Given 9504aec2bd Function termination gets routed through an exit block; we now have prologues
and epilogues. mcgg now exports some useful data as headers. Start factoring
out some of the architecture-specific bits into an architecture-specific file.
2016-10-15 18:38:46 +02:00
David Given 5ad3aa8595 Add a pile of new instructions used by Pascal; I'm going to need to think about
how locals and the local base are handled.
2016-10-15 13:07:59 +02:00
David Given 517120d0fb Allow asm names for registers which are different from the friendly names shown
in the tracing (because PowerPC register names are just numbers).
2016-10-15 11:42:47 +02:00
David Given bb17aea73a You can now mark a register as corrupting a certain register class; calls work,
or at least look like they work. The bad news is that the register allocator
has a rare talent for putting things in the wrong register.
2016-10-15 01:15:08 +02:00
David Given 98fe70a7de Output register equality constraints work. 2016-10-14 22:17:02 +02:00
David Given f06b51c981 Keep track of register types as well as attributes --- the type being how we
find new registers when evicting values. Input constraints work (they were
being ignored before). Various bug fixing so they actually work.
2016-10-12 22:58:46 +02:00
David Given 23c3575f0f The register allocator now makes a spirited attempt to honour register
attributes when allocating. Unfortunately, backward edges don't work (because
the limited def-use chain stuff doesn't work across basic blocks). Needs more
thought.
2016-10-09 15:09:34 +02:00
David Given cfe5312fcc Predicates can now take numeric arguments. The PowerPC predicates have been
turned into generic ones (as they'll be useful everywhere). Node arguments for
predicates require the '%' prefix for consistency. Hex numbers are permitted.
2016-10-09 12:32:36 +02:00
David Given 2198db69b1 Instruction predicates work now. 2016-10-08 11:35:33 +02:00
George Koehler 65c2a8a0ae Remove stackadjust and stackoffset() from ncg.
This feature has never been used since its introduction, more than 3
years ago, in David Given's commit c93cb69 of May 8, 2013.  The commit
was for "PowerPC and M68K work".  I am not undoing the entire commit.
I am only removing the stackadjust and stackoffset() feature.

This commit removes the feature from my branch kernigh-linuxppc.  This
removal includes the mach/proto/ncg parts.  The default branch already
removed most of the feature, but kept the mach/proto/ncg parts.  That
removal happened in commit 81778b6 of May 13, 2013 (which was a merge;
git diff af0dede 81778b6).  The branch dtrg-experimental-powerpc
merged the default branch but without the removal.  That merge was
commit 4703db0f of Sep 15, 2016 (git diff 8c94b13 4703db0).  My branch
kernigh-linuxppc is off branch dtrg-experimental-powerpc, so I can no
longer get the removal by merging default.

David Given described the stackadjust feature in
  https://sourceforge.net/p/tack/mailman/message/30814691/

The instruction stackadjust would add a value to the offset, and the
function stackoffset() would return this offset.  One would use this
to track sp - fp, then omit the frame pointer by not keeping fp in a
register.
2016-10-07 20:52:13 -04:00
David Given 7f901aa4d0 We're not using 'allocates' any more; clean up. 2016-10-06 21:33:43 +02:00
David Given 88fb231d6e Better constraint syntax; mcgg now passes register usage information up to mcg;
mcg can track individual hop inputs and outputs (needed for live range
analysis!); the register allocator now puts the basic blocks into the right
order in preparation for live range analysis.
2016-10-05 22:56:25 +02:00
David Given 92502901a7 Better management of register data. Add struct hreg. 2016-10-05 21:00:28 +02:00
David Given 8d4186130d Oops --- hadn't updated the nts array for the new child order. 2016-10-04 21:32:28 +02:00
David Given bd28bddb92 Massive rewrite of how emitters and the instruction selector works, after I
realised that the existing approach wasn't working. Now, hopefully, tracks the
instruction trees generated during selection properly.
2016-10-04 00:16:06 +02:00
David Given 68f98cbad7 Instruction selection now happens on a shadow tree, rather than on the IR tree
itself. Currently it's semantically the same but the implementation is cleaner.
2016-10-03 20:52:36 +02:00
David Given 288ee56203 Get quite a long way towards basic output-register equality constraints (needed
to make special nodes like NOP work properly). Realise that the way I'm dealing
with the instruction selector is all wrong; I need to physically copy chunks of
tree to give to burg (so I can terminate them correctly).
2016-10-02 23:25:54 +02:00
David Given 3aa30e50d1 Come up with a syntax for register constraints. 2016-10-02 21:51:25 +02:00
David Given c079e97492 Perform SSA conversion of locals. Much, *much* better code now, at least
inasmuch as it looks better before register allocation. Basic blocks now know
their own successors and predecessors (after a certain point in the IR
processing).
2016-10-02 17:50:34 +02:00
David Given 21898f784a We're going to need some type inference after all, I think. Let's do a little
for now and see how it goes.
2016-10-01 19:10:22 +02:00
David Given 91e277e046 Predicates work; we now have prefers and requires clauses. Predicates must be
functions. Not convinced that semantic types are actually working --- there are
still problems with earlier statements leaving things in the wrong registers.
2016-10-01 13:56:52 +02:00
David Given 4a3a9a98dc It doesn't really make a lot of sense to have BURG nonterminal names different
to register classes, so combine them. Refactor the map code.
2016-10-01 12:17:14 +02:00
David Given 3a973a19f3 Move fatal(), warning() and aprintf() into the new data module (because they're
really useful).
2016-09-30 19:10:30 +02:00
David Given b32883b013 More properly keep track of register classes. 2016-09-29 22:32:43 +02:00
David Given b27758b7de Error check fragment rules which don't emit anything. 2016-09-29 22:14:11 +02:00
David Given 0d246c0d73 Much better handling of fragments (no run-time code needed to distinguish them
from registers) and better handling of individual hops within a paragraph ---
no more ghastly hacks to try and distinguish the input from the output.
2016-09-29 22:06:04 +02:00
David Given a0131fdb47 You know what, the type inference stuff is a complete red herring. What this
actually needs is a more intelligent register allocator. So, remove the type
inference.
2016-09-29 19:58:02 +02:00
David Given cc176e5183 Keep more data around about ir instructions. Implement a half-baked type
inference routine to propagate information about floats up the tree, so we know
whether to put floats into special registers as early as possible.
2016-09-26 22:12:46 +02:00
David Given 416b13fd76 Start factoring out the hardware op code. 2016-09-25 23:29:59 +02:00
David Given 39aa672422 Sort of keep track of registers and register classes. Start walking the
generated instruction tree --- holy cow, they look like instructions!
2016-09-25 22:17:14 +02:00
David Given bde5792b1a Collapse several rule arrays into one; actually generate the array properly. 2016-09-25 17:14:54 +02:00
David Given bcc74ba18d Stupid stringlist is stupid. Use a proper data structure, properly abstracted
out (so other things can use it).
2016-09-25 12:18:39 +02:00
David Given 9f78e0b36b Rethink the way patterns are mapped to rules; generate emitters (probably
badly).
2016-09-25 11:49:51 +02:00
David Given 7c028bdd45 We now record the code fragments to be emitted by each rule. 2016-09-25 00:21:46 +02:00
David Given 629e0ddfc6 Some instruction selection is now happening. 2016-09-24 22:46:08 +02:00
David Given c8fcbe282a More grammar changes. 2016-09-24 19:03:55 +02:00
David Given 2acc4ed29d IR codes are now owned by mcgg; ir terminals are inserted into the table during
compilation (so you can refer to them).
2016-09-24 18:31:35 +02:00
David Given 1516657907 Crudely bolt on mcgg to mcg itself. 2016-09-24 17:20:40 +02:00
David Given 13132128a1 Parameters are parsed with getopt. Simplify, constify. 2016-09-24 16:59:49 +02:00
David Given 434eafd35d Change the predicate stuff to use costs instead; now you can use when clauses
on leaves. Remove an iburg premature optimisation (required for above).
2016-09-24 13:33:59 +02:00
David Given d96ceea08a Lots of exploratory new grammar for instruction definitions and string and
fragment emission (none of which is hooked up to anything yet).
2016-09-24 13:08:17 +02:00
David Given 960259f0b0 Add support for labelled tree nodes. 2016-09-24 12:11:30 +02:00
David Given 4546dd5f22 Massive grammar overhaul and refactor. Hacked in support for predicates, where
instructions can be turned on and off based on their parameters. New lexer
using a lexer. Now quite a lot of the way towards being a real instruction
selector.
2016-09-21 00:43:10 +02:00
David Given 2183c6c622 Run through clang-format. 2016-09-20 21:00:16 +02:00
David Given 03b7202e54 Strip out surplus files. Rewrite README. 2016-09-20 20:46:45 +02:00
David Given 5cb3fbb3d3 Import iburg. 2016-09-20 20:44:51 +02:00
David Given 13c117d15d Import iburg. 2016-09-20 20:37:16 +02:00
George Koehler 9db305b338 Enable the Hall check again, and get powerpc to pass it.
Upon enabling the check, mach/powerpc/ncg/table fails to build as ncgg
gives many errors of "Previous rule impossible on empty stack".  David
Given reported this problem in 2013:
  https://sourceforge.net/p/tack/mailman/message/30814694/

Commit c93cb69 commented out the error in util/ncgg/cgg.y to disable
the Hall check.  This commit enables it again.  In ncgg, the Hall
check is checking that a rule is possible with an empty fake stack.
It would be possible if ncg can coerce the values from the real stack
to the fake stack.  The powerpc table defined coercions from STACK to
{FS, %a} and {FD, %a}, but the Hall check didn't understand the
coercions and rejected each rule "with FS" or "with FD".

This commit removes the FS and FD tokens and adds a new group of FSREG
registers for single-precision floats, while keeping FREG registers
for double precision.  The registers overlap, with each FSREG
containing one FREG, because it is the same register in PowerPC
hardware.  FS tokens become FSREG registers and FD tokens become FREG
registers.  The Hall check understands the coercions from STACK to
FSREG and FREG.  The idea to define separate but overlapping registers
comes from the PDP-11 table (mach/pdp/ncg/table).

This commit also removes F0 from the FREG group.  This is my attempt
to keep F0 off the fake stack, because one of the stacking rules uses
F0 as a scratch register (FSCRATCH).
2016-09-18 15:08:55 -04:00
George Koehler 9ec2918e14 In ncgg, increase MAXREGS from 80 to 200.
I need this to add more registers to powerpc.
2016-09-18 14:37:42 -04:00
George Koehler ff4a7e3d2a Merge branch 'default' into kernigh-linuxppc 2016-09-17 18:15:54 -04:00
David Given 80cb6ba927 Eliminate the RELOH2 relocation, as it never worked --- the address would be
calculated incorrectly because of overflow errors.

Replace it with an extended RELOPPC relocation which understands addis/ori
pairs; add an la pseudoop to the assembler which generates these and the
appropriate relocation. Make good.

--HG--
branch : dtrg-experimental-powerpc-branch
2016-09-17 12:43:15 +02:00
David Given 4703db0fff Merge from default.
--HG--
branch : dtrg-experimental-powerpc-branch
2016-09-15 22:59:01 +02:00
George Koehler b1d1b5e1f8 Fix bugs with memory allocation in ego.
cf/cf_loop.c and share/put.c tried to read the next pointer in an
element of a linked list after freeing the element.  ud/ud_copy.c
tried to read beyond the end of the _defs_ array: it only has
_nrexpldefs_ elements, not _nrdefs_ elements.

These bugs caused core dumps on OpenBSD.  Its malloc() put _defs_ near
the end of a page, so reading beyond the end crossed into an unmapped
page.  Its free() wrote junk bytes and changed the next pointer to
0xdfdfdfdfdfdfdfdf.
2016-09-09 23:37:43 -04:00
David Given f67c98e239 Distributions are a pain --- let's not bother any more. Instead, we just tag
the repository and download a complete snapshot, old and ancient stuff and all.
2016-09-02 23:00:38 +02:00
David Given 612e38f1c6 Remove the old make-based build system, plus some big chunks of horribly
obsolete protomake build system.
2016-09-02 22:17:51 +02:00
David Given 2b6d251dec Fix a fun bug where, every now again, ego would get its temporary files mangled
and generate invalid calls to the optimisers.

Previously ego would generate a temporary file template that looked like
/tmp/ego.A.BB.XXXXXX, call mktemp() on it to randomise the XXXXXX, and then
replace A and BB with data.

However, it used strrchr to find the A and B. Which would fine, except when
mktemp produced an A or a B in the randomised part...

This code was written on 4 March 1991. I was 16.
2016-08-22 23:53:01 +02:00
David Given 2a95b1c5e3 Forgot to check a file in. 2016-08-22 22:45:32 +02:00
David Given 5bae29a00c ego now builds and is used.
This needed lots of refactoring to ego --- not all platforms have ego descr
files, and ego will just crash if you invoke it without one. I think originally
it was never intended that these platforms would be used at -O2 or above.

Plats now only specify the ego descr file if they have one.
2016-08-21 22:01:19 +02:00
David Given 84ee7c9cc4 Fix linking bug where em_decode would generate binary data instead of text. 2016-08-21 20:27:52 +02:00
David Given 2b2bd93e44 Run through clang-format. 2016-08-21 20:08:05 +02:00
David Given 44b6421519 Run through clang-format. 2016-08-21 19:53:14 +02:00
David Given 671bf250f5 Run through clang-format. 2016-08-21 19:46:19 +02:00
David Given 918f300513 Run through clang-format. 2016-08-21 19:38:54 +02:00
David Given 1b66b63eae Run through clang-format. 2016-08-21 19:38:02 +02:00
David Given 3584ddb6e9 Push through clang-format. 2016-08-21 19:34:54 +02:00
David Given a4f136f999 Run through clang-format. 2016-08-21 18:51:36 +02:00
David Given 03a0b182c4 Push em_ego.c through clang-format before working on it. 2016-08-21 18:45:25 +02:00
David Given 53c9731036 aal doesn't build the ranlib table if you don't set -DAAL. 2016-08-20 14:04:46 +02:00
David Given f561b94b49 Print hex numbers actually properly this time. 2016-08-20 14:02:12 +02:00
David Given 7b8d9e2d0e Fix compiler warnings and 64bitisms. 2016-08-14 23:01:12 +02:00
David Given a42939df50 LED builds now. 2016-08-14 14:40:01 +02:00
David Given 4d24666432 Move util/data into modules/src/em_data, for consistency with the other
modules.
2016-08-14 14:09:38 +02:00
David Given 262c5fedcf Biggish refactor to break cycles; my build rules were full of them. cpm builds,
which requires top and topgen.
2016-08-14 01:39:40 +02:00
David Given 0d77cb8279 We can build our first C file. 2016-08-07 21:56:53 +02:00
David Given 5e84be70fd Massive ackbuilder refactor --- cleaner and more expressive. Lists
are automatically flattened (leading to better build files), and the
list and filename functions are vastly more orthogonal.
2016-08-04 23:51:19 +02:00
David Given b2bb4ce3b2 Builds libend (the simplest library). Becoming obvious I need to rework the way
ackbuilder deals with lists.
2016-07-30 00:39:22 +02:00
David Given 363d13cc2f C preprocessor; tabgen; now the pc86 boot.s builds using the ack
toolchain.
2016-07-29 00:22:49 +02:00
David Given f9c77fca03 Replace the hacky cflags variable with an equally hacky but vastly
more useful magic vars variable.
2016-07-27 00:10:15 +02:00
David Given cdeea836f2 Replaced the fairly complex environment code with a much simpler
emitter object.
2016-07-26 23:43:31 +02:00
David Given a8a9d1bbfa yacc, ncgg; platform ncg builds now. 2016-07-26 23:35:30 +02:00
David Given bff5c4019c Baby steps towards building a platform --- make the assembler work.
Add ackbuilder support for C preprocessor files and yacc.
2016-07-24 00:50:02 +02:00
David Given 2770a83837 More programs, more libraries. src/modules build files are now saner. 2016-07-23 00:30:31 +02:00
David Given 1fdc69fb97 cemcom.ansi now builds. 2016-07-19 23:43:14 +02:00
David Given 2d2497c318 ackbuilder rules files now require absolute paths in external variables
(otherwise commands which change directory don't work).
2016-07-18 23:16:27 +02:00
David Given bcf3408e36 More stuff builds; almost the C compiler now. 2016-07-14 23:54:13 +02:00
David Given d805052205 All the amisc binaries now build. 2016-06-19 09:32:45 +02:00
David Given 2af8568cc3 First draft at installables; not very satisfactory. make bugs with multiple
output targets and parallelism?
2016-06-16 05:26:44 +02:00
David Given 09554cb324 installable works, although it's a bit kludgy. Change the : separator to +
because : is special in make and non of the others I could think of would work.
2016-06-14 07:34:14 +02:00
David Given 605651776e We can build a real program now! 2016-06-12 20:59:43 +02:00
David Given 88bd7ce126 Remove defunct pmfiles.
--HG--
branch : default-branch
2016-06-03 13:56:50 +02:00
David Given ef8e6e25e0 Fix a whole pile of issues related to the failed attempt to increase
the number of types of relocation possible in the object file. (Now,
hopefully, working.)

Also change the object serialiser/deserialiser to never try to read or
write raw structures; it's way safer this way and we don't need the
performance boost any more.

--HG--
branch : default-branch
2016-03-18 21:46:55 +01:00
David Given fd7e9f9046 Fix an insidious 64-bitness bug which was causing incorrectly optimised code.
--HG--
branch : default-branch
2016-03-17 22:30:24 +01:00
David Given 7e964dd25e Raise the limit on ack.out relocation types by making the size of a
relocation structure bigger. Bump ack.out magic number.

--HG--
branch : default-branch
2016-03-14 21:08:55 +01:00
David Given ff0c78cc78 Merge from default.
--HG--
branch : dtrg-videocore-branch-branch
2016-03-13 21:13:09 +01:00
David Given 44b5d01525 Merge.
--HG--
rename : util/ncgg/build.mk => util/cgg/build.mk
2015-03-23 00:14:10 +01:00
David Given b146d2641c Fix a slightly mysterious dependency issue. 2015-03-23 00:09:41 +01:00
David Given 98ea849d03 Improve flex correctness. 2015-03-23 00:09:27 +01:00
David Given 9f23fbbe6a Allow machines to use cg if they wish.
--HG--
rename : mach/proto/ncg/build.mk => mach/proto/cg/build.mk
rename : util/ncgg/build.mk => util/cgg/build.mk
2015-03-23 00:08:51 +01:00
David Given 3d5e72e20b Newer versions of GNU Make have a new function which collides with a
variable we're using; change the name of the variable.
2015-03-22 12:09:46 +01:00
David Given 2271bcd0a7 Fixed a parallel build race condition (forgot to declare a dependency to
the makefile).
2014-11-09 18:47:51 +01:00
David Given 6a340ea1bd Remove regrettable comment. 2014-08-31 13:40:39 +02:00
David Given d3e3e72860 Update from trunk.
--HG--
branch : dtrg-videocore
2013-05-29 15:03:48 +01:00
David Given 6fff2d45fe Attempt to fix 64-bitness error in ashow. Deprecate the structure format macros in h/out.h because they make no sense on 64-bit platforms. 2013-05-29 14:48:51 +01:00
David Given 5e9102955c Reworked VC4 relocations and some of the instruction encoding to be actually correct. Now generating what could be real code!
--HG--
branch : dtrg-videocore
2013-05-21 23:17:30 +01:00
David Given c18a82ec40 Apply build system fixes for OpenBSD contributed by George Koehler. 2013-05-18 12:15:53 +01:00
David Given 5378e3fe53 Add special relocation type for VC4 jump instructions.
--HG--
branch : dtrg-videocore
2013-05-17 22:40:50 +01:00
David Given 11377070fd Update distribution files.
--HG--
branch : dtrg-buildsystem
2013-05-15 23:46:15 +01:00
David Given aaa3f14a79 Fix build error in opt which was causing all code, everywhere, to be broken.
Remember to build opt2 too.

--HG--
branch : dtrg-buildsystem
2013-05-15 22:09:28 +01:00
David Given e9233b4712 Build ego.
--HG--
branch : dtrg-buildsystem
rename : util/arch/build.mk => util/ego/build.mk
2013-05-15 21:14:06 +01:00
David Given d5f0107746 Build the Basic run-time library (after some modernisation).
--HG--
branch : dtrg-buildsystem
2013-05-14 16:11:29 +01:00
David Given 07453d184a Top, topgen, aelflod. Moved the libraries back into the platform-specific
directories --- wrangling descr files was too hard. C programs can be built
for cpm, pc86, linux386, linux68k!

--HG--
branch : dtrg-buildsystem
rename : util/ack/build.mk => util/led/build.mk
rename : util/LLgen/build.mk => util/topgen/build.mk
2013-05-13 23:26:15 +01:00
David Given 81778b603f Merge updates from trunk.
--HG--
branch : dtrg-buildsystem
2013-05-13 12:37:27 +01:00
David Given b0c238eb5d Made a start on building the runtimes for each platform and language; the
Linuxes all build.

--HG--
branch : dtrg-buildsystem
rename : modules/src/em_mes/build.mk => modules/src/read_em/build.mk
rename : plat/pc86/build.mk => plat/linux386/build.mk
rename : plat/pc86/build.mk => plat/linux68k/build.mk
rename : plat/pc86/build.mk => plat/linuxppc/build.mk
rename : util/ack/build.mk => util/misc/build.mk
2013-05-12 23:51:55 +01:00
David Given c1aca7dae5 First milestone of replacing the build system.
--HG--
branch : dtrg-buildsystem
rename : lang/cem/cpp.ansi/Parameters => lang/cem/cpp.ansi/parameters.h
2013-05-12 20:45:55 +01:00
David Given d89f172841 Change fatal() and error() to use varargs. 2013-05-10 12:04:21 +01:00
David Given d91a1dc1a6 Merge changes from branch: linux68k platform, linuxppc platform (partially
working), and miscellaneous changes to support these.
2013-05-09 18:14:16 +01:00
David Given b9b808e01a Apply George Koehler's aelflod fix for generating non-EM_386 binaries.
Adjust platforms to use it. Fix some bugs in the linux386 platform.

--HG--
branch : dtrg-experimental-powerpc
2013-05-09 15:54:23 +01:00
David Given 99d7f513f2 Properly error out if something goes wrong rather than ploughing ahead
anyway.

--HG--
branch : dtrg-experimental-powerpc
2013-05-09 11:20:36 +01:00
David Given c93cb69959 Check in incomplete Linux PowerPC and M68K work.
--HG--
branch : dtrg-experimental-powerpc
2013-05-08 00:48:48 +01:00
George Koehler c8fdcff960 Some fixes for aelflod and aslod.
Copy rhead() and rsect() from aslod to aelflod, so aelflod can work
for machine with 64-bit long.

In aelflod, fix ELF header so file(1) no longer reports "corrupted
section header size".
2013-04-24 19:57:23 -04:00
George Koehler 0fc7fd5d33 Prevent segfault when trying to print an error message.
Use <stdarg.h> to pass arguments correctly, as ack/util/util.c
already uses <stdarg.h> the same way.
2012-10-24 13:44:50 -04:00
David Given 4349d702fa Change from using platform-specific types to stdint platform-independent types
when reading the structure header.
2012-09-27 11:32:40 +01:00
George Koehler 7ef9b79c11 Merge deletion of many undead files. 2012-09-23 15:31:16 -04:00
George Koehler e7c79415b5 Prevent division by zero in aslod.
rhead() and rsect() had assumed sizeof(long) == 4, but OpenBSD/amd64
has sizeof(long) == 8.  The problem revealed itself when sect->os_lign
became zero, and align() divided by zero.
2012-09-21 22:51:12 -04:00
George Koehler 0131ca4d46 Delete 689 undead files.
These files "magically reappeared" after the conversion from CVS to
Mercurial.  The old CVS repository deleted these files but did not
record *when* it deleted these files.  The conversion resurrected these
files because they have no history of deletion.  These files were
probably deleted before year 1995.  The CVS repository begins to record
deletions around 1995.

These files may still appear in older revisions of this Mercurial
repository, when they should already be deleted.  There is no way to fix
this, because the CVS repository provides no dates of deletion.

See http://sourceforge.net/mailarchive/message.php?msg_id=29823032
2012-09-20 22:26:32 -04:00
George Koehler 96ea0a5903 Fix more functions in util/ack for 64-bit hosts.
This continues the fix from changeset aabde0589450.  We must use
va_list to forward the arguments, because some of the arguments might
be 64-bit pointers.  A pointer does not fit in an int.
2012-09-07 16:28:10 -04:00
David Given 6ea172d0d9 Fix a 64-bitness issue (removed some untyped K&R C code that assumed ints
and pointers were the same size).
2012-02-27 22:36:36 +00:00
Ceriel Jacobs 1072a8797e Added atol() that ignores overflow, so that unsigned long constants are dealt with properly 2011-06-15 11:13:48 +02:00
Ceriel Jacobs 2483e5723d Fixed CFU 2011-06-15 10:56:58 +02:00
cjhjacobs 58613009f8 Fixed bug reported on tack-devel mailing list on 20-3-2011 2011-05-18 19:19:19 +02:00
David Given b6dfaefeff Removed file that the CVS conversion procedure left in (when it shouldn't have). 2011-03-20 20:47:10 +00:00
dtrg c326f3c6a3 Remove references to using-machine-name-for-compiler, as we don't do that any more. 2010-08-09 22:47:33 +00:00
dtrg 5a872eed38 Prevent build failure on modern Bisons (which are more picky than the old yacc this was written for). 2010-08-01 10:36:01 +00:00
dtrg ee72886e54 Renamed 'switch' variable to avoid conflict with a keyword in modern awks. 2010-08-01 10:35:04 +00:00
dtrg 2c54f8c742 Renamed getline() to getln() to avoid conflict with glibc's version. 2010-08-01 10:34:27 +00:00
dtrg 494d9a3e4a Now runs descr files through the ANSI C preprocessor, rather than the K&R one (which no longer exists). 2007-04-29 21:23:55 +00:00
dtrg 24ea8aee3d Updated for the 6.0pre2 release. 2007-04-24 20:45:58 +00:00
dtrg f6085fb234 Updated use of headers to compile cleanly. 2007-04-24 19:33:53 +00:00
dtrg ae9ac25f45 Modified to run ncgg input files through the ANSI preprocessor rather than the K&R one. 2007-04-23 23:40:59 +00:00
dtrg f471d2e618 Added the aelflod tool for generating ELF executables. Added documentation for aelflod and ashow. Now installs the documentation when built. 2007-04-23 23:40:10 +00:00
dtrg 6a0dd9377d Removed a dynamically generated file from the distribution. 2007-02-25 22:49:22 +00:00
dtrg 040151dd76 Removed some explicit (and wrong) redeclarations of system
functions.
2007-02-25 20:58:16 +00:00
dtrg b611731ec3 Updated .distr files for the new release. 2007-02-25 12:51:55 +00:00
dtrg 6d58210806 em_table is now in /h, not /etc. 2007-02-25 12:51:21 +00:00
dtrg 0f16e7540d new_table is now in /util/data, not /etc. 2007-02-25 12:49:04 +00:00
dtrg 903796a817 Now installs the man page. 2007-02-25 12:48:06 +00:00
dtrg 0974fa0e28 Remove non-standard .SB tags. 2007-02-25 12:47:50 +00:00
dtrg 26a9b76507 Added pregenerated versions of the LLgen source files (to ease
bootstrapping issues).
2007-02-24 02:01:57 +00:00
dtrg 478d0b1d8a Fixed a compilation error that was causing opt to not have its
peephole optimisation tables, which would make it generate
duff code.
2007-02-20 00:27:01 +00:00
dtrg 1c7bb87041 Fixed a bug in the maximum segment calculation. 2006-11-11 23:00:55 +00:00
dtrg 30b980bf7e Added a pmfile to allow LLgen to be built as part of the ACK again. 2006-11-11 22:58:30 +00:00
dtrg c0ecde554a Added support for anm, asize, ashow, astrip and the new aslod tool. 2006-10-16 23:25:56 +00:00
dtrg 47e1c27c05 Added new aslod tool for making memory dumps. 2006-10-16 23:25:27 +00:00
dtrg 12683dd8c6 Sanitised the use of #include files to more properly conform to the standards. 2006-10-16 23:20:11 +00:00
dtrg dbe10d2c19 Updated to the version 0.1 of Prime Mover (which involves some syntax changes). 2006-10-15 00:28:12 +00:00
dtrg 1e4ca91a8b Modified to install aal's manpage. 2006-07-30 23:45:35 +00:00
dtrg 45b4fef7d6 Rationalised use of #includes to be more standards-compliant. 2006-07-30 23:40:35 +00:00
dtrg 30e34f493f Rationalised use of #includes to be more standards-compliant. 2006-07-26 18:22:02 +00:00
dtrg 8558656665 Now avoids piping shell scripts into a new instance of sh, instead
using a subshell.
2006-07-26 12:29:47 +00:00
dtrg dc5d08b2a3 Modified to include the appropriate header file rather than (badly)
prototyping syscalls itself.
2006-07-26 12:28:56 +00:00
dtrg 3435e8d6ed Modified to not try to unlink directories when installing. 2006-07-25 23:29:12 +00:00
dtrg b3b2ec567f Updated version number. 2006-07-25 23:24:39 +00:00
dtrg 7068d0d301 Modified to use rename() instead of link()/unlink() to rename files. 2006-07-25 23:24:20 +00:00
dtrg f756747414 Updated to the latest version of pm which installs files with symlinks. 2006-07-25 23:22:58 +00:00
dtrg b24e1f5aae Updated to the latest version of pm. 2006-07-25 13:28:35 +00:00
dtrg 1799cb0706 Added a workaround for an OSX compiler bug. 2006-07-23 20:33:26 +00:00
dtrg f39d595f98 Updated to the latest version of pm. 2006-07-23 20:07:19 +00:00
dtrg 014be56fb0 Replaced calls to the custom strindex() and strrindex() functions with the
exactly equivalent and standard strchr() and strrchr() functions instead.
2006-07-23 20:01:02 +00:00
dtrg 05d3be79cd Removed a really unpleasant test for whether a pointer points at a string
constant or not by comparing it with 'end', which presumably points at
the top of the BSS. In fact, on Linux it evaluates to NULL, and on OSX it
doesn't exist at all, so it appears to be unnecessary.
2006-07-23 19:38:13 +00:00
dtrg 345f4c8978 Modified to avoid creating a zero-length iargs array, which some compilers
(OSX) do not create a symbol for.
2006-07-23 18:29:38 +00:00
dtrg eed5d461e4 cpp now gets installed in the right place. 2006-07-23 17:52:23 +00:00
dtrg 7af0c5696d cpp now gets installed in the right place. 2006-07-22 20:58:27 +00:00
dtrg 558a1ef405 led now gets installed into the right place. 2006-07-22 20:52:44 +00:00
dtrg 8499270aef Added support for the esize object inspection tool. 2006-07-22 20:10:41 +00:00
dtrg aa2dab31cf Rationalised use of #includes to be more standards-compliant. 2006-07-22 20:08:08 +00:00
dtrg 113383e31c Added support for the led link editor. 2006-07-22 20:04:41 +00:00
dtrg f232b4dc29 Rationalised use of #includes to be more standards-compliant. 2006-07-22 17:58:49 +00:00
dtrg 304c0e21a0 Added support for the top target peephole optimiser. 2006-07-22 12:31:19 +00:00
dtrg fdcdaadcb8 Rationalised use of #includes to be more standards-compliant. 2006-07-22 12:28:20 +00:00
dtrg 744d0ca7be Removed a huge, ancient comment dating from the genmake days. 2006-07-22 12:27:31 +00:00
dtrg 1a037b9685 Added support for the ego global optimisation suite. 2006-07-22 00:52:01 +00:00
dtrg f371b251d2 Rationalised use of #includes to be more standards-compliant. 2006-07-22 00:46:16 +00:00
dtrg d220081198 Changed to declare symbols as extern rather than just mentioning
them without qualification.
2006-07-22 00:45:51 +00:00
dtrg 86e20aa483 Added a concrete definition of nrglobals, because this was not always happening
otherwise.
2006-07-22 00:44:52 +00:00
dtrg 3afd3e4cb4 Updated version number. 2006-07-21 11:25:05 +00:00
dtrg c0c8695ea4 Now resolves symlinks when creating releases (which avoids including a symlink to pm in the distribution, and not pm itself). 2006-07-21 11:24:46 +00:00
dtrg 154b23cd39 Updated version number. Corrected some typos. 2006-07-21 11:19:42 +00:00
dtrg 34ae7c4634 Removed duplicate (and incorrect) system function declarations. 2006-07-21 11:17:18 +00:00
dtrg 70218cfeed Updated to the latest version of pm. 2006-07-21 11:15:14 +00:00