11a5ab3e9SJonas Paulsson //=- SystemZTargetStreamer.h - SystemZ Target Streamer ----------*- C++ -*-===// 21a5ab3e9SJonas Paulsson // 31a5ab3e9SJonas Paulsson // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 41a5ab3e9SJonas Paulsson // See https://llvm.org/LICENSE.txt for license information. 51a5ab3e9SJonas Paulsson // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 61a5ab3e9SJonas Paulsson // 71a5ab3e9SJonas Paulsson //===----------------------------------------------------------------------===// 81a5ab3e9SJonas Paulsson 91a5ab3e9SJonas Paulsson #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETSTREAMER_H 101a5ab3e9SJonas Paulsson #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETSTREAMER_H 111a5ab3e9SJonas Paulsson 121a5ab3e9SJonas Paulsson #include "llvm/ADT/StringRef.h" 131a5ab3e9SJonas Paulsson #include "llvm/MC/MCStreamer.h" 141a5ab3e9SJonas Paulsson 151a5ab3e9SJonas Paulsson namespace llvm { 161a5ab3e9SJonas Paulsson 171a5ab3e9SJonas Paulsson class SystemZTargetStreamer : public MCTargetStreamer { 181a5ab3e9SJonas Paulsson public: 191a5ab3e9SJonas Paulsson SystemZTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {} 201a5ab3e9SJonas Paulsson 21*a48b43f9SJonas Paulsson typedef std::pair<MCInst, const MCSubtargetInfo *> MCInstSTIPair; 22*a48b43f9SJonas Paulsson struct CmpMCInst { 23*a48b43f9SJonas Paulsson bool operator()(const MCInstSTIPair &MCI_STI_A, 24*a48b43f9SJonas Paulsson const MCInstSTIPair &MCI_STI_B) const { 25*a48b43f9SJonas Paulsson if (MCI_STI_A.second != MCI_STI_B.second) 26*a48b43f9SJonas Paulsson return uintptr_t(MCI_STI_A.second) < uintptr_t(MCI_STI_B.second); 27*a48b43f9SJonas Paulsson const MCInst &A = MCI_STI_A.first; 28*a48b43f9SJonas Paulsson const MCInst &B = MCI_STI_B.first; 29*a48b43f9SJonas Paulsson assert(A.getNumOperands() == B.getNumOperands() && 30*a48b43f9SJonas Paulsson A.getNumOperands() == 5 && A.getOperand(2).getImm() == 1 && 31*a48b43f9SJonas Paulsson B.getOperand(2).getImm() == 1 && "Unexpected EXRL target MCInst"); 32*a48b43f9SJonas Paulsson if (A.getOpcode() != B.getOpcode()) 33*a48b43f9SJonas Paulsson return A.getOpcode() < B.getOpcode(); 34*a48b43f9SJonas Paulsson if (A.getOperand(0).getReg() != B.getOperand(0).getReg()) 35*a48b43f9SJonas Paulsson return A.getOperand(0).getReg() < B.getOperand(0).getReg(); 36*a48b43f9SJonas Paulsson if (A.getOperand(1).getImm() != B.getOperand(1).getImm()) 37*a48b43f9SJonas Paulsson return A.getOperand(1).getImm() < B.getOperand(1).getImm(); 38*a48b43f9SJonas Paulsson if (A.getOperand(3).getReg() != B.getOperand(3).getReg()) 39*a48b43f9SJonas Paulsson return A.getOperand(3).getReg() < B.getOperand(3).getReg(); 40*a48b43f9SJonas Paulsson if (A.getOperand(4).getImm() != B.getOperand(4).getImm()) 41*a48b43f9SJonas Paulsson return A.getOperand(4).getImm() < B.getOperand(4).getImm(); 42*a48b43f9SJonas Paulsson return false; 43*a48b43f9SJonas Paulsson } 44*a48b43f9SJonas Paulsson }; 45*a48b43f9SJonas Paulsson typedef std::map<MCInstSTIPair, MCSymbol *, CmpMCInst> EXRLT2SymMap; 46*a48b43f9SJonas Paulsson EXRLT2SymMap EXRLTargets2Sym; 47*a48b43f9SJonas Paulsson 48*a48b43f9SJonas Paulsson void emitConstantPools() override; 49*a48b43f9SJonas Paulsson 501a5ab3e9SJonas Paulsson virtual void emitMachine(StringRef CPU) = 0; 511a5ab3e9SJonas Paulsson }; 521a5ab3e9SJonas Paulsson 531a5ab3e9SJonas Paulsson } // end namespace llvm 541a5ab3e9SJonas Paulsson 551a5ab3e9SJonas Paulsson #endif // LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETSTREAMER_H 56