| 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" |
| Colin LeMahieu | ff06261 | 2014-11-20 21:56:35 +0000 | [diff] [blame] | 16 | #include "MCTargetDesc/HexagonInstPrinter.h" |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 17 | #include "llvm/MC/MCCodeGenInfo.h" |
| Colin LeMahieu | 2c76920 | 2014-11-06 17:05:51 +0000 | [diff] [blame] | 18 | #include "llvm/MC/MCELFStreamer.h" |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 19 | #include "llvm/MC/MCInstrInfo.h" |
| 20 | #include "llvm/MC/MCRegisterInfo.h" |
| Jyotsna Verma | 7503a62 | 2013-02-20 16:13:27 +0000 | [diff] [blame] | 21 | #include "llvm/MC/MCStreamer.h" |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 22 | #include "llvm/MC/MCSubtargetInfo.h" |
| Chandler Carruth | 8a8cd2b | 2014-01-07 11:48:04 +0000 | [diff] [blame] | 23 | #include "llvm/MC/MachineLocation.h" |
| Craig Topper | c4965bc | 2012-02-05 07:21:30 +0000 | [diff] [blame] | 24 | #include "llvm/Support/ErrorHandling.h" |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 25 | #include "llvm/Support/TargetRegistry.h" |
| 26 | |
| Chandler Carruth | d174b72 | 2014-04-22 02:03:14 +0000 | [diff] [blame] | 27 | using namespace llvm; |
| 28 | |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 29 | #define GET_INSTRINFO_MC_DESC |
| 30 | #include "HexagonGenInstrInfo.inc" |
| 31 | |
| 32 | #define GET_SUBTARGETINFO_MC_DESC |
| 33 | #include "HexagonGenSubtargetInfo.inc" |
| 34 | |
| 35 | #define GET_REGINFO_MC_DESC |
| 36 | #include "HexagonGenRegisterInfo.inc" |
| 37 | |
| Colin LeMahieu | f08a3cc | 2015-02-19 17:38:39 +0000 | [diff] [blame] | 38 | MCInstrInfo *llvm::createHexagonMCInstrInfo() { |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 39 | MCInstrInfo *X = new MCInstrInfo(); |
| 40 | InitHexagonMCInstrInfo(X); |
| 41 | return X; |
| 42 | } |
| 43 | |
| 44 | static MCRegisterInfo *createHexagonMCRegisterInfo(StringRef TT) { |
| 45 | MCRegisterInfo *X = new MCRegisterInfo(); |
| 46 | InitHexagonMCRegisterInfo(X, Hexagon::R0); |
| 47 | return X; |
| 48 | } |
| 49 | |
| Sid Manning | 7da3f9a | 2014-10-03 13:18:11 +0000 | [diff] [blame] | 50 | static MCSubtargetInfo * |
| 51 | createHexagonMCSubtargetInfo(StringRef TT, StringRef CPU, StringRef FS) { |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 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). |
| Sid Manning | 7da3f9a | 2014-10-03 13:18:11 +0000 | [diff] [blame] | 62 | MCCFIInstruction Inst = |
| 63 | MCCFIInstruction::createDefCfa(nullptr, Hexagon::R30, 0); |
| Rafael Espindola | 227144c | 2013-05-13 01:16:13 +0000 | [diff] [blame] | 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, |
| Sid Manning | 7da3f9a | 2014-10-03 13:18:11 +0000 | [diff] [blame] | 70 | CodeModel::Model CM, |
| 71 | CodeGenOpt::Level OL) { |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 72 | MCCodeGenInfo *X = new MCCodeGenInfo(); |
| 73 | // For the time being, use static relocations, since there's really no |
| 74 | // support for PIC yet. |
| Jim Grosbach | 4c98cf7 | 2015-05-15 19:13:31 +0000 | [diff] [blame] | 75 | X->initMCCodeGenInfo(Reloc::Static, CM, OL); |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 76 | return X; |
| 77 | } |
| Eric Christopher | fbe80f5 | 2015-04-09 19:20:37 +0000 | [diff] [blame] | 78 | |
| Eric Christopher | f801940 | 2015-03-31 00:10:04 +0000 | [diff] [blame] | 79 | static MCInstPrinter *createHexagonMCInstPrinter(const Triple &T, |
| 80 | unsigned SyntaxVariant, |
| Sid Manning | 12cd21a | 2014-10-15 18:27:40 +0000 | [diff] [blame] | 81 | const MCAsmInfo &MAI, |
| 82 | const MCInstrInfo &MII, |
| Eric Christopher | f801940 | 2015-03-31 00:10:04 +0000 | [diff] [blame] | 83 | const MCRegisterInfo &MRI) { |
| Eric Christopher | fbe80f5 | 2015-04-09 19:20:37 +0000 | [diff] [blame] | 84 | if (SyntaxVariant == 0) |
| 85 | return(new HexagonInstPrinter(MAI, MII, MRI)); |
| 86 | else |
| 87 | return nullptr; |
| Sid Manning | 12cd21a | 2014-10-15 18:27:40 +0000 | [diff] [blame] | 88 | } |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 89 | |
| 90 | // Force static initialization. |
| 91 | extern "C" void LLVMInitializeHexagonTargetMC() { |
| 92 | // Register the MC asm info. |
| 93 | RegisterMCAsmInfoFn X(TheHexagonTarget, createHexagonMCAsmInfo); |
| 94 | |
| 95 | // Register the MC codegen info. |
| 96 | TargetRegistry::RegisterMCCodeGenInfo(TheHexagonTarget, |
| 97 | createHexagonMCCodeGenInfo); |
| 98 | |
| 99 | // Register the MC instruction info. |
| Sid Manning | 7da3f9a | 2014-10-03 13:18:11 +0000 | [diff] [blame] | 100 | TargetRegistry::RegisterMCInstrInfo(TheHexagonTarget, |
| 101 | createHexagonMCInstrInfo); |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 102 | |
| 103 | // Register the MC register info. |
| 104 | TargetRegistry::RegisterMCRegInfo(TheHexagonTarget, |
| 105 | createHexagonMCRegisterInfo); |
| 106 | |
| 107 | // Register the MC subtarget info. |
| 108 | TargetRegistry::RegisterMCSubtargetInfo(TheHexagonTarget, |
| 109 | createHexagonMCSubtargetInfo); |
| Sid Manning | 7da3f9a | 2014-10-03 13:18:11 +0000 | [diff] [blame] | 110 | |
| 111 | // Register the MC Code Emitter |
| 112 | TargetRegistry::RegisterMCCodeEmitter(TheHexagonTarget, |
| 113 | createHexagonMCCodeEmitter); |
| Sid Manning | 12cd21a | 2014-10-15 18:27:40 +0000 | [diff] [blame] | 114 | |
| Colin LeMahieu | a675077 | 2015-06-03 17:34:16 +0000 | [diff] [blame] | 115 | // Register the asm backend |
| 116 | TargetRegistry::RegisterMCAsmBackend(TheHexagonTarget, |
| 117 | createHexagonAsmBackend); |
| 118 | |
| Sid Manning | 12cd21a | 2014-10-15 18:27:40 +0000 | [diff] [blame] | 119 | // Register the MC Inst Printer |
| 120 | TargetRegistry::RegisterMCInstPrinter(TheHexagonTarget, |
| 121 | createHexagonMCInstPrinter); |
| Tony Linthicum | b3705e0 | 2011-12-15 22:29:08 +0000 | [diff] [blame] | 122 | } |