LLVM 23.0.0git
SystemZMCTargetDesc.cpp
Go to the documentation of this file.
1//===-- SystemZMCTargetDesc.cpp - SystemZ 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
13#include "SystemZMCAsmInfo.h"
16#include "llvm/MC/MCContext.h"
17#include "llvm/MC/MCDwarf.h"
18#include "llvm/MC/MCInst.h"
20#include "llvm/MC/MCInstrInfo.h"
22#include "llvm/MC/MCStreamer.h"
27
28using namespace llvm;
29
30#define GET_INSTRINFO_MC_DESC
31#define ENABLE_INSTR_PREDICATE_VERIFIER
32#include "SystemZGenInstrInfo.inc"
33
34#define GET_SUBTARGETINFO_MC_DESC
35#include "SystemZGenSubtargetInfo.inc"
36
37#define GET_REGINFO_MC_DESC
38#include "SystemZGenRegisterInfo.inc"
39
40const unsigned SystemZMC::GR32Regs[16] = {
41 SystemZ::R0L, SystemZ::R1L, SystemZ::R2L, SystemZ::R3L,
42 SystemZ::R4L, SystemZ::R5L, SystemZ::R6L, SystemZ::R7L,
43 SystemZ::R8L, SystemZ::R9L, SystemZ::R10L, SystemZ::R11L,
44 SystemZ::R12L, SystemZ::R13L, SystemZ::R14L, SystemZ::R15L};
45
46const unsigned SystemZMC::GRH32Regs[16] = {
47 SystemZ::R0H, SystemZ::R1H, SystemZ::R2H, SystemZ::R3H,
48 SystemZ::R4H, SystemZ::R5H, SystemZ::R6H, SystemZ::R7H,
49 SystemZ::R8H, SystemZ::R9H, SystemZ::R10H, SystemZ::R11H,
50 SystemZ::R12H, SystemZ::R13H, SystemZ::R14H, SystemZ::R15H};
51
52const unsigned SystemZMC::GR64Regs[16] = {
53 SystemZ::R0D, SystemZ::R1D, SystemZ::R2D, SystemZ::R3D,
54 SystemZ::R4D, SystemZ::R5D, SystemZ::R6D, SystemZ::R7D,
55 SystemZ::R8D, SystemZ::R9D, SystemZ::R10D, SystemZ::R11D,
56 SystemZ::R12D, SystemZ::R13D, SystemZ::R14D, SystemZ::R15D};
57
58const unsigned SystemZMC::GR128Regs[16] = {
59 SystemZ::R0Q, 0, SystemZ::R2Q, 0, SystemZ::R4Q, 0, SystemZ::R6Q, 0,
60 SystemZ::R8Q, 0, SystemZ::R10Q, 0, SystemZ::R12Q, 0, SystemZ::R14Q, 0};
61
62const unsigned SystemZMC::FP16Regs[16] = {
63 SystemZ::F0H, SystemZ::F1H, SystemZ::F2H, SystemZ::F3H,
64 SystemZ::F4H, SystemZ::F5H, SystemZ::F6H, SystemZ::F7H,
65 SystemZ::F8H, SystemZ::F9H, SystemZ::F10H, SystemZ::F11H,
66 SystemZ::F12H, SystemZ::F13H, SystemZ::F14H, SystemZ::F15H};
67
68const unsigned SystemZMC::FP32Regs[16] = {
69 SystemZ::F0S, SystemZ::F1S, SystemZ::F2S, SystemZ::F3S,
70 SystemZ::F4S, SystemZ::F5S, SystemZ::F6S, SystemZ::F7S,
71 SystemZ::F8S, SystemZ::F9S, SystemZ::F10S, SystemZ::F11S,
72 SystemZ::F12S, SystemZ::F13S, SystemZ::F14S, SystemZ::F15S};
73
74const unsigned SystemZMC::FP64Regs[16] = {
75 SystemZ::F0D, SystemZ::F1D, SystemZ::F2D, SystemZ::F3D,
76 SystemZ::F4D, SystemZ::F5D, SystemZ::F6D, SystemZ::F7D,
77 SystemZ::F8D, SystemZ::F9D, SystemZ::F10D, SystemZ::F11D,
78 SystemZ::F12D, SystemZ::F13D, SystemZ::F14D, SystemZ::F15D};
79
80const unsigned SystemZMC::FP128Regs[16] = {
81 SystemZ::F0Q, SystemZ::F1Q, 0, 0, SystemZ::F4Q, SystemZ::F5Q, 0, 0,
82 SystemZ::F8Q, SystemZ::F9Q, 0, 0, SystemZ::F12Q, SystemZ::F13Q, 0, 0};
83
84const unsigned SystemZMC::VR16Regs[32] = {
85 SystemZ::F0H, SystemZ::F1H, SystemZ::F2H, SystemZ::F3H, SystemZ::F4H,
86 SystemZ::F5H, SystemZ::F6H, SystemZ::F7H, SystemZ::F8H, SystemZ::F9H,
87 SystemZ::F10H, SystemZ::F11H, SystemZ::F12H, SystemZ::F13H, SystemZ::F14H,
88 SystemZ::F15H, SystemZ::F16H, SystemZ::F17H, SystemZ::F18H, SystemZ::F19H,
89 SystemZ::F20H, SystemZ::F21H, SystemZ::F22H, SystemZ::F23H, SystemZ::F24H,
90 SystemZ::F25H, SystemZ::F26H, SystemZ::F27H, SystemZ::F28H, SystemZ::F29H,
91 SystemZ::F30H, SystemZ::F31H};
92
93const unsigned SystemZMC::VR32Regs[32] = {
94 SystemZ::F0S, SystemZ::F1S, SystemZ::F2S, SystemZ::F3S, SystemZ::F4S,
95 SystemZ::F5S, SystemZ::F6S, SystemZ::F7S, SystemZ::F8S, SystemZ::F9S,
96 SystemZ::F10S, SystemZ::F11S, SystemZ::F12S, SystemZ::F13S, SystemZ::F14S,
97 SystemZ::F15S, SystemZ::F16S, SystemZ::F17S, SystemZ::F18S, SystemZ::F19S,
98 SystemZ::F20S, SystemZ::F21S, SystemZ::F22S, SystemZ::F23S, SystemZ::F24S,
99 SystemZ::F25S, SystemZ::F26S, SystemZ::F27S, SystemZ::F28S, SystemZ::F29S,
100 SystemZ::F30S, SystemZ::F31S};
101
102const unsigned SystemZMC::VR64Regs[32] = {
103 SystemZ::F0D, SystemZ::F1D, SystemZ::F2D, SystemZ::F3D, SystemZ::F4D,
104 SystemZ::F5D, SystemZ::F6D, SystemZ::F7D, SystemZ::F8D, SystemZ::F9D,
105 SystemZ::F10D, SystemZ::F11D, SystemZ::F12D, SystemZ::F13D, SystemZ::F14D,
106 SystemZ::F15D, SystemZ::F16D, SystemZ::F17D, SystemZ::F18D, SystemZ::F19D,
107 SystemZ::F20D, SystemZ::F21D, SystemZ::F22D, SystemZ::F23D, SystemZ::F24D,
108 SystemZ::F25D, SystemZ::F26D, SystemZ::F27D, SystemZ::F28D, SystemZ::F29D,
109 SystemZ::F30D, SystemZ::F31D};
110
111const unsigned SystemZMC::VR128Regs[32] = {
112 SystemZ::V0, SystemZ::V1, SystemZ::V2, SystemZ::V3, SystemZ::V4,
113 SystemZ::V5, SystemZ::V6, SystemZ::V7, SystemZ::V8, SystemZ::V9,
114 SystemZ::V10, SystemZ::V11, SystemZ::V12, SystemZ::V13, SystemZ::V14,
115 SystemZ::V15, SystemZ::V16, SystemZ::V17, SystemZ::V18, SystemZ::V19,
116 SystemZ::V20, SystemZ::V21, SystemZ::V22, SystemZ::V23, SystemZ::V24,
117 SystemZ::V25, SystemZ::V26, SystemZ::V27, SystemZ::V28, SystemZ::V29,
118 SystemZ::V30, SystemZ::V31};
119
120const unsigned SystemZMC::AR32Regs[16] = {
121 SystemZ::A0, SystemZ::A1, SystemZ::A2, SystemZ::A3,
122 SystemZ::A4, SystemZ::A5, SystemZ::A6, SystemZ::A7,
123 SystemZ::A8, SystemZ::A9, SystemZ::A10, SystemZ::A11,
124 SystemZ::A12, SystemZ::A13, SystemZ::A14, SystemZ::A15};
125
126const unsigned SystemZMC::CR64Regs[16] = {
127 SystemZ::C0, SystemZ::C1, SystemZ::C2, SystemZ::C3,
128 SystemZ::C4, SystemZ::C5, SystemZ::C6, SystemZ::C7,
129 SystemZ::C8, SystemZ::C9, SystemZ::C10, SystemZ::C11,
130 SystemZ::C12, SystemZ::C13, SystemZ::C14, SystemZ::C15};
131
132unsigned SystemZMC::getFirstReg(unsigned Reg) {
133 static unsigned Map[SystemZ::NUM_TARGET_REGS];
134 static bool Initialized = false;
135 if (!Initialized) {
136 for (unsigned I = 0; I < 16; ++I) {
137 Map[GR32Regs[I]] = I;
138 Map[GRH32Regs[I]] = I;
139 Map[GR64Regs[I]] = I;
140 Map[GR128Regs[I]] = I;
141 Map[FP128Regs[I]] = I;
142 Map[AR32Regs[I]] = I;
143 }
144 for (unsigned I = 0; I < 32; ++I) {
145 Map[VR16Regs[I]] = I;
146 Map[VR32Regs[I]] = I;
147 Map[VR64Regs[I]] = I;
148 Map[VR128Regs[I]] = I;
149 }
150 }
151 assert(Reg < SystemZ::NUM_TARGET_REGS);
152 return Map[Reg];
153}
154
156 const Triple &TT,
157 const MCTargetOptions &Options) {
158 if (TT.isOSzOS())
159 return new SystemZMCAsmInfoGOFF(TT, Options);
160
161 MCAsmInfo *MAI = new SystemZMCAsmInfoELF(TT, Options);
163 nullptr, MRI.getDwarfRegNum(SystemZ::R15D, true),
165 MAI->addInitialFrameState(Inst);
166 return MAI;
167}
168
170 MCInstrInfo *X = new MCInstrInfo();
171 InitSystemZMCInstrInfo(X);
172 return X;
173}
174
177 InitSystemZMCRegisterInfo(X, SystemZ::R14D);
178 return X;
179}
180
181static MCSubtargetInfo *
183 return createSystemZMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
184}
185
187 unsigned SyntaxVariant,
188 const MCAsmInfo &MAI,
189 const MCInstrInfo &MII,
190 const MCRegisterInfo &MRI) {
191 if (SyntaxVariant == AD_HLASM)
192 return new SystemZHLASMInstPrinter(MAI, MII, MRI);
193
194 return new SystemZGNUInstPrinter(MAI, MII, MRI);
195}
196
199 MCInstPrinter *InstPrint) {
201 return new SystemZTargetHLASMStreamer(S, OS);
202 else
203 return new SystemZTargetGNUStreamer(S, OS);
204}
205
207 MCContext &Ctx, std::unique_ptr<formatted_raw_ostream> OS,
208 std::unique_ptr<MCInstPrinter> IP, std::unique_ptr<MCCodeEmitter> CE,
209 std::unique_ptr<MCAsmBackend> TAB) {
210
211 auto TT = Ctx.getTargetTriple();
212 if (TT.isOSzOS())
213 return new SystemZHLASMAsmStreamer(Ctx, std::move(OS), std::move(IP),
214 std::move(CE), std::move(TAB));
215
216 return llvm::createAsmStreamer(Ctx, std::move(OS), std::move(IP),
217 std::move(CE), std::move(TAB));
218}
219
220static MCTargetStreamer *
223 return new SystemZTargetGOFFStreamer(S);
224 else
225 return new SystemZTargetELFStreamer(S);
226}
227
228static MCTargetStreamer *
232
234 return new MCInstrAnalysis(Info);
235}
236
239 // Register the MCAsmInfo.
242
243 // Register the MCCodeEmitter.
246
247 // Register the MCInstrInfo.
250
251 // Register the MCRegisterInfo.
254
255 // Register the MCSubtargetInfo.
258
259 // Register the MCAsmBackend.
262
263 // Register the MCInstPrinter.
266
267 // Register the asm streamer.
270
271 // Register the asm target streamer.
274
275 // Register the obj streamer
278
279 // Register the null streamer
282
283 // Register the MCInstrAnalysis.
286}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define X(NUM, ENUM, NAME)
Definition ELF.h:856
#define LLVM_ABI
Definition Compiler.h:215
#define LLVM_EXTERNAL_VISIBILITY
Definition Compiler.h:132
static LVOptions Options
Definition LVOptions.cpp:25
#define I(x, y, z)
Definition MD5.cpp:57
#define T
static MCTargetStreamer * createNullTargetStreamer(MCStreamer &S)
static MCTargetStreamer * createAsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint)
static MCTargetStreamer * createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
static MCRegisterInfo * createSystemZMCRegisterInfo(const Triple &TT)
static MCInstPrinter * createSystemZMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
static MCInstrInfo * createSystemZMCInstrInfo()
static MCTargetStreamer * createNullTargetStreamer(MCStreamer &S)
static MCInstrAnalysis * createSystemZMCInstrAnalysis(const MCInstrInfo *Info)
static MCTargetStreamer * createAsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint)
static MCTargetStreamer * createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
static MCAsmInfo * createSystemZMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT, const MCTargetOptions &Options)
LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSystemZTargetMC()
static MCStreamer * createSystemZAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, std::unique_ptr< MCInstPrinter > IP, std::unique_ptr< MCCodeEmitter > CE, std::unique_ptr< MCAsmBackend > TAB)
static MCSubtargetInfo * createSystemZMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition MCAsmInfo.h:66
void addInitialFrameState(const MCCFIInstruction &Inst)
Definition MCAsmInfo.cpp:53
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it.
Definition MCDwarf.h:615
Context object for machine code objects.
Definition MCContext.h:83
const Triple & getTargetTriple() const
Definition MCContext.h:397
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Interface to description of machine instruction set.
Definition MCInstrInfo.h:27
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
virtual int64_t getDwarfRegNum(MCRegister Reg, bool isEH) const
Map a target register to an equivalent dwarf register number.
Streaming machine code generation interface.
Definition MCStreamer.h:222
MCContext & getContext() const
Definition MCStreamer.h:326
Generic base class for all target subtargets.
Target specific streamer interface.
Definition MCStreamer.h:95
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
bool isOSzOS() const
Definition Triple.h:706
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
const unsigned GR64Regs[16]
const unsigned VR128Regs[32]
const unsigned VR16Regs[32]
const unsigned GR128Regs[16]
const unsigned GRH32Regs[16]
const unsigned FP32Regs[16]
const unsigned FP16Regs[16]
const unsigned GR32Regs[16]
const unsigned FP64Regs[16]
const int64_t ELFCFAOffsetFromInitialSP
const unsigned VR64Regs[32]
unsigned getFirstReg(unsigned Reg)
const unsigned FP128Regs[16]
const unsigned AR32Regs[16]
const unsigned VR32Regs[32]
const unsigned CR64Regs[16]
This is an optimization pass for GlobalISel generic memory operations.
Target & getTheSystemZTarget()
LLVM_ABI MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, std::unique_ptr< MCInstPrinter > InstPrint, std::unique_ptr< MCCodeEmitter > CE, std::unique_ptr< MCAsmBackend > TAB)
Create a machine code streamer which will print out assembly for the native target,...
MCAsmBackend * createSystemZMCAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
MCCodeEmitter * createSystemZMCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn)
RegisterMCAsmBackend - Register a MCAsmBackend implementation for the given target.
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
static void RegisterMCAsmInfo(Target &T, Target::MCAsmInfoCtorFnTy Fn)
RegisterMCAsmInfo - Register a MCAsmInfo implementation for the given target.
static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target.
static void RegisterObjectTargetStreamer(Target &T, Target::ObjectTargetStreamerCtorTy Fn)
static void RegisterMCInstrAnalysis(Target &T, Target::MCInstrAnalysisCtorFnTy Fn)
RegisterMCInstrAnalysis - Register a MCInstrAnalysis implementation for the given target.
static void RegisterAsmStreamer(Target &T, Target::AsmStreamerCtorTy Fn)
static void RegisterNullTargetStreamer(Target &T, Target::NullTargetStreamerCtorTy Fn)
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target.
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)