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

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Sat Jan 13 12:54:59 GMT 2024


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

--- Comment #86 from Dmitry Selyutin <ghostmansd at gmail.com> ---
A huge update. Many operations are now supported. From now on, every integer
should be represented by a structure which will look like this:

struct oppc_int {
    uint64_t bits;
    uint64_t value[];
};


The functions would then deal with the poiners to such structures:

struct oppc_int *
oppc_add(struct oppc_int *rv, struct oppc_int const *lhs, struct oppc_int const
*rhs);

struct oppc_int *
oppc_assign(struct oppc_int *dst, struct oppc_int const *src);

bool
oppc_lt(struct oppc_int const *lhs, struct oppc_int const *rhs);


This is needed mostly for stuff like concatenation to work on binary and
hexadecimal literals, plus to make call chains simpler. Decimal and registers
have bits equal to XLEN (should be part of the context).


Plus, from now on, everything is a call. I obviously had to cheat a bit and use
compound literals. The code is too big to post here, you can check what's
generated from __main__ upon `python3 -m openpower.oppc`. I'll post just minor
excerpts below for the record.

To clarify about function calls and integer type. I have no intent to provide a
completely __working__ C code in scope of this task. This would require to
implement an analogue of SelectableInt, invent context with all the registers
and states, etc. etc. It will never fit the time constraints, and certainly
already doesn't fit the budget.

The idea at this stage is:
1. Emit the code which is valid C code.
2. Check whether it's buildable with some stubs instead of functions and
context.

This is it. This is just a task "take pseudocode and emit C code", not "make a
fully-blown decoder and simulator". Any objections?

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


More information about the libre-soc-bugs mailing list