1 //===-- HexagonMCTargetDesc.cpp - Hexagon Target Descriptions -------------===//
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 Hexagon specific target descriptions.
12 //===----------------------------------------------------------------------===//
14 #include "HexagonMCTargetDesc.h"
15 #include "HexagonMCAsmInfo.h"
16 #include "MCTargetDesc/HexagonInstPrinter.h"
17 #include "llvm/MC/MCCodeGenInfo.h"
18 #include "llvm/MC/MCELFStreamer.h"
19 #include "llvm/MC/MCInstrInfo.h"
20 #include "llvm/MC/MCRegisterInfo.h"
21 #include "llvm/MC/MCStreamer.h"
22 #include "llvm/MC/MCSubtargetInfo.h"
23 #include "llvm/MC/MachineLocation.h"
24 #include "llvm/Support/ErrorHandling.h"
25 #include "llvm/Support/TargetRegistry.h"
29 #define GET_INSTRINFO_MC_DESC
30 #include "HexagonGenInstrInfo.inc"
32 #define GET_SUBTARGETINFO_MC_DESC
33 #include "HexagonGenSubtargetInfo.inc"
35 #define GET_REGINFO_MC_DESC
36 #include "HexagonGenRegisterInfo.inc"
38 MCInstrInfo *llvm::createHexagonMCInstrInfo() {
39 MCInstrInfo *X = new MCInstrInfo();
40 InitHexagonMCInstrInfo(X);
44 static MCRegisterInfo *createHexagonMCRegisterInfo(StringRef TT) {
45 MCRegisterInfo *X = new MCRegisterInfo();
46 InitHexagonMCRegisterInfo(X, Hexagon::R0);
51 createHexagonELFStreamer(MCContext &Context, MCAsmBackend &MAB,
52 raw_ostream &OS, MCCodeEmitter *CE,
54 MCELFStreamer *ES = new MCELFStreamer(Context, MAB, OS, CE);
59 static MCSubtargetInfo *
60 createHexagonMCSubtargetInfo(StringRef TT, StringRef CPU, StringRef FS) {
61 MCSubtargetInfo *X = new MCSubtargetInfo();
62 InitHexagonMCSubtargetInfo(X, TT, CPU, FS);
66 static MCAsmInfo *createHexagonMCAsmInfo(const MCRegisterInfo &MRI,
68 MCAsmInfo *MAI = new HexagonMCAsmInfo(TT);
70 // VirtualFP = (R30 + #0).
71 MCCFIInstruction Inst =
72 MCCFIInstruction::createDefCfa(nullptr, Hexagon::R30, 0);
73 MAI->addInitialFrameState(Inst);
78 static MCStreamer *createMCStreamer(const Triple &T, MCContext &Context,
79 MCAsmBackend &MAB, raw_ostream &OS,
80 MCCodeEmitter *Emitter,
81 MCSubtargetInfo const &STI, bool RelaxAll) {
82 MCStreamer *ES = createHexagonELFStreamer(Context, MAB, OS, Emitter, RelaxAll);
83 new MCTargetStreamer(*ES);
88 static MCCodeGenInfo *createHexagonMCCodeGenInfo(StringRef TT, Reloc::Model RM,
90 CodeGenOpt::Level OL) {
91 MCCodeGenInfo *X = new MCCodeGenInfo();
92 // For the time being, use static relocations, since there's really no
93 // support for PIC yet.
94 X->InitMCCodeGenInfo(Reloc::Static, CM, OL);
97 static MCInstPrinter *createHexagonMCInstPrinter(const Target &T,
98 unsigned SyntaxVariant,
100 const MCInstrInfo &MII,
101 const MCRegisterInfo &MRI,
102 const MCSubtargetInfo &STI) {
103 return new HexagonInstPrinter(MAI, MII, MRI);
106 // Force static initialization.
107 extern "C" void LLVMInitializeHexagonTargetMC() {
108 // Register the MC asm info.
109 RegisterMCAsmInfoFn X(TheHexagonTarget, createHexagonMCAsmInfo);
111 // Register the MC codegen info.
112 TargetRegistry::RegisterMCCodeGenInfo(TheHexagonTarget,
113 createHexagonMCCodeGenInfo);
115 // Register the MC instruction info.
116 TargetRegistry::RegisterMCInstrInfo(TheHexagonTarget,
117 createHexagonMCInstrInfo);
119 // Register the MC register info.
120 TargetRegistry::RegisterMCRegInfo(TheHexagonTarget,
121 createHexagonMCRegisterInfo);
123 // Register the MC subtarget info.
124 TargetRegistry::RegisterMCSubtargetInfo(TheHexagonTarget,
125 createHexagonMCSubtargetInfo);
127 // Register the MC Code Emitter
128 TargetRegistry::RegisterMCCodeEmitter(TheHexagonTarget,
129 createHexagonMCCodeEmitter);
131 // Register the MC Inst Printer
132 TargetRegistry::RegisterMCInstPrinter(TheHexagonTarget,
133 createHexagonMCInstPrinter);
135 // Register the asm backend
136 TargetRegistry::RegisterMCAsmBackend(TheHexagonTarget,
137 createHexagonAsmBackend);
139 // Register the obj streamer
140 TargetRegistry::RegisterMCObjectStreamer(TheHexagonTarget, createMCStreamer);