1 //===-- MipsMCTargetDesc.cpp - Mips 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 Mips specific target descriptions.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "MipsMCTargetDesc.h"
15 #include "MipsMCAsmInfo.h"
16 #include "llvm/MC/MachineLocation.h"
17 #include "llvm/MC/MCInstrInfo.h"
18 #include "llvm/MC/MCRegisterInfo.h"
19 #include "llvm/MC/MCSubtargetInfo.h"
20 #include "llvm/Target/TargetRegistry.h"
21
22 #define GET_INSTRINFO_MC_DESC
23 #include "MipsGenInstrInfo.inc"
24
25 #define GET_SUBTARGETINFO_MC_DESC
26 #include "MipsGenSubtargetInfo.inc"
27
28 #define GET_REGINFO_MC_DESC
29 #include "MipsGenRegisterInfo.inc"
30
31 using namespace llvm;
32
createMipsMCInstrInfo()33 static MCInstrInfo *createMipsMCInstrInfo() {
34 MCInstrInfo *X = new MCInstrInfo();
35 InitMipsMCInstrInfo(X);
36 return X;
37 }
38
LLVMInitializeMipsMCInstrInfo()39 extern "C" void LLVMInitializeMipsMCInstrInfo() {
40 TargetRegistry::RegisterMCInstrInfo(TheMipsTarget, createMipsMCInstrInfo);
41 }
42
createMipsMCRegisterInfo(StringRef TT)43 static MCRegisterInfo *createMipsMCRegisterInfo(StringRef TT) {
44 MCRegisterInfo *X = new MCRegisterInfo();
45 InitMipsMCRegisterInfo(X, Mips::RA);
46 return X;
47 }
48
LLVMInitializeMipsMCRegisterInfo()49 extern "C" void LLVMInitializeMipsMCRegisterInfo() {
50 TargetRegistry::RegisterMCRegInfo(TheMipsTarget, createMipsMCRegisterInfo);
51 TargetRegistry::RegisterMCRegInfo(TheMipselTarget, createMipsMCRegisterInfo);
52 }
53
createMipsMCSubtargetInfo(StringRef TT,StringRef CPU,StringRef FS)54 static MCSubtargetInfo *createMipsMCSubtargetInfo(StringRef TT, StringRef CPU,
55 StringRef FS) {
56 MCSubtargetInfo *X = new MCSubtargetInfo();
57 InitMipsMCSubtargetInfo(X, TT, CPU, FS);
58 return X;
59 }
60
LLVMInitializeMipsMCSubtargetInfo()61 extern "C" void LLVMInitializeMipsMCSubtargetInfo() {
62 TargetRegistry::RegisterMCSubtargetInfo(TheMipsTarget,
63 createMipsMCSubtargetInfo);
64 }
65
createMipsMCAsmInfo(const Target & T,StringRef TT)66 static MCAsmInfo *createMipsMCAsmInfo(const Target &T, StringRef TT) {
67 MCAsmInfo *MAI = new MipsMCAsmInfo(T, TT);
68
69 MachineLocation Dst(MachineLocation::VirtualFP);
70 MachineLocation Src(Mips::SP, 0);
71 MAI->addInitialFrameState(0, Dst, Src);
72
73 return MAI;
74 }
75
LLVMInitializeMipsMCAsmInfo()76 extern "C" void LLVMInitializeMipsMCAsmInfo() {
77 RegisterMCAsmInfoFn X(TheMipsTarget, createMipsMCAsmInfo);
78 RegisterMCAsmInfoFn Y(TheMipselTarget, createMipsMCAsmInfo);
79 }
80
createMipsMCCodeGenInfo(StringRef TT,Reloc::Model RM)81 MCCodeGenInfo *createMipsMCCodeGenInfo(StringRef TT, Reloc::Model RM) {
82 MCCodeGenInfo *X = new MCCodeGenInfo();
83 if (RM == Reloc::Default) {
84 // Abicall enables PIC by default
85 if (TT.find("mipsallegrex") != std::string::npos ||
86 TT.find("psp") != std::string::npos)
87 RM = Reloc::Static;
88 else
89 RM = Reloc::PIC_;
90 }
91 X->InitMCCodeGenInfo(RM);
92 return X;
93 }
94
LLVMInitializeMipsMCCodeGenInfo()95 extern "C" void LLVMInitializeMipsMCCodeGenInfo() {
96 TargetRegistry::RegisterMCCodeGenInfo(TheMipsTarget,
97 createMipsMCCodeGenInfo);
98 TargetRegistry::RegisterMCCodeGenInfo(TheMipselTarget,
99 createMipsMCCodeGenInfo);
100 }
101