[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ooc-m68k-960119
On Jan 19, Michael van Acken wrote:
> Funny how this project unveils a whole bunch of bugs in both o2c and
> Oberon-A. Somewhat annoying though to have to release a new version
> of o2c every month or so. :-(
What it unveils most is Oberon-A's inadequate register management,
especially in relation to type guards. While there are only 5 address
registers free to be used in expressions, I would have thought that would
be enough for most purposes :-(.
I forgot to say that I found another expression too complex for Oberon-A,
in ParseExpr.CorrectCondGate(). Here's the modified code I used to get it
to compile:
PROCEDURE CorrectCondGate* (region: D.Region; value: D.Usable): D.Usable;
(* If `value' is a gate of a "merge-cond:" instruction, and the current region
is nested in the negation of the merge, then replace `value' by the
appropriate gate operand. *)
VAR
merge: D.Merge;
newValue: D.Usable;
innerGuard: D.Guard;
(* Added to simplify expression [fjc] *)
arg: D.Usable;
nextOpnd: D.Opnd;
CONST
true = 1; false = -1; both = 0;
PROCEDURE GuardClass (i: D.Instruction): SHORTINT;
VAR
left, right: SHORTINT;
BEGIN
CASE i. opcode OF
| Opc.guardTrue: RETURN true
| Opc.guardFalse: RETURN false
| Opc.mergeCond:
left := GuardClass (i. opndList. arg(D.Instruction));
right := GuardClass (i. opndList. nextOpnd. arg(D.Instruction));
IF (left = right) THEN
RETURN left
ELSE
RETURN both
END
END
END GuardClass;
BEGIN
IF (value IS D.Gate) &
(value(D.Gate). opndList. arg(D.Merge). opcode = Opc.mergeCond) THEN
merge := value(D.Gate). opndList. arg(D.Merge);
IF (GuardClass (merge) # both) THEN
(* `value' is gate originating in a condition merge that combines
two "if-false:" or two "if-true:" paths *)
(* Following expression simplified for Oberon-A [fjc] *)
arg := merge.opndList.arg;
nextOpnd := merge.opndList.nextOpnd;
IF (arg IS D.Merge) OR
(~(nextOpnd. arg IS D.Merge) &
(nextOpnd. arg(D.Guard). region. region =
arg(D.Guard). region)) THEN
innerGuard := nextOpnd. arg(D.Guard);
newValue := value(D.Gate). opndList. nextOpnd. nextOpnd. arg
ELSE
innerGuard := arg(D.Guard);
newValue := value(D.Gate). opndList. nextOpnd. arg
END;
IF (innerGuard. region # region) &
Dominates (innerGuard. region, region) THEN
value := CorrectCondGate (region, newValue)
END
END
END;
RETURN value
END CorrectCondGate;
Frank Copeland
--
MODULE Sig;
(* $Author: Frank Copeland <fjc@wossname.apana.org.au> $ *)
IMPORT StdDisclaimer, CleverQuote, AdvocateOberon;
END Sig.