LLVM 22.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"
16#include "llvm/MC/MCStreamer.h"
17#include "llvm/MC/MCSymbol.h"
19#include <map>
20#include <utility>
21
22namespace llvm {
23class SystemZHLASMAsmStreamer;
24
26public:
28
29 typedef std::pair<MCInst, const MCSubtargetInfo *> MCInstSTIPair;
30 struct CmpMCInst {
31 bool operator()(const MCInstSTIPair &MCI_STI_A,
32 const MCInstSTIPair &MCI_STI_B) const {
33 if (MCI_STI_A.second != MCI_STI_B.second)
34 return uintptr_t(MCI_STI_A.second) < uintptr_t(MCI_STI_B.second);
35 const MCInst &A = MCI_STI_A.first;
36 const MCInst &B = MCI_STI_B.first;
37 assert(A.getNumOperands() == B.getNumOperands() &&
38 A.getNumOperands() == 5 && A.getOperand(2).getImm() == 1 &&
39 B.getOperand(2).getImm() == 1 && "Unexpected EXRL target MCInst");
40 if (A.getOpcode() != B.getOpcode())
41 return A.getOpcode() < B.getOpcode();
42 if (A.getOperand(0).getReg() != B.getOperand(0).getReg())
43 return A.getOperand(0).getReg() < B.getOperand(0).getReg();
44 if (A.getOperand(1).getImm() != B.getOperand(1).getImm())
45 return A.getOperand(1).getImm() < B.getOperand(1).getImm();
46 if (A.getOperand(3).getReg() != B.getOperand(3).getReg())
47 return A.getOperand(3).getReg() < B.getOperand(3).getReg();
48 if (A.getOperand(4).getImm() != B.getOperand(4).getImm())
49 return A.getOperand(4).getImm() < B.getOperand(4).getImm();
50 return false;
51 }
52 };
53 typedef std::map<MCInstSTIPair, MCSymbol *, CmpMCInst> EXRLT2SymMap;
55
56 void emitConstantPools() override;
57
58 virtual void emitMachine(StringRef CPUOrCommand) {};
59
60 virtual void emitExtern(StringRef Str) {};
61 virtual void emitEnd() {};
62
63 virtual const MCExpr *createWordDiffExpr(MCContext &Ctx, const MCSymbol *Hi,
64 const MCSymbol *Lo) {
65 return nullptr;
66 }
67};
68
70public:
72 const MCExpr *createWordDiffExpr(MCContext &Ctx, const MCSymbol *Hi,
73 const MCSymbol *Lo) override;
74};
75
78
79public:
83 void emitExtern(StringRef Sym) override;
84 void emitEnd() override;
85 const MCExpr *createWordDiffExpr(MCContext &Ctx, const MCSymbol *Hi,
86 const MCSymbol *Lo) override;
87};
88
90public:
92 void emitMachine(StringRef CPUOrCommand) override {}
93};
94
97
98public:
100 : SystemZTargetStreamer(S), OS(OS) {}
101 void emitMachine(StringRef CPUOrCommand) override {
102 OS << "\t.machine " << CPUOrCommand << "\n";
103 }
104};
105
106} // end namespace llvm
107
108#endif // LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETSTREAMER_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Symbol * Sym
Definition: ELF_riscv.cpp:479
raw_pwrite_stream & OS
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
Streaming machine code generation interface.
Definition: MCStreamer.h:220
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:93
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)
const MCExpr * createWordDiffExpr(MCContext &Ctx, const MCSymbol *Hi, const MCSymbol *Lo) override
SystemZTargetHLASMStreamer(MCStreamer &S, formatted_raw_ostream &OS)
void emitExtern(StringRef Sym) override
SystemZHLASMAsmStreamer & getHLASMStreamer()
const MCExpr * createWordDiffExpr(MCContext &Ctx, const MCSymbol *Hi, const MCSymbol *Lo) override
virtual void emitMachine(StringRef CPUOrCommand)
virtual const MCExpr * createWordDiffExpr(MCContext &Ctx, const MCSymbol *Hi, const MCSymbol *Lo)
std::pair< MCInst, const MCSubtargetInfo * > MCInstSTIPair
virtual void emitExtern(StringRef Str)
std::map< MCInstSTIPair, MCSymbol *, CmpMCInst > EXRLT2SymMap
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: AddressRanges.h:18
bool operator()(const MCInstSTIPair &MCI_STI_A, const MCInstSTIPair &MCI_STI_B) const