[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 16 19:31:01 GMT 2024


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

--- Comment #119 from Dmitry Selyutin <ghostmansd at gmail.com> ---
28 commits since the last update. This was a tough journey!! The code can now
be compiled successfully. This is a valid C code. The most difficult commit was
this:

https://git.libre-soc.org/?p=openpower-isa.git;a=commitdiff;h=90c93ec3cf18b96a9e70464f2b549c9bace1bbe4

Believe it or not, this was done manually. A long and extremely boring series
of "run Python and produce C code, compile it with C, see which function is
broken due to lack of prototype, visit Python code and see its arguments, add
the corresponding C prototype but don't forget to adopt the calling convention,
our result must generate a transient and return a pointer to it". I cannot
stress how annoying and boring it was, probably one of the most annoying tasks
I ever did, but I decided that writing yet another parser would consume even
more time.

This can be checked via the following incantation:

gcc -Os -Isrc/liboppc -Wall -Werror -Wextra test.c -c -o test.o

As you see I took extra measures to ensure we pass some stricter checks.

I'm planning to add src/liboppc/oppc.c autogeneration so that it's compiled as
oppc.o, and be done with the task. The actual implementation of 238 calls (this
includes the implementation of SelectableInt-like semantics, filling all these
defines, all functions we have in helpers and isafn, switching for FPSCR
attributes and so on). Yes, this will be a damn lot of work; even all the
prototypes and definities took 1K+ lines of manually written code. Some
functions can be generated as well, and I think this is the path we should
follow, eventually discarding as many manually written helpers as we can.

So, I'm planning to add src/liboppc/oppc.c autogeneration as part of the build
and be done with this task. I might probably agree to some smallish additions
which hopefully won't be as annoying as that header above. I already feel this
is well underestimated, considering the efforts, though. I'd like to listen to
your thoughts and ideas.

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


More information about the libre-soc-bugs mailing list