1 //===-- XCoreMCTargetDesc.cpp - XCore Target Descriptions -----------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file provides XCore specific target descriptions.
12 //===----------------------------------------------------------------------===//
14 #include "XCoreMCTargetDesc.h"
15 #include "InstPrinter/XCoreInstPrinter.h"
16 #include "XCoreMCAsmInfo.h"
17 #include "llvm/MC/MCCodeGenInfo.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"
24 #define GET_INSTRINFO_MC_DESC
25 #include "XCoreGenInstrInfo.inc"
27 #define GET_SUBTARGETINFO_MC_DESC
28 #include "XCoreGenSubtargetInfo.inc"
30 #define GET_REGINFO_MC_DESC
31 #include "XCoreGenRegisterInfo.inc"
35 static MCInstrInfo *createXCoreMCInstrInfo() {
36 MCInstrInfo *X = new MCInstrInfo();
37 InitXCoreMCInstrInfo(X);
41 static MCRegisterInfo *createXCoreMCRegisterInfo(StringRef TT) {
42 MCRegisterInfo *X = new MCRegisterInfo();
43 InitXCoreMCRegisterInfo(X, XCore::LR);
47 static MCSubtargetInfo *createXCoreMCSubtargetInfo(StringRef TT, StringRef CPU,
49 MCSubtargetInfo *X = new MCSubtargetInfo();
50 InitXCoreMCSubtargetInfo(X, TT, CPU, FS);
54 static MCAsmInfo *createXCoreMCAsmInfo(const MCRegisterInfo &MRI,
56 MCAsmInfo *MAI = new XCoreMCAsmInfo(TT);
58 // Initial state of the frame pointer is SP.
59 MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(0, XCore::SP, 0);
60 MAI->addInitialFrameState(Inst);
65 static MCCodeGenInfo *createXCoreMCCodeGenInfo(StringRef TT, Reloc::Model RM,
67 CodeGenOpt::Level OL) {
68 MCCodeGenInfo *X = new MCCodeGenInfo();
69 if (RM == Reloc::Default) {
72 if (CM == CodeModel::Default) {
73 CM = CodeModel::Small;
75 if (CM != CodeModel::Small && CM != CodeModel::Large)
76 report_fatal_error("Target only supports CodeModel Small or Large");
78 X->InitMCCodeGenInfo(RM, CM, OL);
82 static MCInstPrinter *createXCoreMCInstPrinter(const Target &T,
83 unsigned SyntaxVariant,
85 const MCInstrInfo &MII,
86 const MCRegisterInfo &MRI,
87 const MCSubtargetInfo &STI) {
88 return new XCoreInstPrinter(MAI, MII, MRI);
91 // Force static initialization.
92 extern "C" void LLVMInitializeXCoreTargetMC() {
93 // Register the MC asm info.
94 RegisterMCAsmInfoFn X(TheXCoreTarget, createXCoreMCAsmInfo);
96 // Register the MC codegen info.
97 TargetRegistry::RegisterMCCodeGenInfo(TheXCoreTarget,
98 createXCoreMCCodeGenInfo);
100 // Register the MC instruction info.
101 TargetRegistry::RegisterMCInstrInfo(TheXCoreTarget, createXCoreMCInstrInfo);
103 // Register the MC register info.
104 TargetRegistry::RegisterMCRegInfo(TheXCoreTarget, createXCoreMCRegisterInfo);
106 // Register the MC subtarget info.
107 TargetRegistry::RegisterMCSubtargetInfo(TheXCoreTarget,
108 createXCoreMCSubtargetInfo);
110 // Register the MCInstPrinter
111 TargetRegistry::RegisterMCInstPrinter(TheXCoreTarget,
112 createXCoreMCInstPrinter);