1 //===- HexagonMCInstrInfo.cpp - 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 // Utility functions for Hexagon specific MCInst queries
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCINSTRINFO_H
15 #define LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCINSTRINFO_H
17 #include "llvm/MC/MCInstrInfo.h"
27 enum class MemAccessSize;
29 namespace HexagonMCInstrInfo {
30 void AppendImplicitOperands(MCInst &MCI);
32 // Return memory access size
33 HexagonII::MemAccessSize getAccessSize(MCInstrInfo const &MCII,
36 // Return number of bits in the constant extended operand.
37 unsigned getBitCount(MCInstrInfo const &MCII, MCInst const &MCI);
39 // Return constant extended operand number.
40 unsigned short getCExtOpNum(MCInstrInfo const &MCII, MCInst const &MCI);
42 MCInstrDesc const &getDesc(MCInstrInfo const &MCII, MCInst const &MCI);
44 // Return the implicit alignment of the extendable operand
45 unsigned getExtentAlignment(MCInstrInfo const &MCII, MCInst const &MCI);
47 // Return the number of logical bits of the extendable operand
48 unsigned getExtentBits(MCInstrInfo const &MCII, MCInst const &MCI);
50 std::bitset<16> GetImplicitBits(MCInst const &MCI);
52 // Return the max value that a constant extendable operand can have
53 // without being extended.
54 int getMaxValue(MCInstrInfo const &MCII, MCInst const &MCI);
56 // Return the min value that a constant extendable operand can have
57 // without being extended.
58 int getMinValue(MCInstrInfo const &MCII, MCInst const &MCI);
60 // Return instruction name
61 char const *getName(MCInstrInfo const &MCII, MCInst const &MCI);
63 // Return the operand that consumes or produces a new value.
64 MCOperand const &getNewValue(MCInstrInfo const &MCII, MCInst const &MCI);
66 // Return the Hexagon ISA class for the insn.
67 unsigned getType(MCInstrInfo const &MCII, MCInst const &MCI);
69 // Return whether the instruction is a legal new-value producer.
70 bool hasNewValue(MCInstrInfo const &MCII, MCInst const &MCI);
72 // Return whether the insn is an actual insn.
73 bool isCanon(MCInstrInfo const &MCII, MCInst const &MCI);
75 // Return whether the instruction needs to be constant extended.
76 bool isConstExtended(MCInstrInfo const &MCII, MCInst const &MCI);
78 // Return true if the insn may be extended based on the operand value.
79 bool isExtendable(MCInstrInfo const &MCII, MCInst const &MCI);
81 // Return whether the instruction must be always extended.
82 bool isExtended(MCInstrInfo const &MCII, MCInst const &MCI);
84 // Return whether the insn is a new-value consumer.
85 bool isNewValue(MCInstrInfo const &MCII, MCInst const &MCI);
87 // Return true if the operand can be constant extended.
88 bool isOperandExtended(MCInstrInfo const &MCII, MCInst const &MCI,
89 unsigned short OperandNum);
91 bool isPacketBegin(MCInst const &MCI);
93 bool isPacketEnd(MCInst const &MCI);
95 // Return whether the insn is a prefix.
96 bool isPrefix(MCInstrInfo const &MCII, MCInst const &MCI);
98 // Return whether the insn is solo, i.e., cannot be in a packet.
99 bool isSolo(MCInstrInfo const &MCII, MCInst const &MCI);
101 static const size_t packetBeginIndex = 0;
102 static const size_t packetEndIndex = 1;
104 void resetPacket(MCInst &MCI);
106 inline void SanityCheckImplicitOperands(MCInst const &MCI) {
107 assert(MCI.getNumOperands() >= 2 && "At least the two implicit operands");
108 assert(MCI.getOperand(MCI.getNumOperands() - 1).isInst() &&
109 "Implicit bits and flags");
110 assert(MCI.getOperand(MCI.getNumOperands() - 2).isImm() && "Parent pointer");
113 void SetImplicitBits(MCInst &MCI, std::bitset<16> Bits);
115 void setPacketBegin(MCInst &MCI, bool Y);
117 void setPacketEnd(MCInst &MCI, bool Y);
121 #endif // LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCINSTRINFO_H