1 //===-- MBlazeMCTargetDesc.cpp - MBlaze Target Descriptions -----*- C++ -*-===//
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 MBlaze specific target descriptions.
12 //===----------------------------------------------------------------------===//
14 #include "MBlazeMCTargetDesc.h"
15 #include "MBlazeMCAsmInfo.h"
16 #include "InstPrinter/MBlazeInstPrinter.h"
17 #include "llvm/MC/MCCodeGenInfo.h"
18 #include "llvm/MC/MCInstrInfo.h"
19 #include "llvm/MC/MCRegisterInfo.h"
20 #include "llvm/MC/MCStreamer.h"
21 #include "llvm/MC/MCSubtargetInfo.h"
22 #include "llvm/Target/TargetRegistry.h"
23 #include "llvm/Support/ErrorHandling.h"
25 #define GET_INSTRINFO_MC_DESC
26 #include "MBlazeGenInstrInfo.inc"
28 #define GET_SUBTARGETINFO_MC_DESC
29 #include "MBlazeGenSubtargetInfo.inc"
31 #define GET_REGINFO_MC_DESC
32 #include "MBlazeGenRegisterInfo.inc"
37 static MCInstrInfo *createMBlazeMCInstrInfo() {
38 MCInstrInfo *X = new MCInstrInfo();
39 InitMBlazeMCInstrInfo(X);
43 static MCRegisterInfo *createMBlazeMCRegisterInfo(StringRef TT) {
44 MCRegisterInfo *X = new MCRegisterInfo();
45 InitMBlazeMCRegisterInfo(X, MBlaze::R15);
49 static MCSubtargetInfo *createMBlazeMCSubtargetInfo(StringRef TT, StringRef CPU,
51 MCSubtargetInfo *X = new MCSubtargetInfo();
52 InitMBlazeMCSubtargetInfo(X, TT, CPU, FS);
56 static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) {
58 switch (TheTriple.getOS()) {
60 return new MBlazeMCAsmInfo();
64 static MCCodeGenInfo *createMBlazeMCCodeGenInfo(StringRef TT, Reloc::Model RM,
65 CodeModel::Model CM) {
66 MCCodeGenInfo *X = new MCCodeGenInfo();
67 if (RM == Reloc::Default)
69 if (CM == CodeModel::Default)
70 CM = CodeModel::Small;
71 X->InitMCCodeGenInfo(RM, CM);
75 static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
76 MCContext &Ctx, MCAsmBackend &MAB,
78 MCCodeEmitter *_Emitter,
83 if (TheTriple.isOSDarwin()) {
84 llvm_unreachable("MBlaze does not support Darwin MACH-O format");
88 if (TheTriple.isOSWindows()) {
89 llvm_unreachable("MBlaze does not support Windows COFF format");
93 return createELFStreamer(Ctx, MAB, _OS, _Emitter, RelaxAll, NoExecStack);
96 static MCInstPrinter *createMBlazeMCInstPrinter(const Target &T,
97 unsigned SyntaxVariant,
98 const MCAsmInfo &MAI) {
99 if (SyntaxVariant == 0)
100 return new MBlazeInstPrinter(MAI);
104 // Force static initialization.
105 extern "C" void LLVMInitializeMBlazeTargetMC() {
106 // Register the MC asm info.
107 RegisterMCAsmInfoFn X(TheMBlazeTarget, createMCAsmInfo);
109 // Register the MC codegen info.
110 TargetRegistry::RegisterMCCodeGenInfo(TheMBlazeTarget,
111 createMBlazeMCCodeGenInfo);
113 // Register the MC instruction info.
114 TargetRegistry::RegisterMCInstrInfo(TheMBlazeTarget, createMBlazeMCInstrInfo);
116 // Register the MC register info.
117 TargetRegistry::RegisterMCRegInfo(TheMBlazeTarget,
118 createMBlazeMCRegisterInfo);
120 // Register the MC subtarget info.
121 TargetRegistry::RegisterMCSubtargetInfo(TheMBlazeTarget,
122 createMBlazeMCSubtargetInfo);
124 // Register the MC code emitter
125 TargetRegistry::RegisterMCCodeEmitter(TheMBlazeTarget,
126 llvm::createMBlazeMCCodeEmitter);
128 // Register the asm backend
129 TargetRegistry::RegisterMCAsmBackend(TheMBlazeTarget,
130 createMBlazeAsmBackend);
132 // Register the object streamer
133 TargetRegistry::RegisterMCObjectStreamer(TheMBlazeTarget,
136 // Register the MCInstPrinter.
137 TargetRegistry::RegisterMCInstPrinter(TheMBlazeTarget,
138 createMBlazeMCInstPrinter);