[Hexagon] Disassembling, printing, and emitting instructions a whole-bundle at a...
[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/MCInst.h"
18 #include "llvm/MC/MCInstrInfo.h"
19
20 #include <bitset>
21
22 namespace llvm {
23 class MCInstrDesc;
24 class MCInstrInfo;
25 class MCInst;
26 class MCOperand;
27 namespace HexagonII {
28 enum class MemAccessSize;
29 }
30 namespace HexagonMCInstrInfo {
31 size_t const innerLoopOffset = 0;
32 int64_t const innerLoopMask = 1 << innerLoopOffset;
33
34 size_t const outerLoopOffset = 1;
35 int64_t const outerLoopMask = 1 << outerLoopOffset;
36
37 size_t const bundleInstructionsOffset = 1;
38
39 // Returns the number of instructions in the bundle
40 size_t bundleSize(MCInst const &MCI);
41
42 // Returns a iterator range of instructions in this bundle
43 iterator_range<MCInst::const_iterator> bundleInstructions(MCInst const &MCI);
44
45 // Return memory access size
46 HexagonII::MemAccessSize getAccessSize(MCInstrInfo const &MCII,
47                                        MCInst const &MCI);
48
49 // Return number of bits in the constant extended operand.
50 unsigned getBitCount(MCInstrInfo const &MCII, MCInst const &MCI);
51
52 // Return constant extended operand number.
53 unsigned short getCExtOpNum(MCInstrInfo const &MCII, MCInst const &MCI);
54
55 MCInstrDesc const &getDesc(MCInstrInfo const &MCII, MCInst const &MCI);
56
57 // Return the implicit alignment of the extendable operand
58 unsigned getExtentAlignment(MCInstrInfo const &MCII, MCInst const &MCI);
59
60 // Return the number of logical bits of the extendable operand
61 unsigned getExtentBits(MCInstrInfo const &MCII, MCInst const &MCI);
62
63 // Return the max value that a constant extendable operand can have
64 // without being extended.
65 int getMaxValue(MCInstrInfo const &MCII, MCInst const &MCI);
66
67 // Return the min value that a constant extendable operand can have
68 // without being extended.
69 int getMinValue(MCInstrInfo const &MCII, MCInst const &MCI);
70
71 // Return instruction name
72 char const *getName(MCInstrInfo const &MCII, MCInst const &MCI);
73
74 // Return the operand index for the new value.
75 unsigned short getNewValueOp(MCInstrInfo const &MCII, MCInst const &MCI);
76
77 // Return the operand that consumes or produces a new value.
78 MCOperand const &getNewValueOperand(MCInstrInfo const &MCII, MCInst const &MCI);
79
80 // Return the Hexagon ISA class for the insn.
81 unsigned getType(MCInstrInfo const &MCII, MCInst const &MCI);
82
83 // Return whether the instruction is a legal new-value producer.
84 bool hasNewValue(MCInstrInfo const &MCII, MCInst const &MCI);
85
86 // Returns whether this MCInst is a wellformed bundle
87 bool isBundle(MCInst const &MCI);
88
89 // Return whether the insn is an actual insn.
90 bool isCanon(MCInstrInfo const &MCII, MCInst const &MCI);
91
92 // Return whether the instruction needs to be constant extended.
93 bool isConstExtended(MCInstrInfo const &MCII, MCInst const &MCI);
94
95 // Return true if the insn may be extended based on the operand value.
96 bool isExtendable(MCInstrInfo const &MCII, MCInst const &MCI);
97
98 // Return whether the instruction must be always extended.
99 bool isExtended(MCInstrInfo const &MCII, MCInst const &MCI);
100
101 // Returns whether this instruction is an immediate extender
102 bool isImmext(MCInst const &MCI);
103
104 // Returns whether this bundle is an endloop0
105 bool isInnerLoop(MCInst const &MCI);
106
107 // Return whether the insn is a new-value consumer.
108 bool isNewValue(MCInstrInfo const &MCII, MCInst const &MCI);
109
110 // Return true if the operand can be constant extended.
111 bool isOperandExtended(MCInstrInfo const &MCII, MCInst const &MCI,
112                        unsigned short OperandNum);
113
114 // Returns whether this bundle is an endloop1
115 bool isOuterLoop(MCInst const &MCI);
116
117 // Return whether this instruction is predicated
118 bool isPredicated(MCInstrInfo const &MCII, MCInst const &MCI);
119
120 // Return whether the predicate sense is true
121 bool isPredicatedTrue(MCInstrInfo const &MCII, MCInst const &MCI);
122
123 // Return whether the insn is a prefix.
124 bool isPrefix(MCInstrInfo const &MCII, MCInst const &MCI);
125
126 // Return whether the insn is solo, i.e., cannot be in a packet.
127 bool isSolo(MCInstrInfo const &MCII, MCInst const &MCI);
128
129 // Pad the bundle with nops to satisfy endloop requirements
130 void padEndloop(MCInst &MCI);
131
132 // Marks a bundle as endloop0
133 void setInnerLoop(MCInst &MCI);
134
135 // Marks a bundle as endloop1
136 void setOuterLoop(MCInst &MCI);
137 }
138 }
139
140 #endif // LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCINSTRINFO_H