1 //===-- XtensaMCTargetDesc.cpp - Xtensa target descriptions ---------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 6 // See https://llvm.org/LICENSE.txt for license information. 7 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 8 // 9 //===----------------------------------------------------------------------===// 10 #include "XtensaMCTargetDesc.h" 11 #include "XtensaInstPrinter.h" 12 #include "XtensaMCAsmInfo.h" 13 #include "TargetInfo/XtensaTargetInfo.h" 14 #include "llvm/ADT/STLExtras.h" 15 #include "llvm/MC/MCAsmInfo.h" 16 #include "llvm/MC/MCInstrInfo.h" 17 #include "llvm/MC/MCRegisterInfo.h" 18 #include "llvm/MC/MCStreamer.h" 19 #include "llvm/MC/MCSubtargetInfo.h" 20 #include "llvm/MC/TargetRegistry.h" 21 #include "llvm/Support/ErrorHandling.h" 22 23 #define GET_INSTRINFO_MC_DESC 24 #include "XtensaGenInstrInfo.inc" 25 26 #define GET_REGINFO_MC_DESC 27 #include "XtensaGenRegisterInfo.inc" 28 29 #define GET_SUBTARGETINFO_MC_DESC 30 #include "XtensaGenSubtargetInfo.inc" 31 32 using namespace llvm; 33 34 static MCAsmInfo *createXtensaMCAsmInfo(const MCRegisterInfo &MRI, 35 const Triple &TT, 36 const MCTargetOptions &Options) { 37 MCAsmInfo *MAI = new XtensaMCAsmInfo(TT); 38 return MAI; 39 } 40 41 static MCInstrInfo *createXtensaMCInstrInfo() { 42 MCInstrInfo *X = new MCInstrInfo(); 43 InitXtensaMCInstrInfo(X); 44 return X; 45 } 46 47 static MCInstPrinter *createXtensaMCInstPrinter(const Triple &TT, 48 unsigned SyntaxVariant, 49 const MCAsmInfo &MAI, 50 const MCInstrInfo &MII, 51 const MCRegisterInfo &MRI) { 52 return new XtensaInstPrinter(MAI, MII, MRI); 53 } 54 55 static MCRegisterInfo *createXtensaMCRegisterInfo(const Triple &TT) { 56 MCRegisterInfo *X = new MCRegisterInfo(); 57 InitXtensaMCRegisterInfo(X, Xtensa::SP); 58 return X; 59 } 60 61 static MCSubtargetInfo * 62 createXtensaMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) { 63 return createXtensaMCSubtargetInfoImpl(TT, CPU, CPU, FS); 64 } 65 66 extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXtensaTargetMC() { 67 // Register the MCAsmInfo. 68 TargetRegistry::RegisterMCAsmInfo(getTheXtensaTarget(), createXtensaMCAsmInfo); 69 70 // Register the MCCodeEmitter. 71 TargetRegistry::RegisterMCCodeEmitter(getTheXtensaTarget(), 72 createXtensaMCCodeEmitter); 73 74 // Register the MCInstrInfo. 75 TargetRegistry::RegisterMCInstrInfo(getTheXtensaTarget(), createXtensaMCInstrInfo); 76 77 // Register the MCInstPrinter. 78 TargetRegistry::RegisterMCInstPrinter(getTheXtensaTarget(), 79 createXtensaMCInstPrinter); 80 81 // Register the MCRegisterInfo. 82 TargetRegistry::RegisterMCRegInfo(getTheXtensaTarget(), 83 createXtensaMCRegisterInfo); 84 85 // Register the MCSubtargetInfo. 86 TargetRegistry::RegisterMCSubtargetInfo(getTheXtensaTarget(), 87 createXtensaMCSubtargetInfo); 88 89 // Register the MCAsmBackend. 90 TargetRegistry::RegisterMCAsmBackend(getTheXtensaTarget(), 91 createXtensaMCAsmBackend); 92 } 93