This contains just enough for lib/Target/RISCV to compile. Notably a basic RISCVTargetMachine and RISCVTargetInfo. At this point you can attempt llc -march=riscv32 myinput.ll and will find it fails due to the lack of MCAsmInfo.
Details
Diff Detail
Event Timeline
lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp | ||
---|---|---|
20 | Does it support JIT? I'd have thought you'd flip this when implementing the pseudo-linker under lib/ExecutionEngine. |
Address review comment from @t.p.northover
lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp | ||
---|---|---|
20 | That's an error - good catch! Thanks. |
lib/Target/RISCV/RISCVTargetMachine.cpp | ||
---|---|---|
40 | Default model is expected to be PIC instead of static? That's different from most general purpose targets. Perhaps deserves a comment? Or a note in the nonexistent psABI doc. :) |
Address review comment from @jyknight, match RISC-V gcc's behaviour in defaulting to Reloc::Static.
lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp | ||
---|---|---|
28 | Might want to add an assert(false && "not yet implemented"). |
Add a link to the RISC-V ISA docs in CompilerWriterInfo.rst
lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp | ||
---|---|---|
28 | llvm_unreachable would be even better. However in this specific case we actually need to define LLVMInitializeRISCVTargetMC as a no-op. llc will call the initialisation functions for all backends that were compiled in, so if this function is made to assert it means that all codegen tests for other archs will fail. I've modified the comment to be clear it's not purely a matter of being present for linking. |
A couple of small nits inline.
CMakeLists.txt | ||
---|---|---|
275 | Not really an objection, but MIPS and SPARC are both capitalised as if they were words. It would be more consistent to call the back end RiscV, though this would be ugly. | |
docs/CompilerWriterInfo.rst | ||
86 ↗ | (On Diff #69347) | Please also add a link to the ABI spec here. |
lib/Target/RISCV/RISCVTargetMachine.cpp | ||
35 | Please assert TT.isArch32Bit() here, so that we catch fire if someone tries to use this back end for the 128-bit RISC-V variant in the future. |
assert if trying to compile for RV128 (or at least, a RISC-V that is neither 32-bit or 64-bit).
CMakeLists.txt | ||
---|---|---|
275 | Yes, after considering the alternatives I decided RISCV would be least ugly. Plus ARM of course goes for all caps too. | |
docs/CompilerWriterInfo.rst | ||
86 ↗ | (On Diff #69347) | What exists of the ABI spec is contained within the user-level ISA specification (chapter 20). The separate ABI doc was an extract from the user-level ISA that was put out because the ABI supported by the tools was changed in-between ISA releases. The v2.1 spec contains the most up to date and complete ABI specification. |
I think everything here looks reasonable now. I only had a minor comment though so it may be good to check others are happy.
Refresh patch to follow the changes made to other backends in rL283702, moving TheRISCV32Target and TheRISCV64Target behind an accessor function.
Not really an objection, but MIPS and SPARC are both capitalised as if they were words. It would be more consistent to call the back end RiscV, though this would be ugly.