1 //===-- XCoreMCTargetDesc.cpp - XCore Target Descriptions -----------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file provides XCore specific target descriptions. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "XCoreMCTargetDesc.h" 15 #include "XCoreMCAsmInfo.h" 16 #include "llvm/MC/MCCodeGenInfo.h" 17 #include "llvm/MC/MCInstrInfo.h" 18 #include "llvm/MC/MCRegisterInfo.h" 19 #include "llvm/MC/MCSubtargetInfo.h" 20 #include "llvm/Support/ErrorHandling.h" 21 #include "llvm/Support/TargetRegistry.h" 22 23 #define GET_INSTRINFO_MC_DESC 24 #include "XCoreGenInstrInfo.inc" 25 26 #define GET_SUBTARGETINFO_MC_DESC 27 #include "XCoreGenSubtargetInfo.inc" 28 29 #define GET_REGINFO_MC_DESC 30 #include "XCoreGenRegisterInfo.inc" 31 32 using namespace llvm; 33 34 static MCInstrInfo *createXCoreMCInstrInfo() { 35 MCInstrInfo *X = new MCInstrInfo(); 36 InitXCoreMCInstrInfo(X); 37 return X; 38 } 39 40 static MCRegisterInfo *createXCoreMCRegisterInfo(StringRef TT) { 41 MCRegisterInfo *X = new MCRegisterInfo(); 42 InitXCoreMCRegisterInfo(X, XCore::LR); 43 return X; 44 } 45 46 static MCSubtargetInfo *createXCoreMCSubtargetInfo(StringRef TT, StringRef CPU, 47 StringRef FS) { 48 MCSubtargetInfo *X = new MCSubtargetInfo(); 49 InitXCoreMCSubtargetInfo(X, TT, CPU, FS); 50 return X; 51 } 52 53 static MCAsmInfo *createXCoreMCAsmInfo(const Target &T, StringRef TT) { 54 MCAsmInfo *MAI = new XCoreMCAsmInfo(T, TT); 55 56 // Initial state of the frame pointer is SP. 57 MachineLocation Dst(MachineLocation::VirtualFP); 58 MachineLocation Src(XCore::SP, 0); 59 MAI->addInitialFrameState(0, Dst, Src); 60 61 return MAI; 62 } 63 64 static MCCodeGenInfo *createXCoreMCCodeGenInfo(StringRef TT, Reloc::Model RM, 65 CodeModel::Model CM, 66 CodeGenOpt::Level OL) { 67 MCCodeGenInfo *X = new MCCodeGenInfo(); 68 X->InitMCCodeGenInfo(RM, CM, OL); 69 return X; 70 } 71 72 // Force static initialization. 73 extern "C" void LLVMInitializeXCoreTargetMC() { 74 // Register the MC asm info. 75 RegisterMCAsmInfoFn X(TheXCoreTarget, createXCoreMCAsmInfo); 76 77 // Register the MC codegen info. 78 TargetRegistry::RegisterMCCodeGenInfo(TheXCoreTarget, 79 createXCoreMCCodeGenInfo); 80 81 // Register the MC instruction info. 82 TargetRegistry::RegisterMCInstrInfo(TheXCoreTarget, createXCoreMCInstrInfo); 83 84 // Register the MC register info. 85 TargetRegistry::RegisterMCRegInfo(TheXCoreTarget, createXCoreMCRegisterInfo); 86 87 // Register the MC subtarget info. 88 TargetRegistry::RegisterMCSubtargetInfo(TheXCoreTarget, 89 createXCoreMCSubtargetInfo); 90 } 91