]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - opencl/llvm.git/blob - lib/Target/Hexagon/MCTargetDesc/HexagonMCInst.h
e8d95537235ecc8464b9523877355737e67368b8
[opencl/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 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCINST_H
15 #define LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCINST_H
17 #include "HexagonTargetMachine.h"
18 #include "llvm/MC/MCInst.h"
20 #include <memory>
22 extern "C" void LLVMInitializeHexagonTargetMC();
23 namespace llvm {
24 class MCOperand;
26 class HexagonMCInst : public MCInst {
27   friend void ::LLVMInitializeHexagonTargetMC();
28   // Used to access TSFlags
29   static std::unique_ptr <MCInstrInfo const> MCII;
31 public:
32   explicit HexagonMCInst();
33   HexagonMCInst(const MCInstrDesc &mcid);
35   static void AppendImplicitOperands(MCInst &MCI);
36   static std::bitset<16> GetImplicitBits(MCInst const &MCI);
37   static void SetImplicitBits(MCInst &MCI, std::bitset<16> Bits);
38   static void SanityCheckImplicitOperands(MCInst const &MCI) {
39     assert(MCI.getNumOperands() >= 2 && "At least the two implicit operands");
40     assert(MCI.getOperand(MCI.getNumOperands() - 1).isInst() &&
41            "Implicit bits and flags");
42     assert(MCI.getOperand(MCI.getNumOperands() - 2).isImm() &&
43            "Parent pointer");
44   }
46   void setPacketBegin(bool Y);
47   bool isPacketBegin() const;
48   static const size_t packetBeginIndex = 0;
49   void setPacketEnd(bool Y);
50   bool isPacketEnd() const;
51   static const size_t packetEndIndex = 1;
52   void resetPacket();
54   // Return the slots used by the insn.
55   unsigned getUnits(const HexagonTargetMachine *TM) const;
57   // Return the Hexagon ISA class for the insn.
58   unsigned getType() const;
60   MCInstrDesc const &getDesc() const;
62   // Return whether the insn is an actual insn.
63   bool isCanon() const;
65   // Return whether the insn is a prefix.
66   bool isPrefix() const;
68   // Return whether the insn is solo, i.e., cannot be in a packet.
69   bool isSolo() const;
71   // Return whether the instruction needs to be constant extended.
72   bool isConstExtended() const;
74   // Return constant extended operand number.
75   unsigned short getCExtOpNum(void) const;
77   // Return whether the insn is a new-value consumer.
78   bool isNewValue() const;
80   // Return whether the instruction is a legal new-value producer.
81   bool hasNewValue() const;
83   // Return the operand that consumes or produces a new value.
84   const MCOperand &getNewValue() const;
86   // Return number of bits in the constant extended operand.
87   unsigned getBitCount(void) const;
89 private:
90   // Return whether the instruction must be always extended.
91   bool isExtended() const;
93   // Return true if the insn may be extended based on the operand value.
94   bool isExtendable() const;
96   // Return true if the operand can be constant extended.
97   bool isOperandExtended(const unsigned short OperandNum) const;
99   // Return the min value that a constant extendable operand can have
100   // without being extended.
101   int getMinValue() const;
103   // Return the max value that a constant extendable operand can have
104   // without being extended.
105   int getMaxValue() const;
106 };
109 #endif