[Hexagon] Removing static variable holding MCInstrInfo.
[oota-llvm.git] / lib / Target / Hexagon / MCTargetDesc / HexagonMCInst.h
1 //===- HexagonMCInst.h - Hexagon sub-class of MCInst ----------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This class extends MCInst to allow some VLIW annotations.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCINST_H
15 #define LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCINST_H
16
17 #include "HexagonTargetMachine.h"
18 #include "llvm/MC/MCInst.h"
19 #include <memory>
20
21 extern "C" void LLVMInitializeHexagonTargetMC();
22 namespace llvm {
23 class MCOperand;
24
25 class HexagonMCInst : public MCInst {
26   // Used to access TSFlags
27   std::unique_ptr <MCInstrInfo const> MCII;
28
29 public:
30   explicit HexagonMCInst();
31   HexagonMCInst(const MCInstrDesc &mcid);
32
33   static void AppendImplicitOperands(MCInst &MCI);
34   static std::bitset<16> GetImplicitBits(MCInst const &MCI);
35   static void SetImplicitBits(MCInst &MCI, std::bitset<16> Bits);
36   static void SanityCheckImplicitOperands(MCInst const &MCI) {
37     assert(MCI.getNumOperands() >= 2 && "At least the two implicit operands");
38     assert(MCI.getOperand(MCI.getNumOperands() - 1).isInst() &&
39            "Implicit bits and flags");
40     assert(MCI.getOperand(MCI.getNumOperands() - 2).isImm() &&
41            "Parent pointer");
42   }
43
44   void setPacketBegin(bool Y);
45   bool isPacketBegin() const;
46   static const size_t packetBeginIndex = 0;
47   void setPacketEnd(bool Y);
48   bool isPacketEnd() const;
49   static const size_t packetEndIndex = 1;
50   void resetPacket();
51
52   // Return the Hexagon ISA class for the insn.
53   unsigned getType() const;
54
55   MCInstrDesc const &getDesc() const;
56
57   // Return whether the insn is an actual insn.
58   bool isCanon() const;
59
60   // Return whether the insn is a prefix.
61   bool isPrefix() const;
62
63   // Return whether the insn is solo, i.e., cannot be in a packet.
64   bool isSolo() const;
65
66   // Return whether the instruction needs to be constant extended.
67   bool isConstExtended() const;
68
69   // Return constant extended operand number.
70   unsigned short getCExtOpNum(void) const;
71
72   // Return whether the insn is a new-value consumer.
73   bool isNewValue() const;
74
75   // Return whether the instruction is a legal new-value producer.
76   bool hasNewValue() const;
77
78   // Return the operand that consumes or produces a new value.
79   const MCOperand &getNewValue() const;
80
81   // Return number of bits in the constant extended operand.
82   unsigned getBitCount(void) const;
83
84 private:
85   // Return whether the instruction must be always extended.
86   bool isExtended() const;
87
88   // Return true if the insn may be extended based on the operand value.
89   bool isExtendable() const;
90
91   // Return true if the operand can be constant extended.
92   bool isOperandExtended(const unsigned short OperandNum) const;
93
94   // Return the min value that a constant extendable operand can have
95   // without being extended.
96   int getMinValue() const;
97
98   // Return the max value that a constant extendable operand can have
99   // without being extended.
100   int getMaxValue() const;
101 };
102 }
103
104 #endif