LLVM 24.0.0git
SystemZXPLINKAsmPrinter.h
Go to the documentation of this file.
1//===-- SystemZXPLINKAsmPrinter.h - SystemZ XPLINK asm printer --*- C++ -*-===//
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 declares the SystemZXPLINKAsmPrinter class, which owns all
10// z/OS XPLINK-specific asm printer behaviour: ADA table management, PPA1/PPA2,
11// IDRL, entry-point markers, and XPLINK call/return instruction lowering.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZXPLINKASMPRINTER_H
16#define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZXPLINKASMPRINTER_H
17
19#include "SystemZAsmPrinter.h"
20#include "llvm/ADT/DenseMap.h"
21#include "llvm/ADT/MapVector.h"
22
23namespace llvm {
24class MCStreamer;
25class MCSymbolGOFF;
26class MachineFunction;
27class MachineInstr;
28class MachineOperand;
29class Module;
30class raw_ostream;
31
33 : public SystemZAsmPrinter {
34
35 /// Call type information for XPLINK.
36 enum class CallType {
37 BASR76 = 0, // b'x000' == BASR r7,r6
38 BRAS7 = 1, // b'x001' == BRAS r7,ep
39 RESVD_2 = 2, // b'x010'
40 BRASL7 = 3, // b'x011' == BRASL r7,ep
41 RESVD_4 = 4, // b'x100'
42 RESVD_5 = 5, // b'x101'
43 BALR1415 = 6, // b'x110' == BALR r14,r15
44 BASR33 = 7, // b'x111' == BASR r3,r3
45 };
46
47 // The Associated Data Area (ADA) contains descriptors which help locating
48 // external symbols. For each symbol and type, the displacement into the ADA
49 // is stored.
50 class AssociatedDataAreaTable {
51 public:
52 using DisplacementTable =
54
55 private:
56 const uint64_t PointerSize;
57
58 /// The mapping of name/slot type pairs to displacements.
59 DisplacementTable Displacements;
60
61 /// The next available displacement value. Incremented when new entries into
62 /// the ADA are created.
63 uint32_t NextDisplacement = 0;
64
65 public:
66 AssociatedDataAreaTable(uint64_t PointerSize) : PointerSize(PointerSize) {}
67
68 /// @brief Add a function descriptor to the ADA.
69 /// @param MF The function containing the ADA_ENTRY instruction.
70 /// @param MO The operand describing the descriptor symbol.
71 /// @return The displacement of the descriptor into the ADA.
72 uint32_t insert(const MachineFunction &MF, const MachineOperand &MO);
73
74 /// @brief Get the displacement into associated data area (ADA) for a name.
75 /// If no displacement is already associated with the name, assign one and
76 /// return it.
77 /// @param Sym The symbol for which the displacement should be returned.
78 /// @param SlotKind The ADA type.
79 /// @return The displacement of the descriptor into the ADA.
80 uint32_t insert(const MCSymbol *Sym, unsigned SlotKind);
81
82 /// Get the table of GOFF displacements. This is 'const' since it should
83 /// never be modified by anything except the APIs on this class.
84 const DisplacementTable &getTable() const { return Displacements; }
85
86 uint32_t getNextDisplacement() const { return NextDisplacement; }
87 };
88
89 AssociatedDataAreaTable ADATable;
90
91 // Record a list of GlobalAlias associated with a GlobalObject.
92 // This is used for z/OS's extra-label-at-definition aliasing strategy.
93 // This is similar to what is done for AIX.
95 GOAliasMap;
96
97 void calculatePPA1();
98 void emitPPA2(Module &M);
99 void emitADASection();
100 void emitIDRLSection(Module &M);
101 void emitCallInformation(CallType CT);
102
103 SystemZTargetzOSStreamer *getTargetStreamer() {
104 MCTargetStreamer *TS = OutStreamer->getTargetStreamer();
105 assert(TS && "do not have a target streamer");
106 return static_cast<SystemZTargetzOSStreamer *>(TS);
107 }
108
109public:
111 std::unique_ptr<MCStreamer> Streamer);
112
113 // Override AsmPrinter.
114 void emitInstruction(const MachineInstr *MI) override;
115 void emitXXStructorList(const DataLayout &DL, const Constant *List,
116 bool IsCtor) override;
117 void emitEndOfAsmFile(Module &M) override;
118 bool doInitialization(Module &M) override;
119 void emitFunctionEntryLabel() override;
120 void emitFunctionBodyEnd() override;
121 void emitStartOfAsmFile(Module &M) override;
122 void emitGlobalAlias(const Module &M, const GlobalAlias &GA) override;
123 const MCExpr *lowerConstant(const Constant *CV,
124 const Constant *BaseCV = nullptr,
125 uint64_t Offset = 0) override;
126};
127
128} // end namespace llvm
129
130#endif // LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZXPLINKASMPRINTER_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned uint64_t
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define LLVM_LIBRARY_VISIBILITY
Definition Compiler.h:137
This file defines the DenseMap class.
IRTranslator LLVM IR MI
This file implements a map that provides insertion order iteration.
static SDValue lowerConstant(SDValue Op, SelectionDAG &DAG, const RISCVSubtarget &Subtarget)
std::unique_ptr< MCStreamer > && Streamer
TargetMachine & TM
Target machine description.
Definition AsmPrinter.h:94
MachineFunction * MF
The current machine function.
Definition AsmPrinter.h:109
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition AsmPrinter.h:106
This is an important base class in LLVM.
Definition Constant.h:43
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
Streaming machine code generation interface.
Definition MCStreamer.h:222
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
Target specific streamer interface.
Definition MCStreamer.h:95
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
This class implements a map that also provides access to all stored values in a deterministic order.
Definition MapVector.h:38
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
SystemZAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
void emitGlobalAlias(const Module &M, const GlobalAlias &GA) override
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
SystemZXPLINKAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
void emitFunctionBodyEnd() override
Targets can override this to emit stuff after the last basic block in the function.
void emitStartOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the start of their fi...
void emitFunctionEntryLabel() override
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
void emitInstruction(const MachineInstr *MI) override
Targets should implement this to emit instructions.
void emitEndOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the end of their file...
void emitXXStructorList(const DataLayout &DL, const Constant *List, bool IsCtor) override
This method emits llvm.global_ctors or llvm.global_dtors list.
Primary interface to the complete machine description for the target machine.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577