blob: 14ddd9db3275a8bfe5cb5a65375f4b1663859117 [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"
Tony Linthicumb3705e02011-12-15 22:29:08 +000017#include "llvm/MC/MCCodeGenInfo.h"
Colin LeMahieu2c769202014-11-06 17:05:51 +000018#include "llvm/MC/MCELFStreamer.h"
Tony Linthicumb3705e02011-12-15 22:29:08 +000019#include "llvm/MC/MCInstrInfo.h"
20#include "llvm/MC/MCRegisterInfo.h"
Jyotsna Verma7503a622013-02-20 16:13:27 +000021#include "llvm/MC/MCStreamer.h"
Tony Linthicumb3705e02011-12-15 22:29:08 +000022#include "llvm/MC/MCSubtargetInfo.h"
Chandler Carruth8a8cd2b2014-01-07 11:48:04 +000023#include "llvm/MC/MachineLocation.h"
Craig Topperc4965bc2012-02-05 07:21:30 +000024#include "llvm/Support/ErrorHandling.h"
Tony Linthicumb3705e02011-12-15 22:29:08 +000025#include "llvm/Support/TargetRegistry.h"
26
Chandler Carruthd174b722014-04-22 02:03:14 +000027using namespace llvm;
28
Tony Linthicumb3705e02011-12-15 22:29:08 +000029#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 LeMahieu52418812014-11-04 00:14:36 +000038static MCInstrInfo *createHexagonMCInstrInfo() {
Tony Linthicumb3705e02011-12-15 22:29:08 +000039 MCInstrInfo *X = new MCInstrInfo();
40 InitHexagonMCInstrInfo(X);
41 return X;
42}
43
44static MCRegisterInfo *createHexagonMCRegisterInfo(StringRef TT) {
45 MCRegisterInfo *X = new MCRegisterInfo();
46 InitHexagonMCRegisterInfo(X, Hexagon::R0);
47 return X;
48}
49
Colin LeMahieu2c769202014-11-06 17:05:51 +000050static MCStreamer *
51createHexagonELFStreamer(MCContext &Context, MCAsmBackend &MAB,
52 raw_ostream &OS, MCCodeEmitter *CE,
53 bool RelaxAll) {
54 MCELFStreamer *ES = new MCELFStreamer(Context, MAB, OS, CE);
55 return ES;
56}
57
58
Sid Manning7da3f9a2014-10-03 13:18:11 +000059static MCSubtargetInfo *
60createHexagonMCSubtargetInfo(StringRef TT, StringRef CPU, StringRef FS) {
Tony Linthicumb3705e02011-12-15 22:29:08 +000061 MCSubtargetInfo *X = new MCSubtargetInfo();
62 InitHexagonMCSubtargetInfo(X, TT, CPU, FS);
63 return X;
64}
65
Rafael Espindola227144c2013-05-13 01:16:13 +000066static MCAsmInfo *createHexagonMCAsmInfo(const MCRegisterInfo &MRI,
67 StringRef TT) {
Rafael Espindola140a8372013-05-10 18:16:59 +000068 MCAsmInfo *MAI = new HexagonMCAsmInfo(TT);
Tony Linthicumb3705e02011-12-15 22:29:08 +000069
70 // VirtualFP = (R30 + #0).
Sid Manning7da3f9a2014-10-03 13:18:11 +000071 MCCFIInstruction Inst =
72 MCCFIInstruction::createDefCfa(nullptr, Hexagon::R30, 0);
Rafael Espindola227144c2013-05-13 01:16:13 +000073 MAI->addInitialFrameState(Inst);
Tony Linthicumb3705e02011-12-15 22:29:08 +000074
75 return MAI;
76}
77
Colin LeMahieu2c769202014-11-06 17:05:51 +000078static MCStreamer *createMCStreamer(Target const &T, StringRef TT,
79 MCContext &Context, MCAsmBackend &MAB,
80 raw_ostream &OS, MCCodeEmitter *Emitter,
81 MCSubtargetInfo const &STI, bool RelaxAll) {
82 MCStreamer *ES = createHexagonELFStreamer(Context, MAB, OS, Emitter, RelaxAll);
83 new MCTargetStreamer(*ES);
84 return ES;
85}
86
87
Tony Linthicumb3705e02011-12-15 22:29:08 +000088static MCCodeGenInfo *createHexagonMCCodeGenInfo(StringRef TT, Reloc::Model RM,
Sid Manning7da3f9a2014-10-03 13:18:11 +000089 CodeModel::Model CM,
90 CodeGenOpt::Level OL) {
Tony Linthicumb3705e02011-12-15 22:29:08 +000091 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);
95 return X;
96}
Sid Manning12cd21a2014-10-15 18:27:40 +000097static MCInstPrinter *createHexagonMCInstPrinter(const Target &T,
98 unsigned SyntaxVariant,
99 const MCAsmInfo &MAI,
100 const MCInstrInfo &MII,
101 const MCRegisterInfo &MRI,
102 const MCSubtargetInfo &STI) {
103 return new HexagonInstPrinter(MAI, MII, MRI);
104}
Tony Linthicumb3705e02011-12-15 22:29:08 +0000105
106// Force static initialization.
107extern "C" void LLVMInitializeHexagonTargetMC() {
108 // Register the MC asm info.
109 RegisterMCAsmInfoFn X(TheHexagonTarget, createHexagonMCAsmInfo);
110
111 // Register the MC codegen info.
112 TargetRegistry::RegisterMCCodeGenInfo(TheHexagonTarget,
113 createHexagonMCCodeGenInfo);
114
115 // Register the MC instruction info.
Sid Manning7da3f9a2014-10-03 13:18:11 +0000116 TargetRegistry::RegisterMCInstrInfo(TheHexagonTarget,
117 createHexagonMCInstrInfo);
Tony Linthicumb3705e02011-12-15 22:29:08 +0000118
119 // Register the MC register info.
120 TargetRegistry::RegisterMCRegInfo(TheHexagonTarget,
121 createHexagonMCRegisterInfo);
122
123 // Register the MC subtarget info.
124 TargetRegistry::RegisterMCSubtargetInfo(TheHexagonTarget,
125 createHexagonMCSubtargetInfo);
Sid Manning7da3f9a2014-10-03 13:18:11 +0000126
127 // Register the MC Code Emitter
128 TargetRegistry::RegisterMCCodeEmitter(TheHexagonTarget,
129 createHexagonMCCodeEmitter);
Sid Manning12cd21a2014-10-15 18:27:40 +0000130
131 // Register the MC Inst Printer
132 TargetRegistry::RegisterMCInstPrinter(TheHexagonTarget,
133 createHexagonMCInstPrinter);
Colin LeMahieu2c769202014-11-06 17:05:51 +0000134
135 // Register the asm backend
136 TargetRegistry::RegisterMCAsmBackend(TheHexagonTarget,
137 createHexagonAsmBackend);
138
139 // Register the obj streamer
140 TargetRegistry::RegisterMCObjectStreamer(TheHexagonTarget, createMCStreamer);
Tony Linthicumb3705e02011-12-15 22:29:08 +0000141}