LLVM 23.0.0git
SystemZTargetStreamer.h
Go to the documentation of this file.
1//=- SystemZTargetStreamer.h - SystemZ Target Streamer ----------*- 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#ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETSTREAMER_H
10#define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETSTREAMER_H
11
12#include "llvm/ADT/StringRef.h"
13#include "llvm/MC/MCContext.h"
14#include "llvm/MC/MCExpr.h"
15#include "llvm/MC/MCInst.h"
17#include "llvm/MC/MCStreamer.h"
18#include "llvm/MC/MCSymbol.h"
21#include <map>
22#include <utility>
23
24namespace llvm {
25class MCGOFFStreamer;
27
29public:
31
32 typedef std::pair<MCInst, const MCSubtargetInfo *> MCInstSTIPair;
33 struct CmpMCInst {
34 bool operator()(const MCInstSTIPair &MCI_STI_A,
35 const MCInstSTIPair &MCI_STI_B) const {
36 if (MCI_STI_A.second != MCI_STI_B.second)
37 return uintptr_t(MCI_STI_A.second) < uintptr_t(MCI_STI_B.second);
38 const MCInst &A = MCI_STI_A.first;
39 const MCInst &B = MCI_STI_B.first;
40 assert(A.getNumOperands() == B.getNumOperands() &&
41 A.getNumOperands() == 5 && A.getOperand(2).getImm() == 1 &&
42 B.getOperand(2).getImm() == 1 && "Unexpected EXRL target MCInst");
43 if (A.getOpcode() != B.getOpcode())
44 return A.getOpcode() < B.getOpcode();
45 if (A.getOperand(0).getReg() != B.getOperand(0).getReg())
46 return A.getOperand(0).getReg() < B.getOperand(0).getReg();
47 if (A.getOperand(1).getImm() != B.getOperand(1).getImm())
48 return A.getOperand(1).getImm() < B.getOperand(1).getImm();
49 if (A.getOperand(3).getReg() != B.getOperand(3).getReg())
50 return A.getOperand(3).getReg() < B.getOperand(3).getReg();
51 if (A.getOperand(4).getImm() != B.getOperand(4).getImm())
52 return A.getOperand(4).getImm() < B.getOperand(4).getImm();
53 return false;
54 }
55 };
56 typedef std::map<MCInstSTIPair, MCSymbol *, CmpMCInst> EXRLT2SymMap;
58
59 void emitConstantPools() override;
60
61 virtual void emitMachine(StringRef CPUOrCommand) {};
62
63 virtual void emitExternalName(MCSymbol *Sym, StringRef Name) {}
64 virtual void emitExternalName(MCSection *Sec, StringRef Name) {}
65
66 virtual const MCExpr *createWordDiffExpr(MCContext &Ctx, const MCSymbol *Hi,
67 const MCSymbol *Lo) {
68 return nullptr;
69 }
70
71 virtual void emitADA(MCSymbol *Sym, MCSection *Section) {}
72};
73
75public:
77 const MCExpr *createWordDiffExpr(MCContext &Ctx, const MCSymbol *Hi,
78 const MCSymbol *Lo) override;
79 virtual void emitExternalName(MCSymbol *Sym, StringRef Name) override {
80 static_cast<MCSymbolGOFF *>(Sym)->setExternalName(Name);
81 }
82 virtual void emitExternalName(MCSection *Sec, StringRef Name) override {
83 static_cast<MCSectionGOFF *>(Sec)->setExternalName(Name);
84 }
85 void emitADA(MCSymbol *Sym, MCSection *Section) override {
86 static_cast<MCSymbolGOFF *>(Sym)->setADA(
87 static_cast<MCSectionGOFF *>(Section));
88 }
89};
90
93
94public:
98 const MCExpr *createWordDiffExpr(MCContext &Ctx, const MCSymbol *Hi,
99 const MCSymbol *Lo) override;
100 virtual void emitExternalName(MCSymbol *Sym, StringRef Name) override {
101 static_cast<MCSymbolGOFF *>(Sym)->setExternalName(Name);
102 }
103 virtual void emitExternalName(MCSection *Sec, StringRef Name) override {
104 static_cast<MCSectionGOFF *>(Sec)->setExternalName(Name);
105 }
106 void emitADA(MCSymbol *Sym, MCSection *Section) override {
107 static_cast<MCSymbolGOFF *>(Sym)->setADA(
108 static_cast<MCSectionGOFF *>(Section));
109 }
110};
111
117
120
121public:
124 void emitMachine(StringRef CPUOrCommand) override {
125 OS << "\t.machine " << CPUOrCommand << "\n";
126 }
127};
128
129} // end namespace llvm
130
131#endif // LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETSTREAMER_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file declares the MCSectionGOFF class, which contains all of the necessary machine code sections...
This file contains the MCSymbolGOFF class.
Context object for machine code objects.
Definition MCContext.h:83
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:516
Streaming machine code generation interface.
Definition MCStreamer.h:221
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
MCTargetStreamer(MCStreamer &S)
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
void emitMachine(StringRef CPUOrCommand) override
void emitMachine(StringRef CPUOrCommand) override
SystemZTargetGNUStreamer(MCStreamer &S, formatted_raw_ostream &OS)
virtual void emitExternalName(MCSection *Sec, StringRef Name) override
void emitADA(MCSymbol *Sym, MCSection *Section) override
const MCExpr * createWordDiffExpr(MCContext &Ctx, const MCSymbol *Hi, const MCSymbol *Lo) override
virtual void emitExternalName(MCSymbol *Sym, StringRef Name) override
virtual void emitExternalName(MCSymbol *Sym, StringRef Name) override
virtual void emitExternalName(MCSection *Sec, StringRef Name) override
void emitADA(MCSymbol *Sym, MCSection *Section) override
SystemZTargetHLASMStreamer(MCStreamer &S, formatted_raw_ostream &OS)
SystemZHLASMAsmStreamer & getHLASMStreamer()
const MCExpr * createWordDiffExpr(MCContext &Ctx, const MCSymbol *Hi, const MCSymbol *Lo) override
virtual void emitMachine(StringRef CPUOrCommand)
virtual void emitADA(MCSymbol *Sym, MCSection *Section)
virtual void emitExternalName(MCSection *Sec, StringRef Name)
virtual const MCExpr * createWordDiffExpr(MCContext &Ctx, const MCSymbol *Hi, const MCSymbol *Lo)
std::pair< MCInst, const MCSubtargetInfo * > MCInstSTIPair
std::map< MCInstSTIPair, MCSymbol *, CmpMCInst > EXRLT2SymMap
virtual void emitExternalName(MCSymbol *Sym, StringRef Name)
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
bool operator()(const MCInstSTIPair &MCI_STI_A, const MCInstSTIPair &MCI_STI_B) const