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. |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #include "AVRMCTargetDesc.h" |
14 | #include "AVRELFStreamer.h" |
15 | #include "AVRInstPrinter.h" |
16 | #include "AVRMCAsmInfo.h" |
17 | #include "AVRMCELFStreamer.h" |
18 | #include "AVRTargetStreamer.h" |
19 | #include "TargetInfo/AVRTargetInfo.h" |
20 | |
21 | #include "llvm/MC/MCAsmBackend.h" |
22 | #include "llvm/MC/MCCodeEmitter.h" |
23 | #include "llvm/MC/MCELFStreamer.h" |
24 | #include "llvm/MC/MCInstrInfo.h" |
25 | #include "llvm/MC/MCRegisterInfo.h" |
26 | #include "llvm/MC/MCSubtargetInfo.h" |
27 | #include "llvm/MC/TargetRegistry.h" |
28 | |
29 | #define GET_INSTRINFO_MC_DESC |
30 | #define ENABLE_INSTR_PREDICATE_VERIFIER |
31 | #include "AVRGenInstrInfo.inc" |
32 | |
33 | #define GET_SUBTARGETINFO_MC_DESC |
34 | #include "AVRGenSubtargetInfo.inc" |
35 | |
36 | #define GET_REGINFO_MC_DESC |
37 | #include "AVRGenRegisterInfo.inc" |
38 | |
39 | using namespace llvm; |
40 | |
41 | MCInstrInfo *llvm::createAVRMCInstrInfo() { |
42 | MCInstrInfo *X = new MCInstrInfo(); |
43 | InitAVRMCInstrInfo(II: X); |
44 | |
45 | return X; |
46 | } |
47 | |
48 | static MCRegisterInfo *createAVRMCRegisterInfo(const Triple &TT) { |
49 | MCRegisterInfo *X = new MCRegisterInfo(); |
50 | InitAVRMCRegisterInfo(RI: X, RA: 0); |
51 | |
52 | return X; |
53 | } |
54 | |
55 | static MCSubtargetInfo *createAVRMCSubtargetInfo(const Triple &TT, |
56 | StringRef CPU, StringRef FS) { |
57 | return createAVRMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS); |
58 | } |
59 | |
60 | static MCInstPrinter *createAVRMCInstPrinter(const Triple &T, |
61 | unsigned SyntaxVariant, |
62 | const MCAsmInfo &MAI, |
63 | const MCInstrInfo &MII, |
64 | const MCRegisterInfo &MRI) { |
65 | if (SyntaxVariant == 0) { |
66 | return new AVRInstPrinter(MAI, MII, MRI); |
67 | } |
68 | |
69 | return nullptr; |
70 | } |
71 | |
72 | static MCStreamer *createMCStreamer(const Triple &T, MCContext &Context, |
73 | std::unique_ptr<MCAsmBackend> &&MAB, |
74 | std::unique_ptr<MCObjectWriter> &&OW, |
75 | std::unique_ptr<MCCodeEmitter> &&Emitter) { |
76 | return createELFStreamer(Ctx&: Context, TAB: std::move(MAB), OW: std::move(OW), |
77 | CE: std::move(Emitter)); |
78 | } |
79 | |
80 | static MCTargetStreamer * |
81 | createAVRObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI) { |
82 | return new AVRELFStreamer(S, STI); |
83 | } |
84 | |
85 | static MCTargetStreamer *createMCAsmTargetStreamer(MCStreamer &S, |
86 | formatted_raw_ostream &OS, |
87 | MCInstPrinter *InstPrint) { |
88 | return new AVRTargetAsmStreamer(S); |
89 | } |
90 | |
91 | extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAVRTargetMC() { |
92 | // Register the MC asm info. |
93 | RegisterMCAsmInfo<AVRMCAsmInfo> X(getTheAVRTarget()); |
94 | |
95 | // Register the MC instruction info. |
96 | TargetRegistry::RegisterMCInstrInfo(T&: getTheAVRTarget(), Fn: createAVRMCInstrInfo); |
97 | |
98 | // Register the MC register info. |
99 | TargetRegistry::RegisterMCRegInfo(T&: getTheAVRTarget(), Fn: createAVRMCRegisterInfo); |
100 | |
101 | // Register the MC subtarget info. |
102 | TargetRegistry::RegisterMCSubtargetInfo(T&: getTheAVRTarget(), |
103 | Fn: createAVRMCSubtargetInfo); |
104 | |
105 | // Register the MCInstPrinter. |
106 | TargetRegistry::RegisterMCInstPrinter(T&: getTheAVRTarget(), |
107 | Fn: createAVRMCInstPrinter); |
108 | |
109 | // Register the MC Code Emitter |
110 | TargetRegistry::RegisterMCCodeEmitter(T&: getTheAVRTarget(), |
111 | Fn: createAVRMCCodeEmitter); |
112 | |
113 | // Register the obj streamer |
114 | TargetRegistry::RegisterELFStreamer(T&: getTheAVRTarget(), Fn: createMCStreamer); |
115 | |
116 | // Register the obj target streamer. |
117 | TargetRegistry::RegisterObjectTargetStreamer(T&: getTheAVRTarget(), |
118 | Fn: createAVRObjectTargetStreamer); |
119 | |
120 | // Register the asm target streamer. |
121 | TargetRegistry::RegisterAsmTargetStreamer(T&: getTheAVRTarget(), |
122 | Fn: createMCAsmTargetStreamer); |
123 | |
124 | // Register the asm backend (as little endian). |
125 | TargetRegistry::RegisterMCAsmBackend(T&: getTheAVRTarget(), Fn: createAVRAsmBackend); |
126 | } |
127 | |