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/MCInstrInfo.h"
18 #include "llvm/MC/MCRegisterInfo.h"
19 #include "llvm/MC/MCSubtargetInfo.h"
20 #include "llvm/Target/TargetRegistry.h"
22 #define GET_INSTRINFO_MC_DESC
23 #include "SPUGenInstrInfo.inc"
25 #define GET_SUBTARGETINFO_MC_DESC
26 #include "SPUGenSubtargetInfo.inc"
28 #define GET_REGINFO_MC_DESC
29 #include "SPUGenRegisterInfo.inc"
33 static MCInstrInfo *createSPUMCInstrInfo() {
34 MCInstrInfo *X = new MCInstrInfo();
35 InitSPUMCInstrInfo(X);
39 static MCRegisterInfo *createCellSPUMCRegisterInfo(StringRef TT) {
40 MCRegisterInfo *X = new MCRegisterInfo();
41 InitSPUMCRegisterInfo(X, SPU::R0);
45 static MCSubtargetInfo *createSPUMCSubtargetInfo(StringRef TT, StringRef CPU,
47 MCSubtargetInfo *X = new MCSubtargetInfo();
48 InitSPUMCSubtargetInfo(X, TT, CPU, FS);
52 static MCAsmInfo *createSPUMCAsmInfo(const Target &T, StringRef TT) {
53 MCAsmInfo *MAI = new SPULinuxMCAsmInfo(T, TT);
55 // Initial state of the frame pointer is R1.
56 MachineLocation Dst(MachineLocation::VirtualFP);
57 MachineLocation Src(SPU::R1, 0);
58 MAI->addInitialFrameState(0, Dst, Src);
63 static MCCodeGenInfo *createSPUMCCodeGenInfo(StringRef TT, Reloc::Model RM,
64 CodeModel::Model CM) {
65 MCCodeGenInfo *X = new MCCodeGenInfo();
66 // For the time being, use static relocations, since there's really no
67 // support for PIC yet.
68 X->InitMCCodeGenInfo(Reloc::Static, CM);
72 // Force static initialization.
73 extern "C" void LLVMInitializeCellSPUTargetMC() {
74 // Register the MC asm info.
75 RegisterMCAsmInfoFn X(TheCellSPUTarget, createSPUMCAsmInfo);
77 // Register the MC codegen info.
78 TargetRegistry::RegisterMCCodeGenInfo(TheCellSPUTarget,
79 createSPUMCCodeGenInfo);
81 // Register the MC instruction info.
82 TargetRegistry::RegisterMCInstrInfo(TheCellSPUTarget, createSPUMCInstrInfo);
84 // Register the MC register info.
85 TargetRegistry::RegisterMCRegInfo(TheCellSPUTarget,
86 createCellSPUMCRegisterInfo);
88 // Register the MC subtarget info.
89 TargetRegistry::RegisterMCSubtargetInfo(TheCellSPUTarget,
90 createSPUMCSubtargetInfo);