Path: blob/main/contrib/llvm-project/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZTargetStreamer.h
213845 views
//=- SystemZTargetStreamer.h - SystemZ Target Streamer ----------*- C++ -*-===//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//===----------------------------------------------------------------------===//78#ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETSTREAMER_H9#define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETSTREAMER_H1011#include "llvm/ADT/StringRef.h"12#include "llvm/MC/MCContext.h"13#include "llvm/MC/MCExpr.h"14#include "llvm/MC/MCInst.h"15#include "llvm/MC/MCStreamer.h"16#include "llvm/MC/MCSymbol.h"17#include "llvm/Support/FormattedStream.h"18#include <map>19#include <utility>2021namespace llvm {22class SystemZHLASMAsmStreamer;2324class SystemZTargetStreamer : public MCTargetStreamer {25public:26SystemZTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}2728typedef std::pair<MCInst, const MCSubtargetInfo *> MCInstSTIPair;29struct CmpMCInst {30bool operator()(const MCInstSTIPair &MCI_STI_A,31const MCInstSTIPair &MCI_STI_B) const {32if (MCI_STI_A.second != MCI_STI_B.second)33return uintptr_t(MCI_STI_A.second) < uintptr_t(MCI_STI_B.second);34const MCInst &A = MCI_STI_A.first;35const MCInst &B = MCI_STI_B.first;36assert(A.getNumOperands() == B.getNumOperands() &&37A.getNumOperands() == 5 && A.getOperand(2).getImm() == 1 &&38B.getOperand(2).getImm() == 1 && "Unexpected EXRL target MCInst");39if (A.getOpcode() != B.getOpcode())40return A.getOpcode() < B.getOpcode();41if (A.getOperand(0).getReg() != B.getOperand(0).getReg())42return A.getOperand(0).getReg() < B.getOperand(0).getReg();43if (A.getOperand(1).getImm() != B.getOperand(1).getImm())44return A.getOperand(1).getImm() < B.getOperand(1).getImm();45if (A.getOperand(3).getReg() != B.getOperand(3).getReg())46return A.getOperand(3).getReg() < B.getOperand(3).getReg();47if (A.getOperand(4).getImm() != B.getOperand(4).getImm())48return A.getOperand(4).getImm() < B.getOperand(4).getImm();49return false;50}51};52typedef std::map<MCInstSTIPair, MCSymbol *, CmpMCInst> EXRLT2SymMap;53EXRLT2SymMap EXRLTargets2Sym;5455void emitConstantPools() override;5657virtual void emitMachine(StringRef CPUOrCommand) {};5859virtual void emitExtern(StringRef Str) {};60virtual void emitEnd() {};6162virtual const MCExpr *createWordDiffExpr(MCContext &Ctx, const MCSymbol *Hi,63const MCSymbol *Lo) {64return nullptr;65}66};6768class SystemZTargetGOFFStreamer : public SystemZTargetStreamer {69public:70SystemZTargetGOFFStreamer(MCStreamer &S) : SystemZTargetStreamer(S) {}71const MCExpr *createWordDiffExpr(MCContext &Ctx, const MCSymbol *Hi,72const MCSymbol *Lo) override;73};7475class SystemZTargetHLASMStreamer : public SystemZTargetStreamer {76formatted_raw_ostream &OS;7778public:79SystemZTargetHLASMStreamer(MCStreamer &S, formatted_raw_ostream &OS)80: SystemZTargetStreamer(S), OS(OS) {}81SystemZHLASMAsmStreamer &getHLASMStreamer();82void emitExtern(StringRef Sym) override;83void emitEnd() override;84const MCExpr *createWordDiffExpr(MCContext &Ctx, const MCSymbol *Hi,85const MCSymbol *Lo) override;86};8788class SystemZTargetELFStreamer : public SystemZTargetStreamer {89public:90SystemZTargetELFStreamer(MCStreamer &S) : SystemZTargetStreamer(S) {}91void emitMachine(StringRef CPUOrCommand) override {}92};9394class SystemZTargetGNUStreamer : public SystemZTargetStreamer {95formatted_raw_ostream &OS;9697public:98SystemZTargetGNUStreamer(MCStreamer &S, formatted_raw_ostream &OS)99: SystemZTargetStreamer(S), OS(OS) {}100void emitMachine(StringRef CPUOrCommand) override {101OS << "\t.machine " << CPUOrCommand << "\n";102}103};104105} // end namespace llvm106107#endif // LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETSTREAMER_H108109110