createXXXMCCodeGenInfo should be static.
[oota-llvm.git] / lib / Target / MBlaze / MCTargetDesc / MBlazeMCTargetDesc.cpp
1 //===-- MBlazeMCTargetDesc.cpp - MBlaze Target Descriptions -----*- C++ -*-===//
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 MBlaze specific target descriptions.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "MBlazeMCTargetDesc.h"
15 #include "MBlazeMCAsmInfo.h"
16 #include "llvm/MC/MCInstrInfo.h"
17 #include "llvm/MC/MCRegisterInfo.h"
18 #include "llvm/MC/MCSubtargetInfo.h"
19 #include "llvm/Target/TargetRegistry.h"
20
21 #define GET_INSTRINFO_MC_DESC
22 #include "MBlazeGenInstrInfo.inc"
23
24 #define GET_SUBTARGETINFO_MC_DESC
25 #include "MBlazeGenSubtargetInfo.inc"
26
27 #define GET_REGINFO_MC_DESC
28 #include "MBlazeGenRegisterInfo.inc"
29
30 using namespace llvm;
31
32
33 static MCInstrInfo *createMBlazeMCInstrInfo() {
34   MCInstrInfo *X = new MCInstrInfo();
35   InitMBlazeMCInstrInfo(X);
36   return X;
37 }
38
39 static MCRegisterInfo *createMBlazeMCRegisterInfo(StringRef TT) {
40   MCRegisterInfo *X = new MCRegisterInfo();
41   InitMBlazeMCRegisterInfo(X, MBlaze::R15);
42   return X;
43 }
44
45 static MCSubtargetInfo *createMBlazeMCSubtargetInfo(StringRef TT, StringRef CPU,
46                                                     StringRef FS) {
47   MCSubtargetInfo *X = new MCSubtargetInfo();
48   InitMBlazeMCSubtargetInfo(X, TT, CPU, FS);
49   return X;
50 }
51
52 static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) {
53   Triple TheTriple(TT);
54   switch (TheTriple.getOS()) {
55   default:
56     return new MBlazeMCAsmInfo();
57   }
58 }
59
60 static MCCodeGenInfo *createMBlazeMCCodeGenInfo(StringRef TT, Reloc::Model RM,
61                                                 CodeModel::Model CM) {
62   MCCodeGenInfo *X = new MCCodeGenInfo();
63   if (RM == Reloc::Default)
64     RM = Reloc::Static;
65   if (CM == CodeModel::Default)
66     CM = CodeModel::Small;
67   X->InitMCCodeGenInfo(RM, CM);
68   return X;
69 }
70
71 // Force static initialization.
72 extern "C" void LLVMInitializeMBlazeTargetMC() {
73   // Register the MC asm info.
74   RegisterMCAsmInfoFn X(TheMBlazeTarget, createMCAsmInfo);
75
76   // Register the MC codegen info.
77   TargetRegistry::RegisterMCCodeGenInfo(TheMBlazeTarget,
78                                         createMBlazeMCCodeGenInfo);
79
80   // Register the MC instruction info.
81   TargetRegistry::RegisterMCInstrInfo(TheMBlazeTarget, createMBlazeMCInstrInfo);
82
83   // Register the MC register info.
84   TargetRegistry::RegisterMCRegInfo(TheMBlazeTarget,
85                                     createMBlazeMCRegisterInfo);
86
87   // Register the MC subtarget info.
88   TargetRegistry::RegisterMCSubtargetInfo(TheMBlazeTarget,
89                                           createMBlazeMCSubtargetInfo);
90 }