[Libre-soc-bugs] [Bug 980] Implement C-based Power ISA pseudocode compiler

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Tue Jan 9 21:10:06 GMT 2024


https://bugs.libre-soc.org/show_bug.cgi?id=980

--- Comment #75 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
(In reply to Dmitry Selyutin from comment #72)
> Many updates, too many to enumerate, briefly:
> 1) simplified the ternary condition operator pseudocode;
> 2) simplified special words parsing (GPR, FPR, CR, reserved, etc.);
> 3) minor hierarchy refactoring for the future C code generation.

fantastic. any joy on a python-cffi importer (if nothing else,
to do unit tests) or is that just too much for the $?

(In reply to Dmitry Selyutin from comment #73)

> With a local code I have now, 

(please do push it immediately to fulfil the Project Coding Standards,
to avoid Audit and Transparency "red flags", thank you for understanding
and patience here Dmitry)

> we're already able to convert this
> pseudocode...
> 
> src <- [0]*64
> src[64-XLEN:63] <- (RS)
> result <- [0]*64
> do i = 0 to 1
>     n <- i * 32
>     result[n+0:n+7] <- 0
>     result[n+8:n+19] <- DPD_TO_BCD(src[n+12:n+21])
>     result[n+20:n+31] <- DPD_TO_BCD(src[n+22:n+31])
> RA <- result[64-XLEN:63]

fantastic. calling functions, dealing with loops, local variables - nice.


> 
> ...into declarations:
> 
> void
> oppc_cdtbcd(void) {
>     uint64_t src;
>     uint64_t result;
>     uint64_t i;
>     uint64_t n;
> }

one thing: all return results need a boolean "ok" flag which is
set on write.

    RA <- result[64-XLEN:63]

outputs:

    RA->value = result...  ;
    RA->ok    = true;

or..

    RA = result.... ;
    ok_flags->RA = true;

or

    #define RA_result_index 0
    #define CR0_result_index 1
    ok_flags |= 1<<RA_result_index;

(separate ok bitfield or something)


this actually reflects the hardware design, so is not surprising,
but turns out to be absolutely essential in the FP routines for
flags, and a few other obscure areas.

basically *some* pseudocode *optionally* writes to registers,
using *runtime* arbitrary decisions, not static deterministic
ones based on known information going into the routine.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the libre-soc-bugs mailing list