| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame^] | 1 | //===-- HexagonMCTargetDesc.cpp - Cell Hexagon Target Descriptions -----*- C++ -*-===// |
| 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 Hexagon specific target descriptions. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "HexagonMCTargetDesc.h" |
| 15 | #include "HexagonMCAsmInfo.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/TargetRegistry.h" |
| 22 | |
| 23 | #define GET_INSTRINFO_MC_DESC |
| 24 | #include "HexagonGenInstrInfo.inc" |
| 25 | |
| 26 | #define GET_SUBTARGETINFO_MC_DESC |
| 27 | #include "HexagonGenSubtargetInfo.inc" |
| 28 | |
| 29 | #define GET_REGINFO_MC_DESC |
| 30 | #include "HexagonGenRegisterInfo.inc" |
| 31 | |
| 32 | using namespace llvm; |
| 33 | |
| 34 | static MCInstrInfo *createHexagonMCInstrInfo() { |
| 35 | MCInstrInfo *X = new MCInstrInfo(); |
| 36 | InitHexagonMCInstrInfo(X); |
| 37 | return X; |
| 38 | } |
| 39 | |
| 40 | static MCRegisterInfo *createHexagonMCRegisterInfo(StringRef TT) { |
| 41 | MCRegisterInfo *X = new MCRegisterInfo(); |
| 42 | InitHexagonMCRegisterInfo(X, Hexagon::R0); |
| 43 | return X; |
| 44 | } |
| 45 | |
| 46 | static MCSubtargetInfo *createHexagonMCSubtargetInfo(StringRef TT, |
| 47 | StringRef CPU, |
| 48 | StringRef FS) { |
| 49 | MCSubtargetInfo *X = new MCSubtargetInfo(); |
| 50 | InitHexagonMCSubtargetInfo(X, TT, CPU, FS); |
| 51 | return X; |
| 52 | } |
| 53 | |
| 54 | static MCAsmInfo *createHexagonMCAsmInfo(const Target &T, StringRef TT) { |
| 55 | MCAsmInfo *MAI = new HexagonMCAsmInfo(T, TT); |
| 56 | |
| 57 | // VirtualFP = (R30 + #0). |
| 58 | MachineLocation Dst(MachineLocation::VirtualFP); |
| 59 | MachineLocation Src(Hexagon::R30, 0); |
| 60 | MAI->addInitialFrameState(0, Dst, Src); |
| 61 | |
| 62 | return MAI; |
| 63 | } |
| 64 | |
| 65 | static MCCodeGenInfo *createHexagonMCCodeGenInfo(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 LLVMInitializeHexagonTargetMC() { |
| 77 | // Register the MC asm info. |
| 78 | RegisterMCAsmInfoFn X(TheHexagonTarget, createHexagonMCAsmInfo); |
| 79 | |
| 80 | // Register the MC codegen info. |
| 81 | TargetRegistry::RegisterMCCodeGenInfo(TheHexagonTarget, |
| 82 | createHexagonMCCodeGenInfo); |
| 83 | |
| 84 | // Register the MC instruction info. |
| 85 | TargetRegistry::RegisterMCInstrInfo(TheHexagonTarget, createHexagonMCInstrInfo); |
| 86 | |
| 87 | // Register the MC register info. |
| 88 | TargetRegistry::RegisterMCRegInfo(TheHexagonTarget, |
| 89 | createHexagonMCRegisterInfo); |
| 90 | |
| 91 | // Register the MC subtarget info. |
| 92 | TargetRegistry::RegisterMCSubtargetInfo(TheHexagonTarget, |
| 93 | createHexagonMCSubtargetInfo); |
| 94 | } |