]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / llvm / lib / Target / Sparc / MCTargetDesc / SparcMCTargetDesc.cpp
1 //===-- SparcMCTargetDesc.cpp - Sparc 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 Sparc specific target descriptions.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "SparcMCTargetDesc.h"
15 #include "SparcMCAsmInfo.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 "SparcGenInstrInfo.inc"
25
26 #define GET_SUBTARGETINFO_MC_DESC
27 #include "SparcGenSubtargetInfo.inc"
28
29 #define GET_REGINFO_MC_DESC
30 #include "SparcGenRegisterInfo.inc"
31
32 using namespace llvm;
33
34 static MCInstrInfo *createSparcMCInstrInfo() {
35   MCInstrInfo *X = new MCInstrInfo();
36   InitSparcMCInstrInfo(X);
37   return X;
38 }
39
40 static MCRegisterInfo *createSparcMCRegisterInfo(StringRef TT) {
41   MCRegisterInfo *X = new MCRegisterInfo();
42   InitSparcMCRegisterInfo(X, SP::I7);
43   return X;
44 }
45
46 static MCSubtargetInfo *createSparcMCSubtargetInfo(StringRef TT, StringRef CPU,
47                                                    StringRef FS) {
48   MCSubtargetInfo *X = new MCSubtargetInfo();
49   InitSparcMCSubtargetInfo(X, TT, CPU, FS);
50   return X;
51 }
52
53 // Code models. Some only make sense for 64-bit code.
54 //
55 // SunCC  Reloc   CodeModel  Constraints
56 // abs32  Static  Small      text+data+bss linked below 2^32 bytes
57 // abs44  Static  Medium     text+data+bss linked below 2^44 bytes
58 // abs64  Static  Large      text smaller than 2^31 bytes
59 // pic13  PIC_    Small      GOT < 2^13 bytes
60 // pic32  PIC_    Medium     GOT < 2^32 bytes
61 //
62 // All code models require that the text segment is smaller than 2GB.
63
64 static MCCodeGenInfo *createSparcMCCodeGenInfo(StringRef TT, Reloc::Model RM,
65                                                CodeModel::Model CM,
66                                                CodeGenOpt::Level OL) {
67   MCCodeGenInfo *X = new MCCodeGenInfo();
68
69   // The default 32-bit code model is abs32/pic32.
70   if (CM == CodeModel::Default)
71     CM = RM == Reloc::PIC_ ? CodeModel::Medium : CodeModel::Small;
72
73   X->InitMCCodeGenInfo(RM, CM, OL);
74   return X;
75 }
76
77 static MCCodeGenInfo *createSparcV9MCCodeGenInfo(StringRef TT, Reloc::Model RM,
78                                                  CodeModel::Model CM,
79                                                  CodeGenOpt::Level OL) {
80   MCCodeGenInfo *X = new MCCodeGenInfo();
81
82   // The default 64-bit code model is abs44/pic32.
83   if (CM == CodeModel::Default)
84     CM = CodeModel::Medium;
85
86   X->InitMCCodeGenInfo(RM, CM, OL);
87   return X;
88 }
89 extern "C" void LLVMInitializeSparcTargetMC() {
90   // Register the MC asm info.
91   RegisterMCAsmInfo<SparcELFMCAsmInfo> X(TheSparcTarget);
92   RegisterMCAsmInfo<SparcELFMCAsmInfo> Y(TheSparcV9Target);
93
94   // Register the MC codegen info.
95   TargetRegistry::RegisterMCCodeGenInfo(TheSparcTarget,
96                                        createSparcMCCodeGenInfo);
97   TargetRegistry::RegisterMCCodeGenInfo(TheSparcV9Target,
98                                        createSparcV9MCCodeGenInfo);
99
100   // Register the MC instruction info.
101   TargetRegistry::RegisterMCInstrInfo(TheSparcTarget, createSparcMCInstrInfo);
102
103   // Register the MC register info.
104   TargetRegistry::RegisterMCRegInfo(TheSparcTarget, createSparcMCRegisterInfo);
105
106   // Register the MC subtarget info.
107   TargetRegistry::RegisterMCSubtargetInfo(TheSparcTarget,
108                                           createSparcMCSubtargetInfo);
109 }