1480093f4SDimitry Andric //===-- VEMCTargetDesc.cpp - VE Target Descriptions -----------------------===// 2480093f4SDimitry Andric // 3480093f4SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4480093f4SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5480093f4SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6480093f4SDimitry Andric // 7480093f4SDimitry Andric //===----------------------------------------------------------------------===// 8480093f4SDimitry Andric // 9480093f4SDimitry Andric // This file provides VE specific target descriptions. 10480093f4SDimitry Andric // 11480093f4SDimitry Andric //===----------------------------------------------------------------------===// 12480093f4SDimitry Andric 13480093f4SDimitry Andric #include "VEMCTargetDesc.h" 14*5ffd83dbSDimitry Andric #include "TargetInfo/VETargetInfo.h" 15*5ffd83dbSDimitry Andric #include "VEInstPrinter.h" 16480093f4SDimitry Andric #include "VEMCAsmInfo.h" 17480093f4SDimitry Andric #include "VETargetStreamer.h" 18480093f4SDimitry Andric #include "llvm/MC/MCInstrInfo.h" 19480093f4SDimitry Andric #include "llvm/MC/MCRegisterInfo.h" 20480093f4SDimitry Andric #include "llvm/MC/MCSubtargetInfo.h" 21480093f4SDimitry Andric #include "llvm/Support/ErrorHandling.h" 22480093f4SDimitry Andric #include "llvm/Support/TargetRegistry.h" 23480093f4SDimitry Andric 24480093f4SDimitry Andric using namespace llvm; 25480093f4SDimitry Andric 26480093f4SDimitry Andric #define GET_INSTRINFO_MC_DESC 27480093f4SDimitry Andric #include "VEGenInstrInfo.inc" 28480093f4SDimitry Andric 29480093f4SDimitry Andric #define GET_SUBTARGETINFO_MC_DESC 30480093f4SDimitry Andric #include "VEGenSubtargetInfo.inc" 31480093f4SDimitry Andric 32480093f4SDimitry Andric #define GET_REGINFO_MC_DESC 33480093f4SDimitry Andric #include "VEGenRegisterInfo.inc" 34480093f4SDimitry Andric 35480093f4SDimitry Andric static MCAsmInfo *createVEMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT, 36480093f4SDimitry Andric const MCTargetOptions &Options) { 37480093f4SDimitry Andric MCAsmInfo *MAI = new VEELFMCAsmInfo(TT); 38480093f4SDimitry Andric unsigned Reg = MRI.getDwarfRegNum(VE::SX11, true); 39*5ffd83dbSDimitry Andric MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(nullptr, Reg, 0); 40480093f4SDimitry Andric MAI->addInitialFrameState(Inst); 41480093f4SDimitry Andric return MAI; 42480093f4SDimitry Andric } 43480093f4SDimitry Andric 44480093f4SDimitry Andric static MCInstrInfo *createVEMCInstrInfo() { 45480093f4SDimitry Andric MCInstrInfo *X = new MCInstrInfo(); 46480093f4SDimitry Andric InitVEMCInstrInfo(X); 47480093f4SDimitry Andric return X; 48480093f4SDimitry Andric } 49480093f4SDimitry Andric 50480093f4SDimitry Andric static MCRegisterInfo *createVEMCRegisterInfo(const Triple &TT) { 51480093f4SDimitry Andric MCRegisterInfo *X = new MCRegisterInfo(); 52480093f4SDimitry Andric InitVEMCRegisterInfo(X, VE::SX10); 53480093f4SDimitry Andric return X; 54480093f4SDimitry Andric } 55480093f4SDimitry Andric 56480093f4SDimitry Andric static MCSubtargetInfo *createVEMCSubtargetInfo(const Triple &TT, StringRef CPU, 57480093f4SDimitry Andric StringRef FS) { 58480093f4SDimitry Andric if (CPU.empty()) 59480093f4SDimitry Andric CPU = "ve"; 60480093f4SDimitry Andric return createVEMCSubtargetInfoImpl(TT, CPU, FS); 61480093f4SDimitry Andric } 62480093f4SDimitry Andric 63480093f4SDimitry Andric static MCTargetStreamer * 64480093f4SDimitry Andric createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI) { 65480093f4SDimitry Andric return new VETargetELFStreamer(S); 66480093f4SDimitry Andric } 67480093f4SDimitry Andric 68480093f4SDimitry Andric static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S, 69480093f4SDimitry Andric formatted_raw_ostream &OS, 70480093f4SDimitry Andric MCInstPrinter *InstPrint, 71480093f4SDimitry Andric bool isVerboseAsm) { 72480093f4SDimitry Andric return new VETargetAsmStreamer(S, OS); 73480093f4SDimitry Andric } 74480093f4SDimitry Andric 75480093f4SDimitry Andric static MCInstPrinter *createVEMCInstPrinter(const Triple &T, 76480093f4SDimitry Andric unsigned SyntaxVariant, 77480093f4SDimitry Andric const MCAsmInfo &MAI, 78480093f4SDimitry Andric const MCInstrInfo &MII, 79480093f4SDimitry Andric const MCRegisterInfo &MRI) { 80480093f4SDimitry Andric return new VEInstPrinter(MAI, MII, MRI); 81480093f4SDimitry Andric } 82480093f4SDimitry Andric 83480093f4SDimitry Andric extern "C" void LLVMInitializeVETargetMC() { 84480093f4SDimitry Andric // Register the MC asm info. 85480093f4SDimitry Andric RegisterMCAsmInfoFn X(getTheVETarget(), createVEMCAsmInfo); 86480093f4SDimitry Andric 87480093f4SDimitry Andric for (Target *T : {&getTheVETarget()}) { 88480093f4SDimitry Andric // Register the MC instruction info. 89480093f4SDimitry Andric TargetRegistry::RegisterMCInstrInfo(*T, createVEMCInstrInfo); 90480093f4SDimitry Andric 91480093f4SDimitry Andric // Register the MC register info. 92480093f4SDimitry Andric TargetRegistry::RegisterMCRegInfo(*T, createVEMCRegisterInfo); 93480093f4SDimitry Andric 94480093f4SDimitry Andric // Register the MC subtarget info. 95480093f4SDimitry Andric TargetRegistry::RegisterMCSubtargetInfo(*T, createVEMCSubtargetInfo); 96480093f4SDimitry Andric 97*5ffd83dbSDimitry Andric // Register the MC Code Emitter. 98*5ffd83dbSDimitry Andric TargetRegistry::RegisterMCCodeEmitter(*T, createVEMCCodeEmitter); 99*5ffd83dbSDimitry Andric 100*5ffd83dbSDimitry Andric // Register the asm backend. 101*5ffd83dbSDimitry Andric TargetRegistry::RegisterMCAsmBackend(*T, createVEAsmBackend); 102*5ffd83dbSDimitry Andric 103480093f4SDimitry Andric // Register the object target streamer. 104480093f4SDimitry Andric TargetRegistry::RegisterObjectTargetStreamer(*T, 105480093f4SDimitry Andric createObjectTargetStreamer); 106480093f4SDimitry Andric 107480093f4SDimitry Andric // Register the asm streamer. 108480093f4SDimitry Andric TargetRegistry::RegisterAsmTargetStreamer(*T, createTargetAsmStreamer); 109480093f4SDimitry Andric 110480093f4SDimitry Andric // Register the MCInstPrinter 111480093f4SDimitry Andric TargetRegistry::RegisterMCInstPrinter(*T, createVEMCInstPrinter); 112480093f4SDimitry Andric } 113480093f4SDimitry Andric } 114