Recommit r373598 "[yaml2obj/obj2yaml] - Add support for SHT_LLVM_ADDRSIG sections."
[llvm-complete.git] / lib / Target / AVR / MCTargetDesc / AVRMCTargetDesc.cpp
blobf6607b26a065b5e527b221151623c38a985baa96
1 //===-- AVRMCTargetDesc.cpp - AVR Target Descriptions ---------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file provides AVR specific target descriptions.
11 //===----------------------------------------------------------------------===//
13 #include "AVRELFStreamer.h"
14 #include "AVRInstPrinter.h"
15 #include "AVRMCAsmInfo.h"
16 #include "AVRMCELFStreamer.h"
17 #include "AVRMCTargetDesc.h"
18 #include "AVRTargetStreamer.h"
19 #include "TargetInfo/AVRTargetInfo.h"
21 #include "llvm/MC/MCAsmBackend.h"
22 #include "llvm/MC/MCELFStreamer.h"
23 #include "llvm/MC/MCCodeEmitter.h"
24 #include "llvm/MC/MCInstrInfo.h"
25 #include "llvm/MC/MCRegisterInfo.h"
26 #include "llvm/MC/MCSubtargetInfo.h"
27 #include "llvm/Support/TargetRegistry.h"
29 #define GET_INSTRINFO_MC_DESC
30 #include "AVRGenInstrInfo.inc"
32 #define GET_SUBTARGETINFO_MC_DESC
33 #include "AVRGenSubtargetInfo.inc"
35 #define GET_REGINFO_MC_DESC
36 #include "AVRGenRegisterInfo.inc"
38 using namespace llvm;
40 MCInstrInfo *llvm::createAVRMCInstrInfo() {
41 MCInstrInfo *X = new MCInstrInfo();
42 InitAVRMCInstrInfo(X);
44 return X;
47 static MCRegisterInfo *createAVRMCRegisterInfo(const Triple &TT) {
48 MCRegisterInfo *X = new MCRegisterInfo();
49 InitAVRMCRegisterInfo(X, 0);
51 return X;
54 static MCSubtargetInfo *createAVRMCSubtargetInfo(const Triple &TT,
55 StringRef CPU, StringRef FS) {
56 return createAVRMCSubtargetInfoImpl(TT, CPU, FS);
59 static MCInstPrinter *createAVRMCInstPrinter(const Triple &T,
60 unsigned SyntaxVariant,
61 const MCAsmInfo &MAI,
62 const MCInstrInfo &MII,
63 const MCRegisterInfo &MRI) {
64 if (SyntaxVariant == 0) {
65 return new AVRInstPrinter(MAI, MII, MRI);
68 return nullptr;
71 static MCStreamer *createMCStreamer(const Triple &T, MCContext &Context,
72 std::unique_ptr<MCAsmBackend> &&MAB,
73 std::unique_ptr<MCObjectWriter> &&OW,
74 std::unique_ptr<MCCodeEmitter> &&Emitter,
75 bool RelaxAll) {
76 return createELFStreamer(Context, std::move(MAB), std::move(OW),
77 std::move(Emitter), RelaxAll);
80 static MCTargetStreamer *
81 createAVRObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI) {
82 return new AVRELFStreamer(S, STI);
85 static MCTargetStreamer *createMCAsmTargetStreamer(MCStreamer &S,
86 formatted_raw_ostream &OS,
87 MCInstPrinter *InstPrint,
88 bool isVerboseAsm) {
89 return new AVRTargetAsmStreamer(S);
92 extern "C" void LLVMInitializeAVRTargetMC() {
93 // Register the MC asm info.
94 RegisterMCAsmInfo<AVRMCAsmInfo> X(getTheAVRTarget());
96 // Register the MC instruction info.
97 TargetRegistry::RegisterMCInstrInfo(getTheAVRTarget(), createAVRMCInstrInfo);
99 // Register the MC register info.
100 TargetRegistry::RegisterMCRegInfo(getTheAVRTarget(), createAVRMCRegisterInfo);
102 // Register the MC subtarget info.
103 TargetRegistry::RegisterMCSubtargetInfo(getTheAVRTarget(),
104 createAVRMCSubtargetInfo);
106 // Register the MCInstPrinter.
107 TargetRegistry::RegisterMCInstPrinter(getTheAVRTarget(),
108 createAVRMCInstPrinter);
110 // Register the MC Code Emitter
111 TargetRegistry::RegisterMCCodeEmitter(getTheAVRTarget(), createAVRMCCodeEmitter);
113 // Register the obj streamer
114 TargetRegistry::RegisterELFStreamer(getTheAVRTarget(), createMCStreamer);
116 // Register the obj target streamer.
117 TargetRegistry::RegisterObjectTargetStreamer(getTheAVRTarget(),
118 createAVRObjectTargetStreamer);
120 // Register the asm target streamer.
121 TargetRegistry::RegisterAsmTargetStreamer(getTheAVRTarget(),
122 createMCAsmTargetStreamer);
124 // Register the asm backend (as little endian).
125 TargetRegistry::RegisterMCAsmBackend(getTheAVRTarget(), createAVRAsmBackend);