[Oberon] Constant folding, Re: Bit-fiddling: SETs and type casts in Oberon-07

joerg.straube at iaeth.ch joerg.straube at iaeth.ch
Tue Aug 9 11:09:15 CEST 2022


Oops. Mine does. I obviously added the code to do so but forgot that I did 😊

Jörg

Von: Oberon <oberon-bounces at lists.inf.ethz.ch> im Auftrag von Paul Reed <paulreed at paddedcell.com>
Datum: Dienstag, 9. August 2022 um 10:25
An: ETH Oberon and related systems <oberon at lists.inf.ethz.ch>
Betreff: [Oberon] Constant folding, Re: Bit-fiddling: SETs and type casts in Oberon-07
Hi Jörg,

> ... CHR( ORD(ch) - ORD(“a”) + ORD(“A”) );
>
> ...the compiler folds these constants into one value

Should perhaps, but doesn't (the Oberon-07 compilers anyway): there is
some associative and even commutative constant folding which could be
done, but isn't currently. RISC ORTool gives:

PROCEDURE P;
   VAR ch: CHAR;
BEGIN ch := CHR( ORD(ch) - ORD("a") + ORD("A") );
END P;

    2  90E00004 LDR  R0 SP       4
    3  40090061 SUB  R0  R0     97
    4  40080041 ADD  R0  R0     65
    5  B0E00004 STR   R0 SP       4

Cheers,
Paul

--
Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
https://lists.inf.ethz.ch/mailman/listinfo/oberon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20220809/94c98dec/attachment.html>


More information about the Oberon mailing list