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/MCInst.h" 14 #include "llvm/MC/MCStreamer.h" 15 #include <map> 16 #include <utility> 17 18 namespace llvm { 19 20 class SystemZTargetStreamer : public MCTargetStreamer { 21 public: 22 SystemZTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {} 23 24 typedef std::pair<MCInst, const MCSubtargetInfo *> MCInstSTIPair; 25 struct CmpMCInst { 26 bool operator()(const MCInstSTIPair &MCI_STI_A, 27 const MCInstSTIPair &MCI_STI_B) const { 28 if (MCI_STI_A.second != MCI_STI_B.second) 29 return uintptr_t(MCI_STI_A.second) < uintptr_t(MCI_STI_B.second); 30 const MCInst &A = MCI_STI_A.first; 31 const MCInst &B = MCI_STI_B.first; 32 assert(A.getNumOperands() == B.getNumOperands() && 33 A.getNumOperands() == 5 && A.getOperand(2).getImm() == 1 && 34 B.getOperand(2).getImm() == 1 && "Unexpected EXRL target MCInst"); 35 if (A.getOpcode() != B.getOpcode()) 36 return A.getOpcode() < B.getOpcode(); 37 if (A.getOperand(0).getReg() != B.getOperand(0).getReg()) 38 return A.getOperand(0).getReg() < B.getOperand(0).getReg(); 39 if (A.getOperand(1).getImm() != B.getOperand(1).getImm()) 40 return A.getOperand(1).getImm() < B.getOperand(1).getImm(); 41 if (A.getOperand(3).getReg() != B.getOperand(3).getReg()) 42 return A.getOperand(3).getReg() < B.getOperand(3).getReg(); 43 if (A.getOperand(4).getImm() != B.getOperand(4).getImm()) 44 return A.getOperand(4).getImm() < B.getOperand(4).getImm(); 45 return false; 46 } 47 }; 48 typedef std::map<MCInstSTIPair, MCSymbol *, CmpMCInst> EXRLT2SymMap; 49 EXRLT2SymMap EXRLTargets2Sym; 50 51 void emitConstantPools() override; 52 53 virtual void emitMachine(StringRef CPU) {}; 54 }; 55 56 } // end namespace llvm 57 58 #endif // LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETSTREAMER_H 59