[PATCH] D50314: M680x0 codegen target

Artyom Goncharov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 5 10:46:01 PDT 2018


m4yers created this revision.
Herald added subscribers: llvm-commits, dexonsmith, fedor.sergeev, mgorny.

Trivia
------

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.

Tests
-----

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

1. LLVM Modifications
2. 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.
3. "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. M680x0InstrFormats.td 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.
4. utils/extract-section is a small bash script that extracts an object file's section, used to test code emission etc.
5. Minor CMake tweaks.


Repository:
  rL LLVM

https://reviews.llvm.org/D50314

Files:
  CMakeLists.txt
  cmake/config-ix.cmake
  cmake/modules/HandleLLVMOptions.cmake
  include/llvm/ADT/Triple.h
  include/llvm/BinaryFormat/ELF.h
  include/llvm/BinaryFormat/ELFRelocs/m680x0.def
  include/llvm/MC/MCExpr.h
  include/llvm/MC/MCInstrDesc.h
  include/llvm/Object/ELFObjectFile.h
  include/llvm/module.modulemap
  lib/MC/MCExpr.cpp
  lib/Object/ELF.cpp
  lib/ObjectYAML/ELFYAML.cpp
  lib/Support/Triple.cpp
  lib/Target/LLVMBuild.txt
  lib/Target/M680x0/
  lib/Target/M680x0/CMakeLists.txt
  lib/Target/M680x0/InstPrinter/
  lib/Target/M680x0/InstPrinter/CMakeLists.txt
  lib/Target/M680x0/InstPrinter/LLVMBuild.txt
  lib/Target/M680x0/InstPrinter/M680x0InstPrinter.cpp
  lib/Target/M680x0/InstPrinter/M680x0InstPrinter.h
  lib/Target/M680x0/LLVMBuild.txt
  lib/Target/M680x0/M680x0.h
  lib/Target/M680x0/M680x0.td
  lib/Target/M680x0/M680x0AsmPrinter.cpp
  lib/Target/M680x0/M680x0AsmPrinter.h
  lib/Target/M680x0/M680x0CallingConv.h
  lib/Target/M680x0/M680x0CallingConv.td
  lib/Target/M680x0/M680x0CollapseMOVEMPass.cpp
  lib/Target/M680x0/M680x0ExpandPseudo.cpp
  lib/Target/M680x0/M680x0FrameLowering.cpp
  lib/Target/M680x0/M680x0FrameLowering.h
  lib/Target/M680x0/M680x0ISelDAGToDAG.cpp
  lib/Target/M680x0/M680x0ISelLowering.cpp
  lib/Target/M680x0/M680x0ISelLowering.h
  lib/Target/M680x0/M680x0InstrArithmetic.td
  lib/Target/M680x0/M680x0InstrBits.td
  lib/Target/M680x0/M680x0InstrBuilder.h
  lib/Target/M680x0/M680x0InstrCompiler.td
  lib/Target/M680x0/M680x0InstrControl.td
  lib/Target/M680x0/M680x0InstrData.td
  lib/Target/M680x0/M680x0InstrFormats.td
  lib/Target/M680x0/M680x0InstrInfo.cpp
  lib/Target/M680x0/M680x0InstrInfo.h
  lib/Target/M680x0/M680x0InstrInfo.td
  lib/Target/M680x0/M680x0InstrShiftRotate.td
  lib/Target/M680x0/M680x0MCInstLower.cpp
  lib/Target/M680x0/M680x0MCInstLower.h
  lib/Target/M680x0/M680x0MachineFunction.cpp
  lib/Target/M680x0/M680x0MachineFunction.h
  lib/Target/M680x0/M680x0RegisterInfo.cpp
  lib/Target/M680x0/M680x0RegisterInfo.h
  lib/Target/M680x0/M680x0RegisterInfo.td
  lib/Target/M680x0/M680x0Schedule.td
  lib/Target/M680x0/M680x0Subtarget.cpp
  lib/Target/M680x0/M680x0Subtarget.h
  lib/Target/M680x0/M680x0TargetMachine.cpp
  lib/Target/M680x0/M680x0TargetMachine.h
  lib/Target/M680x0/M680x0TargetObjectFile.cpp
  lib/Target/M680x0/M680x0TargetObjectFile.h
  lib/Target/M680x0/MCTargetDesc/
  lib/Target/M680x0/MCTargetDesc/CMakeLists.txt
  lib/Target/M680x0/MCTargetDesc/LLVMBuild.txt
  lib/Target/M680x0/MCTargetDesc/M680x0AsmBackend.cpp
  lib/Target/M680x0/MCTargetDesc/M680x0BaseInfo.h
  lib/Target/M680x0/MCTargetDesc/M680x0ELFObjectWriter.cpp
  lib/Target/M680x0/MCTargetDesc/M680x0FixupKinds.h
  lib/Target/M680x0/MCTargetDesc/M680x0MCAsmInfo.cpp
  lib/Target/M680x0/MCTargetDesc/M680x0MCAsmInfo.h
  lib/Target/M680x0/MCTargetDesc/M680x0MCCodeEmitter.cpp
  lib/Target/M680x0/MCTargetDesc/M680x0MCTargetDesc.cpp
  lib/Target/M680x0/MCTargetDesc/M680x0MCTargetDesc.h
  lib/Target/M680x0/README.md
  lib/Target/M680x0/TODO.md
  lib/Target/M680x0/TargetInfo/
  lib/Target/M680x0/TargetInfo/CMakeLists.txt
  lib/Target/M680x0/TargetInfo/LLVMBuild.txt
  lib/Target/M680x0/TargetInfo/M680x0TargetInfo.cpp
  test/CodeGen/M680x0/
  test/CodeGen/M680x0/ASM/
  test/CodeGen/M680x0/ASM/Alloc/
  test/CodeGen/M680x0/ASM/Alloc/dyn_alloca_aligned.ll
  test/CodeGen/M680x0/ASM/Arith/
  test/CodeGen/M680x0/ASM/Arith/add-with-overflow.ll
  test/CodeGen/M680x0/ASM/Arith/add.ll
  test/CodeGen/M680x0/ASM/Arith/divide-by-constant.ll
  test/CodeGen/M680x0/ASM/Arith/imul.ll
  test/CodeGen/M680x0/ASM/Arith/lshr.ll
  test/CodeGen/M680x0/ASM/Arith/mul64.ll
  test/CodeGen/M680x0/ASM/Arith/sdiv-exact.ll
  test/CodeGen/M680x0/ASM/Arith/smul-with-overflow.ll
  test/CodeGen/M680x0/ASM/Arith/sub-with-overflow.ll
  test/CodeGen/M680x0/ASM/Arith/sub.ll
  test/CodeGen/M680x0/ASM/Arith/umul-with-overflow.ll
  test/CodeGen/M680x0/ASM/CConv/
  test/CodeGen/M680x0/ASM/CConv/c-args-inreg.ll
  test/CodeGen/M680x0/ASM/CConv/c-args.ll
  test/CodeGen/M680x0/ASM/CConv/c-call.ll
  test/CodeGen/M680x0/ASM/CConv/fastcc-args.ll
  test/CodeGen/M680x0/ASM/CConv/fastcc-call.ll
  test/CodeGen/M680x0/ASM/CodeModel/
  test/CodeGen/M680x0/ASM/CodeModel/medium-pic.ll
  test/CodeGen/M680x0/ASM/CodeModel/medium-pie-global-access.ll
  test/CodeGen/M680x0/ASM/CodeModel/medium-pie.ll
  test/CodeGen/M680x0/ASM/CodeModel/medium-static.ll
  test/CodeGen/M680x0/ASM/CodeModel/small-pic.ll
  test/CodeGen/M680x0/ASM/CodeModel/small-pie-global-access.ll
  test/CodeGen/M680x0/ASM/CodeModel/small-pie.ll
  test/CodeGen/M680x0/ASM/CodeModel/small-static.ll
  test/CodeGen/M680x0/ASM/Control/
  test/CodeGen/M680x0/ASM/Control/cmp.ll
  test/CodeGen/M680x0/ASM/Control/long-setcc.ll
  test/CodeGen/M680x0/ASM/Control/setcc.ll
  test/CodeGen/M680x0/ASM/Std/
  test/CodeGen/M680x0/ASM/Std/varargs.ll
  test/CodeGen/M680x0/OBJ/
  test/CodeGen/M680x0/OBJ/Arith/
  test/CodeGen/M680x0/OBJ/Arith/Classes/
  test/CodeGen/M680x0/OBJ/Arith/Classes/MxBiArOp_FMI.mir
  test/CodeGen/M680x0/OBJ/Arith/Classes/MxBiArOp_FMR.mir
  test/CodeGen/M680x0/OBJ/Arith/Classes/MxBiArOp_RFRI.mir
  test/CodeGen/M680x0/OBJ/Arith/Classes/MxBiArOp_RFRI_xEA.mir
  test/CodeGen/M680x0/OBJ/Arith/Classes/MxBiArOp_RFRM.mir
  test/CodeGen/M680x0/OBJ/Arith/Classes/MxBiArOp_RFRRF.mir
  test/CodeGen/M680x0/OBJ/Arith/Classes/MxBiArOp_RFRR_EAd.mir
  test/CodeGen/M680x0/OBJ/Arith/Classes/MxBiArOp_RFRR_xEA.mir
  test/CodeGen/M680x0/OBJ/Arith/Classes/MxCMP_BI.mir
  test/CodeGen/M680x0/OBJ/Arith/Classes/MxCMP_MI.mir
  test/CodeGen/M680x0/OBJ/Arith/Classes/MxCMP_RI.mir
  test/CodeGen/M680x0/OBJ/Arith/Classes/MxCMP_RM.mir
  test/CodeGen/M680x0/OBJ/Arith/Classes/MxCMP_RR.mir
  test/CodeGen/M680x0/OBJ/Arith/Classes/MxDiMu.mir
  test/CodeGen/M680x0/OBJ/Arith/Classes/MxExt.mir
  test/CodeGen/M680x0/OBJ/Arith/Classes/MxNEG.mir
  test/CodeGen/M680x0/OBJ/Bits/
  test/CodeGen/M680x0/OBJ/Bits/Classes/
  test/CodeGen/M680x0/OBJ/Bits/Classes/MxBTST_MI.mir
  test/CodeGen/M680x0/OBJ/Bits/Classes/MxBTST_MR.mir
  test/CodeGen/M680x0/OBJ/Bits/Classes/MxBTST_RI.mir
  test/CodeGen/M680x0/OBJ/Bits/Classes/MxBTST_RR.mir
  test/CodeGen/M680x0/OBJ/Control/
  test/CodeGen/M680x0/OBJ/Control/Classes/
  test/CodeGen/M680x0/OBJ/Control/Classes/MxBRA.mir
  test/CodeGen/M680x0/OBJ/Control/Classes/MxBcc.mir
  test/CodeGen/M680x0/OBJ/Control/Classes/MxCALL.mir
  test/CodeGen/M680x0/OBJ/Control/Classes/MxJMP.mir
  test/CodeGen/M680x0/OBJ/Control/Classes/MxNOP.mir
  test/CodeGen/M680x0/OBJ/Control/Classes/MxRTS.mir
  test/CodeGen/M680x0/OBJ/Control/Classes/MxScc.mir
  test/CodeGen/M680x0/OBJ/Control/branch-pc-rel.mir
  test/CodeGen/M680x0/OBJ/Control/call-pc-rel.mir
  test/CodeGen/M680x0/OBJ/Data/
  test/CodeGen/M680x0/OBJ/Data/Classes/
  test/CodeGen/M680x0/OBJ/Data/Classes/MxLEA.mir
  test/CodeGen/M680x0/OBJ/Data/Classes/MxMOVEM_MR.mir
  test/CodeGen/M680x0/OBJ/Data/Classes/MxMOVEM_RM.mir
  test/CodeGen/M680x0/OBJ/Data/Classes/MxMoveCCR.mir
  test/CodeGen/M680x0/OBJ/Data/Classes/MxMove_MI.mir
  test/CodeGen/M680x0/OBJ/Data/Classes/MxMove_MM.mir
  test/CodeGen/M680x0/OBJ/Data/Classes/MxMove_MR.mir
  test/CodeGen/M680x0/OBJ/Data/Classes/MxMove_RI.mir
  test/CodeGen/M680x0/OBJ/Data/Classes/MxMove_RM.mir
  test/CodeGen/M680x0/OBJ/Data/Classes/MxMove_RR.mir
  test/CodeGen/M680x0/OBJ/README.md
  test/CodeGen/M680x0/OBJ/Relaxations/
  test/CodeGen/M680x0/OBJ/Relaxations/branch.mir
  test/CodeGen/M680x0/OBJ/Relocations/
  test/CodeGen/M680x0/OBJ/Relocations/data-abs.mir
  test/CodeGen/M680x0/OBJ/Relocations/data-gotoff.mir
  test/CodeGen/M680x0/OBJ/Relocations/data-gotpcrel.mir
  test/CodeGen/M680x0/OBJ/Relocations/data-pc-rel.mir
  test/CodeGen/M680x0/OBJ/Relocations/text-plt.mir
  test/CodeGen/M680x0/OBJ/ShiftRotate/
  test/CodeGen/M680x0/OBJ/ShiftRotate/Classes/
  test/CodeGen/M680x0/OBJ/ShiftRotate/Classes/MxSR_DD.mir
  test/CodeGen/M680x0/OBJ/ShiftRotate/Classes/MxSR_DI.mir
  test/CodeGen/M680x0/PAS/
  test/CodeGen/M680x0/PAS/CollapseMOVEM.mir
  test/CodeGen/M680x0/lit.local.cfg
  utils/TableGen/CMakeLists.txt
  utils/TableGen/CodeBeadsGen.cpp
  utils/TableGen/InstrInfoEmitter.cpp
  utils/TableGen/TableGen.cpp
  utils/TableGen/TableGenBackends.h
  utils/extract-section





More information about the llvm-commits mailing list