Path: blob/main/contrib/llvm-project/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZTargetStreamer.cpp
213845 views
//==-- SystemZTargetStreamer.cpp - SystemZ Target Streamer Methods ----------=//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7///8/// \file9/// This file defines SystemZ-specific target streamer classes.10/// These are for implementing support for target-specific assembly directives.11///12//===----------------------------------------------------------------------===//1314#include "SystemZTargetStreamer.h"15#include "SystemZHLASMAsmStreamer.h"16#include "llvm/MC/MCAsmInfo.h"17#include "llvm/MC/MCObjectFileInfo.h"1819using namespace llvm;2021void SystemZTargetStreamer::emitConstantPools() {22// Emit EXRL target instructions.23if (EXRLTargets2Sym.empty())24return;25// Switch to the .text section.26const MCObjectFileInfo &OFI = *Streamer.getContext().getObjectFileInfo();27Streamer.switchSection(OFI.getTextSection());28for (auto &I : EXRLTargets2Sym) {29Streamer.emitLabel(I.second);30const MCInstSTIPair &MCI_STI = I.first;31Streamer.emitInstruction(MCI_STI.first, *MCI_STI.second);32}33EXRLTargets2Sym.clear();34}3536SystemZHLASMAsmStreamer &SystemZTargetHLASMStreamer::getHLASMStreamer() {37return static_cast<SystemZHLASMAsmStreamer &>(getStreamer());38}3940void SystemZTargetHLASMStreamer::emitExtern(StringRef Sym) {41getStreamer().emitRawText(Twine(" EXTRN ") + Twine(Sym));42}4344void SystemZTargetHLASMStreamer::emitEnd() { getHLASMStreamer().emitEnd(); }4546// HLASM statements can only perform a single operation at a time47const MCExpr *SystemZTargetHLASMStreamer::createWordDiffExpr(48MCContext &Ctx, const MCSymbol *Hi, const MCSymbol *Lo) {49assert(Hi && Lo && "Symbols required to calculate expression");50MCSymbol *Temp = Ctx.createTempSymbol();51OS << Temp->getName() << " EQU ";52const MCBinaryExpr *TempExpr = MCBinaryExpr::createSub(53MCSymbolRefExpr::create(Hi, Ctx), MCSymbolRefExpr::create(Lo, Ctx), Ctx);54Ctx.getAsmInfo()->printExpr(OS, *TempExpr);55OS << "\n";56return MCBinaryExpr::createLShr(MCSymbolRefExpr::create(Temp, Ctx),57MCConstantExpr::create(1, Ctx), Ctx);58}5960const MCExpr *SystemZTargetGOFFStreamer::createWordDiffExpr(61MCContext &Ctx, const MCSymbol *Hi, const MCSymbol *Lo) {62assert(Hi && Lo && "Symbols required to calculate expression");63return MCBinaryExpr::createLShr(64MCBinaryExpr::createSub(MCSymbolRefExpr::create(Hi, Ctx),65MCSymbolRefExpr::create(Lo, Ctx), Ctx),66MCConstantExpr::create(1, Ctx), Ctx);67}686970