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

Skulski, Wojciech skulski at pas.rochester.edu
Tue Aug 9 13:10:37 CEST 2022


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

Andreas? Time for a small fix of yours?

Wojtek

________________________________________
From: Oberon [oberon-bounces at lists.inf.ethz.ch] on behalf of joerg.straube at iaeth.ch [joerg.straube at iaeth.ch]
Sent: Tuesday, August 9, 2022 5:09 AM
To: ETH Oberon and related systems
Subject: [EXT] Re: [Oberon] Constant folding, Re:  Bit-fiddling: SETs and type casts in Oberon-07

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




More information about the Oberon mailing list