[Hexagon] Adding expression MC emission and removing XFAIL from test that hits this...
[oota-llvm.git] / lib / Target / Hexagon / MCTargetDesc / HexagonMCInstrInfo.h
1 //===- HexagonMCInstrInfo.cpp - 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 // Utility functions for Hexagon specific MCInst queries
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCINSTRINFO_H
15 #define LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCINSTRINFO_H
16
17 #include "llvm/MC/MCInstrInfo.h"
18
19 #include <bitset>
20
21 namespace llvm {
22 class MCInstrDesc;
23 class MCInstrInfo;
24 class MCInst;
25 class MCOperand;
26 namespace HexagonII {
27 enum class MemAccessSize;
28 }
29 namespace HexagonMCInstrInfo {
30 void AppendImplicitOperands(MCInst &MCI);
31
32 // Return memory access size
33 HexagonII::MemAccessSize getAccessSize(MCInstrInfo const &MCII,
34                                        MCInst const &MCI);
35
36 // Return number of bits in the constant extended operand.
37 unsigned getBitCount(MCInstrInfo const &MCII, MCInst const &MCI);
38
39 // Return constant extended operand number.
40 unsigned short getCExtOpNum(MCInstrInfo const &MCII, MCInst const &MCI);
41
42 MCInstrDesc const &getDesc(MCInstrInfo const &MCII, MCInst const &MCI);
43
44 // Return the implicit alignment of the extendable operand
45 unsigned getExtentAlignment(MCInstrInfo const &MCII, MCInst const &MCI);
46
47 // Return the number of logical bits of the extendable operand
48 unsigned getExtentBits(MCInstrInfo const &MCII, MCInst const &MCI);
49
50 std::bitset<16> GetImplicitBits(MCInst const &MCI);
51
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);
55
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);
59
60 // Return instruction name
61 char const *getName(MCInstrInfo const &MCII, MCInst const &MCI);
62
63 // Return the operand that consumes or produces a new value.
64 MCOperand const &getNewValue(MCInstrInfo const &MCII, MCInst const &MCI);
65
66 // Return the Hexagon ISA class for the insn.
67 unsigned getType(MCInstrInfo const &MCII, MCInst const &MCI);
68
69 // Return whether the instruction is a legal new-value producer.
70 bool hasNewValue(MCInstrInfo const &MCII, MCInst const &MCI);
71
72 // Return whether the insn is an actual insn.
73 bool isCanon(MCInstrInfo const &MCII, MCInst const &MCI);
74
75 // Return whether the instruction needs to be constant extended.
76 bool isConstExtended(MCInstrInfo const &MCII, MCInst const &MCI);
77
78 // Return true if the insn may be extended based on the operand value.
79 bool isExtendable(MCInstrInfo const &MCII, MCInst const &MCI);
80
81 // Return whether the instruction must be always extended.
82 bool isExtended(MCInstrInfo const &MCII, MCInst const &MCI);
83
84 // Return whether the insn is a new-value consumer.
85 bool isNewValue(MCInstrInfo const &MCII, MCInst const &MCI);
86
87 // Return true if the operand can be constant extended.
88 bool isOperandExtended(MCInstrInfo const &MCII, MCInst const &MCI,
89                        unsigned short OperandNum);
90
91 bool isPacketBegin(MCInst const &MCI);
92
93 bool isPacketEnd(MCInst const &MCI);
94
95 // Return whether the insn is a prefix.
96 bool isPrefix(MCInstrInfo const &MCII, MCInst const &MCI);
97
98 // Return whether the insn is solo, i.e., cannot be in a packet.
99 bool isSolo(MCInstrInfo const &MCII, MCInst const &MCI);
100
101 static const size_t packetBeginIndex = 0;
102 static const size_t packetEndIndex = 1;
103
104 void resetPacket(MCInst &MCI);
105
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");
111 }
112
113 void SetImplicitBits(MCInst &MCI, std::bitset<16> Bits);
114
115 void setPacketBegin(MCInst &MCI, bool Y);
116
117 void setPacketEnd(MCInst &MCI, bool Y);
118 }
119 }
120
121 #endif // LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCINSTRINFO_H