ack.git
7 years agoDon't allow the same IR to be added to the sequence list more than once
David Given [Tue, 11 Oct 2016 22:45:36 +0000 (00:45 +0200)]
Don't allow the same IR to be added to the sequence list more than once
(sometimes happens because op_dup, but makes no sense).

7 years agoClean up the allocator a bit, in preparation for making it lots more
David Given [Tue, 11 Oct 2016 21:17:30 +0000 (23:17 +0200)]
Clean up the allocator a bit, in preparation for making it lots more
complicated; no semantic changes.

7 years agoA few more opcodes.
David Given [Mon, 10 Oct 2016 22:29:18 +0000 (00:29 +0200)]
A few more opcodes.

7 years agoA little fiddling with store instructions. The PowerPC is not friendly to
David Given [Mon, 10 Oct 2016 22:23:35 +0000 (00:23 +0200)]
A little fiddling with store instructions. The PowerPC is not friendly to
iburg.

7 years agoRefactored the way hops are rendered; add support for emitting code (although
David Given [Mon, 10 Oct 2016 22:12:11 +0000 (00:12 +0200)]
Refactored the way hops are rendered; add support for emitting code (although
with no prologue or epilogue yet).

7 years agoRegister allocator now gets all the way through all of my test file without
David Given [Mon, 10 Oct 2016 21:19:46 +0000 (23:19 +0200)]
Register allocator now gets all the way through all of my test file without
crashing (albeit with register moves and swaps stubbed out). Correct code? Who
knows.

7 years agoD'oh, need multiple passes over the edge splitter in order to properly find all
David Given [Mon, 10 Oct 2016 21:18:37 +0000 (23:18 +0200)]
D'oh, need multiple passes over the edge splitter in order to properly find all
cases.

7 years agoCalculate phi congruency groups; use them to solve the
David Given [Sun, 9 Oct 2016 20:04:20 +0000 (22:04 +0200)]
Calculate phi congruency groups; use them to solve the
importing-hreg-from-the-future problem (probably poorly).

7 years agoAdd pmap_remove().
David Given [Sun, 9 Oct 2016 20:03:44 +0000 (22:03 +0200)]
Add pmap_remove().

7 years agoThe register allocator now makes a spirited attempt to honour register
David Given [Sun, 9 Oct 2016 13:09:34 +0000 (15:09 +0200)]
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.

7 years agoFloating point promotion was broken since the IR float change. Fix.
David Given [Sun, 9 Oct 2016 13:08:03 +0000 (15:08 +0200)]
Floating point promotion was broken since the IR float change. Fix.

7 years agoAdd some more opcodes; rearrange the registers to be more PowerPC-friendly.
David Given [Sun, 9 Oct 2016 12:45:13 +0000 (14:45 +0200)]
Add some more opcodes; rearrange the registers to be more PowerPC-friendly.

7 years agoPredicates can now take numeric arguments. The PowerPC predicates have been
David Given [Sun, 9 Oct 2016 10:32:36 +0000 (12:32 +0200)]
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.

7 years agoBasic register allocation works!
David Given [Sat, 8 Oct 2016 21:32:54 +0000 (23:32 +0200)]
Basic register allocation works!

7 years agoReplace pmap_get() with pmap_findleft() and pmap_findright(), to allow lookups
David Given [Sat, 8 Oct 2016 21:32:13 +0000 (23:32 +0200)]
Replace pmap_get() with pmap_findleft() and pmap_findright(), to allow lookups
in both directions.

7 years agoOnly allocate an output vreg if the instruction actually wants one.
David Given [Sat, 8 Oct 2016 10:15:21 +0000 (12:15 +0200)]
Only allocate an output vreg if the instruction actually wants one.

7 years agoInstruction predicates work now.
David Given [Sat, 8 Oct 2016 09:35:33 +0000 (11:35 +0200)]
Instruction predicates work now.

7 years agoMinor cleanup.
David Given [Sat, 8 Oct 2016 09:07:28 +0000 (11:07 +0200)]
Minor cleanup.

7 years agoFix bug where pushes were being placed in the wrong blocks.
David Given [Sat, 8 Oct 2016 08:21:24 +0000 (10:21 +0200)]
Fix bug where pushes were being placed in the wrong blocks.

7 years agoOverhaul of everything phi related; critical edge splitting now happens before
David Given [Fri, 7 Oct 2016 22:21:23 +0000 (00:21 +0200)]
Overhaul of everything phi related; critical edge splitting now happens before
anything SSA happens; liveness calculations now look like they might be
working.

7 years agoAdd array_{appendall,removeall,appendallu}.
David Given [Fri, 7 Oct 2016 22:20:26 +0000 (00:20 +0200)]
Add array_{appendall,removeall,appendallu}.

7 years agoRefactor the cfg and dominance stuff to make it a lot nicer.
David Given [Thu, 6 Oct 2016 19:34:21 +0000 (21:34 +0200)]
Refactor the cfg and dominance stuff to make it a lot nicer.

7 years agoWe're not using 'allocates' any more; clean up.
David Given [Thu, 6 Oct 2016 19:33:43 +0000 (21:33 +0200)]
We're not using 'allocates' any more; clean up.

7 years agoThe register allocator is really a pass, so arrange the code like one.
David Given [Wed, 5 Oct 2016 21:55:38 +0000 (23:55 +0200)]
The register allocator is really a pass, so arrange the code like one.

7 years agoWarning fix.
David Given [Wed, 5 Oct 2016 21:55:04 +0000 (23:55 +0200)]
Warning fix.

7 years agoNo, dammit, for register allocation I need to walk the blocks in *dominance*
David Given [Wed, 5 Oct 2016 21:52:54 +0000 (23:52 +0200)]
No, dammit, for register allocation I need to walk the blocks in *dominance*
order. Since the dominance tree has changed when I fiddled with the graph, I
need to recompute it, so factor it out of the SSA pass. Code is uglier than I'd
like but at least the RET statement goes last in the generated code now.

7 years agoAllowing an input filename on the command line makes debuggers happy. (Then we
David Given [Wed, 5 Oct 2016 21:24:29 +0000 (23:24 +0200)]
Allowing an input filename on the command line makes debuggers happy. (Then we
don't need to redirect stdin.)

7 years agoBetter constraint syntax; mcgg now passes register usage information up to mcg;
David Given [Wed, 5 Oct 2016 20:56:25 +0000 (22:56 +0200)]
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.

7 years agoMade sure that all files end in vim magic.
David Given [Wed, 5 Oct 2016 19:07:29 +0000 (21:07 +0200)]
Made sure that all files end in vim magic.

7 years agoBetter management of register data. Add struct hreg.
David Given [Wed, 5 Oct 2016 19:00:28 +0000 (21:00 +0200)]
Better management of register data. Add struct hreg.

7 years agoAdd a pass to do critical edge splitting.
David Given [Tue, 4 Oct 2016 21:42:00 +0000 (23:42 +0200)]
Add a pass to do critical edge splitting.

7 years agoAdded support for the op_bXX conditional branch instructions.
David Given [Tue, 4 Oct 2016 21:28:16 +0000 (23:28 +0200)]
Added support for the op_bXX conditional branch instructions.

7 years agoFix the horror of the startup code; now uses getopt and stuff and the debug
David Given [Tue, 4 Oct 2016 20:36:01 +0000 (22:36 +0200)]
Fix the horror of the startup code; now uses getopt and stuff and the debug
flags can be set as an option.

7 years agoRemove unused variable (reduce memory usage by 1/10).
David Given [Tue, 4 Oct 2016 20:35:08 +0000 (22:35 +0200)]
Remove unused variable (reduce memory usage by 1/10).

7 years agoBodge in enough phi support to let the instruction generator complete on basic
David Given [Tue, 4 Oct 2016 19:58:31 +0000 (21:58 +0200)]
Bodge in enough phi support to let the instruction generator complete on basic
programs.

7 years agoOops --- hadn't updated the nts array for the new child order.
David Given [Tue, 4 Oct 2016 19:32:28 +0000 (21:32 +0200)]
Oops --- hadn't updated the nts array for the new child order.

7 years agoDon't allocate new vregs for REG and NOP --- a bit hacky, but suppresses stray
David Given [Tue, 4 Oct 2016 19:29:03 +0000 (21:29 +0200)]
Don't allocate new vregs for REG and NOP --- a bit hacky, but suppresses stray
movs very effectively.

7 years agoMassive rewrite of how emitters and the instruction selector works, after I
David Given [Mon, 3 Oct 2016 22:16:06 +0000 (00:16 +0200)]
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.

7 years agoInstruction selection now happens on a shadow tree, rather than on the IR tree
David Given [Mon, 3 Oct 2016 18:52:36 +0000 (20:52 +0200)]
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.

7 years agoGet quite a long way towards basic output-register equality constraints (needed
David Given [Sun, 2 Oct 2016 21:25:54 +0000 (23:25 +0200)]
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).

7 years agoCome up with a syntax for register constraints.
David Given [Sun, 2 Oct 2016 19:51:25 +0000 (21:51 +0200)]
Come up with a syntax for register constraints.

7 years agoPerform SSA conversion of locals. Much, *much* better code now, at least
David Given [Sun, 2 Oct 2016 15:50:34 +0000 (17:50 +0200)]
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).

7 years agoAdd array push/pop; fix ghastly memory overrun bug.
David Given [Sun, 2 Oct 2016 15:24:31 +0000 (17:24 +0200)]
Add array push/pop; fix ghastly memory overrun bug.

7 years agoAdd zrl opcode. Keep track of local sizes as well as offsets.
David Given [Sun, 2 Oct 2016 14:08:46 +0000 (16:08 +0200)]
Add zrl opcode. Keep track of local sizes as well as offsets.

7 years agoAdd inl and del opcodes.
David Given [Sun, 2 Oct 2016 12:44:21 +0000 (14:44 +0200)]
Add inl and del opcodes.

7 years agoRefactor mcg.h as it's getting a bit big; keep track of register variables.
David Given [Sat, 1 Oct 2016 22:30:33 +0000 (00:30 +0200)]
Refactor mcg.h as it's getting a bit big; keep track of register variables.

7 years agoMake betterer.
David Given [Sat, 1 Oct 2016 21:41:45 +0000 (23:41 +0200)]
Make betterer.

7 years agoFix edge case where leftover pushes would occasionally cause infinite loops in
David Given [Sat, 1 Oct 2016 21:41:35 +0000 (23:41 +0200)]
Fix edge case where leftover pushes would occasionally cause infinite loops in
the analysis.

7 years agoShow expression trees correctly.
David Given [Sat, 1 Oct 2016 21:41:03 +0000 (23:41 +0200)]
Show expression trees correctly.

7 years agoDeal with malformed mes instructions emitted by ego.
David Given [Sat, 1 Oct 2016 21:13:39 +0000 (23:13 +0200)]
Deal with malformed mes instructions emitted by ego.

7 years agoMore rigorous dealing of IR groups; no need for is_generated and is_root any
David Given [Sat, 1 Oct 2016 20:58:29 +0000 (22:58 +0200)]
More rigorous dealing of IR groups; no need for is_generated and is_root any
more (but now passes are required to set IR roots properly when changing
instructions).

7 years agoWe're going to need some type inference after all, I think. Let's do a little
David Given [Sat, 1 Oct 2016 17:10:22 +0000 (19:10 +0200)]
We're going to need some type inference after all, I think. Let's do a little
for now and see how it goes.

7 years agoPredicates work; we now have prefers and requires clauses. Predicates must be
David Given [Sat, 1 Oct 2016 11:56:52 +0000 (13:56 +0200)]
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.

7 years agoIt doesn't really make a lot of sense to have BURG nonterminal names different
David Given [Sat, 1 Oct 2016 10:17:14 +0000 (12:17 +0200)]
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.

7 years agoMove fatal(), warning() and aprintf() into the new data module (because they're
David Given [Fri, 30 Sep 2016 17:10:30 +0000 (19:10 +0200)]
Move fatal(), warning() and aprintf() into the new data module (because they're
really useful).

7 years agoMore properly keep track of register classes.
David Given [Thu, 29 Sep 2016 20:32:43 +0000 (22:32 +0200)]
More properly keep track of register classes.

7 years agoError check fragment rules which don't emit anything.
David Given [Thu, 29 Sep 2016 20:14:11 +0000 (22:14 +0200)]
Error check fragment rules which don't emit anything.

7 years agoMuch better handling of fragments (no run-time code needed to distinguish them
David Given [Thu, 29 Sep 2016 20:06:04 +0000 (22:06 +0200)]
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.

7 years agoYou know what, the type inference stuff is a complete red herring. What this
David Given [Thu, 29 Sep 2016 17:58:02 +0000 (19:58 +0200)]
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.

7 years agoYou can tell whether an item already exists in the array when calling
David Given [Wed, 28 Sep 2016 21:39:00 +0000 (23:39 +0200)]
You can tell whether an item already exists in the array when calling
array_appendu() now.

7 years agoActually, I don't need vregs: hops work just as well. Particularly if I
David Given [Tue, 27 Sep 2016 21:38:47 +0000 (23:38 +0200)]
Actually, I don't need vregs: hops work just as well. Particularly if I
restructure things so that I don't need to walk the blasted ir / burg tree
every time I look at an instruction.

7 years agoFleshed out hops and vregs. The result is almost looking like code now ---
David Given [Mon, 26 Sep 2016 22:19:45 +0000 (00:19 +0200)]
Fleshed out hops and vregs. The result is almost looking like code now ---
uncanny.

7 years agoMove map into the data module.
David Given [Mon, 26 Sep 2016 21:03:04 +0000 (23:03 +0200)]
Move map into the data module.

7 years agoRevamp the array module not to use nasty macros any more. Slightly more verbose
David Given [Mon, 26 Sep 2016 20:48:58 +0000 (22:48 +0200)]
Revamp the array module not to use nasty macros any more. Slightly more verbose
to use, but definitely cleaner.

7 years agoMove the array library into the data module.
David Given [Mon, 26 Sep 2016 20:24:49 +0000 (22:24 +0200)]
Move the array library into the data module.

7 years agoKeep more data around about ir instructions. Implement a half-baked type
David Given [Mon, 26 Sep 2016 20:12:46 +0000 (22:12 +0200)]
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.

7 years agoStart factoring out the hardware op code.
David Given [Sun, 25 Sep 2016 21:29:59 +0000 (23:29 +0200)]
Start factoring out the hardware op code.

7 years agoSort of keep track of registers and register classes. Start walking the
David Given [Sun, 25 Sep 2016 20:17:14 +0000 (22:17 +0200)]
Sort of keep track of registers and register classes. Start walking the
generated instruction tree --- holy cow, they look like instructions!

7 years agoCollapse several rule arrays into one; actually generate the array properly.
David Given [Sun, 25 Sep 2016 15:14:54 +0000 (17:14 +0200)]
Collapse several rule arrays into one; actually generate the array properly.

7 years agoRename struct insn to struct em (throughout).
David Given [Sun, 25 Sep 2016 10:29:03 +0000 (12:29 +0200)]
Rename struct insn to struct em (throughout).

7 years agoStupid stringlist is stupid. Use a proper data structure, properly abstracted
David Given [Sun, 25 Sep 2016 10:18:39 +0000 (12:18 +0200)]
Stupid stringlist is stupid. Use a proper data structure, properly abstracted
out (so other things can use it).

7 years agoRethink the way patterns are mapped to rules; generate emitters (probably
David Given [Sun, 25 Sep 2016 09:49:51 +0000 (11:49 +0200)]
Rethink the way patterns are mapped to rules; generate emitters (probably
badly).

7 years agoWe now record the code fragments to be emitted by each rule.
David Given [Sat, 24 Sep 2016 22:21:46 +0000 (00:21 +0200)]
We now record the code fragments to be emitted by each rule.

7 years agoInstruction selection is so important the file needs a longer name.
David Given [Sat, 24 Sep 2016 20:50:53 +0000 (22:50 +0200)]
Instruction selection is so important the file needs a longer name.

7 years agoSome instruction selection is now happening.
David Given [Sat, 24 Sep 2016 20:46:08 +0000 (22:46 +0200)]
Some instruction selection is now happening.

7 years agoMore grammar changes.
David Given [Sat, 24 Sep 2016 17:03:55 +0000 (19:03 +0200)]
More grammar changes.

7 years agoIR codes are now owned by mcgg; ir terminals are inserted into the table during
David Given [Sat, 24 Sep 2016 16:31:35 +0000 (18:31 +0200)]
IR codes are now owned by mcgg; ir terminals are inserted into the table during
compilation (so you can refer to them).

7 years agoCrudely bolt on mcgg to mcg itself.
David Given [Sat, 24 Sep 2016 15:20:40 +0000 (17:20 +0200)]
Crudely bolt on mcgg to mcg itself.

7 years agoParameters are parsed with getopt. Simplify, constify.
David Given [Sat, 24 Sep 2016 14:59:49 +0000 (16:59 +0200)]
Parameters are parsed with getopt. Simplify, constify.

7 years agoChange the predicate stuff to use costs instead; now you can use when clauses
David Given [Sat, 24 Sep 2016 11:33:59 +0000 (13:33 +0200)]
Change the predicate stuff to use costs instead; now you can use when clauses
on leaves. Remove an iburg premature optimisation (required for above).

7 years agoLots of exploratory new grammar for instruction definitions and string and
David Given [Sat, 24 Sep 2016 11:08:17 +0000 (13:08 +0200)]
Lots of exploratory new grammar for instruction definitions and string and
fragment emission (none of which is hooked up to anything yet).

7 years agoAdd support for labelled tree nodes.
David Given [Sat, 24 Sep 2016 10:11:30 +0000 (12:11 +0200)]
Add support for labelled tree nodes.

7 years agoFix some late-night typo bugs.
David Given [Fri, 23 Sep 2016 23:09:32 +0000 (01:09 +0200)]
Fix some late-night typo bugs.

7 years agoProcedure compilation now happens after the entire EM file has been read in (so
David Given [Fri, 23 Sep 2016 23:04:00 +0000 (01:04 +0200)]
Procedure compilation now happens after the entire EM file has been read in (so
that we can look inside data blocks which might be defined in the future...
sigh, csa and csb). csa and csb no longer generate invalid IR.

7 years agoReplaced the block splicer with a trivial block eliminator (which rewrites
David Given [Fri, 23 Sep 2016 21:59:15 +0000 (23:59 +0200)]
Replaced the block splicer with a trivial block eliminator (which rewrites
jumps to blocks which contain only a jump). Don't bother storing the bb graph
in the ir nodes; we can find it on demand by walking the tree instead ---
slower, but much easier to understand and more robust. Added a terrible map
library.

7 years agoEach pass now lives in its own source file; much cleaner.
David Given [Fri, 23 Sep 2016 19:07:16 +0000 (21:07 +0200)]
Each pass now lives in its own source file; much cleaner.

7 years agoAdd a bodged in algorithm for converting basic block communication from stacked
David Given [Thu, 22 Sep 2016 21:19:29 +0000 (23:19 +0200)]
Add a bodged in algorithm for converting basic block communication from stacked
variables to SSA. Also add dead block removal and block splicing. IR code is
much better now.

8 years agoTracing cleanup. Simplified the IR code. Some more opcodes.
David Given [Wed, 21 Sep 2016 22:15:48 +0000 (00:15 +0200)]
Tracing cleanup. Simplified the IR code. Some more opcodes.

8 years agoMassive grammar overhaul and refactor. Hacked in support for predicates, where
David Given [Tue, 20 Sep 2016 22:43:10 +0000 (00:43 +0200)]
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.

8 years agoRun through clang-format.
David Given [Tue, 20 Sep 2016 19:00:16 +0000 (21:00 +0200)]
Run through clang-format.

8 years agoStrip out surplus files. Rewrite README.
David Given [Tue, 20 Sep 2016 18:46:45 +0000 (20:46 +0200)]
Strip out surplus files. Rewrite README.

8 years agoImport iburg.
David Given [Tue, 20 Sep 2016 18:44:51 +0000 (20:44 +0200)]
Import iburg.

8 years agoImport iburg. iburg-import
David Given [Tue, 20 Sep 2016 18:37:16 +0000 (20:37 +0200)]
Import iburg.

8 years agoCreate hacky fake basic blocks for data fragments, used to track which
David Given [Mon, 19 Sep 2016 22:19:39 +0000 (00:19 +0200)]
Create hacky fake basic blocks for data fragments, used to track which
instruction labels descriptor blocks refer to; this allows csa and csb to know
where they're going.

8 years agoTreebuilder now gets to the bottom of my test file, merrily generating
David Given [Mon, 19 Sep 2016 21:30:41 +0000 (23:30 +0200)]
Treebuilder now gets to the bottom of my test file, merrily generating
(probably horribly broken) IR.

8 years agoStore the EM code up front and build the basic block graph *before*
David Given [Mon, 19 Sep 2016 21:06:59 +0000 (23:06 +0200)]
Store the EM code up front and build the basic block graph *before*
generating the IR code. Lots more IR code.

8 years agoArchival checking of the half-written IR treebuilder.
David Given [Sun, 18 Sep 2016 21:24:54 +0000 (23:24 +0200)]
Archival checking of the half-written IR treebuilder.

8 years agoANSIise to fix warnings.
David Given [Sat, 17 Sep 2016 22:23:42 +0000 (00:23 +0200)]
ANSIise to fix warnings.

8 years agoAbstract out the EM reader; skeleton of the tree builder.
David Given [Sat, 17 Sep 2016 22:02:16 +0000 (00:02 +0200)]
Abstract out the EM reader; skeleton of the tree builder.

8 years agoBasic skeleton of em parser.
David Given [Sat, 17 Sep 2016 20:21:47 +0000 (22:21 +0200)]
Basic skeleton of em parser.