1 //===-- SPUMCTargetDesc.cpp - Cell SPU Target Descriptions -----*- C++ -*-===//
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 Cell SPU specific target descriptions.
12 //===----------------------------------------------------------------------===//
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"
24 #define GET_INSTRINFO_MC_DESC
25 #include "SPUGenInstrInfo.inc"
27 #define GET_SUBTARGETINFO_MC_DESC
28 #include "SPUGenSubtargetInfo.inc"
30 #define GET_REGINFO_MC_DESC
31 #include "SPUGenRegisterInfo.inc"
35 static MCInstrInfo *createSPUMCInstrInfo() {
36 MCInstrInfo *X = new MCInstrInfo();
37 InitSPUMCInstrInfo(X);
41 static MCRegisterInfo *createCellSPUMCRegisterInfo(StringRef TT) {
42 MCRegisterInfo *X = new MCRegisterInfo();
43 InitSPUMCRegisterInfo(X, SPU::R0);
47 static MCSubtargetInfo *createSPUMCSubtargetInfo(StringRef TT, StringRef CPU,
49 MCSubtargetInfo *X = new MCSubtargetInfo();
50 InitSPUMCSubtargetInfo(X, TT, CPU, FS);
54 static MCAsmInfo *createSPUMCAsmInfo(const Target &T, StringRef TT) {
55 MCAsmInfo *MAI = new SPULinuxMCAsmInfo(T, TT);
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);
65 static MCCodeGenInfo *createSPUMCCodeGenInfo(StringRef TT, Reloc::Model RM,
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);
75 // Force static initialization.
76 extern "C" void LLVMInitializeCellSPUTargetMC() {
77 // Register the MC asm info.
78 RegisterMCAsmInfoFn X(TheCellSPUTarget, createSPUMCAsmInfo);
80 // Register the MC codegen info.
81 TargetRegistry::RegisterMCCodeGenInfo(TheCellSPUTarget,
82 createSPUMCCodeGenInfo);
84 // Register the MC instruction info.
85 TargetRegistry::RegisterMCInstrInfo(TheCellSPUTarget, createSPUMCInstrInfo);
87 // Register the MC register info.
88 TargetRegistry::RegisterMCRegInfo(TheCellSPUTarget,
89 createCellSPUMCRegisterInfo);
91 // Register the MC subtarget info.
92 TargetRegistry::RegisterMCSubtargetInfo(TheCellSPUTarget,
93 createSPUMCSubtargetInfo);