blob: 8971ae487f4ac26cbd59982e9304361b2884cf40 [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
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080021#include <stdint.h>
pancake9c10ace2015-02-24 04:55:55 +010022#include "capstone/platform.h"
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080023
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,
Nguyen Anh Quynhb52f11f2014-08-13 22:38:15 +0800112 MCID_ExtraDefRegAllocReq,
113 MCID_RegSequence,
Nguyen Anh Quynhd1fc2bd2015-03-03 16:26:32 +0800114 MCID_ExtractSubreg,
115 MCID_InsertSubreg
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +0800116};
117
118/// MCInstrDesc - Describe properties that are true of each instruction in the
119/// target description file. This captures information about side effects,
120/// register use and many other things. There is one instance of this struct
121/// for each target instruction class, and the MachineInstr class points to
122/// this struct directly to describe itself.
123typedef struct MCInstrDesc {
124 unsigned short Opcode; // The opcode number
125 unsigned short NumOperands; // Num of args (may be more if variable_ops)
126 unsigned short NumDefs; // Num of args that are definitions
127 unsigned short SchedClass; // enum identifying instr sched class
128 unsigned short Size; // Number of bytes in encoding.
129 unsigned Flags; // Flags identifying machine instr class
130 uint64_t TSFlags; // Target Specific Flag values
131 uint16_t *ImplicitUses; // Registers implicitly read by this instr
132 uint16_t *ImplicitDefs; // Registers implicitly defined by this instr
133 MCOperandInfo *OpInfo; // 'NumOperands' entries about operands
134 uint64_t DeprecatedFeatureMask;// Feature bits that this is deprecated on, if any
135 // A complex method to determine is a certain is deprecated or not, and return
136 // the reason for deprecation.
137 //bool (*ComplexDeprecationInfo)(MCInst &, MCSubtargetInfo &, std::string &);
138 unsigned ComplexDeprecationInfo; // dummy field, just to satisfy initializer
139} MCInstrDesc;
140
141bool MCOperandInfo_isPredicate(MCOperandInfo *m);
142
143bool MCOperandInfo_isOptionalDef(MCOperandInfo *m);
144
145#endif