Jyotsna Verma | 7503a62 | 2013-02-20 16:13:27 +0000 | [diff] [blame] | 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 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 14 | #ifndef LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCINST_H |
| 15 | #define LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCINST_H |
Jyotsna Verma | 7503a62 | 2013-02-20 16:13:27 +0000 | [diff] [blame] | 16 | |
| 17 | #include "HexagonTargetMachine.h" |
| 18 | #include "llvm/MC/MCInst.h" |
| 19 | |
| 20 | namespace llvm { |
| 21 | class MCOperand; |
| 22 | |
| 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; |
| 28 | |
| 29 | // Packet start and end markers |
| 30 | unsigned packetStart: 1, packetEnd: 1; |
| 31 | |
| 32 | public: |
| 33 | explicit HexagonMCInst(): |
Craig Topper | e73658d | 2014-04-28 04:05:08 +0000 | [diff] [blame] | 34 | MCInst(), MCID(nullptr), packetStart(0), packetEnd(0) {}; |
Jyotsna Verma | 7503a62 | 2013-02-20 16:13:27 +0000 | [diff] [blame] | 35 | HexagonMCInst(const MCInstrDesc& mcid): |
| 36 | MCInst(), MCID(&mcid), packetStart(0), packetEnd(0) {}; |
| 37 | |
| 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); }; |
| 43 | |
| 44 | // Return the slots used by the insn. |
| 45 | unsigned getUnits(const HexagonTargetMachine* TM) const; |
| 46 | |
| 47 | // Return the Hexagon ISA class for the insn. |
| 48 | unsigned getType() const; |
| 49 | |
| 50 | void setDesc(const MCInstrDesc& mcid) { MCID = &mcid; }; |
| 51 | const MCInstrDesc& getDesc(void) const { return *MCID; }; |
| 52 | |
| 53 | // Return whether the insn is an actual insn. |
| 54 | bool isCanon() const; |
| 55 | |
| 56 | // Return whether the insn is a prefix. |
| 57 | bool isPrefix() const; |
| 58 | |
| 59 | // Return whether the insn is solo, i.e., cannot be in a packet. |
| 60 | bool isSolo() const; |
| 61 | |
| 62 | // Return whether the instruction needs to be constant extended. |
| 63 | bool isConstExtended() const; |
| 64 | |
| 65 | // Return constant extended operand number. |
| 66 | unsigned short getCExtOpNum(void) const; |
| 67 | |
| 68 | // Return whether the insn is a new-value consumer. |
| 69 | bool isNewValue() const; |
| 70 | |
| 71 | // Return whether the instruction is a legal new-value producer. |
| 72 | bool hasNewValue() const; |
| 73 | |
| 74 | // Return the operand that consumes or produces a new value. |
| 75 | const MCOperand& getNewValue() const; |
| 76 | |
| 77 | // Return number of bits in the constant extended operand. |
| 78 | unsigned getBitCount(void) const; |
| 79 | |
| 80 | private: |
| 81 | // Return whether the instruction must be always extended. |
| 82 | bool isExtended() const; |
| 83 | |
| 84 | // Return true if the insn may be extended based on the operand value. |
| 85 | bool isExtendable() const; |
| 86 | |
| 87 | // Return true if the operand can be constant extended. |
| 88 | bool isOperandExtended(const unsigned short OperandNum) const; |
| 89 | |
| 90 | // Return the min value that a constant extendable operand can have |
| 91 | // without being extended. |
| 92 | int getMinValue() const; |
| 93 | |
| 94 | // Return the max value that a constant extendable operand can have |
| 95 | // without being extended. |
| 96 | int getMaxValue() const; |
| 97 | }; |
| 98 | } |
| 99 | |
| 100 | #endif |