xref: /freebsd/contrib/llvm-project/llvm/lib/Target/SystemZ/SystemZTargetStreamer.h (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
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"
15349cc55cSDimitry Andric 
16349cc55cSDimitry Andric namespace llvm {
17349cc55cSDimitry Andric 
18349cc55cSDimitry Andric class SystemZTargetStreamer : public MCTargetStreamer {
19349cc55cSDimitry Andric public:
20349cc55cSDimitry Andric   SystemZTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
21349cc55cSDimitry Andric 
22349cc55cSDimitry Andric   typedef std::pair<MCInst, const MCSubtargetInfo *> MCInstSTIPair;
23349cc55cSDimitry Andric   struct CmpMCInst {
24349cc55cSDimitry Andric     bool operator()(const MCInstSTIPair &MCI_STI_A,
25349cc55cSDimitry Andric                     const MCInstSTIPair &MCI_STI_B) const {
26349cc55cSDimitry Andric       if (MCI_STI_A.second != MCI_STI_B.second)
27349cc55cSDimitry Andric         return uintptr_t(MCI_STI_A.second) < uintptr_t(MCI_STI_B.second);
28349cc55cSDimitry Andric       const MCInst &A = MCI_STI_A.first;
29349cc55cSDimitry Andric       const MCInst &B = MCI_STI_B.first;
30349cc55cSDimitry Andric       assert(A.getNumOperands() == B.getNumOperands() &&
31349cc55cSDimitry Andric              A.getNumOperands() == 5 && A.getOperand(2).getImm() == 1 &&
32349cc55cSDimitry Andric              B.getOperand(2).getImm() == 1 && "Unexpected EXRL target MCInst");
33349cc55cSDimitry Andric       if (A.getOpcode() != B.getOpcode())
34349cc55cSDimitry Andric         return A.getOpcode() < B.getOpcode();
35349cc55cSDimitry Andric       if (A.getOperand(0).getReg() != B.getOperand(0).getReg())
36349cc55cSDimitry Andric         return A.getOperand(0).getReg() < B.getOperand(0).getReg();
37349cc55cSDimitry Andric       if (A.getOperand(1).getImm() != B.getOperand(1).getImm())
38349cc55cSDimitry Andric         return A.getOperand(1).getImm() < B.getOperand(1).getImm();
39349cc55cSDimitry Andric       if (A.getOperand(3).getReg() != B.getOperand(3).getReg())
40349cc55cSDimitry Andric         return A.getOperand(3).getReg() < B.getOperand(3).getReg();
41349cc55cSDimitry Andric       if (A.getOperand(4).getImm() != B.getOperand(4).getImm())
42349cc55cSDimitry Andric         return A.getOperand(4).getImm() < B.getOperand(4).getImm();
43349cc55cSDimitry Andric       return false;
44349cc55cSDimitry Andric     }
45349cc55cSDimitry Andric   };
46349cc55cSDimitry Andric   typedef std::map<MCInstSTIPair, MCSymbol *, CmpMCInst> EXRLT2SymMap;
47349cc55cSDimitry Andric   EXRLT2SymMap EXRLTargets2Sym;
48349cc55cSDimitry Andric 
49349cc55cSDimitry Andric   void emitConstantPools() override;
50349cc55cSDimitry Andric 
51*bdd1243dSDimitry Andric   virtual void emitMachine(StringRef CPU) {};
52349cc55cSDimitry Andric };
53349cc55cSDimitry Andric 
54349cc55cSDimitry Andric } // end namespace llvm
55349cc55cSDimitry Andric 
56349cc55cSDimitry Andric #endif // LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETSTREAMER_H
57