| Craig Topper | f3f6650 | 2012-03-17 09:39:20 +0000 | [diff] [blame] | 1 | //===-- HexagonMCTargetDesc.cpp - Hexagon Target Descriptions -------------===// |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 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 | // |
| Craig Topper | bc3168b | 2012-03-17 09:28:37 +0000 | [diff] [blame] | 10 | // This file provides Hexagon specific target descriptions. |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "HexagonMCTargetDesc.h" |
| 15 | #include "HexagonMCAsmInfo.h" |
| Jyotsna Verma | 7503a62 | 2013-02-20 16:13:27 +0000 | [diff] [blame] | 16 | #include "InstPrinter/HexagonInstPrinter.h" |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 17 | #include "llvm/MC/MCCodeGenInfo.h" |
| 18 | #include "llvm/MC/MCInstrInfo.h" |
| 19 | #include "llvm/MC/MCRegisterInfo.h" |
| Jyotsna Verma | 7503a62 | 2013-02-20 16:13:27 +0000 | [diff] [blame] | 20 | #include "llvm/MC/MCStreamer.h" |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 21 | #include "llvm/MC/MCSubtargetInfo.h" |
| Chandler Carruth | 8a8cd2b | 2014-01-07 11:48:04 +0000 | [diff] [blame] | 22 | #include "llvm/MC/MachineLocation.h" |
| Craig Topper | c4965bc | 2012-02-05 07:21:30 +0000 | [diff] [blame] | 23 | #include "llvm/Support/ErrorHandling.h" |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 24 | #include "llvm/Support/TargetRegistry.h" |
| 25 | |
| Chandler Carruth | d174b72 | 2014-04-22 02:03:14 +0000 | [diff] [blame^] | 26 | using namespace llvm; |
| 27 | |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 28 | #define GET_INSTRINFO_MC_DESC |
| 29 | #include "HexagonGenInstrInfo.inc" |
| 30 | |
| 31 | #define GET_SUBTARGETINFO_MC_DESC |
| 32 | #include "HexagonGenSubtargetInfo.inc" |
| 33 | |
| 34 | #define GET_REGINFO_MC_DESC |
| 35 | #include "HexagonGenRegisterInfo.inc" |
| 36 | |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 37 | static MCInstrInfo *createHexagonMCInstrInfo() { |
| 38 | MCInstrInfo *X = new MCInstrInfo(); |
| 39 | InitHexagonMCInstrInfo(X); |
| 40 | return X; |
| 41 | } |
| 42 | |
| 43 | static MCRegisterInfo *createHexagonMCRegisterInfo(StringRef TT) { |
| 44 | MCRegisterInfo *X = new MCRegisterInfo(); |
| 45 | InitHexagonMCRegisterInfo(X, Hexagon::R0); |
| 46 | return X; |
| 47 | } |
| 48 | |
| 49 | static MCSubtargetInfo *createHexagonMCSubtargetInfo(StringRef TT, |
| 50 | StringRef CPU, |
| 51 | StringRef FS) { |
| 52 | MCSubtargetInfo *X = new MCSubtargetInfo(); |
| 53 | InitHexagonMCSubtargetInfo(X, TT, CPU, FS); |
| 54 | return X; |
| 55 | } |
| 56 | |
| Rafael Espindola | 227144c | 2013-05-13 01:16:13 +0000 | [diff] [blame] | 57 | static MCAsmInfo *createHexagonMCAsmInfo(const MCRegisterInfo &MRI, |
| 58 | StringRef TT) { |
| Rafael Espindola | 140a837 | 2013-05-10 18:16:59 +0000 | [diff] [blame] | 59 | MCAsmInfo *MAI = new HexagonMCAsmInfo(TT); |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 60 | |
| 61 | // VirtualFP = (R30 + #0). |
| Rafael Espindola | 227144c | 2013-05-13 01:16:13 +0000 | [diff] [blame] | 62 | MCCFIInstruction Inst = MCCFIInstruction::createDefCfa( |
| 63 | 0, Hexagon::R30, 0); |
| 64 | MAI->addInitialFrameState(Inst); |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 65 | |
| 66 | return MAI; |
| 67 | } |
| 68 | |
| 69 | static MCCodeGenInfo *createHexagonMCCodeGenInfo(StringRef TT, Reloc::Model RM, |
| 70 | CodeModel::Model CM, |
| 71 | CodeGenOpt::Level OL) { |
| 72 | MCCodeGenInfo *X = new MCCodeGenInfo(); |
| 73 | // For the time being, use static relocations, since there's really no |
| 74 | // support for PIC yet. |
| 75 | X->InitMCCodeGenInfo(Reloc::Static, CM, OL); |
| 76 | return X; |
| 77 | } |
| 78 | |
| 79 | // Force static initialization. |
| 80 | extern "C" void LLVMInitializeHexagonTargetMC() { |
| 81 | // Register the MC asm info. |
| 82 | RegisterMCAsmInfoFn X(TheHexagonTarget, createHexagonMCAsmInfo); |
| 83 | |
| 84 | // Register the MC codegen info. |
| 85 | TargetRegistry::RegisterMCCodeGenInfo(TheHexagonTarget, |
| 86 | createHexagonMCCodeGenInfo); |
| 87 | |
| 88 | // Register the MC instruction info. |
| 89 | TargetRegistry::RegisterMCInstrInfo(TheHexagonTarget, createHexagonMCInstrInfo); |
| 90 | |
| 91 | // Register the MC register info. |
| 92 | TargetRegistry::RegisterMCRegInfo(TheHexagonTarget, |
| 93 | createHexagonMCRegisterInfo); |
| 94 | |
| 95 | // Register the MC subtarget info. |
| 96 | TargetRegistry::RegisterMCSubtargetInfo(TheHexagonTarget, |
| 97 | createHexagonMCSubtargetInfo); |
| 98 | } |