[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ooc-960812 -- First Working OOC Compiler!
Hi.
I got some good news and some bad news. The good news is that we got
the very first OOC based compiler: oo2c. The bad news is that it only
translates to ANSI-C and besides does a very bad job about it.
Nevertheless, its a working compiler and it proves that the whole OOC
project makes sense. With this initial version of oo2c it should be
much simpler to add improvements step by step. Note that the bad
quality of the generated code is solely caused by the back-end. But
it will get better over time. This I promise, although I'm in no
particular hurry to do it. ;-)
I only tried it on a single test case: it's own source code. Since
the sources cover a _very_ large part of the language, the front-end,
and the back-end, I'm fairly optimisitic that I got rid of most of the
bugs (especially of the critical ones that were caused by design
errors). Both compilers, the one generated by o2c, and the one built
by oo2c itself, emit the same code. Being able to bootstrap itself is
a nice quality of a compiler, isn't it? :-)
The current ANSI-C back-end is the quick&dirty hack I promised some
time ago. Some parts are considerably dirtier than others, and some
are _very_ preliminary. Especially the allocator needs to be replaced
by a decent one. Currently it emits masses of unnecessary local
variables and a gigantic number of equally superfluous copy
instructions. This is the main reason for the inadequate quality of
the generated code and gives gcc/as a major headache. Ever seen an
assembler process touching 10MB in process size? No fun, I tell you,
if you have to work (even temporarily) with a slow 8MB machine.
I didn't try to enable the existing optimization with oo2c and see if
it works. This is Juergen's game and I don't want to spoil his fun
(or frustration ;-). I hope he'll be able to test them as soon as he
returns from his holiday. He's currently working on an alias analysis
to improve the efficiency of accesses to nonlocal and structured
variables. This suits me fine since aliasing plays a large part in
the scheduler, too. Maybe we'll be able to come up with satisfying
solution to the problem of scheduling of anti-dependencies together.
My big question at the moment is: Is anyone actually working on an
assembler back-end? With working I mean not just merely thinking
about it, but actually writing code. If someone is working on such a
beast I'd suggest we coordinate our efforts, discuss the general
problems of building a low-level back-end, decide which functionality
can be shared between all back-ends, and, most of all, put together a
detailed description of how to create a top-notch back-end.
Personally, I'm more interested in the discussion part. I'd like to
hear an opinion, e.g. on the scheduling pitfalls, from a different
point of view. On the other hand I gained a lot of experience from
the C back-end. A large part of the problems I've had to deal with
will certainly appear in an assembler back-end, too (plus some more).
I'd like to offer my help with working out the design of a low-level
back-end, and even to to write some modules as long as they are useful
for the C back-end, too.
So, is there anyone out there working on a back-end?
-- mva
P.S.: Last update's file ooc-960801-rcs.tar.gz was broken. Therefore
I can't put up any patches this time. You have to get the full
sources...
------------------------------------------------------------------------
ChangeLog Jul 26 to Aug 12:
Mon Aug 12 09:25:34 1996 Michael van Acken <acken@informatik.uni-kl.de>
* backend/ansi-c/GenStatm.Mod (BoundInstr):
Suppress redundant index checks.
* frontend/doc/AccessLocal: Initial revision
* frontend/doc/Aliasing:
Added note that OOC doesn't use or create MayAlias instructions.
* optimizers/GuardCond.Mod (Init):
Added guard propagation to avoid spurious `undefined variable'
warnings from the front-end.
* frontend/Data.Mod:
Doc fix: `instrCheckNil' can be set for access-heap, update-heap,
array-length, and type-tag instructions.
* frontend/ParseStatm.Mod (AssignToDesignator):
Fixed structured assignment to dereferenced
pointer variable.
* frontend/Opcode.Mod (access-heap, update-heap):
Should trap if the given address is NIL
and the flag `instrCheckNil' is set.
(ValueOperand): First argument of access-local resp. update-local
isn't a value.
* frontend/ParseExpr.Mod (Designator):
Reset index counter to 0 if a new array is selected.
(ConditionExit): Fixed code generation of termination condition for
WHILE loops. Loops with multiple nonlocal exits, like a RETURN and an
ASSERT, weren't translated properly.
* frontend/Attributes.Mod (InitGreg):
Initialize pseudo variables $return and $trap with a copy
of FALSE, instead the the constant FALSE itself. Otherwise the
introduction of of a loop gate for one of those variables will break
the loop by replacing all occurences of FALSE within the loop with a
bogus value.
Sun Aug 11 23:05:26 1996 Michael van Acken <acken@informatik.uni-kl.de>
* optimizers/AlgebraicTransformation.Mod (ArithmTransform):
Don't touch bound-index resp. bound-range
instructions.
Wed Aug 7 17:55:25 1996 Michael van Acken <acken@informatik.uni-kl.de>
* backend/demo/CodeGen.Mod (ForwardProcedure):
New. Called by the front-end to notify the
back-end of the presence of a forward declaration.
Some doc fixes.
* frontend/SideEffects.Mod (PropogateSideEffects):
Don't add a nonlocal variable to a caller's
enter instruction if it was been initialized by the caller
previously.
(PropagateMem): Working list wasn't traversed properly.
(Adjust): When cleaning up restore the `info' fields of all global
regions to their previous state, i.e. set the pointer to the one that
was valid before `AddProc' was called.
* frontend/ParseExpr.Mod (CondOr, CondAnd):
Fixed initialization problem -- again.
* frontend/Data.Mod:
New flag for Objects.flags: objWasForwardDeclaration. Set if the
object was introduced by a forward declaration, but has been resolved
in the meantime.
* frontend/Attributes.Mod, frontend/Opcode.Mod:
Added value parameter to array-length and type-tag instruction to
avoid scheduling of pointer dereference behind the computation of the
array length resp. type tag.
Thu Aug 1 05:34:58 1996 Michael van Acken <acken@informatik.uni-kl.de>
* backend/ansi-c/Schedule.Mod: Initial revision
* frontend/WriteGSA.Mod:
Reworked output of object names. New option `--gsa-qnames' will write
longer (but unambiguous) names by qualifying every name with procedure
and module name.
* frontend/SideEffects.Mod (AdjustOperands):
Make sure that no unused collect instructions
survive. A free floating collect can have disastrous effects :-(
* frontend/ParseStatm.Mod, frontend/ParseExpr.Mod:
The operands of dyadic operations and procedure calls were ignored
when creating a loop gate.
* frontend/Opcode.Mod (opcode update-local):
The update instruction takes the old value of
the updated variable as 3rd argument.
(OperatorSubclass): Default subclass for an undefined input type is
`subclS'.
* frontend/Data.Mod (ReverseInstr):
New. Reverses the instruction list of the given
region.
* frontend/Check.Mod (All): Added test for structural consistency.
* frontend/Attributes.Mod (SizeOfItem):
Fixed size calculation of open arrays.
Sat Jul 27 07:05:42 1996 Michael van Acken <acken@informatik.uni-kl.de>
* frontend/ParamPragmas.Mod: Fixed procedures Pop and Restore.
Fri Jul 26 22:33:05 1996 Michael van Acken <acken@informatik.uni-kl.de>
* frontend/ParseStatm.Mod (RepeatStatement):
Fixed code generation of FOR loop. Nonlocal exits
from the loop (i.e. RETURN or EXIT) were ignored when calculating the
boolean condition that terminates the loop.
Fri Jul 26 14:01:37 1996 Michael van Acken <acken@informatik.uni-kl.de>
* frontend/SymbolFile.Mod, frontend/doc/SymbolFile.ebnf:
Add index of type-bound procedure to symbol file.
Fri Jul 26 10:06:42 1996 Michael van Acken <acken@informatik.uni-kl.de>
* frontend/Opcode.Mod:
Don't mark delete-store instruction as disabled, but as potenial trap.
This way it's never considered to be dead code.
(GetFormalParam): Completely rewritten. Did the previous
implementation ever work?
* frontend/Attributes.Mod (TypeTag):
Fixed dynamic tag for variables that have only a static
type.
(CleanupGreg): Don't mark delete-store instruction as disabled, but as
potenial trap. This way it's never considered to be dead code.
* frontend/ParseStatm.Mod (PassParameter): Fixed location variable.
(ProcedureCall): Fixed address of called procedure. The previous code
didn't work for procedure variables and type-bound procedures.
* frontend/ParseExpr.Mod (Designator):
Fixed type tag used for a type-bound procedure call.