blob: 0c911fd6999c8012a4623cf6674232c1f089f518 [file] [log] [blame]
Craig Topperf3f66502012-03-17 09:39:20 +00001//===-- HexagonMCTargetDesc.cpp - Hexagon Target Descriptions -------------===//
Tony Linthicumb3705e02011-12-15 22:29:08 +00002//
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 Topperbc3168b2012-03-17 09:28:37 +000010// This file provides Hexagon specific target descriptions.
Tony Linthicumb3705e02011-12-15 22:29:08 +000011//
12//===----------------------------------------------------------------------===//
13
14#include "HexagonMCTargetDesc.h"
15#include "HexagonMCAsmInfo.h"
Colin LeMahieuff062612014-11-20 21:56:35 +000016#include "MCTargetDesc/HexagonInstPrinter.h"
Colin LeMahieu654f2d22014-12-03 21:40:25 +000017#include "MCTargetDesc/HexagonMCInst.h"
Tony Linthicumb3705e02011-12-15 22:29:08 +000018#include "llvm/MC/MCCodeGenInfo.h"
Colin LeMahieu2c769202014-11-06 17:05:51 +000019#include "llvm/MC/MCELFStreamer.h"
Tony Linthicumb3705e02011-12-15 22:29:08 +000020#include "llvm/MC/MCInstrInfo.h"
21#include "llvm/MC/MCRegisterInfo.h"
Jyotsna Verma7503a622013-02-20 16:13:27 +000022#include "llvm/MC/MCStreamer.h"
Tony Linthicumb3705e02011-12-15 22:29:08 +000023#include "llvm/MC/MCSubtargetInfo.h"
Chandler Carruth8a8cd2b2014-01-07 11:48:04 +000024#include "llvm/MC/MachineLocation.h"
Craig Topperc4965bc2012-02-05 07:21:30 +000025#include "llvm/Support/ErrorHandling.h"
Tony Linthicumb3705e02011-12-15 22:29:08 +000026#include "llvm/Support/TargetRegistry.h"
27
Chandler Carruthd174b722014-04-22 02:03:14 +000028using namespace llvm;
29
Tony Linthicumb3705e02011-12-15 22:29:08 +000030#define GET_INSTRINFO_MC_DESC
31#include "HexagonGenInstrInfo.inc"
32
33#define GET_SUBTARGETINFO_MC_DESC
34#include "HexagonGenSubtargetInfo.inc"
35
36#define GET_REGINFO_MC_DESC
37#include "HexagonGenRegisterInfo.inc"
38
Colin LeMahieuf08a3cc2015-02-19 17:38:39 +000039MCInstrInfo *llvm::createHexagonMCInstrInfo() {
Tony Linthicumb3705e02011-12-15 22:29:08 +000040 MCInstrInfo *X = new MCInstrInfo();
41 InitHexagonMCInstrInfo(X);
42 return X;
43}
44
45static MCRegisterInfo *createHexagonMCRegisterInfo(StringRef TT) {
46 MCRegisterInfo *X = new MCRegisterInfo();
47 InitHexagonMCRegisterInfo(X, Hexagon::R0);
48 return X;
49}
50
Colin LeMahieu2c769202014-11-06 17:05:51 +000051static MCStreamer *
52createHexagonELFStreamer(MCContext &Context, MCAsmBackend &MAB,
53 raw_ostream &OS, MCCodeEmitter *CE,
54 bool RelaxAll) {
55 MCELFStreamer *ES = new MCELFStreamer(Context, MAB, OS, CE);
56 return ES;
57}
58
59
Sid Manning7da3f9a2014-10-03 13:18:11 +000060static MCSubtargetInfo *
61createHexagonMCSubtargetInfo(StringRef TT, StringRef CPU, StringRef FS) {
Tony Linthicumb3705e02011-12-15 22:29:08 +000062 MCSubtargetInfo *X = new MCSubtargetInfo();
63 InitHexagonMCSubtargetInfo(X, TT, CPU, FS);
64 return X;
65}
66
Rafael Espindola227144c2013-05-13 01:16:13 +000067static MCAsmInfo *createHexagonMCAsmInfo(const MCRegisterInfo &MRI,
68 StringRef TT) {
Rafael Espindola140a8372013-05-10 18:16:59 +000069 MCAsmInfo *MAI = new HexagonMCAsmInfo(TT);
Tony Linthicumb3705e02011-12-15 22:29:08 +000070
71 // VirtualFP = (R30 + #0).
Sid Manning7da3f9a2014-10-03 13:18:11 +000072 MCCFIInstruction Inst =
73 MCCFIInstruction::createDefCfa(nullptr, Hexagon::R30, 0);
Rafael Espindola227144c2013-05-13 01:16:13 +000074 MAI->addInitialFrameState(Inst);
Tony Linthicumb3705e02011-12-15 22:29:08 +000075
76 return MAI;
77}
78
Colin LeMahieu2c769202014-11-06 17:05:51 +000079static MCStreamer *createMCStreamer(Target const &T, StringRef TT,
80 MCContext &Context, MCAsmBackend &MAB,
81 raw_ostream &OS, MCCodeEmitter *Emitter,
82 MCSubtargetInfo const &STI, bool RelaxAll) {
83 MCStreamer *ES = createHexagonELFStreamer(Context, MAB, OS, Emitter, RelaxAll);
84 new MCTargetStreamer(*ES);
85 return ES;
86}
87
88
Tony Linthicumb3705e02011-12-15 22:29:08 +000089static MCCodeGenInfo *createHexagonMCCodeGenInfo(StringRef TT, Reloc::Model RM,
Sid Manning7da3f9a2014-10-03 13:18:11 +000090 CodeModel::Model CM,
91 CodeGenOpt::Level OL) {
Tony Linthicumb3705e02011-12-15 22:29:08 +000092 MCCodeGenInfo *X = new MCCodeGenInfo();
93 // For the time being, use static relocations, since there's really no
94 // support for PIC yet.
95 X->InitMCCodeGenInfo(Reloc::Static, CM, OL);
96 return X;
97}
Sid Manning12cd21a2014-10-15 18:27:40 +000098static MCInstPrinter *createHexagonMCInstPrinter(const Target &T,
99 unsigned SyntaxVariant,
100 const MCAsmInfo &MAI,
101 const MCInstrInfo &MII,
102 const MCRegisterInfo &MRI,
103 const MCSubtargetInfo &STI) {
104 return new HexagonInstPrinter(MAI, MII, MRI);
105}
Tony Linthicumb3705e02011-12-15 22:29:08 +0000106
107// Force static initialization.
108extern "C" void LLVMInitializeHexagonTargetMC() {
109 // Register the MC asm info.
110 RegisterMCAsmInfoFn X(TheHexagonTarget, createHexagonMCAsmInfo);
111
112 // Register the MC codegen info.
113 TargetRegistry::RegisterMCCodeGenInfo(TheHexagonTarget,
114 createHexagonMCCodeGenInfo);
115
116 // Register the MC instruction info.
Sid Manning7da3f9a2014-10-03 13:18:11 +0000117 TargetRegistry::RegisterMCInstrInfo(TheHexagonTarget,
118 createHexagonMCInstrInfo);
Tony Linthicumb3705e02011-12-15 22:29:08 +0000119
120 // Register the MC register info.
121 TargetRegistry::RegisterMCRegInfo(TheHexagonTarget,
122 createHexagonMCRegisterInfo);
123
124 // Register the MC subtarget info.
125 TargetRegistry::RegisterMCSubtargetInfo(TheHexagonTarget,
126 createHexagonMCSubtargetInfo);
Sid Manning7da3f9a2014-10-03 13:18:11 +0000127
128 // Register the MC Code Emitter
129 TargetRegistry::RegisterMCCodeEmitter(TheHexagonTarget,
130 createHexagonMCCodeEmitter);
Sid Manning12cd21a2014-10-15 18:27:40 +0000131
132 // Register the MC Inst Printer
133 TargetRegistry::RegisterMCInstPrinter(TheHexagonTarget,
134 createHexagonMCInstPrinter);
Colin LeMahieu2c769202014-11-06 17:05:51 +0000135
136 // Register the asm backend
137 TargetRegistry::RegisterMCAsmBackend(TheHexagonTarget,
138 createHexagonAsmBackend);
139
140 // Register the obj streamer
141 TargetRegistry::RegisterMCObjectStreamer(TheHexagonTarget, createMCStreamer);
Tony Linthicumb3705e02011-12-15 22:29:08 +0000142}