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 MachineInstr;
27class Module;
28class raw_ostream;
29
31 : public SystemZAsmPrinter {
32
33 /// Call type information for XPLINK.
34 enum class CallType {
35 BASR76 = 0, // b'x000' == BASR r7,r6
36 BRAS7 = 1, // b'x001' == BRAS r7,ep
37 RESVD_2 = 2, // b'x010'
38 BRASL7 = 3, // b'x011' == BRASL r7,ep
39 RESVD_4 = 4, // b'x100'
40 RESVD_5 = 5, // b'x101'
41 BALR1415 = 6, // b'x110' == BALR r14,r15
42 BASR33 = 7, // b'x111' == BASR r3,r3
43 };
44
45 // The Associated Data Area (ADA) contains descriptors which help locating
46 // external symbols. For each symbol and type, the displacement into the ADA
47 // is stored.
48 class AssociatedDataAreaTable {
49 public:
50 using DisplacementTable =
52
53 private:
54 const uint64_t PointerSize;
55
56 /// The mapping of name/slot type pairs to displacements.
57 DisplacementTable Displacements;
58
59 /// The next available displacement value. Incremented when new entries into
60 /// the ADA are created.
61 uint32_t NextDisplacement = 0;
62
63 public:
64 AssociatedDataAreaTable(uint64_t PointerSize) : PointerSize(PointerSize) {}
65
66 /// @brief Add a function descriptor to the ADA.
67 /// @param MI Pointer to an ADA_ENTRY instruction.
68 /// @return The displacement of the descriptor into the ADA.
69 uint32_t insert(const MachineOperand MO);
70
71 /// @brief Get the displacement into associated data area (ADA) for a name.
72 /// If no displacement is already associated with the name, assign one and
73 /// return it.
74 /// @param Sym The symbol for which the displacement should be returned.
75 /// @param SlotKind The ADA type.
76 /// @return The displacement of the descriptor into the ADA.
77 uint32_t insert(const MCSymbol *Sym, unsigned SlotKind);
78
79 /// Get the table of GOFF displacements. This is 'const' since it should
80 /// never be modified by anything except the APIs on this class.
81 const DisplacementTable &getTable() const { return Displacements; }
82
83 uint32_t getNextDisplacement() const { return NextDisplacement; }
84 };
85
86 AssociatedDataAreaTable ADATable;
87
88 // Record a list of GlobalAlias associated with a GlobalObject.
89 // This is used for z/OS's extra-label-at-definition aliasing strategy.
90 // This is similar to what is done for AIX.
92 GOAliasMap;
93
94 void calculatePPA1();
95 void emitPPA2(Module &M);
96 void emitADASection();
97 void emitIDRLSection(Module &M);
98 void emitCallInformation(CallType CT);
99
100 SystemZTargetzOSStreamer *getTargetStreamer() {
101 MCTargetStreamer *TS = OutStreamer->getTargetStreamer();
102 assert(TS && "do not have a target streamer");
103 return static_cast<SystemZTargetzOSStreamer *>(TS);
104 }
105
106public:
108 std::unique_ptr<MCStreamer> Streamer);
109
110 // Override AsmPrinter.
111 void emitInstruction(const MachineInstr *MI) override;
112 void emitXXStructorList(const DataLayout &DL, const Constant *List,
113 bool IsCtor) override;
114 void emitEndOfAsmFile(Module &M) override;
115 bool doInitialization(Module &M) override;
116 void emitFunctionEntryLabel() override;
117 void emitFunctionBodyEnd() override;
118 void emitStartOfAsmFile(Module &M) override;
119 void emitGlobalAlias(const Module &M, const GlobalAlias &GA) override;
120 const MCExpr *lowerConstant(const Constant *CV,
121 const Constant *BaseCV = nullptr,
122 uint64_t Offset = 0) override;
123};
124
125} // end namespace llvm
126
127#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
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:67
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:578