Page MenuHomePhabricator

M680x0 codegen target

Authored by m4yers on Aug 5 2018, 10:45 AM.




This is a M680x0 codegen backend I've started/suspended a couple years back,
now I finally got some time and willing to continue working on it. To keep up
with LLVM changes I'd like to merge it upstream.

Though motorolla processors are mostly not used today there are relatively
small communities of enthusiasts that are interested in this llvm target,
namely m68k debian linux port team and demoscene artists; so, not just me;)

Current Status

ATM this target is able to emit linkable/relocatable (no tls) object files that
can be linked with GNU ld against glibc or newlib. ISA is limited to M68000 but
is easily extensible. It can cross-compile GNU Hello executable that you can
run on Debian m68k port. As far as I can tell this project covers all c98
features, most of it of course is handled by clang itself, but llvm-wise it has
everything you need to compile a C program. For now it is compiler only, so you
still need GNU stuff, e.g. linker, debugger, binutils etc.


Cover almost every feature available atm, including code emission and object
file lowering.

LLVM Modifications

  • Added MIOperandInfo tablegen emission. This type provides a higher level view onto instruction operands aggregates, the actual instruction defined by tablegen. In M680x0 it is necessary to know the operands aggregates borders.
  • "Code Beads" tablegen emission. M680x0 is a CISC and its binary emission is reminiscent of X86, but looking at ~40K lines of X86 code emission I've decided to push machine code generation to tablegen as much as possible. M680x0 "Code Beads" are binary strings defined for every instruction and provide machine binary pattern for an instruction. For the most part it is the actual machine command with replacement slots (e.g. registers placeholders), occasionally it contains weird transformation magic. Once emitted this binary string is processed by C++ "thin" code emitter that "unpacks" and fixes beads producing final instruction. contains beads format for this backend.

    Further these beads may evolve into a state machine of sorts to accommodate more complex machine code emission patterns.
  • utils/extract-section is a small bash script that extracts an object file's section, used to test code emission etc.
  • Minor CMake tweaks.

Diff Detail

Event Timeline

m4yers created this revision.Aug 5 2018, 10:45 AM
m4yers edited the summary of this revision. (Show Details)Aug 5 2018, 10:46 AM
m4yers edited the summary of this revision. (Show Details)Aug 5 2018, 11:05 AM

@m4yers You really need to have this discussed on the llvm-dev mailing list first - adding a new target is not a small matter.

starkat99 rescinded a token.
starkat99 awarded a token.

@m4yers Abandon this now that the m68k target has landed?

Herald added a project: Restricted Project. · View Herald TranscriptMar 14 2021, 10:07 AM
m4yers abandoned this revision.Mar 16 2021, 1:37 AM