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