1 //===- HexagonMCInst.h - Hexagon sub-class of MCInst ----------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This class extends MCInst to allow some VLIW annotations.
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"
21 extern "C" void LLVMInitializeHexagonTargetMC();
25 class HexagonMCInst : public MCInst {
26 friend void ::LLVMInitializeHexagonTargetMC();
27 // Used to access TSFlags
28 static std::unique_ptr <MCInstrInfo const> MCII;
31 explicit HexagonMCInst();
32 HexagonMCInst(const MCInstrDesc &mcid);
34 static void AppendImplicitOperands(MCInst &MCI);
35 static std::bitset<16> GetImplicitBits(MCInst const &MCI);
36 static void SetImplicitBits(MCInst &MCI, std::bitset<16> Bits);
37 static void SanityCheckImplicitOperands(MCInst const &MCI) {
38 assert(MCI.getNumOperands() >= 2 && "At least the two implicit operands");
39 assert(MCI.getOperand(MCI.getNumOperands() - 1).isInst() &&
40 "Implicit bits and flags");
41 assert(MCI.getOperand(MCI.getNumOperands() - 2).isImm() &&
45 void setPacketBegin(bool Y);
46 bool isPacketBegin() const;
47 static const size_t packetBeginIndex = 0;
48 void setPacketEnd(bool Y);
49 bool isPacketEnd() const;
50 static const size_t packetEndIndex = 1;
53 // Return the Hexagon ISA class for the insn.
54 unsigned getType() const;
56 MCInstrDesc const &getDesc() const;
58 // Return whether the insn is an actual insn.
61 // Return whether the insn is a prefix.
62 bool isPrefix() const;
64 // Return whether the insn is solo, i.e., cannot be in a packet.
67 // Return whether the instruction needs to be constant extended.
68 bool isConstExtended() const;
70 // Return constant extended operand number.
71 unsigned short getCExtOpNum(void) const;
73 // Return whether the insn is a new-value consumer.
74 bool isNewValue() const;
76 // Return whether the instruction is a legal new-value producer.
77 bool hasNewValue() const;
79 // Return the operand that consumes or produces a new value.
80 const MCOperand &getNewValue() const;
82 // Return number of bits in the constant extended operand.
83 unsigned getBitCount(void) const;
86 // Return whether the instruction must be always extended.
87 bool isExtended() const;
89 // Return true if the insn may be extended based on the operand value.
90 bool isExtendable() const;
92 // Return true if the operand can be constant extended.
93 bool isOperandExtended(const unsigned short OperandNum) const;
95 // Return the min value that a constant extendable operand can have
96 // without being extended.
97 int getMinValue() const;
99 // Return the max value that a constant extendable operand can have
100 // without being extended.
101 int getMaxValue() const;