1 //===-- VEMCTargetDesc.cpp - VE Target Descriptions -----------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file provides VE specific target descriptions. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #include "VEMCTargetDesc.h" 14 #include "TargetInfo/VETargetInfo.h" 15 #include "VEInstPrinter.h" 16 #include "VEMCAsmInfo.h" 17 #include "VETargetStreamer.h" 18 #include "llvm/MC/MCInstrInfo.h" 19 #include "llvm/MC/MCRegisterInfo.h" 20 #include "llvm/MC/MCSubtargetInfo.h" 21 #include "llvm/Support/ErrorHandling.h" 22 #include "llvm/Support/TargetRegistry.h" 23 24 using namespace llvm; 25 26 #define GET_INSTRINFO_MC_DESC 27 #include "VEGenInstrInfo.inc" 28 29 #define GET_SUBTARGETINFO_MC_DESC 30 #include "VEGenSubtargetInfo.inc" 31 32 #define GET_REGINFO_MC_DESC 33 #include "VEGenRegisterInfo.inc" 34 35 static MCAsmInfo *createVEMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT, 36 const MCTargetOptions &Options) { 37 MCAsmInfo *MAI = new VEELFMCAsmInfo(TT); 38 unsigned Reg = MRI.getDwarfRegNum(VE::SX11, true); 39 MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(nullptr, Reg, 0); 40 MAI->addInitialFrameState(Inst); 41 return MAI; 42 } 43 44 static MCInstrInfo *createVEMCInstrInfo() { 45 MCInstrInfo *X = new MCInstrInfo(); 46 InitVEMCInstrInfo(X); 47 return X; 48 } 49 50 static MCRegisterInfo *createVEMCRegisterInfo(const Triple &TT) { 51 MCRegisterInfo *X = new MCRegisterInfo(); 52 InitVEMCRegisterInfo(X, VE::SX10); 53 return X; 54 } 55 56 static MCSubtargetInfo *createVEMCSubtargetInfo(const Triple &TT, StringRef CPU, 57 StringRef FS) { 58 if (CPU.empty()) 59 CPU = "ve"; 60 return createVEMCSubtargetInfoImpl(TT, CPU, FS); 61 } 62 63 static MCTargetStreamer * 64 createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI) { 65 return new VETargetELFStreamer(S); 66 } 67 68 static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S, 69 formatted_raw_ostream &OS, 70 MCInstPrinter *InstPrint, 71 bool isVerboseAsm) { 72 return new VETargetAsmStreamer(S, OS); 73 } 74 75 static MCInstPrinter *createVEMCInstPrinter(const Triple &T, 76 unsigned SyntaxVariant, 77 const MCAsmInfo &MAI, 78 const MCInstrInfo &MII, 79 const MCRegisterInfo &MRI) { 80 return new VEInstPrinter(MAI, MII, MRI); 81 } 82 83 extern "C" void LLVMInitializeVETargetMC() { 84 // Register the MC asm info. 85 RegisterMCAsmInfoFn X(getTheVETarget(), createVEMCAsmInfo); 86 87 for (Target *T : {&getTheVETarget()}) { 88 // Register the MC instruction info. 89 TargetRegistry::RegisterMCInstrInfo(*T, createVEMCInstrInfo); 90 91 // Register the MC register info. 92 TargetRegistry::RegisterMCRegInfo(*T, createVEMCRegisterInfo); 93 94 // Register the MC subtarget info. 95 TargetRegistry::RegisterMCSubtargetInfo(*T, createVEMCSubtargetInfo); 96 97 // Register the MC Code Emitter. 98 TargetRegistry::RegisterMCCodeEmitter(*T, createVEMCCodeEmitter); 99 100 // Register the asm backend. 101 TargetRegistry::RegisterMCAsmBackend(*T, createVEAsmBackend); 102 103 // Register the object target streamer. 104 TargetRegistry::RegisterObjectTargetStreamer(*T, 105 createObjectTargetStreamer); 106 107 // Register the asm streamer. 108 TargetRegistry::RegisterAsmTargetStreamer(*T, createTargetAsmStreamer); 109 110 // Register the MCInstPrinter 111 TargetRegistry::RegisterMCInstPrinter(*T, createVEMCInstPrinter); 112 } 113 } 114