Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/capstone/MCInstrDesc.h
4387 views
1
//===-- llvm/MC/MCInstrDesc.h - Instruction Descriptors -*- C++ -*-===//
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 file defines the MCOperandInfo and MCInstrDesc classes, which
11
// are used to describe target instructions and their operands.
12
//
13
//===----------------------------------------------------------------------===//
14
15
/* Capstone Disassembly Engine */
16
/* By Nguyen Anh Quynh <[email protected]>, 2013-2019 */
17
18
#ifndef CS_LLVM_MC_MCINSTRDESC_H
19
#define CS_LLVM_MC_MCINSTRDESC_H
20
21
#include "MCRegisterInfo.h"
22
#include "capstone/platform.h"
23
24
//===----------------------------------------------------------------------===//
25
// Machine Operand Flags and Description
26
//===----------------------------------------------------------------------===//
27
28
/// Operand constraints. These are encoded in 16 bits with one of the
29
/// low-order 3 bits specifying that a constraint is present and the
30
/// corresponding high-order hex digit specifying the constraint value.
31
/// This allows for a maximum of 3 constraints.
32
typedef enum {
33
MCOI_TIED_TO = 0, // Operand tied to another operand.
34
MCOI_EARLY_CLOBBER // Operand is an early clobber register operand
35
} MCOI_OperandConstraint;
36
37
// Define a macro to produce each constraint value.
38
#define CONSTRAINT_MCOI_TIED_TO(op) \
39
((1 << MCOI_TIED_TO) | ((op) << (4 + MCOI_TIED_TO * 4)))
40
41
#define CONSTRAINT_MCOI_EARLY_CLOBBER \
42
(1 << MCOI_EARLY_CLOBBER)
43
44
/// OperandFlags - These are flags set on operands, but should be considered
45
/// private, all access should go through the MCOperandInfo accessors.
46
/// See the accessors for a description of what these are.
47
enum MCOI_OperandFlags {
48
MCOI_LookupPtrRegClass = 0,
49
MCOI_Predicate,
50
MCOI_OptionalDef
51
};
52
53
/// Operand Type - Operands are tagged with one of the values of this enum.
54
enum MCOI_OperandType {
55
MCOI_OPERAND_UNKNOWN = 0,
56
MCOI_OPERAND_IMMEDIATE = 1,
57
MCOI_OPERAND_REGISTER = 2,
58
MCOI_OPERAND_MEMORY = 3,
59
MCOI_OPERAND_PCREL = 4,
60
61
MCOI_OPERAND_FIRST_GENERIC = 6,
62
MCOI_OPERAND_GENERIC_0 = 6,
63
MCOI_OPERAND_GENERIC_1 = 7,
64
MCOI_OPERAND_GENERIC_2 = 8,
65
MCOI_OPERAND_GENERIC_3 = 9,
66
MCOI_OPERAND_GENERIC_4 = 10,
67
MCOI_OPERAND_GENERIC_5 = 11,
68
MCOI_OPERAND_LAST_GENERIC = 11,
69
70
MCOI_OPERAND_FIRST_GENERIC_IMM = 12,
71
MCOI_OPERAND_GENERIC_IMM_0 = 12,
72
MCOI_OPERAND_LAST_GENERIC_IMM = 12,
73
74
MCOI_OPERAND_FIRST_TARGET = 13,
75
};
76
77
78
/// MCOperandInfo - This holds information about one operand of a machine
79
/// instruction, indicating the register class for register operands, etc.
80
///
81
typedef struct MCOperandInfo {
82
/// This specifies the register class enumeration of the operand
83
/// if the operand is a register. If isLookupPtrRegClass is set, then this is
84
/// an index that is passed to TargetRegisterInfo::getPointerRegClass(x) to
85
/// get a dynamic register class.
86
int16_t RegClass;
87
88
/// These are flags from the MCOI::OperandFlags enum.
89
uint8_t Flags;
90
91
/// Information about the type of the operand.
92
uint8_t OperandType;
93
94
/// The lower 16 bits are used to specify which constraints are set.
95
/// The higher 16 bits are used to specify the value of constraints (4 bits each).
96
uint32_t Constraints;
97
/// Currently no other information.
98
} MCOperandInfo;
99
100
101
//===----------------------------------------------------------------------===//
102
// Machine Instruction Flags and Description
103
//===----------------------------------------------------------------------===//
104
105
/// MCInstrDesc flags - These should be considered private to the
106
/// implementation of the MCInstrDesc class. Clients should use the predicate
107
/// methods on MCInstrDesc, not use these directly. These all correspond to
108
/// bitfields in the MCInstrDesc::Flags field.
109
enum {
110
MCID_Variadic = 0,
111
MCID_HasOptionalDef,
112
MCID_Pseudo,
113
MCID_Return,
114
MCID_Call,
115
MCID_Barrier,
116
MCID_Terminator,
117
MCID_Branch,
118
MCID_IndirectBranch,
119
MCID_Compare,
120
MCID_MoveImm,
121
MCID_MoveReg,
122
MCID_Bitcast,
123
MCID_Select,
124
MCID_DelaySlot,
125
MCID_FoldableAsLoad,
126
MCID_MayLoad,
127
MCID_MayStore,
128
MCID_Predicable,
129
MCID_NotDuplicable,
130
MCID_UnmodeledSideEffects,
131
MCID_Commutable,
132
MCID_ConvertibleTo3Addr,
133
MCID_UsesCustomInserter,
134
MCID_HasPostISelHook,
135
MCID_Rematerializable,
136
MCID_CheapAsAMove,
137
MCID_ExtraSrcRegAllocReq,
138
MCID_ExtraDefRegAllocReq,
139
MCID_RegSequence,
140
MCID_ExtractSubreg,
141
MCID_InsertSubreg,
142
MCID_Convergent,
143
MCID_Add,
144
MCID_Trap,
145
};
146
147
/// MCInstrDesc - Describe properties that are true of each instruction in the
148
/// target description file. This captures information about side effects,
149
/// register use and many other things. There is one instance of this struct
150
/// for each target instruction class, and the MachineInstr class points to
151
/// this struct directly to describe itself.
152
typedef struct MCInstrDesc {
153
unsigned char NumOperands; // Num of args (may be more if variable_ops)
154
const MCOperandInfo *OpInfo; // 'NumOperands' entries about operands
155
} MCInstrDesc;
156
157
bool MCOperandInfo_isPredicate(const MCOperandInfo *m);
158
159
bool MCOperandInfo_isOptionalDef(const MCOperandInfo *m);
160
161
bool MCOperandInfo_isTiedToOp(const MCOperandInfo *m);
162
163
int MCOperandInfo_getOperandConstraint(const MCInstrDesc *OpInfo,
164
unsigned OpNum,
165
MCOI_OperandConstraint Constraint);
166
167
#endif
168
169