2013-11-27 04:11:31 +00:00
|
|
|
//===-- llvm/MC/MCInstrDesc.h - Instruction Descriptors -*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the MCOperandInfo and MCInstrDesc classes, which
|
|
|
|
// are used to describe target instructions and their operands.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-04-29 03:21:04 +00:00
|
|
|
/* Capstone Disassembly Engine */
|
2019-02-26 07:19:51 +00:00
|
|
|
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */
|
2013-11-27 04:11:31 +00:00
|
|
|
|
|
|
|
#ifndef CS_LLVM_MC_MCINSTRDESC_H
|
|
|
|
#define CS_LLVM_MC_MCINSTRDESC_H
|
|
|
|
|
2019-02-26 07:19:51 +00:00
|
|
|
#include "MCRegisterInfo.h"
|
2015-02-24 03:55:55 +00:00
|
|
|
#include "capstone/platform.h"
|
2013-11-27 04:11:31 +00:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Machine Operand Flags and Description
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2023-05-17 23:27:03 +00:00
|
|
|
/// Operand constraints. These are encoded in 16 bits with one of the
|
|
|
|
/// low-order 3 bits specifying that a constraint is present and the
|
|
|
|
/// corresponding high-order hex digit specifying the constraint value.
|
|
|
|
/// This allows for a maximum of 3 constraints.
|
|
|
|
typedef enum {
|
|
|
|
MCOI_TIED_TO = 0, // Operand tied to another operand.
|
2013-11-27 04:11:31 +00:00
|
|
|
MCOI_EARLY_CLOBBER // Operand is an early clobber register operand
|
2023-05-17 23:27:03 +00:00
|
|
|
} MCOI_OperandConstraint;
|
|
|
|
|
|
|
|
// Define a macro to produce each constraint value.
|
|
|
|
#define CONSTRAINT_MCOI_TIED_TO(op) \
|
|
|
|
((1 << MCOI_TIED_TO) | ((op) << (4 + MCOI_TIED_TO * 4)))
|
|
|
|
|
|
|
|
#define CONSTRAINT_MCOI_EARLY_CLOBBER \
|
|
|
|
(1 << MCOI_EARLY_CLOBBER)
|
2013-11-27 04:11:31 +00:00
|
|
|
|
|
|
|
/// OperandFlags - These are flags set on operands, but should be considered
|
|
|
|
/// private, all access should go through the MCOperandInfo accessors.
|
|
|
|
/// See the accessors for a description of what these are.
|
|
|
|
enum MCOI_OperandFlags {
|
|
|
|
MCOI_LookupPtrRegClass = 0,
|
|
|
|
MCOI_Predicate,
|
|
|
|
MCOI_OptionalDef
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Operand Type - Operands are tagged with one of the values of this enum.
|
|
|
|
enum MCOI_OperandType {
|
2019-02-26 07:19:51 +00:00
|
|
|
MCOI_OPERAND_UNKNOWN = 0,
|
|
|
|
MCOI_OPERAND_IMMEDIATE = 1,
|
|
|
|
MCOI_OPERAND_REGISTER = 2,
|
|
|
|
MCOI_OPERAND_MEMORY = 3,
|
|
|
|
MCOI_OPERAND_PCREL = 4,
|
|
|
|
|
|
|
|
MCOI_OPERAND_FIRST_GENERIC = 6,
|
|
|
|
MCOI_OPERAND_GENERIC_0 = 6,
|
|
|
|
MCOI_OPERAND_GENERIC_1 = 7,
|
|
|
|
MCOI_OPERAND_GENERIC_2 = 8,
|
|
|
|
MCOI_OPERAND_GENERIC_3 = 9,
|
|
|
|
MCOI_OPERAND_GENERIC_4 = 10,
|
|
|
|
MCOI_OPERAND_GENERIC_5 = 11,
|
|
|
|
MCOI_OPERAND_LAST_GENERIC = 11,
|
|
|
|
|
2023-03-26 01:29:40 +00:00
|
|
|
MCOI_OPERAND_FIRST_GENERIC_IMM = 12,
|
|
|
|
MCOI_OPERAND_GENERIC_IMM_0 = 12,
|
|
|
|
MCOI_OPERAND_LAST_GENERIC_IMM = 12,
|
|
|
|
|
|
|
|
MCOI_OPERAND_FIRST_TARGET = 13,
|
2013-11-27 04:11:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// MCOperandInfo - This holds information about one operand of a machine
|
|
|
|
/// instruction, indicating the register class for register operands, etc.
|
|
|
|
///
|
|
|
|
typedef struct MCOperandInfo {
|
2019-02-26 07:19:51 +00:00
|
|
|
/// This specifies the register class enumeration of the operand
|
2013-11-27 04:11:31 +00:00
|
|
|
/// if the operand is a register. If isLookupPtrRegClass is set, then this is
|
|
|
|
/// an index that is passed to TargetRegisterInfo::getPointerRegClass(x) to
|
|
|
|
/// get a dynamic register class.
|
|
|
|
int16_t RegClass;
|
|
|
|
|
2019-02-26 07:19:51 +00:00
|
|
|
/// These are flags from the MCOI::OperandFlags enum.
|
2013-11-27 04:11:31 +00:00
|
|
|
uint8_t Flags;
|
|
|
|
|
2019-02-26 07:19:51 +00:00
|
|
|
/// Information about the type of the operand.
|
2013-11-27 04:11:31 +00:00
|
|
|
uint8_t OperandType;
|
|
|
|
|
2023-07-19 09:56:27 +00:00
|
|
|
/// The lower 3 bits are used to specify which constraints are set.
|
|
|
|
/// The higher 13 bits are used to specify the value of constraints (4 bits each).
|
|
|
|
uint16_t Constraints;
|
2013-11-27 04:11:31 +00:00
|
|
|
/// Currently no other information.
|
|
|
|
} MCOperandInfo;
|
|
|
|
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Machine Instruction Flags and Description
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
/// MCInstrDesc flags - These should be considered private to the
|
2019-02-26 07:19:51 +00:00
|
|
|
/// implementation of the MCInstrDesc class. Clients should use the predicate
|
|
|
|
/// methods on MCInstrDesc, not use these directly. These all correspond to
|
2013-11-27 04:11:31 +00:00
|
|
|
/// bitfields in the MCInstrDesc::Flags field.
|
|
|
|
enum {
|
|
|
|
MCID_Variadic = 0,
|
|
|
|
MCID_HasOptionalDef,
|
|
|
|
MCID_Pseudo,
|
|
|
|
MCID_Return,
|
|
|
|
MCID_Call,
|
|
|
|
MCID_Barrier,
|
|
|
|
MCID_Terminator,
|
|
|
|
MCID_Branch,
|
|
|
|
MCID_IndirectBranch,
|
|
|
|
MCID_Compare,
|
|
|
|
MCID_MoveImm,
|
2019-02-26 07:19:51 +00:00
|
|
|
MCID_MoveReg,
|
2013-11-27 04:11:31 +00:00
|
|
|
MCID_Bitcast,
|
|
|
|
MCID_Select,
|
|
|
|
MCID_DelaySlot,
|
|
|
|
MCID_FoldableAsLoad,
|
|
|
|
MCID_MayLoad,
|
|
|
|
MCID_MayStore,
|
|
|
|
MCID_Predicable,
|
|
|
|
MCID_NotDuplicable,
|
|
|
|
MCID_UnmodeledSideEffects,
|
|
|
|
MCID_Commutable,
|
|
|
|
MCID_ConvertibleTo3Addr,
|
|
|
|
MCID_UsesCustomInserter,
|
|
|
|
MCID_HasPostISelHook,
|
|
|
|
MCID_Rematerializable,
|
|
|
|
MCID_CheapAsAMove,
|
|
|
|
MCID_ExtraSrcRegAllocReq,
|
2014-08-13 14:38:15 +00:00
|
|
|
MCID_ExtraDefRegAllocReq,
|
|
|
|
MCID_RegSequence,
|
2015-03-03 08:26:32 +00:00
|
|
|
MCID_ExtractSubreg,
|
2019-02-26 07:19:51 +00:00
|
|
|
MCID_InsertSubreg,
|
|
|
|
MCID_Convergent,
|
|
|
|
MCID_Add,
|
|
|
|
MCID_Trap,
|
2013-11-27 04:11:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// MCInstrDesc - Describe properties that are true of each instruction in the
|
2019-02-26 07:19:51 +00:00
|
|
|
/// target description file. This captures information about side effects,
|
|
|
|
/// register use and many other things. There is one instance of this struct
|
2013-11-27 04:11:31 +00:00
|
|
|
/// for each target instruction class, and the MachineInstr class points to
|
|
|
|
/// this struct directly to describe itself.
|
|
|
|
typedef struct MCInstrDesc {
|
2015-03-10 07:40:09 +00:00
|
|
|
unsigned char NumOperands; // Num of args (may be more if variable_ops)
|
2017-10-22 00:45:40 +00:00
|
|
|
const MCOperandInfo *OpInfo; // 'NumOperands' entries about operands
|
2013-11-27 04:11:31 +00:00
|
|
|
} MCInstrDesc;
|
|
|
|
|
2017-10-22 00:45:40 +00:00
|
|
|
bool MCOperandInfo_isPredicate(const MCOperandInfo *m);
|
2013-11-27 04:11:31 +00:00
|
|
|
|
2017-10-22 00:45:40 +00:00
|
|
|
bool MCOperandInfo_isOptionalDef(const MCOperandInfo *m);
|
2013-11-27 04:11:31 +00:00
|
|
|
|
2023-05-30 03:08:18 +00:00
|
|
|
bool MCOperandInfo_isTiedToOp(const MCOperandInfo *m);
|
|
|
|
|
2023-05-30 03:09:37 +00:00
|
|
|
int MCOperandInfo_getOperandConstraint(const MCInstrDesc *OpInfo,
|
|
|
|
unsigned OpNum,
|
|
|
|
MCOI_OperandConstraint Constraint);
|
2023-05-30 03:08:18 +00:00
|
|
|
|
2013-11-27 04:11:31 +00:00
|
|
|
#endif
|