LLVM 22.0.0git
SystemZTargetStreamer.cpp
Go to the documentation of this file.
1//==-- SystemZTargetStreamer.cpp - SystemZ Target Streamer Methods ----------=//
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/// \file
10/// This file defines SystemZ-specific target streamer classes.
11/// These are for implementing support for target-specific assembly directives.
12///
13//===----------------------------------------------------------------------===//
14
17#include "llvm/MC/MCAsmInfo.h"
19
20using namespace llvm;
21
23 // Emit EXRL target instructions.
24 if (EXRLTargets2Sym.empty())
25 return;
26 // Switch to the .text section.
29 for (auto &I : EXRLTargets2Sym) {
30 Streamer.emitLabel(I.second);
31 const MCInstSTIPair &MCI_STI = I.first;
32 Streamer.emitInstruction(MCI_STI.first, *MCI_STI.second);
33 }
34 EXRLTargets2Sym.clear();
35}
36
38 return static_cast<SystemZHLASMAsmStreamer &>(getStreamer());
39}
40
42 getStreamer().emitRawText(Twine(" EXTRN ") + Twine(Sym));
43}
44
46
47// HLASM statements can only perform a single operation at a time
49 MCContext &Ctx, const MCSymbol *Hi, const MCSymbol *Lo) {
50 assert(Hi && Lo && "Symbols required to calculate expression");
51 MCSymbol *Temp = Ctx.createTempSymbol();
52 OS << Temp->getName() << " EQU ";
53 const MCBinaryExpr *TempExpr = MCBinaryExpr::createSub(
55 Ctx.getAsmInfo()->printExpr(OS, *TempExpr);
56 OS << "\n";
58 MCConstantExpr::create(1, Ctx), Ctx);
59}
60
62 MCContext &Ctx, const MCSymbol *Hi, const MCSymbol *Lo) {
63 assert(Hi && Lo && "Symbols required to calculate expression");
66 MCSymbolRefExpr::create(Lo, Ctx), Ctx),
67 MCConstantExpr::create(1, Ctx), Ctx);
68}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Symbol * Sym
Definition: ELF_riscv.cpp:479
#define I(x, y, z)
Definition: MD5.cpp:58
void printExpr(raw_ostream &, const MCExpr &) const
Definition: MCAsmInfo.cpp:153
Binary assembler expressions.
Definition: MCExpr.h:299
static const MCBinaryExpr * createLShr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:423
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:428
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition: MCExpr.cpp:212
Context object for machine code objects.
Definition: MCContext.h:83
const MCObjectFileInfo * getObjectFileInfo() const
Definition: MCContext.h:416
LLVM_ABI MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
Definition: MCContext.cpp:386
const MCAsmInfo * getAsmInfo() const
Definition: MCContext.h:412
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
MCSection * getTextSection() const
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
MCContext & getContext() const
Definition: MCStreamer.h:314
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
Definition: MCStreamer.cpp:395
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
void emitRawText(const Twine &String)
If this file is backed by a assembly streamer, this dumps the specified string in the output ....
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.h:214
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
StringRef getName() const
getName - Get the symbol name.
Definition: MCSymbol.h:188
MCStreamer & getStreamer()
Definition: MCStreamer.h:101
MCStreamer & Streamer
Definition: MCStreamer.h:95
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
const MCExpr * createWordDiffExpr(MCContext &Ctx, const MCSymbol *Hi, const MCSymbol *Lo) override
void emitExtern(StringRef Sym) override
SystemZHLASMAsmStreamer & getHLASMStreamer()
const MCExpr * createWordDiffExpr(MCContext &Ctx, const MCSymbol *Hi, const MCSymbol *Lo) override
std::pair< MCInst, const MCSubtargetInfo * > MCInstSTIPair
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:82
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18