xref: /freebsd-src/contrib/llvm-project/llvm/lib/Target/SystemZ/SystemZTargetStreamer.h (revision 5f757f3ff9144b609b3c433dfd370cc6bdc191ad)
1349cc55cSDimitry Andric //=- SystemZTargetStreamer.h - SystemZ Target Streamer ----------*- C++ -*-===//
2349cc55cSDimitry Andric //
3349cc55cSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4349cc55cSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5349cc55cSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6349cc55cSDimitry Andric //
7349cc55cSDimitry Andric //===----------------------------------------------------------------------===//
8349cc55cSDimitry Andric 
9349cc55cSDimitry Andric #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETSTREAMER_H
10349cc55cSDimitry Andric #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETSTREAMER_H
11349cc55cSDimitry Andric 
12349cc55cSDimitry Andric #include "llvm/ADT/StringRef.h"
1381ad6265SDimitry Andric #include "llvm/MC/MCInst.h"
14349cc55cSDimitry Andric #include "llvm/MC/MCStreamer.h"
15*5f757f3fSDimitry Andric #include <map>
16*5f757f3fSDimitry Andric #include <utility>
17349cc55cSDimitry Andric 
18349cc55cSDimitry Andric namespace llvm {
19349cc55cSDimitry Andric 
20349cc55cSDimitry Andric class SystemZTargetStreamer : public MCTargetStreamer {
21349cc55cSDimitry Andric public:
SystemZTargetStreamer(MCStreamer & S)22349cc55cSDimitry Andric   SystemZTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
23349cc55cSDimitry Andric 
24349cc55cSDimitry Andric   typedef std::pair<MCInst, const MCSubtargetInfo *> MCInstSTIPair;
25349cc55cSDimitry Andric   struct CmpMCInst {
operatorCmpMCInst26349cc55cSDimitry Andric     bool operator()(const MCInstSTIPair &MCI_STI_A,
27349cc55cSDimitry Andric                     const MCInstSTIPair &MCI_STI_B) const {
28349cc55cSDimitry Andric       if (MCI_STI_A.second != MCI_STI_B.second)
29349cc55cSDimitry Andric         return uintptr_t(MCI_STI_A.second) < uintptr_t(MCI_STI_B.second);
30349cc55cSDimitry Andric       const MCInst &A = MCI_STI_A.first;
31349cc55cSDimitry Andric       const MCInst &B = MCI_STI_B.first;
32349cc55cSDimitry Andric       assert(A.getNumOperands() == B.getNumOperands() &&
33349cc55cSDimitry Andric              A.getNumOperands() == 5 && A.getOperand(2).getImm() == 1 &&
34349cc55cSDimitry Andric              B.getOperand(2).getImm() == 1 && "Unexpected EXRL target MCInst");
35349cc55cSDimitry Andric       if (A.getOpcode() != B.getOpcode())
36349cc55cSDimitry Andric         return A.getOpcode() < B.getOpcode();
37349cc55cSDimitry Andric       if (A.getOperand(0).getReg() != B.getOperand(0).getReg())
38349cc55cSDimitry Andric         return A.getOperand(0).getReg() < B.getOperand(0).getReg();
39349cc55cSDimitry Andric       if (A.getOperand(1).getImm() != B.getOperand(1).getImm())
40349cc55cSDimitry Andric         return A.getOperand(1).getImm() < B.getOperand(1).getImm();
41349cc55cSDimitry Andric       if (A.getOperand(3).getReg() != B.getOperand(3).getReg())
42349cc55cSDimitry Andric         return A.getOperand(3).getReg() < B.getOperand(3).getReg();
43349cc55cSDimitry Andric       if (A.getOperand(4).getImm() != B.getOperand(4).getImm())
44349cc55cSDimitry Andric         return A.getOperand(4).getImm() < B.getOperand(4).getImm();
45349cc55cSDimitry Andric       return false;
46349cc55cSDimitry Andric     }
47349cc55cSDimitry Andric   };
48349cc55cSDimitry Andric   typedef std::map<MCInstSTIPair, MCSymbol *, CmpMCInst> EXRLT2SymMap;
49349cc55cSDimitry Andric   EXRLT2SymMap EXRLTargets2Sym;
50349cc55cSDimitry Andric 
51349cc55cSDimitry Andric   void emitConstantPools() override;
52349cc55cSDimitry Andric 
emitMachine(StringRef CPU)53bdd1243dSDimitry Andric   virtual void emitMachine(StringRef CPU) {};
54349cc55cSDimitry Andric };
55349cc55cSDimitry Andric 
56349cc55cSDimitry Andric } // end namespace llvm
57349cc55cSDimitry Andric 
58349cc55cSDimitry Andric #endif // LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETSTREAMER_H
59