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 HEXAGONMCINST_H
15 #define HEXAGONMCINST_H
17 #include "HexagonTargetMachine.h"
18 #include "llvm/MC/MCInst.h"
23 class HexagonMCInst: public MCInst {
24 // MCID is set during instruction lowering.
25 // It is needed in order to access TSFlags for
26 // use in checking MC instruction properties.
27 const MCInstrDesc *MCID;
29 // Packet start and end markers
30 unsigned packetStart: 1, packetEnd: 1;
33 explicit HexagonMCInst():
34 MCInst(), MCID(0), packetStart(0), packetEnd(0) {};
35 HexagonMCInst(const MCInstrDesc& mcid):
36 MCInst(), MCID(&mcid), packetStart(0), packetEnd(0) {};
38 bool isPacketStart() const { return (packetStart); };
39 bool isPacketEnd() const { return (packetEnd); };
40 void setPacketStart(bool Y) { packetStart = Y; };
41 void setPacketEnd(bool Y) { packetEnd = Y; };
42 void resetPacket() { setPacketStart(false); setPacketEnd(false); };
44 // Return the slots used by the insn.
45 unsigned getUnits(const HexagonTargetMachine* TM) const;
47 // Return the Hexagon ISA class for the insn.
48 unsigned getType() const;
50 void setDesc(const MCInstrDesc& mcid) { MCID = &mcid; };
51 const MCInstrDesc& getDesc(void) const { return *MCID; };
53 // Return whether the insn is an actual insn.
56 // Return whether the insn is a prefix.
57 bool isPrefix() const;
59 // Return whether the insn is solo, i.e., cannot be in a packet.
62 // Return whether the instruction needs to be constant extended.
63 bool isConstExtended() const;
65 // Return constant extended operand number.
66 unsigned short getCExtOpNum(void) const;
68 // Return whether the insn is a new-value consumer.
69 bool isNewValue() const;
71 // Return whether the instruction is a legal new-value producer.
72 bool hasNewValue() const;
74 // Return the operand that consumes or produces a new value.
75 const MCOperand& getNewValue() const;
77 // Return number of bits in the constant extended operand.
78 unsigned getBitCount(void) const;
81 // Return whether the instruction must be always extended.
82 bool isExtended() const;
84 // Return true if the insn may be extended based on the operand value.
85 bool isExtendable() const;
87 // Return true if the operand can be constant extended.
88 bool isOperandExtended(const unsigned short OperandNum) const;
90 // Return the min value that a constant extendable operand can have
91 // without being extended.
92 int getMinValue() const;
94 // Return the max value that a constant extendable operand can have
95 // without being extended.
96 int getMaxValue() const;