LLVM API Documentation

SparcV9RegisterInfo.cpp

Go to the documentation of this file.
00001 //===- SparcV9RegisterInfo.cpp - SparcV9 Register Information ---*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by the LLVM research group and is distributed under
00006 // the University of Illinois Open Source License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains the SparcV9 implementation of the MRegisterInfo class.
00011 // It also contains stuff needed to instantiate that class, which would
00012 // ordinarily be provided by TableGen.
00013 //
00014 // This is NOT used by the SparcV9 backend to do register allocation, yet.
00015 //
00016 //===----------------------------------------------------------------------===//
00017 //
00018 // The first section of this file (immediately following) is what
00019 // you would find in SparcV9GenRegisterInfo.inc, if we were using
00020 // TableGen to generate the register file description automatically.
00021 // It consists of register classes and register class instances
00022 // for the SparcV9 target.
00023 //
00024 // FIXME: the alignments listed here are wild guesses.
00025 //
00026 //===----------------------------------------------------------------------===//
00027 
00028 #include "SparcV9RegisterInfo.h"
00029 #include "llvm/CodeGen/MachineFunction.h"
00030 #include "llvm/CodeGen/ValueTypes.h"
00031 using namespace llvm;
00032 
00033 namespace llvm {
00034 
00035 namespace {
00036   // IR Register Class...
00037   const unsigned IR[] = {
00038     SparcV9::o0, SparcV9::o1, SparcV9::o2, SparcV9::o3, SparcV9::o4,
00039     SparcV9::o5, SparcV9::o7, SparcV9::l0, SparcV9::l1, SparcV9::l2,
00040     SparcV9::l3, SparcV9::l4, SparcV9::l5, SparcV9::l6, SparcV9::l7,
00041     SparcV9::i0, SparcV9::i1, SparcV9::i2, SparcV9::i3, SparcV9::i4,
00042     SparcV9::i5, SparcV9::i6, SparcV9::i7, SparcV9::g0, SparcV9::g1,
00043     SparcV9::g2, SparcV9::g3, SparcV9::g4, SparcV9::g5, SparcV9::g6,
00044     SparcV9::g7, SparcV9::o6
00045   };
00046   const MVT::ValueType IRVTs[] = { MVT::i64, MVT::Other };
00047   struct IRClass : public TargetRegisterClass {
00048     IRClass() : TargetRegisterClass(IRVTs, 8, 8, IR, IR + 32) {}
00049   } IRInstance;
00050 
00051 
00052   // FR Register Class...
00053   const unsigned FR[] = {
00054     SparcV9::f0, SparcV9::f1, SparcV9::f2, SparcV9::f3, SparcV9::f4,
00055     SparcV9::f5, SparcV9::f6, SparcV9::f7, SparcV9::f8, SparcV9::f9,
00056     SparcV9::f10, SparcV9::f11, SparcV9::f12, SparcV9::f13,
00057     SparcV9::f14, SparcV9::f15, SparcV9::f16, SparcV9::f17,
00058     SparcV9::f18, SparcV9::f19, SparcV9::f20, SparcV9::f21,
00059     SparcV9::f22, SparcV9::f23, SparcV9::f24, SparcV9::f25,
00060     SparcV9::f26, SparcV9::f27, SparcV9::f28, SparcV9::f29,
00061     SparcV9::f30, SparcV9::f31, SparcV9::f32, SparcV9::f33,
00062     SparcV9::f34, SparcV9::f35, SparcV9::f36, SparcV9::f37,
00063     SparcV9::f38, SparcV9::f39, SparcV9::f40, SparcV9::f41,
00064     SparcV9::f42, SparcV9::f43, SparcV9::f44, SparcV9::f45,
00065     SparcV9::f46, SparcV9::f47, SparcV9::f48, SparcV9::f49,
00066     SparcV9::f50, SparcV9::f51, SparcV9::f52, SparcV9::f53,
00067     SparcV9::f54, SparcV9::f55, SparcV9::f56, SparcV9::f57,
00068     SparcV9::f58, SparcV9::f59, SparcV9::f60, SparcV9::f61,
00069     SparcV9::f62, SparcV9::f63
00070   };
00071   const MVT::ValueType FRVTs[] = { MVT::f32, MVT::Other };
00072   // FIXME: The size is correct for the first 32 registers. The
00073   // latter 32 do not all really exist; you can only access every other
00074   // one (32, 34, ...), and they must contain double-fp or quad-fp
00075   // values... see below about the aliasing problems.
00076   struct FRClass : public TargetRegisterClass {
00077     FRClass() : TargetRegisterClass(FRVTs, 4, 8, FR, FR + 64) {}
00078   } FRInstance;
00079 
00080 
00081   // ICCR Register Class...
00082   const unsigned ICCR[] = {
00083     SparcV9::xcc, SparcV9::icc, SparcV9::ccr
00084   };
00085   const MVT::ValueType ICCRVTs[] = { MVT::i1, MVT::Other };
00086   struct ICCRClass : public TargetRegisterClass {
00087     ICCRClass() : TargetRegisterClass(ICCRVTs, 1, 8, ICCR, ICCR + 3) {}
00088   } ICCRInstance;
00089 
00090 
00091   // FCCR Register Class...
00092   const unsigned FCCR[] = {
00093     SparcV9::fcc0, SparcV9::fcc1, SparcV9::fcc2, SparcV9::fcc3
00094   };
00095   const MVT::ValueType FCCRVTs[] = { MVT::i1, MVT::Other };
00096   struct FCCRClass : public TargetRegisterClass {
00097     FCCRClass() : TargetRegisterClass(FCCRVTs, 1, 8, FCCR, FCCR + 4) {}
00098   } FCCRInstance;
00099 
00100 
00101   // SR Register Class...
00102   const unsigned SR[] = {
00103     SparcV9::fsr
00104   };
00105   const MVT::ValueType SRVTs[] = { MVT::i64, MVT::Other };
00106   struct SRClass : public TargetRegisterClass {
00107     SRClass() : TargetRegisterClass(SRVTs, 8, 8, SR, SR + 1) {}
00108   } SRInstance;
00109 
00110 
00111   // Register Classes...
00112   const TargetRegisterClass* const RegisterClasses[] = {
00113     &IRInstance,
00114     &FRInstance,
00115     &ICCRInstance,
00116     &FCCRInstance,
00117     &SRInstance
00118   };
00119 
00120 
00121   // Register Alias Sets...
00122   // FIXME: Note that the SparcV9 backend does not currently abstract
00123   // very well over the way that double-fp and quad-fp values may alias
00124   // single-fp values in registers. Therefore those aliases are NOT
00125   // reflected here.
00126   const unsigned Empty_AliasSet[] = { 0 };
00127   const unsigned fcc3_AliasSet[] = { SparcV9::fsr, 0 };
00128   const unsigned fcc2_AliasSet[] = { SparcV9::fsr, 0 };
00129   const unsigned fcc1_AliasSet[] = { SparcV9::fsr, 0 };
00130   const unsigned fcc0_AliasSet[] = { SparcV9::fsr, 0 };
00131   const unsigned fsr_AliasSet[] = { SparcV9::fcc3, SparcV9::fcc2,
00132                                     SparcV9::fcc1, SparcV9::fcc0, 0 };
00133   const unsigned xcc_AliasSet[] = { SparcV9::ccr, 0 };
00134   const unsigned icc_AliasSet[] = { SparcV9::ccr, 0 };
00135   const unsigned ccr_AliasSet[] = { SparcV9::xcc, SparcV9::icc, 0 };
00136 
00137 const TargetRegisterDesc RegisterDescriptors[] = { // Descriptors
00138   { "o0", Empty_AliasSet },
00139   { "o1", Empty_AliasSet },
00140   { "o2", Empty_AliasSet },
00141   { "o3", Empty_AliasSet },
00142   { "o4", Empty_AliasSet },
00143   { "o5", Empty_AliasSet },
00144   { "o7", Empty_AliasSet },
00145   { "l0", Empty_AliasSet },
00146   { "l1", Empty_AliasSet },
00147   { "l2", Empty_AliasSet },
00148   { "l3", Empty_AliasSet },
00149   { "l4", Empty_AliasSet },
00150   { "l5", Empty_AliasSet },
00151   { "l6", Empty_AliasSet },
00152   { "l7", Empty_AliasSet },
00153   { "i0", Empty_AliasSet },
00154   { "i1", Empty_AliasSet },
00155   { "i2", Empty_AliasSet },
00156   { "i3", Empty_AliasSet },
00157   { "i4", Empty_AliasSet },
00158   { "i5", Empty_AliasSet },
00159   { "i6", Empty_AliasSet },
00160   { "i7", Empty_AliasSet },
00161   { "g0", Empty_AliasSet },
00162   { "g1", Empty_AliasSet },
00163   { "g2", Empty_AliasSet },
00164   { "g3", Empty_AliasSet },
00165   { "g4", Empty_AliasSet },
00166   { "g5", Empty_AliasSet },
00167   { "g6", Empty_AliasSet },
00168   { "g7", Empty_AliasSet },
00169   { "o6", Empty_AliasSet },
00170   { "f0", Empty_AliasSet },
00171   { "f1", Empty_AliasSet },
00172   { "f2", Empty_AliasSet },
00173   { "f3", Empty_AliasSet },
00174   { "f4", Empty_AliasSet },
00175   { "f5", Empty_AliasSet },
00176   { "f6", Empty_AliasSet },
00177   { "f7", Empty_AliasSet },
00178   { "f8", Empty_AliasSet },
00179   { "f9", Empty_AliasSet },
00180   { "f10", Empty_AliasSet },
00181   { "f11", Empty_AliasSet },
00182   { "f12", Empty_AliasSet },
00183   { "f13", Empty_AliasSet },
00184   { "f14", Empty_AliasSet },
00185   { "f15", Empty_AliasSet },
00186   { "f16", Empty_AliasSet },
00187   { "f17", Empty_AliasSet },
00188   { "f18", Empty_AliasSet },
00189   { "f19", Empty_AliasSet },
00190   { "f20", Empty_AliasSet },
00191   { "f21", Empty_AliasSet },
00192   { "f22", Empty_AliasSet },
00193   { "f23", Empty_AliasSet },
00194   { "f24", Empty_AliasSet },
00195   { "f25", Empty_AliasSet },
00196   { "f26", Empty_AliasSet },
00197   { "f27", Empty_AliasSet },
00198   { "f28", Empty_AliasSet },
00199   { "f29", Empty_AliasSet },
00200   { "f30", Empty_AliasSet },
00201   { "f31", Empty_AliasSet },
00202   { "f32", Empty_AliasSet },
00203   { "f33", Empty_AliasSet },
00204   { "f34", Empty_AliasSet },
00205   { "f35", Empty_AliasSet },
00206   { "f36", Empty_AliasSet },
00207   { "f37", Empty_AliasSet },
00208   { "f38", Empty_AliasSet },
00209   { "f39", Empty_AliasSet },
00210   { "f40", Empty_AliasSet },
00211   { "f41", Empty_AliasSet },
00212   { "f42", Empty_AliasSet },
00213   { "f43", Empty_AliasSet },
00214   { "f44", Empty_AliasSet },
00215   { "f45", Empty_AliasSet },
00216   { "f46", Empty_AliasSet },
00217   { "f47", Empty_AliasSet },
00218   { "f48", Empty_AliasSet },
00219   { "f49", Empty_AliasSet },
00220   { "f50", Empty_AliasSet },
00221   { "f51", Empty_AliasSet },
00222   { "f52", Empty_AliasSet },
00223   { "f53", Empty_AliasSet },
00224   { "f54", Empty_AliasSet },
00225   { "f55", Empty_AliasSet },
00226   { "f56", Empty_AliasSet },
00227   { "f57", Empty_AliasSet },
00228   { "f58", Empty_AliasSet },
00229   { "f59", Empty_AliasSet },
00230   { "f60", Empty_AliasSet },
00231   { "f61", Empty_AliasSet },
00232   { "f62", Empty_AliasSet },
00233   { "f63", Empty_AliasSet },
00234   { "xcc", xcc_AliasSet },
00235   { "icc", icc_AliasSet },
00236   { "ccr", ccr_AliasSet },
00237   { "fcc0", fcc0_AliasSet },
00238   { "fcc1", fcc1_AliasSet },
00239   { "fcc2", fcc2_AliasSet },
00240   { "fcc3", fcc3_AliasSet },
00241   { "fsr", fsr_AliasSet },
00242 };
00243 
00244 } // end anonymous namespace
00245 
00246 namespace SparcV9 { // Register classes
00247   TargetRegisterClass *IRRegisterClass = &IRInstance;
00248   TargetRegisterClass *FRRegisterClass = &FRInstance;
00249   TargetRegisterClass *ICCRRegisterClass = &ICCRInstance;
00250   TargetRegisterClass *FCCRRegisterClass = &FCCRInstance;
00251   TargetRegisterClass *SRRegisterClass = &SRInstance;
00252 } // end namespace SparcV9
00253 
00254 const unsigned *SparcV9RegisterInfo::getCalleeSaveRegs() const {
00255   // FIXME: This should be verified against the SparcV9 ABI at some point.
00256   // These are the registers which the SparcV9 backend considers
00257   // "non-volatile".
00258   static const unsigned CalleeSaveRegs[] = {
00259      SparcV9::l0, SparcV9::l1, SparcV9::l2, SparcV9::l3, SparcV9::l4,
00260      SparcV9::l5, SparcV9::l6, SparcV9::l7, SparcV9::i0, SparcV9::i1,
00261      SparcV9::i2, SparcV9::i3, SparcV9::i4, SparcV9::i5, SparcV9::i6,
00262      SparcV9::i7, SparcV9::g0, SparcV9::g1, SparcV9::g2, SparcV9::g3,
00263      SparcV9::g4, SparcV9::g5, SparcV9::g6, SparcV9::g7, SparcV9::o6,
00264      0
00265   };
00266   return CalleeSaveRegs;
00267 }
00268 
00269 } // end namespace llvm
00270 
00271 //===----------------------------------------------------------------------===//
00272 //
00273 // The second section of this file (immediately following) contains the
00274 // SparcV9 implementation of the MRegisterInfo class. It currently consists
00275 // entirely of stub functions, because the SparcV9 target does not use the
00276 // same register allocator that the X86 target uses.
00277 //
00278 //===----------------------------------------------------------------------===//
00279 
00280 SparcV9RegisterInfo::SparcV9RegisterInfo ()
00281   : MRegisterInfo (RegisterDescriptors, 104, RegisterClasses,
00282                    RegisterClasses + 5) {
00283 }
00284 
00285 void SparcV9RegisterInfo::storeRegToStackSlot(MachineBasicBlock &MBB,
00286                                          MachineBasicBlock::iterator MI,
00287                                          unsigned SrcReg, int FrameIndex,
00288                                          const TargetRegisterClass *RC) const {
00289   abort ();
00290 }
00291 
00292 void SparcV9RegisterInfo::loadRegFromStackSlot(MachineBasicBlock &MBB,
00293                                           MachineBasicBlock::iterator MI,
00294                                           unsigned DestReg, int FrameIndex,
00295                                           const TargetRegisterClass *RC) const {
00296   abort ();
00297 }
00298 
00299 void SparcV9RegisterInfo::copyRegToReg(MachineBasicBlock &MBB,
00300                                       MachineBasicBlock::iterator MI,
00301                                       unsigned DestReg, unsigned SrcReg,
00302                                       const TargetRegisterClass *RC) const {
00303   abort ();
00304 }
00305 
00306 void SparcV9RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator MI)
00307   const {
00308   abort ();
00309 }
00310 
00311 void SparcV9RegisterInfo::emitPrologue(MachineFunction &MF) const {
00312   abort ();
00313 }
00314 
00315 void SparcV9RegisterInfo::emitEpilogue(MachineFunction &MF,
00316                                        MachineBasicBlock &MBB) const {
00317   abort ();
00318 }
00319 
00320 int SparcV9RegisterInfo::getDwarfRegNum(unsigned RegNum) const {
00321   abort ();
00322   return 0;
00323 }
00324 
00325 unsigned SparcV9RegisterInfo::getRARegister() const {
00326   abort ();
00327   return 0;
00328 }
00329 
00330 unsigned SparcV9RegisterInfo::getFrameRegister(MachineFunction &MF) const {
00331   abort ();
00332   return 0;
00333 }