1 //===-- SparcMCTargetDesc.cpp - Sparc 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 Sparc specific target descriptions.
12 //===----------------------------------------------------------------------===//
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"
23 #define GET_INSTRINFO_MC_DESC
24 #include "SparcGenInstrInfo.inc"
26 #define GET_SUBTARGETINFO_MC_DESC
27 #include "SparcGenSubtargetInfo.inc"
29 #define GET_REGINFO_MC_DESC
30 #include "SparcGenRegisterInfo.inc"
34 static MCInstrInfo *createSparcMCInstrInfo() {
35 MCInstrInfo *X = new MCInstrInfo();
36 InitSparcMCInstrInfo(X);
40 static MCRegisterInfo *createSparcMCRegisterInfo(StringRef TT) {
41 MCRegisterInfo *X = new MCRegisterInfo();
42 InitSparcMCRegisterInfo(X, SP::I7);
46 static MCSubtargetInfo *createSparcMCSubtargetInfo(StringRef TT, StringRef CPU,
48 MCSubtargetInfo *X = new MCSubtargetInfo();
49 InitSparcMCSubtargetInfo(X, TT, CPU, FS);
53 // Code models. Some only make sense for 64-bit code.
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
62 // All code models require that the text segment is smaller than 2GB.
64 static MCCodeGenInfo *createSparcMCCodeGenInfo(StringRef TT, Reloc::Model RM,
66 CodeGenOpt::Level OL) {
67 MCCodeGenInfo *X = new MCCodeGenInfo();
69 // The default 32-bit code model is abs32/pic32.
70 if (CM == CodeModel::Default)
71 CM = RM == Reloc::PIC_ ? CodeModel::Medium : CodeModel::Small;
73 X->InitMCCodeGenInfo(RM, CM, OL);
77 static MCCodeGenInfo *createSparcV9MCCodeGenInfo(StringRef TT, Reloc::Model RM,
79 CodeGenOpt::Level OL) {
80 MCCodeGenInfo *X = new MCCodeGenInfo();
82 // The default 64-bit code model is abs44/pic32.
83 if (CM == CodeModel::Default)
84 CM = CodeModel::Medium;
86 X->InitMCCodeGenInfo(RM, CM, OL);
89 extern "C" void LLVMInitializeSparcTargetMC() {
90 // Register the MC asm info.
91 RegisterMCAsmInfo<SparcELFMCAsmInfo> X(TheSparcTarget);
92 RegisterMCAsmInfo<SparcELFMCAsmInfo> Y(TheSparcV9Target);
94 // Register the MC codegen info.
95 TargetRegistry::RegisterMCCodeGenInfo(TheSparcTarget,
96 createSparcMCCodeGenInfo);
97 TargetRegistry::RegisterMCCodeGenInfo(TheSparcV9Target,
98 createSparcV9MCCodeGenInfo);
100 // Register the MC instruction info.
101 TargetRegistry::RegisterMCInstrInfo(TheSparcTarget, createSparcMCInstrInfo);
103 // Register the MC register info.
104 TargetRegistry::RegisterMCRegInfo(TheSparcTarget, createSparcMCRegisterInfo);
106 // Register the MC subtarget info.
107 TargetRegistry::RegisterMCSubtargetInfo(TheSparcTarget,
108 createSparcMCSubtargetInfo);