106c3fb27SDimitry Andric //===-- RISCVMCTargetDesc.cpp - RISC-V Target Descriptions ----------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric ///
906c3fb27SDimitry Andric /// This file provides RISC-V specific target descriptions.
100b57cec5SDimitry Andric ///
110b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric
130b57cec5SDimitry Andric #include "RISCVMCTargetDesc.h"
14e8d8bef9SDimitry Andric #include "RISCVBaseInfo.h"
150b57cec5SDimitry Andric #include "RISCVELFStreamer.h"
160b57cec5SDimitry Andric #include "RISCVInstPrinter.h"
170b57cec5SDimitry Andric #include "RISCVMCAsmInfo.h"
18349cc55cSDimitry Andric #include "RISCVMCObjectFileInfo.h"
190b57cec5SDimitry Andric #include "RISCVTargetStreamer.h"
200b57cec5SDimitry Andric #include "TargetInfo/RISCVTargetInfo.h"
210b57cec5SDimitry Andric #include "llvm/ADT/STLExtras.h"
22fe6060f1SDimitry Andric #include "llvm/MC/MCAsmBackend.h"
230b57cec5SDimitry Andric #include "llvm/MC/MCAsmInfo.h"
24fe6060f1SDimitry Andric #include "llvm/MC/MCCodeEmitter.h"
255ffd83dbSDimitry Andric #include "llvm/MC/MCInstrAnalysis.h"
260b57cec5SDimitry Andric #include "llvm/MC/MCInstrInfo.h"
27349cc55cSDimitry Andric #include "llvm/MC/MCObjectFileInfo.h"
28fe6060f1SDimitry Andric #include "llvm/MC/MCObjectWriter.h"
290b57cec5SDimitry Andric #include "llvm/MC/MCRegisterInfo.h"
300b57cec5SDimitry Andric #include "llvm/MC/MCStreamer.h"
310b57cec5SDimitry Andric #include "llvm/MC/MCSubtargetInfo.h"
32349cc55cSDimitry Andric #include "llvm/MC/TargetRegistry.h"
330b57cec5SDimitry Andric #include "llvm/Support/ErrorHandling.h"
345f757f3fSDimitry Andric #include <bitset>
350b57cec5SDimitry Andric
360b57cec5SDimitry Andric #define GET_INSTRINFO_MC_DESC
37753f127fSDimitry Andric #define ENABLE_INSTR_PREDICATE_VERIFIER
380b57cec5SDimitry Andric #include "RISCVGenInstrInfo.inc"
390b57cec5SDimitry Andric
400b57cec5SDimitry Andric #define GET_REGINFO_MC_DESC
410b57cec5SDimitry Andric #include "RISCVGenRegisterInfo.inc"
420b57cec5SDimitry Andric
430b57cec5SDimitry Andric #define GET_SUBTARGETINFO_MC_DESC
440b57cec5SDimitry Andric #include "RISCVGenSubtargetInfo.inc"
450b57cec5SDimitry Andric
46*0fca6ea1SDimitry Andric namespace llvm::RISCVVInversePseudosTable {
47*0fca6ea1SDimitry Andric
48*0fca6ea1SDimitry Andric using namespace RISCV;
49*0fca6ea1SDimitry Andric
50*0fca6ea1SDimitry Andric #define GET_RISCVVInversePseudosTable_IMPL
51*0fca6ea1SDimitry Andric #include "RISCVGenSearchableTables.inc"
52*0fca6ea1SDimitry Andric
53*0fca6ea1SDimitry Andric } // namespace llvm::RISCVVInversePseudosTable
54*0fca6ea1SDimitry Andric
550b57cec5SDimitry Andric using namespace llvm;
560b57cec5SDimitry Andric
createRISCVMCInstrInfo()570b57cec5SDimitry Andric static MCInstrInfo *createRISCVMCInstrInfo() {
580b57cec5SDimitry Andric MCInstrInfo *X = new MCInstrInfo();
590b57cec5SDimitry Andric InitRISCVMCInstrInfo(X);
600b57cec5SDimitry Andric return X;
610b57cec5SDimitry Andric }
620b57cec5SDimitry Andric
createRISCVMCRegisterInfo(const Triple & TT)630b57cec5SDimitry Andric static MCRegisterInfo *createRISCVMCRegisterInfo(const Triple &TT) {
640b57cec5SDimitry Andric MCRegisterInfo *X = new MCRegisterInfo();
650b57cec5SDimitry Andric InitRISCVMCRegisterInfo(X, RISCV::X1);
660b57cec5SDimitry Andric return X;
670b57cec5SDimitry Andric }
680b57cec5SDimitry Andric
createRISCVMCAsmInfo(const MCRegisterInfo & MRI,const Triple & TT,const MCTargetOptions & Options)690b57cec5SDimitry Andric static MCAsmInfo *createRISCVMCAsmInfo(const MCRegisterInfo &MRI,
70480093f4SDimitry Andric const Triple &TT,
71480093f4SDimitry Andric const MCTargetOptions &Options) {
720b57cec5SDimitry Andric MCAsmInfo *MAI = new RISCVMCAsmInfo(TT);
730b57cec5SDimitry Andric
74e8d8bef9SDimitry Andric MCRegister SP = MRI.getDwarfRegNum(RISCV::X2, true);
755ffd83dbSDimitry Andric MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(nullptr, SP, 0);
760b57cec5SDimitry Andric MAI->addInitialFrameState(Inst);
770b57cec5SDimitry Andric
780b57cec5SDimitry Andric return MAI;
790b57cec5SDimitry Andric }
800b57cec5SDimitry Andric
81349cc55cSDimitry Andric static MCObjectFileInfo *
createRISCVMCObjectFileInfo(MCContext & Ctx,bool PIC,bool LargeCodeModel=false)82349cc55cSDimitry Andric createRISCVMCObjectFileInfo(MCContext &Ctx, bool PIC,
83349cc55cSDimitry Andric bool LargeCodeModel = false) {
84349cc55cSDimitry Andric MCObjectFileInfo *MOFI = new RISCVMCObjectFileInfo();
85349cc55cSDimitry Andric MOFI->initMCObjectFileInfo(Ctx, PIC, LargeCodeModel);
86349cc55cSDimitry Andric return MOFI;
87349cc55cSDimitry Andric }
88349cc55cSDimitry Andric
createRISCVMCSubtargetInfo(const Triple & TT,StringRef CPU,StringRef FS)890b57cec5SDimitry Andric static MCSubtargetInfo *createRISCVMCSubtargetInfo(const Triple &TT,
900b57cec5SDimitry Andric StringRef CPU, StringRef FS) {
9181ad6265SDimitry Andric if (CPU.empty() || CPU == "generic")
92fe6060f1SDimitry Andric CPU = TT.isArch64Bit() ? "generic-rv64" : "generic-rv32";
9381ad6265SDimitry Andric
94fe6060f1SDimitry Andric return createRISCVMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
950b57cec5SDimitry Andric }
960b57cec5SDimitry Andric
createRISCVMCInstPrinter(const Triple & T,unsigned SyntaxVariant,const MCAsmInfo & MAI,const MCInstrInfo & MII,const MCRegisterInfo & MRI)970b57cec5SDimitry Andric static MCInstPrinter *createRISCVMCInstPrinter(const Triple &T,
980b57cec5SDimitry Andric unsigned SyntaxVariant,
990b57cec5SDimitry Andric const MCAsmInfo &MAI,
1000b57cec5SDimitry Andric const MCInstrInfo &MII,
1010b57cec5SDimitry Andric const MCRegisterInfo &MRI) {
1020b57cec5SDimitry Andric return new RISCVInstPrinter(MAI, MII, MRI);
1030b57cec5SDimitry Andric }
1040b57cec5SDimitry Andric
1050b57cec5SDimitry Andric static MCTargetStreamer *
createRISCVObjectTargetStreamer(MCStreamer & S,const MCSubtargetInfo & STI)1060b57cec5SDimitry Andric createRISCVObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI) {
1070b57cec5SDimitry Andric const Triple &TT = STI.getTargetTriple();
1080b57cec5SDimitry Andric if (TT.isOSBinFormatELF())
1090b57cec5SDimitry Andric return new RISCVTargetELFStreamer(S, STI);
1100b57cec5SDimitry Andric return nullptr;
1110b57cec5SDimitry Andric }
1120b57cec5SDimitry Andric
113*0fca6ea1SDimitry Andric static MCTargetStreamer *
createRISCVAsmTargetStreamer(MCStreamer & S,formatted_raw_ostream & OS,MCInstPrinter * InstPrint)114*0fca6ea1SDimitry Andric createRISCVAsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS,
115*0fca6ea1SDimitry Andric MCInstPrinter *InstPrint) {
1160b57cec5SDimitry Andric return new RISCVTargetAsmStreamer(S, OS);
1170b57cec5SDimitry Andric }
1180b57cec5SDimitry Andric
createRISCVNullTargetStreamer(MCStreamer & S)1195ffd83dbSDimitry Andric static MCTargetStreamer *createRISCVNullTargetStreamer(MCStreamer &S) {
1205ffd83dbSDimitry Andric return new RISCVTargetStreamer(S);
1215ffd83dbSDimitry Andric }
1225ffd83dbSDimitry Andric
1235ffd83dbSDimitry Andric namespace {
1245ffd83dbSDimitry Andric
1255ffd83dbSDimitry Andric class RISCVMCInstrAnalysis : public MCInstrAnalysis {
1265f757f3fSDimitry Andric int64_t GPRState[31] = {};
1275f757f3fSDimitry Andric std::bitset<31> GPRValidMask;
1285f757f3fSDimitry Andric
isGPR(unsigned Reg)1295f757f3fSDimitry Andric static bool isGPR(unsigned Reg) {
1305f757f3fSDimitry Andric return Reg >= RISCV::X0 && Reg <= RISCV::X31;
1315f757f3fSDimitry Andric }
1325f757f3fSDimitry Andric
getRegIndex(unsigned Reg)1335f757f3fSDimitry Andric static unsigned getRegIndex(unsigned Reg) {
1345f757f3fSDimitry Andric assert(isGPR(Reg) && Reg != RISCV::X0 && "Invalid GPR reg");
1355f757f3fSDimitry Andric return Reg - RISCV::X1;
1365f757f3fSDimitry Andric }
1375f757f3fSDimitry Andric
setGPRState(unsigned Reg,std::optional<int64_t> Value)1385f757f3fSDimitry Andric void setGPRState(unsigned Reg, std::optional<int64_t> Value) {
1395f757f3fSDimitry Andric if (Reg == RISCV::X0)
1405f757f3fSDimitry Andric return;
1415f757f3fSDimitry Andric
1425f757f3fSDimitry Andric auto Index = getRegIndex(Reg);
1435f757f3fSDimitry Andric
1445f757f3fSDimitry Andric if (Value) {
1455f757f3fSDimitry Andric GPRState[Index] = *Value;
1465f757f3fSDimitry Andric GPRValidMask.set(Index);
1475f757f3fSDimitry Andric } else {
1485f757f3fSDimitry Andric GPRValidMask.reset(Index);
1495f757f3fSDimitry Andric }
1505f757f3fSDimitry Andric }
1515f757f3fSDimitry Andric
getGPRState(unsigned Reg) const1525f757f3fSDimitry Andric std::optional<int64_t> getGPRState(unsigned Reg) const {
1535f757f3fSDimitry Andric if (Reg == RISCV::X0)
1545f757f3fSDimitry Andric return 0;
1555f757f3fSDimitry Andric
1565f757f3fSDimitry Andric auto Index = getRegIndex(Reg);
1575f757f3fSDimitry Andric
1585f757f3fSDimitry Andric if (GPRValidMask.test(Index))
1595f757f3fSDimitry Andric return GPRState[Index];
1605f757f3fSDimitry Andric return std::nullopt;
1615f757f3fSDimitry Andric }
1625f757f3fSDimitry Andric
1635ffd83dbSDimitry Andric public:
RISCVMCInstrAnalysis(const MCInstrInfo * Info)1645ffd83dbSDimitry Andric explicit RISCVMCInstrAnalysis(const MCInstrInfo *Info)
1655ffd83dbSDimitry Andric : MCInstrAnalysis(Info) {}
1665ffd83dbSDimitry Andric
resetState()1675f757f3fSDimitry Andric void resetState() override { GPRValidMask.reset(); }
1685f757f3fSDimitry Andric
updateState(const MCInst & Inst,uint64_t Addr)1695f757f3fSDimitry Andric void updateState(const MCInst &Inst, uint64_t Addr) override {
1705f757f3fSDimitry Andric // Terminators mark the end of a basic block which means the sequentially
1715f757f3fSDimitry Andric // next instruction will be the first of another basic block and the current
1725f757f3fSDimitry Andric // state will typically not be valid anymore. For calls, we assume all
1735f757f3fSDimitry Andric // registers may be clobbered by the callee (TODO: should we take the
1745f757f3fSDimitry Andric // calling convention into account?).
1755f757f3fSDimitry Andric if (isTerminator(Inst) || isCall(Inst)) {
1765f757f3fSDimitry Andric resetState();
1775f757f3fSDimitry Andric return;
1785f757f3fSDimitry Andric }
1795f757f3fSDimitry Andric
1805f757f3fSDimitry Andric switch (Inst.getOpcode()) {
1815f757f3fSDimitry Andric default: {
1825f757f3fSDimitry Andric // Clear the state of all defined registers for instructions that we don't
1835f757f3fSDimitry Andric // explicitly support.
1845f757f3fSDimitry Andric auto NumDefs = Info->get(Inst.getOpcode()).getNumDefs();
1855f757f3fSDimitry Andric for (unsigned I = 0; I < NumDefs; ++I) {
1865f757f3fSDimitry Andric auto DefReg = Inst.getOperand(I).getReg();
1875f757f3fSDimitry Andric if (isGPR(DefReg))
1885f757f3fSDimitry Andric setGPRState(DefReg, std::nullopt);
1895f757f3fSDimitry Andric }
1905f757f3fSDimitry Andric break;
1915f757f3fSDimitry Andric }
1925f757f3fSDimitry Andric case RISCV::AUIPC:
1935f757f3fSDimitry Andric setGPRState(Inst.getOperand(0).getReg(),
1945f757f3fSDimitry Andric Addr + (Inst.getOperand(1).getImm() << 12));
1955f757f3fSDimitry Andric break;
1965f757f3fSDimitry Andric }
1975f757f3fSDimitry Andric }
1985f757f3fSDimitry Andric
evaluateBranch(const MCInst & Inst,uint64_t Addr,uint64_t Size,uint64_t & Target) const1995ffd83dbSDimitry Andric bool evaluateBranch(const MCInst &Inst, uint64_t Addr, uint64_t Size,
2005ffd83dbSDimitry Andric uint64_t &Target) const override {
2015ffd83dbSDimitry Andric if (isConditionalBranch(Inst)) {
2025ffd83dbSDimitry Andric int64_t Imm;
2035ffd83dbSDimitry Andric if (Size == 2)
2045ffd83dbSDimitry Andric Imm = Inst.getOperand(1).getImm();
2055ffd83dbSDimitry Andric else
2065ffd83dbSDimitry Andric Imm = Inst.getOperand(2).getImm();
2075ffd83dbSDimitry Andric Target = Addr + Imm;
2085ffd83dbSDimitry Andric return true;
2095ffd83dbSDimitry Andric }
2105ffd83dbSDimitry Andric
2115ffd83dbSDimitry Andric if (Inst.getOpcode() == RISCV::C_JAL || Inst.getOpcode() == RISCV::C_J) {
2125ffd83dbSDimitry Andric Target = Addr + Inst.getOperand(0).getImm();
2135ffd83dbSDimitry Andric return true;
2145ffd83dbSDimitry Andric }
2155ffd83dbSDimitry Andric
2165ffd83dbSDimitry Andric if (Inst.getOpcode() == RISCV::JAL) {
2175ffd83dbSDimitry Andric Target = Addr + Inst.getOperand(1).getImm();
2185ffd83dbSDimitry Andric return true;
2195ffd83dbSDimitry Andric }
2205ffd83dbSDimitry Andric
2215f757f3fSDimitry Andric if (Inst.getOpcode() == RISCV::JALR) {
2225f757f3fSDimitry Andric if (auto TargetRegState = getGPRState(Inst.getOperand(1).getReg())) {
2235f757f3fSDimitry Andric Target = *TargetRegState + Inst.getOperand(2).getImm();
2245f757f3fSDimitry Andric return true;
2255f757f3fSDimitry Andric }
2265f757f3fSDimitry Andric
2275f757f3fSDimitry Andric return false;
2285f757f3fSDimitry Andric }
2295f757f3fSDimitry Andric
2305ffd83dbSDimitry Andric return false;
2315ffd83dbSDimitry Andric }
23206c3fb27SDimitry Andric
isTerminator(const MCInst & Inst) const23306c3fb27SDimitry Andric bool isTerminator(const MCInst &Inst) const override {
23406c3fb27SDimitry Andric if (MCInstrAnalysis::isTerminator(Inst))
23506c3fb27SDimitry Andric return true;
23606c3fb27SDimitry Andric
23706c3fb27SDimitry Andric switch (Inst.getOpcode()) {
23806c3fb27SDimitry Andric default:
23906c3fb27SDimitry Andric return false;
24006c3fb27SDimitry Andric case RISCV::JAL:
24106c3fb27SDimitry Andric case RISCV::JALR:
24206c3fb27SDimitry Andric return Inst.getOperand(0).getReg() == RISCV::X0;
24306c3fb27SDimitry Andric }
24406c3fb27SDimitry Andric }
24506c3fb27SDimitry Andric
isCall(const MCInst & Inst) const24606c3fb27SDimitry Andric bool isCall(const MCInst &Inst) const override {
24706c3fb27SDimitry Andric if (MCInstrAnalysis::isCall(Inst))
24806c3fb27SDimitry Andric return true;
24906c3fb27SDimitry Andric
25006c3fb27SDimitry Andric switch (Inst.getOpcode()) {
25106c3fb27SDimitry Andric default:
25206c3fb27SDimitry Andric return false;
25306c3fb27SDimitry Andric case RISCV::JAL:
25406c3fb27SDimitry Andric case RISCV::JALR:
25506c3fb27SDimitry Andric return Inst.getOperand(0).getReg() != RISCV::X0;
25606c3fb27SDimitry Andric }
25706c3fb27SDimitry Andric }
25806c3fb27SDimitry Andric
isReturn(const MCInst & Inst) const25906c3fb27SDimitry Andric bool isReturn(const MCInst &Inst) const override {
26006c3fb27SDimitry Andric if (MCInstrAnalysis::isReturn(Inst))
26106c3fb27SDimitry Andric return true;
26206c3fb27SDimitry Andric
26306c3fb27SDimitry Andric switch (Inst.getOpcode()) {
26406c3fb27SDimitry Andric default:
26506c3fb27SDimitry Andric return false;
26606c3fb27SDimitry Andric case RISCV::JALR:
26706c3fb27SDimitry Andric return Inst.getOperand(0).getReg() == RISCV::X0 &&
26806c3fb27SDimitry Andric maybeReturnAddress(Inst.getOperand(1).getReg());
26906c3fb27SDimitry Andric case RISCV::C_JR:
27006c3fb27SDimitry Andric return maybeReturnAddress(Inst.getOperand(0).getReg());
27106c3fb27SDimitry Andric }
27206c3fb27SDimitry Andric }
27306c3fb27SDimitry Andric
isBranch(const MCInst & Inst) const27406c3fb27SDimitry Andric bool isBranch(const MCInst &Inst) const override {
27506c3fb27SDimitry Andric if (MCInstrAnalysis::isBranch(Inst))
27606c3fb27SDimitry Andric return true;
27706c3fb27SDimitry Andric
27806c3fb27SDimitry Andric return isBranchImpl(Inst);
27906c3fb27SDimitry Andric }
28006c3fb27SDimitry Andric
isUnconditionalBranch(const MCInst & Inst) const28106c3fb27SDimitry Andric bool isUnconditionalBranch(const MCInst &Inst) const override {
28206c3fb27SDimitry Andric if (MCInstrAnalysis::isUnconditionalBranch(Inst))
28306c3fb27SDimitry Andric return true;
28406c3fb27SDimitry Andric
28506c3fb27SDimitry Andric return isBranchImpl(Inst);
28606c3fb27SDimitry Andric }
28706c3fb27SDimitry Andric
isIndirectBranch(const MCInst & Inst) const28806c3fb27SDimitry Andric bool isIndirectBranch(const MCInst &Inst) const override {
28906c3fb27SDimitry Andric if (MCInstrAnalysis::isIndirectBranch(Inst))
29006c3fb27SDimitry Andric return true;
29106c3fb27SDimitry Andric
29206c3fb27SDimitry Andric switch (Inst.getOpcode()) {
29306c3fb27SDimitry Andric default:
29406c3fb27SDimitry Andric return false;
29506c3fb27SDimitry Andric case RISCV::JALR:
29606c3fb27SDimitry Andric return Inst.getOperand(0).getReg() == RISCV::X0 &&
29706c3fb27SDimitry Andric !maybeReturnAddress(Inst.getOperand(1).getReg());
29806c3fb27SDimitry Andric case RISCV::C_JR:
29906c3fb27SDimitry Andric return !maybeReturnAddress(Inst.getOperand(0).getReg());
30006c3fb27SDimitry Andric }
30106c3fb27SDimitry Andric }
30206c3fb27SDimitry Andric
30306c3fb27SDimitry Andric private:
maybeReturnAddress(unsigned Reg)30406c3fb27SDimitry Andric static bool maybeReturnAddress(unsigned Reg) {
30506c3fb27SDimitry Andric // X1 is used for normal returns, X5 for returns from outlined functions.
30606c3fb27SDimitry Andric return Reg == RISCV::X1 || Reg == RISCV::X5;
30706c3fb27SDimitry Andric }
30806c3fb27SDimitry Andric
isBranchImpl(const MCInst & Inst)30906c3fb27SDimitry Andric static bool isBranchImpl(const MCInst &Inst) {
31006c3fb27SDimitry Andric switch (Inst.getOpcode()) {
31106c3fb27SDimitry Andric default:
31206c3fb27SDimitry Andric return false;
31306c3fb27SDimitry Andric case RISCV::JAL:
31406c3fb27SDimitry Andric return Inst.getOperand(0).getReg() == RISCV::X0;
31506c3fb27SDimitry Andric case RISCV::JALR:
31606c3fb27SDimitry Andric return Inst.getOperand(0).getReg() == RISCV::X0 &&
31706c3fb27SDimitry Andric !maybeReturnAddress(Inst.getOperand(1).getReg());
31806c3fb27SDimitry Andric case RISCV::C_JR:
31906c3fb27SDimitry Andric return !maybeReturnAddress(Inst.getOperand(0).getReg());
32006c3fb27SDimitry Andric }
32106c3fb27SDimitry Andric }
3225ffd83dbSDimitry Andric };
3235ffd83dbSDimitry Andric
3245ffd83dbSDimitry Andric } // end anonymous namespace
3255ffd83dbSDimitry Andric
createRISCVInstrAnalysis(const MCInstrInfo * Info)3265ffd83dbSDimitry Andric static MCInstrAnalysis *createRISCVInstrAnalysis(const MCInstrInfo *Info) {
3275ffd83dbSDimitry Andric return new RISCVMCInstrAnalysis(Info);
3285ffd83dbSDimitry Andric }
3295ffd83dbSDimitry Andric
330fe6060f1SDimitry Andric namespace {
createRISCVELFStreamer(const Triple & T,MCContext & Context,std::unique_ptr<MCAsmBackend> && MAB,std::unique_ptr<MCObjectWriter> && MOW,std::unique_ptr<MCCodeEmitter> && MCE)331fe6060f1SDimitry Andric MCStreamer *createRISCVELFStreamer(const Triple &T, MCContext &Context,
332fe6060f1SDimitry Andric std::unique_ptr<MCAsmBackend> &&MAB,
333fe6060f1SDimitry Andric std::unique_ptr<MCObjectWriter> &&MOW,
334*0fca6ea1SDimitry Andric std::unique_ptr<MCCodeEmitter> &&MCE) {
335fe6060f1SDimitry Andric return createRISCVELFStreamer(Context, std::move(MAB), std::move(MOW),
336*0fca6ea1SDimitry Andric std::move(MCE));
337fe6060f1SDimitry Andric }
338fe6060f1SDimitry Andric } // end anonymous namespace
339fe6060f1SDimitry Andric
LLVMInitializeRISCVTargetMC()340480093f4SDimitry Andric extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVTargetMC() {
3410b57cec5SDimitry Andric for (Target *T : {&getTheRISCV32Target(), &getTheRISCV64Target()}) {
3420b57cec5SDimitry Andric TargetRegistry::RegisterMCAsmInfo(*T, createRISCVMCAsmInfo);
343349cc55cSDimitry Andric TargetRegistry::RegisterMCObjectFileInfo(*T, createRISCVMCObjectFileInfo);
3440b57cec5SDimitry Andric TargetRegistry::RegisterMCInstrInfo(*T, createRISCVMCInstrInfo);
3450b57cec5SDimitry Andric TargetRegistry::RegisterMCRegInfo(*T, createRISCVMCRegisterInfo);
3460b57cec5SDimitry Andric TargetRegistry::RegisterMCAsmBackend(*T, createRISCVAsmBackend);
3470b57cec5SDimitry Andric TargetRegistry::RegisterMCCodeEmitter(*T, createRISCVMCCodeEmitter);
3480b57cec5SDimitry Andric TargetRegistry::RegisterMCInstPrinter(*T, createRISCVMCInstPrinter);
3490b57cec5SDimitry Andric TargetRegistry::RegisterMCSubtargetInfo(*T, createRISCVMCSubtargetInfo);
350fe6060f1SDimitry Andric TargetRegistry::RegisterELFStreamer(*T, createRISCVELFStreamer);
3510b57cec5SDimitry Andric TargetRegistry::RegisterObjectTargetStreamer(
3520b57cec5SDimitry Andric *T, createRISCVObjectTargetStreamer);
3535ffd83dbSDimitry Andric TargetRegistry::RegisterMCInstrAnalysis(*T, createRISCVInstrAnalysis);
3540b57cec5SDimitry Andric
3550b57cec5SDimitry Andric // Register the asm target streamer.
3560b57cec5SDimitry Andric TargetRegistry::RegisterAsmTargetStreamer(*T, createRISCVAsmTargetStreamer);
3575ffd83dbSDimitry Andric // Register the null target streamer.
3585ffd83dbSDimitry Andric TargetRegistry::RegisterNullTargetStreamer(*T,
3595ffd83dbSDimitry Andric createRISCVNullTargetStreamer);
3600b57cec5SDimitry Andric }
3610b57cec5SDimitry Andric }
362