1894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===- X86RecognizableInstr.h - Disassembler instruction spec ----*- C++ -*-===//
2894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
3894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//                     The LLVM Compiler Infrastructure
4894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
5894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// This file is distributed under the University of Illinois Open Source
6894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// License. See LICENSE.TXT for details.
7894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
8894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===----------------------------------------------------------------------===//
9894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
10894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// This file is part of the X86 Disassembler Emitter.
11894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// It contains the interface of a single recognizable instruction.
12894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// Documentation for the disassembler emitter in general can be found in
13894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//  X86DisasemblerEmitter.h.
14894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
15894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===----------------------------------------------------------------------===//
16894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
17894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#ifndef X86RECOGNIZABLEINSTR_H
18894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define X86RECOGNIZABLEINSTR_H
19894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
20894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "X86DisassemblerTables.h"
21894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
22894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "CodeGenTarget.h"
23894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
2419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "llvm/TableGen/Record.h"
2519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "llvm/Support/DataTypes.h"
26894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/ADT/SmallVector.h"
27894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
28894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumannamespace llvm {
29894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
30894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumannamespace X86Disassembler {
31894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
32894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/// RecognizableInstr - Encapsulates all information required to decode a single
33894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman///   instruction, as extracted from the LLVM instruction tables.  Has methods
34894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman///   to interpret the information available in the LLVM tables, and to emit the
35894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman///   instruction into DisassemblerTables.
36894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanclass RecognizableInstr {
37894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanprivate:
38894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// The opcode of the instruction, as used in an MCInst
39894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  InstrUID UID;
40894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// The record from the .td files corresponding to this instruction
41894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  const Record* Rec;
42894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// The prefix field from the record
43894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  uint8_t Prefix;
44894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// The opcode field from the record; this is the opcode used in the Intel
45894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// encoding and therefore distinct from the UID
46894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  uint8_t Opcode;
47894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// The form field from the record
48894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  uint8_t Form;
49894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// The segment override field from the record
50894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  uint8_t SegOvr;
51894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// The hasOpSizePrefix field from the record
52894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  bool HasOpSizePrefix;
53894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// The hasREX_WPrefix field from the record
54894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  bool HasREX_WPrefix;
5519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  /// The hasVEXPrefix field from the record
5619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  bool HasVEXPrefix;
57894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// The hasVEX_4VPrefix field from the record
58894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  bool HasVEX_4VPrefix;
5919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  /// The hasVEX_WPrefix field from the record
6019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  bool HasVEX_WPrefix;
6119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  /// Inferred from the operands; indicates whether the L bit in the VEX prefix is set
6219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  bool HasVEX_LPrefix;
6319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  // The ignoreVEX_L field from the record
6419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  bool IgnoresVEX_L;
65894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// The hasLockPrefix field from the record
66894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  bool HasLockPrefix;
67894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// The isCodeGenOnly filed from the record
68894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  bool IsCodeGenOnly;
6919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  // Whether the instruction has the predicate "In64BitMode"
7019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  bool Is64Bit;
7119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  // Whether the instruction has the predicate "In32BitMode"
7219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  bool Is32Bit;
73894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
74894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// The instruction name as listed in the tables
75894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  std::string Name;
76894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// The AT&T AsmString for the instruction
77894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  std::string AsmString;
78894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
79894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// Indicates whether the instruction is SSE
80894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  bool IsSSE;
81894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// Indicates whether the instruction has FR operands - MOVs with FR operands
82894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// are typically ignored
83894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  bool HasFROperands;
84894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// Indicates whether the instruction should be emitted into the decode
85894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// tables; regardless, it will be emitted into the instruction info table
86894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  bool ShouldBeEmitted;
87894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
88894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// The operands of the instruction, as listed in the CodeGenInstruction.
89894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// They are not one-to-one with operands listed in the MCInst; for example,
90894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// memory operands expand to 5 operands in the MCInst
9119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  const std::vector<CGIOperandList::OperandInfo>* Operands;
9219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
93894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// The description of the instruction that is emitted into the instruction
94894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// info table
95894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  InstructionSpecifier* Spec;
96894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
97894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// insnContext - Returns the primary context in which the instruction is
98894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   valid.
99894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///
100894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @return - The context in which the instruction is valid.
101894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  InstructionContext insnContext() const;
102894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
103894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  enum filter_ret {
104894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    FILTER_STRONG,    // instruction has no place in the instruction tables
105894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    FILTER_WEAK,      // instruction may conflict, and should be eliminated if
106894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                      // it does
107894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    FILTER_NORMAL     // instruction should have high priority and generate an
108894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                      // error if it conflcits with any other FILTER_NORMAL
109894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                      // instruction
110894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  };
11119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
112894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// filter - Determines whether the instruction should be decodable.  Some
113894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   instructions are pure intrinsics and use unencodable operands; many
114894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   synthetic instructions are duplicates of other instructions; other
115894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   instructions only differ in the logical way in which they are used, and
116894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   have the same decoding.  Because these would cause decode conflicts,
117894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   they must be filtered out.
118894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///
119894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @return - The degree of filtering to be applied (see filter_ret).
120894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  filter_ret filter() const;
12119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
12219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  /// hasFROperands - Returns true if any operand is a FR operand.
12319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  bool hasFROperands() const;
12419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
12519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  /// has256BitOperands - Returns true if any operand is a 256-bit SSE operand.
12619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  bool has256BitOperands() const;
127894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
128894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// typeFromString - Translates an operand type from the string provided in
129894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   the LLVM tables to an OperandType for use in the operand specifier.
130894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///
131894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @param s              - The string, as extracted by calling Rec->getName()
132894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///                         on a CodeGenInstruction::OperandInfo.
133894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @param isSSE          - Indicates whether the instruction is an SSE
134894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///                         instruction.  For SSE instructions, immediates are
135894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///                         fixed-size rather than being affected by the
136894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///                         mandatory OpSize prefix.
137894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @param hasREX_WPrefix - Indicates whether the instruction has a REX.W
138894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///                         prefix.  If it does, 32-bit register operands stay
139894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///                         32-bit regardless of the operand size.
140894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @param hasOpSizePrefix- Indicates whether the instruction has an OpSize
141894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///                         prefix.  If it does not, then 16-bit register
142894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///                         operands stay 16-bit.
143894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @return               - The operand's type.
144894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  static OperandType typeFromString(const std::string& s,
145894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                    bool isSSE,
146894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                    bool hasREX_WPrefix,
147894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                    bool hasOpSizePrefix);
148894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
149894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// immediateEncodingFromString - Translates an immediate encoding from the
150894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   string provided in the LLVM tables to an OperandEncoding for use in
151894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   the operand specifier.
152894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///
153894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @param s                - See typeFromString().
154894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @param hasOpSizePrefix  - Indicates whether the instruction has an OpSize
155894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///                           prefix.  If it does not, then 16-bit immediate
156894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///                           operands stay 16-bit.
157894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @return                 - The operand's encoding.
158894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  static OperandEncoding immediateEncodingFromString(const std::string &s,
159894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                                     bool hasOpSizePrefix);
160894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
161894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// rmRegisterEncodingFromString - Like immediateEncodingFromString, but
162894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   handles operands that are in the REG field of the ModR/M byte.
163894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  static OperandEncoding rmRegisterEncodingFromString(const std::string &s,
164894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                                      bool hasOpSizePrefix);
165894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
166894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// rmRegisterEncodingFromString - Like immediateEncodingFromString, but
167894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   handles operands that are in the REG field of the ModR/M byte.
168894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  static OperandEncoding roRegisterEncodingFromString(const std::string &s,
169894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                                      bool hasOpSizePrefix);
170894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  static OperandEncoding memoryEncodingFromString(const std::string &s,
171894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                                  bool hasOpSizePrefix);
172894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  static OperandEncoding relocationEncodingFromString(const std::string &s,
173894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                                      bool hasOpSizePrefix);
174894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  static OperandEncoding opcodeModifierEncodingFromString(const std::string &s,
175894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                                                          bool hasOpSizePrefix);
17619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  static OperandEncoding vvvvRegisterEncodingFromString(const std::string &s,
17719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                                                        bool HasOpSizePrefix);
178894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
179894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// handleOperand - Converts a single operand from the LLVM table format to
180894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   the emitted table format, handling any duplicate operands it encounters
181894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   and then one non-duplicate.
182894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///
183894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @param optional             - Determines whether to assert that the
184894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///                               operand exists.
185894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @param operandIndex         - The index into the generated operand table.
186894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///                               Incremented by this function one or more
187894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///                               times to reflect possible duplicate
188894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///                               operands).
189894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @param physicalOperandIndex - The index of the current operand into the
190894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///                               set of non-duplicate ('physical') operands.
191894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///                               Incremented by this function once.
192894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @param numPhysicalOperands  - The number of non-duplicate operands in the
193894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///                               instructions.
194894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @param operandMapping       - The operand mapping, which has an entry for
195894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///                               each operand that indicates whether it is a
196894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///                               duplicate, and of what.
197894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  void handleOperand(bool optional,
198894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                     unsigned &operandIndex,
199894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                     unsigned &physicalOperandIndex,
200894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                     unsigned &numPhysicalOperands,
201894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                     unsigned *operandMapping,
202894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                     OperandEncoding (*encodingFromString)
203894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                       (const std::string&,
204894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                        bool hasOpSizePrefix));
205894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
206894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// shouldBeEmitted - Returns the shouldBeEmitted field.  Although filter()
207894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   filters out many instructions, at various points in decoding we
208894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   determine that the instruction should not actually be decodable.  In
209894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   particular, MMX MOV instructions aren't emitted, but they're only
210894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   identified during operand parsing.
211894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///
212894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @return - true if at this point we believe the instruction should be
213894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   emitted; false if not.  This will return false if filter() returns false
214894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   once emitInstructionSpecifier() has been called.
215894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  bool shouldBeEmitted() const {
216894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    return ShouldBeEmitted;
217894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  }
218894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
219894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// emitInstructionSpecifier - Loads the instruction specifier for the current
220894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   instruction into a DisassemblerTables.
221894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///
222894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @arg tables - The DisassemblerTables to populate with the specifier for
223894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///               the current instruction.
224894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  void emitInstructionSpecifier(DisassemblerTables &tables);
225894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
226894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// emitDecodePath - Populates the proper fields in the decode tables
227894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   corresponding to the decode paths for this instruction.
228894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///
229894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @arg tables - The DisassemblerTables to populate with the decode
230894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///               decode information for the current instruction.
231894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  void emitDecodePath(DisassemblerTables &tables) const;
232894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
233894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// Constructor - Initializes a RecognizableInstr with the appropriate fields
234894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   from a CodeGenInstruction.
235894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///
236894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @arg tables - The DisassemblerTables that the specifier will be added to.
237894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @arg insn   - The CodeGenInstruction to extract information from.
238894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @arg uid    - The unique ID of the current instruction.
239894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  RecognizableInstr(DisassemblerTables &tables,
240894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                    const CodeGenInstruction &insn,
241894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                    InstrUID uid);
242894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanpublic:
243894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// processInstr - Accepts a CodeGenInstruction and loads decode information
244894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///   for it into a DisassemblerTables if appropriate.
245894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///
246894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @arg tables - The DiassemblerTables to be populated with decode
247894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///               information.
248894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @arg insn   - The CodeGenInstruction to be used as a source for this
249894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///               information.
250894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// @uid        - The unique ID of the instruction.
251894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  static void processInstr(DisassemblerTables &tables,
252894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                           const CodeGenInstruction &insn,
253894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman                           InstrUID uid);
254894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman};
255894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
256894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} // namespace X86Disassembler
257894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
258894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} // namespace llvm
259894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
260894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif
261