blob: 4181eb3afa1a58cb867ccf991074f98afc03ac38 [file] [log] [blame]
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +08001//===-- 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 Disassembler Engine */
16/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013> */
17
18#ifndef CS_LLVM_MC_MCINSTRDESC_H
19#define CS_LLVM_MC_MCINSTRDESC_H
20
21#include <stdbool.h>
22#include <stdint.h>
23
24//===----------------------------------------------------------------------===//
25// Machine Operand Flags and Description
26//===----------------------------------------------------------------------===//
27
28// Operand constraints
29enum MCOI_OperandConstraint {
30 MCOI_TIED_TO = 0, // Must be allocated the same register as.
31 MCOI_EARLY_CLOBBER // Operand is an early clobber register operand
32};
33
34/// OperandFlags - These are flags set on operands, but should be considered
35/// private, all access should go through the MCOperandInfo accessors.
36/// See the accessors for a description of what these are.
37enum MCOI_OperandFlags {
38 MCOI_LookupPtrRegClass = 0,
39 MCOI_Predicate,
40 MCOI_OptionalDef
41};
42
43/// Operand Type - Operands are tagged with one of the values of this enum.
44enum MCOI_OperandType {
45 MCOI_OPERAND_UNKNOWN,
46 MCOI_OPERAND_IMMEDIATE,
47 MCOI_OPERAND_REGISTER,
48 MCOI_OPERAND_MEMORY,
49 MCOI_OPERAND_PCREL
50};
51
52
53/// MCOperandInfo - This holds information about one operand of a machine
54/// instruction, indicating the register class for register operands, etc.
55///
56typedef struct MCOperandInfo {
57 /// RegClass - This specifies the register class enumeration of the operand
58 /// if the operand is a register. If isLookupPtrRegClass is set, then this is
59 /// an index that is passed to TargetRegisterInfo::getPointerRegClass(x) to
60 /// get a dynamic register class.
61 int16_t RegClass;
62
63 /// Flags - These are flags from the MCOI::OperandFlags enum.
64 uint8_t Flags;
65
66 /// OperandType - Information about the type of the operand.
67 uint8_t OperandType;
68
69 /// Lower 16 bits are used to specify which constraints are set. The higher 16
70 /// bits are used to specify the value of constraints (4 bits each).
71 uint32_t Constraints;
72 /// Currently no other information.
73} MCOperandInfo;
74
75
76//===----------------------------------------------------------------------===//
77// Machine Instruction Flags and Description
78//===----------------------------------------------------------------------===//
79
80/// MCInstrDesc flags - These should be considered private to the
81/// implementation of the MCInstrDesc class. Clients should use the predicate
82/// methods on MCInstrDesc, not use these directly. These all correspond to
83/// bitfields in the MCInstrDesc::Flags field.
84enum {
85 MCID_Variadic = 0,
86 MCID_HasOptionalDef,
87 MCID_Pseudo,
88 MCID_Return,
89 MCID_Call,
90 MCID_Barrier,
91 MCID_Terminator,
92 MCID_Branch,
93 MCID_IndirectBranch,
94 MCID_Compare,
95 MCID_MoveImm,
96 MCID_Bitcast,
97 MCID_Select,
98 MCID_DelaySlot,
99 MCID_FoldableAsLoad,
100 MCID_MayLoad,
101 MCID_MayStore,
102 MCID_Predicable,
103 MCID_NotDuplicable,
104 MCID_UnmodeledSideEffects,
105 MCID_Commutable,
106 MCID_ConvertibleTo3Addr,
107 MCID_UsesCustomInserter,
108 MCID_HasPostISelHook,
109 MCID_Rematerializable,
110 MCID_CheapAsAMove,
111 MCID_ExtraSrcRegAllocReq,
112 MCID_ExtraDefRegAllocReq
113};
114
115/// MCInstrDesc - Describe properties that are true of each instruction in the
116/// target description file. This captures information about side effects,
117/// register use and many other things. There is one instance of this struct
118/// for each target instruction class, and the MachineInstr class points to
119/// this struct directly to describe itself.
120typedef struct MCInstrDesc {
121 unsigned short Opcode; // The opcode number
122 unsigned short NumOperands; // Num of args (may be more if variable_ops)
123 unsigned short NumDefs; // Num of args that are definitions
124 unsigned short SchedClass; // enum identifying instr sched class
125 unsigned short Size; // Number of bytes in encoding.
126 unsigned Flags; // Flags identifying machine instr class
127 uint64_t TSFlags; // Target Specific Flag values
128 uint16_t *ImplicitUses; // Registers implicitly read by this instr
129 uint16_t *ImplicitDefs; // Registers implicitly defined by this instr
130 MCOperandInfo *OpInfo; // 'NumOperands' entries about operands
131 uint64_t DeprecatedFeatureMask;// Feature bits that this is deprecated on, if any
132 // A complex method to determine is a certain is deprecated or not, and return
133 // the reason for deprecation.
134 //bool (*ComplexDeprecationInfo)(MCInst &, MCSubtargetInfo &, std::string &);
135 unsigned ComplexDeprecationInfo; // dummy field, just to satisfy initializer
136} MCInstrDesc;
137
138bool MCOperandInfo_isPredicate(MCOperandInfo *m);
139
140bool MCOperandInfo_isOptionalDef(MCOperandInfo *m);
141
142#endif