Home | History | Annotate | Download | only in MCTargetDesc
      1 //===-- SPUMCTargetDesc.cpp - Cell SPU 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 Cell SPU specific target descriptions.
     11 //
     12 //===----------------------------------------------------------------------===//
     13 
     14 #include "SPUMCTargetDesc.h"
     15 #include "SPUMCAsmInfo.h"
     16 #include "llvm/MC/MachineLocation.h"
     17 #include "llvm/MC/MCCodeGenInfo.h"
     18 #include "llvm/MC/MCInstrInfo.h"
     19 #include "llvm/MC/MCRegisterInfo.h"
     20 #include "llvm/MC/MCSubtargetInfo.h"
     21 #include "llvm/Support/ErrorHandling.h"
     22 #include "llvm/Support/TargetRegistry.h"
     23 
     24 #define GET_INSTRINFO_MC_DESC
     25 #include "SPUGenInstrInfo.inc"
     26 
     27 #define GET_SUBTARGETINFO_MC_DESC
     28 #include "SPUGenSubtargetInfo.inc"
     29 
     30 #define GET_REGINFO_MC_DESC
     31 #include "SPUGenRegisterInfo.inc"
     32 
     33 using namespace llvm;
     34 
     35 static MCInstrInfo *createSPUMCInstrInfo() {
     36   MCInstrInfo *X = new MCInstrInfo();
     37   InitSPUMCInstrInfo(X);
     38   return X;
     39 }
     40 
     41 static MCRegisterInfo *createCellSPUMCRegisterInfo(StringRef TT) {
     42   MCRegisterInfo *X = new MCRegisterInfo();
     43   InitSPUMCRegisterInfo(X, SPU::R0);
     44   return X;
     45 }
     46 
     47 static MCSubtargetInfo *createSPUMCSubtargetInfo(StringRef TT, StringRef CPU,
     48                                                  StringRef FS) {
     49   MCSubtargetInfo *X = new MCSubtargetInfo();
     50   InitSPUMCSubtargetInfo(X, TT, CPU, FS);
     51   return X;
     52 }
     53 
     54 static MCAsmInfo *createSPUMCAsmInfo(const Target &T, StringRef TT) {
     55   MCAsmInfo *MAI = new SPULinuxMCAsmInfo(T, TT);
     56 
     57   // Initial state of the frame pointer is R1.
     58   MachineLocation Dst(MachineLocation::VirtualFP);
     59   MachineLocation Src(SPU::R1, 0);
     60   MAI->addInitialFrameState(0, Dst, Src);
     61 
     62   return MAI;
     63 }
     64 
     65 static MCCodeGenInfo *createSPUMCCodeGenInfo(StringRef TT, Reloc::Model RM,
     66                                              CodeModel::Model CM,
     67                                              CodeGenOpt::Level OL) {
     68   MCCodeGenInfo *X = new MCCodeGenInfo();
     69   // For the time being, use static relocations, since there's really no
     70   // support for PIC yet.
     71   X->InitMCCodeGenInfo(Reloc::Static, CM, OL);
     72   return X;
     73 }
     74 
     75 // Force static initialization.
     76 extern "C" void LLVMInitializeCellSPUTargetMC() {
     77   // Register the MC asm info.
     78   RegisterMCAsmInfoFn X(TheCellSPUTarget, createSPUMCAsmInfo);
     79 
     80   // Register the MC codegen info.
     81   TargetRegistry::RegisterMCCodeGenInfo(TheCellSPUTarget,
     82                                         createSPUMCCodeGenInfo);
     83 
     84   // Register the MC instruction info.
     85   TargetRegistry::RegisterMCInstrInfo(TheCellSPUTarget, createSPUMCInstrInfo);
     86 
     87   // Register the MC register info.
     88   TargetRegistry::RegisterMCRegInfo(TheCellSPUTarget,
     89                                     createCellSPUMCRegisterInfo);
     90 
     91   // Register the MC subtarget info.
     92   TargetRegistry::RegisterMCSubtargetInfo(TheCellSPUTarget,
     93                                           createSPUMCSubtargetInfo);
     94 }
     95