Add `.clang-format` and format
This commit is contained in:
parent
f40f097444
commit
9d6c489c57
116
.clang-format
116
.clang-format
|
@ -1,6 +1,120 @@
|
||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
#
|
||||||
|
# clang-format configuration file. Intended for clang-format >= 11.
|
||||||
|
#
|
||||||
|
# For more information, see:
|
||||||
|
#
|
||||||
|
# Documentation/process/clang-format.rst
|
||||||
|
# https://clang.llvm.org/docs/ClangFormat.html
|
||||||
|
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
|
||||||
|
#
|
||||||
|
---
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveAssignments: false
|
||||||
|
AlignConsecutiveDeclarations: false
|
||||||
|
AlignEscapedNewlines: DontAlign
|
||||||
|
AlignOperands: true
|
||||||
|
AlignTrailingComments:
|
||||||
|
Kind: Always
|
||||||
|
OverEmptyLines: 2
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
|
AllowShortBlocksOnASingleLine: false
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: false
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
BraceWrapping:
|
BraceWrapping:
|
||||||
AfterClass: true
|
AfterClass: false
|
||||||
AfterControlStatement: false
|
AfterControlStatement: false
|
||||||
|
AfterEnum: false
|
||||||
AfterFunction: true
|
AfterFunction: true
|
||||||
|
AfterNamespace: true
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
AfterExternBlock: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: true
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
SplitEmptyNamespace: true
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
BreakBeforeBraces: Custom
|
BreakBeforeBraces: Custom
|
||||||
|
BreakBeforeInheritanceComma: false
|
||||||
|
BreakBeforeTernaryOperators: false
|
||||||
|
BreakConstructorInitializersBeforeComma: false
|
||||||
|
BreakConstructorInitializers: BeforeComma
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakStringLiterals: false
|
||||||
|
ColumnLimit: 80
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||||
|
ConstructorInitializerIndentWidth: 8
|
||||||
|
ContinuationIndentWidth: 8
|
||||||
|
Cpp11BracedListStyle: false
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
DisableFormat: false
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: false
|
||||||
|
|
||||||
|
IncludeBlocks: Preserve
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 1
|
||||||
|
IncludeIsMainRegex: '(Test)?$'
|
||||||
|
IndentCaseLabels: false
|
||||||
|
IndentGotoLabels: false
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentWidth: 8
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: None
|
||||||
|
ObjCBinPackProtocolList: Auto
|
||||||
|
ObjCBlockIndentWidth: 8
|
||||||
|
ObjCSpaceAfterProperty: true
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
|
||||||
|
# Taken from git's rules
|
||||||
|
PenaltyBreakAssignment: 10
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 30
|
||||||
|
PenaltyBreakComment: 10
|
||||||
|
PenaltyBreakFirstLessLess: 0
|
||||||
|
PenaltyBreakString: 10
|
||||||
|
PenaltyExcessCharacter: 100
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
|
|
||||||
|
PointerAlignment: Right
|
||||||
|
ReflowComments: false
|
||||||
|
SortIncludes: false
|
||||||
|
SortUsingDeclarations: false
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: ControlStatementsExceptForEachMacros
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpacesInContainerLiterals: false
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: Cpp03
|
||||||
|
TabWidth: 8
|
||||||
UseTab: Always
|
UseTab: Always
|
19
MCInst.c
19
MCInst.c
|
@ -207,7 +207,8 @@ void MCOperand_CreateImm0(MCInst *mcInst, int64_t Val)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if any operand of the MCInstrDesc is predicable
|
/// Check if any operand of the MCInstrDesc is predicable
|
||||||
bool MCInst_isPredicable(const MCInstrDesc *MIDesc) {
|
bool MCInst_isPredicable(const MCInstrDesc *MIDesc)
|
||||||
|
{
|
||||||
const MCOperandInfo *OpInfo = MIDesc->OpInfo;
|
const MCOperandInfo *OpInfo = MIDesc->OpInfo;
|
||||||
unsigned NumOps = MIDesc->NumOperands;
|
unsigned NumOps = MIDesc->NumOperands;
|
||||||
for (unsigned i = 0; i < NumOps; ++i) {
|
for (unsigned i = 0; i < NumOps; ++i) {
|
||||||
|
@ -221,7 +222,8 @@ bool MCInst_isPredicable(const MCInstrDesc *MIDesc) {
|
||||||
/// Checks if tied operands exist in the instruction and sets
|
/// Checks if tied operands exist in the instruction and sets
|
||||||
/// - The writeback flag in detail
|
/// - The writeback flag in detail
|
||||||
/// - Saves the indices of the tied destination operands.
|
/// - Saves the indices of the tied destination operands.
|
||||||
void MCInst_handleWriteback(MCInst *MI, const MCInstrDesc *InstDesc) {
|
void MCInst_handleWriteback(MCInst *MI, const MCInstrDesc *InstDesc)
|
||||||
|
{
|
||||||
const MCOperandInfo *OpInfo = InstDesc[MCInst_getOpcode(MI)].OpInfo;
|
const MCOperandInfo *OpInfo = InstDesc[MCInst_getOpcode(MI)].OpInfo;
|
||||||
unsigned short NumOps = InstDesc[MCInst_getOpcode(MI)].NumOperands;
|
unsigned short NumOps = InstDesc[MCInst_getOpcode(MI)].NumOperands;
|
||||||
|
|
||||||
|
@ -229,13 +231,15 @@ void MCInst_handleWriteback(MCInst *MI, const MCInstrDesc *InstDesc) {
|
||||||
for (i = 0; i < NumOps; ++i) {
|
for (i = 0; i < NumOps; ++i) {
|
||||||
if (MCOperandInfo_isTiedToOp(&OpInfo[i])) {
|
if (MCOperandInfo_isTiedToOp(&OpInfo[i])) {
|
||||||
int idx = MCOperandInfo_getOperandConstraint(
|
int idx = MCOperandInfo_getOperandConstraint(
|
||||||
&InstDesc[MCInst_getOpcode(MI)], i, MCOI_TIED_TO);
|
&InstDesc[MCInst_getOpcode(MI)], i,
|
||||||
|
MCOI_TIED_TO);
|
||||||
|
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (i >= MAX_MC_OPS) {
|
if (i >= MAX_MC_OPS) {
|
||||||
assert(0 && "Maximum number of MC operands reached.");
|
assert(0 &&
|
||||||
|
"Maximum number of MC operands reached.");
|
||||||
}
|
}
|
||||||
MI->tied_op_idx[i] = idx;
|
MI->tied_op_idx[i] = idx;
|
||||||
|
|
||||||
|
@ -247,7 +251,8 @@ void MCInst_handleWriteback(MCInst *MI, const MCInstrDesc *InstDesc) {
|
||||||
|
|
||||||
/// Check if operand with OpNum is tied by another operand
|
/// Check if operand with OpNum is tied by another operand
|
||||||
/// (operand is tying destination).
|
/// (operand is tying destination).
|
||||||
bool MCInst_opIsTied(const MCInst *MI, unsigned OpNum) {
|
bool MCInst_opIsTied(const MCInst *MI, unsigned OpNum)
|
||||||
|
{
|
||||||
assert(OpNum < MAX_MC_OPS && "Maximum number of MC operands exceeded.");
|
assert(OpNum < MAX_MC_OPS && "Maximum number of MC operands exceeded.");
|
||||||
for (int i = 0; i < MAX_MC_OPS; ++i) {
|
for (int i = 0; i < MAX_MC_OPS; ++i) {
|
||||||
if (MI->tied_op_idx[i] == OpNum)
|
if (MI->tied_op_idx[i] == OpNum)
|
||||||
|
@ -258,8 +263,8 @@ bool MCInst_opIsTied(const MCInst *MI, unsigned OpNum) {
|
||||||
|
|
||||||
/// Check if operand with OpNum is tying another operand
|
/// Check if operand with OpNum is tying another operand
|
||||||
/// (operand is tying src).
|
/// (operand is tying src).
|
||||||
bool MCInst_opIsTying(const MCInst *MI, unsigned OpNum) {
|
bool MCInst_opIsTying(const MCInst *MI, unsigned OpNum)
|
||||||
|
{
|
||||||
assert(OpNum < MAX_MC_OPS && "Maximum number of MC operands exceeded.");
|
assert(OpNum < MAX_MC_OPS && "Maximum number of MC operands exceeded.");
|
||||||
return MI->tied_op_idx[OpNum] != -1;
|
return MI->tied_op_idx[OpNum] != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
3
MCInst.h
3
MCInst.h
|
@ -120,7 +120,8 @@ struct MCInst {
|
||||||
uint8_t x86_prefix[4];
|
uint8_t x86_prefix[4];
|
||||||
uint8_t imm_size; // immediate size for X86_OP_IMM operand
|
uint8_t imm_size; // immediate size for X86_OP_IMM operand
|
||||||
bool writeback; // writeback for ARM
|
bool writeback; // writeback for ARM
|
||||||
int8_t tied_op_idx[MAX_MC_OPS]; ///< Tied operand indices. Index = Src op; Value: Dest op
|
int8_t tied_op_idx
|
||||||
|
[MAX_MC_OPS]; ///< Tied operand indices. Index = Src op; Value: Dest op
|
||||||
// operand access index for list of registers sharing the same access right (for ARM)
|
// operand access index for list of registers sharing the same access right (for ARM)
|
||||||
uint8_t ac_idx;
|
uint8_t ac_idx;
|
||||||
uint8_t popcode_adjust; // Pseudo X86 instruction adjust
|
uint8_t popcode_adjust; // Pseudo X86 instruction adjust
|
||||||
|
|
|
@ -18,7 +18,8 @@ bool MCOperandInfo_isOptionalDef(const MCOperandInfo *m)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if operand is tied to another one.
|
/// Checks if operand is tied to another one.
|
||||||
bool MCOperandInfo_isTiedToOp(const MCOperandInfo *m) {
|
bool MCOperandInfo_isTiedToOp(const MCOperandInfo *m)
|
||||||
|
{
|
||||||
if (m->Constraints & (1 << MCOI_TIED_TO))
|
if (m->Constraints & (1 << MCOI_TIED_TO))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
|
@ -26,8 +27,10 @@ bool MCOperandInfo_isTiedToOp(const MCOperandInfo *m) {
|
||||||
|
|
||||||
/// Returns the value of the specified operand constraint if
|
/// Returns the value of the specified operand constraint if
|
||||||
/// it is present. Returns -1 if it is not present.
|
/// it is present. Returns -1 if it is not present.
|
||||||
int MCOperandInfo_getOperandConstraint(const MCInstrDesc *InstrDesc, unsigned OpNum,
|
int MCOperandInfo_getOperandConstraint(const MCInstrDesc *InstrDesc,
|
||||||
MCOI_OperandConstraint Constraint) {
|
unsigned OpNum,
|
||||||
|
MCOI_OperandConstraint Constraint)
|
||||||
|
{
|
||||||
const MCOperandInfo OpInfo = InstrDesc->OpInfo[OpNum];
|
const MCOperandInfo OpInfo = InstrDesc->OpInfo[OpNum];
|
||||||
if (OpNum < InstrDesc->NumOperands &&
|
if (OpNum < InstrDesc->NumOperands &&
|
||||||
(OpInfo.Constraints & (1 << Constraint))) {
|
(OpInfo.Constraints & (1 << Constraint))) {
|
||||||
|
|
|
@ -160,7 +160,8 @@ bool MCOperandInfo_isOptionalDef(const MCOperandInfo *m);
|
||||||
|
|
||||||
bool MCOperandInfo_isTiedToOp(const MCOperandInfo *m);
|
bool MCOperandInfo_isTiedToOp(const MCOperandInfo *m);
|
||||||
|
|
||||||
int MCOperandInfo_getOperandConstraint(const MCInstrDesc *OpInfo, unsigned OpNum,
|
int MCOperandInfo_getOperandConstraint(const MCInstrDesc *OpInfo,
|
||||||
|
unsigned OpNum,
|
||||||
MCOI_OperandConstraint Constraint);
|
MCOI_OperandConstraint Constraint);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
15
Mapping.h
15
Mapping.h
|
@ -24,8 +24,8 @@ typedef struct insn_map {
|
||||||
///< this instruction
|
///< this instruction
|
||||||
uint16_t regs_mod[MAX_IMPL_W_REGS]; ///< list of implicit registers modified
|
uint16_t regs_mod[MAX_IMPL_W_REGS]; ///< list of implicit registers modified
|
||||||
///< by this instruction
|
///< by this instruction
|
||||||
unsigned char
|
unsigned char groups
|
||||||
groups[MAX_NUM_GROUPS]; ///< list of group this instruction belong to
|
[MAX_NUM_GROUPS]; ///< list of group this instruction belong to
|
||||||
bool branch; // branch instruction?
|
bool branch; // branch instruction?
|
||||||
bool indirect_branch; // indirect branch instruction?
|
bool indirect_branch; // indirect branch instruction?
|
||||||
#endif
|
#endif
|
||||||
|
@ -54,7 +54,8 @@ typedef struct {
|
||||||
|
|
||||||
///< MCOperands of an instruction.
|
///< MCOperands of an instruction.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
mapping_op ops[MAX_NO_INSN_MAP_OPS]; ///< NULL terminated array of insn_op.
|
mapping_op
|
||||||
|
ops[MAX_NO_INSN_MAP_OPS]; ///< NULL terminated array of insn_op.
|
||||||
} map_insn_ops;
|
} map_insn_ops;
|
||||||
|
|
||||||
/// Only usable by `auto-sync` archs!
|
/// Only usable by `auto-sync` archs!
|
||||||
|
@ -79,7 +80,8 @@ const cs_ac_type mapping_get_op_access(MCInst *MI, unsigned OpNum,
|
||||||
/// Only usable by `auto-sync` archs!
|
/// Only usable by `auto-sync` archs!
|
||||||
#define map_get_op_access(MI, OpNum) \
|
#define map_get_op_access(MI, OpNum) \
|
||||||
mapping_get_op_access(MI, OpNum, insn_operands, \
|
mapping_get_op_access(MI, OpNum, insn_operands, \
|
||||||
sizeof(insn_operands) / sizeof(insn_operands[0]))
|
sizeof(insn_operands) / \
|
||||||
|
sizeof(insn_operands[0]))
|
||||||
|
|
||||||
///< Map for ids to their string
|
///< Map for ids to their string
|
||||||
typedef struct name_map {
|
typedef struct name_map {
|
||||||
|
@ -131,7 +133,10 @@ DEFINE_inc_detail_op_count(ppc, PPC);
|
||||||
DEFINE_dec_detail_op_count(ppc, PPC);
|
DEFINE_dec_detail_op_count(ppc, PPC);
|
||||||
|
|
||||||
/// Returns true if a memory operand is currently edited.
|
/// Returns true if a memory operand is currently edited.
|
||||||
static inline bool doing_mem(const MCInst *MI) { return MI->csh->doing_mem; }
|
static inline bool doing_mem(const MCInst *MI)
|
||||||
|
{
|
||||||
|
return MI->csh->doing_mem;
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets the doing_mem flag to @status.
|
/// Sets the doing_mem flag to @status.
|
||||||
static inline void set_doing_mem(const MCInst *MI, bool status)
|
static inline void set_doing_mem(const MCInst *MI, bool status)
|
||||||
|
|
|
@ -119,8 +119,10 @@ typedef enum {
|
||||||
|
|
||||||
CS_DATA_TYPE_v1i128 = 85, // 1 x i128
|
CS_DATA_TYPE_v1i128 = 85, // 1 x i128
|
||||||
|
|
||||||
CS_DATA_TYPE_FIRST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE = CS_DATA_TYPE_v1i1,
|
CS_DATA_TYPE_FIRST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE =
|
||||||
CS_DATA_TYPE_LAST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE = CS_DATA_TYPE_v1i128,
|
CS_DATA_TYPE_v1i1,
|
||||||
|
CS_DATA_TYPE_LAST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE =
|
||||||
|
CS_DATA_TYPE_v1i128,
|
||||||
|
|
||||||
CS_DATA_TYPE_v1f16 = 86, // 1 x f16
|
CS_DATA_TYPE_v1f16 = 86, // 1 x f16
|
||||||
CS_DATA_TYPE_v2f16 = 87, // 2 x f16
|
CS_DATA_TYPE_v2f16 = 87, // 2 x f16
|
||||||
|
@ -219,8 +221,10 @@ typedef enum {
|
||||||
CS_DATA_TYPE_nxv16i64 = 165, // n x 16 x i64
|
CS_DATA_TYPE_nxv16i64 = 165, // n x 16 x i64
|
||||||
CS_DATA_TYPE_nxv32i64 = 166, // n x 32 x i64
|
CS_DATA_TYPE_nxv32i64 = 166, // n x 32 x i64
|
||||||
|
|
||||||
CS_DATA_TYPE_FIRST_INTEGER_SCALABLE_VECTOR_VALUETYPE = CS_DATA_TYPE_nxv1i1,
|
CS_DATA_TYPE_FIRST_INTEGER_SCALABLE_VECTOR_VALUETYPE =
|
||||||
CS_DATA_TYPE_LAST_INTEGER_SCALABLE_VECTOR_VALUETYPE = CS_DATA_TYPE_nxv32i64,
|
CS_DATA_TYPE_nxv1i1,
|
||||||
|
CS_DATA_TYPE_LAST_INTEGER_SCALABLE_VECTOR_VALUETYPE =
|
||||||
|
CS_DATA_TYPE_nxv32i64,
|
||||||
|
|
||||||
CS_DATA_TYPE_nxv1f16 = 167, // n x 1 x f16
|
CS_DATA_TYPE_nxv1f16 = 167, // n x 1 x f16
|
||||||
CS_DATA_TYPE_nxv2f16 = 168, // n x 2 x f16
|
CS_DATA_TYPE_nxv2f16 = 168, // n x 2 x f16
|
||||||
|
@ -258,7 +262,8 @@ typedef enum {
|
||||||
|
|
||||||
CS_DATA_TYPE_x86mmx = 188, // This is an X86 MMX value
|
CS_DATA_TYPE_x86mmx = 188, // This is an X86 MMX value
|
||||||
|
|
||||||
CS_DATA_TYPE_Glue = 189, // This glues nodes together during pre-RA sched
|
CS_DATA_TYPE_Glue =
|
||||||
|
189, // This glues nodes together during pre-RA sched
|
||||||
|
|
||||||
CS_DATA_TYPE_isVoid = 190, // This has no value
|
CS_DATA_TYPE_isVoid = 190, // This has no value
|
||||||
|
|
||||||
|
@ -339,10 +344,14 @@ inline bool isInteger(cs_data_type SimpleTy)
|
||||||
{
|
{
|
||||||
return ((SimpleTy >= CS_DATA_TYPE_FIRST_INTEGER_VALUETYPE &&
|
return ((SimpleTy >= CS_DATA_TYPE_FIRST_INTEGER_VALUETYPE &&
|
||||||
SimpleTy <= CS_DATA_TYPE_LAST_INTEGER_VALUETYPE) ||
|
SimpleTy <= CS_DATA_TYPE_LAST_INTEGER_VALUETYPE) ||
|
||||||
(SimpleTy >= CS_DATA_TYPE_FIRST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE &&
|
(SimpleTy >=
|
||||||
SimpleTy <= CS_DATA_TYPE_LAST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE) ||
|
CS_DATA_TYPE_FIRST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE &&
|
||||||
(SimpleTy >= CS_DATA_TYPE_FIRST_INTEGER_SCALABLE_VECTOR_VALUETYPE &&
|
SimpleTy <=
|
||||||
SimpleTy <= CS_DATA_TYPE_LAST_INTEGER_SCALABLE_VECTOR_VALUETYPE));
|
CS_DATA_TYPE_LAST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE) ||
|
||||||
|
(SimpleTy >=
|
||||||
|
CS_DATA_TYPE_FIRST_INTEGER_SCALABLE_VECTOR_VALUETYPE &&
|
||||||
|
SimpleTy <=
|
||||||
|
CS_DATA_TYPE_LAST_INTEGER_SCALABLE_VECTOR_VALUETYPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if this is an integer, not including vectors.
|
/// Return true if this is an integer, not including vectors.
|
||||||
|
@ -376,37 +385,51 @@ inline bool isFixedLengthVector(cs_data_type SimpleTy)
|
||||||
/// Return true if this is a 16-bit vector type.
|
/// Return true if this is a 16-bit vector type.
|
||||||
inline bool is16BitVector(cs_data_type SimpleTy)
|
inline bool is16BitVector(cs_data_type SimpleTy)
|
||||||
{
|
{
|
||||||
return (SimpleTy == CS_DATA_TYPE_v2i8 || SimpleTy == CS_DATA_TYPE_v1i16 ||
|
return (SimpleTy == CS_DATA_TYPE_v2i8 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v16i1 || SimpleTy == CS_DATA_TYPE_v1f16);
|
SimpleTy == CS_DATA_TYPE_v1i16 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v16i1 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v1f16);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if this is a 32-bit vector type.
|
/// Return true if this is a 32-bit vector type.
|
||||||
inline bool is32BitVector(cs_data_type SimpleTy)
|
inline bool is32BitVector(cs_data_type SimpleTy)
|
||||||
{
|
{
|
||||||
return (SimpleTy == CS_DATA_TYPE_v32i1 || SimpleTy == CS_DATA_TYPE_v4i8 ||
|
return (SimpleTy == CS_DATA_TYPE_v32i1 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v2i16 || SimpleTy == CS_DATA_TYPE_v1i32 ||
|
SimpleTy == CS_DATA_TYPE_v4i8 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v2f16 || SimpleTy == CS_DATA_TYPE_v2bf16 ||
|
SimpleTy == CS_DATA_TYPE_v2i16 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v1i32 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v2f16 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v2bf16 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v1f32);
|
SimpleTy == CS_DATA_TYPE_v1f32);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if this is a 64-bit vector type.
|
/// Return true if this is a 64-bit vector type.
|
||||||
inline bool is64BitVector(cs_data_type SimpleTy)
|
inline bool is64BitVector(cs_data_type SimpleTy)
|
||||||
{
|
{
|
||||||
return (SimpleTy == CS_DATA_TYPE_v64i1 || SimpleTy == CS_DATA_TYPE_v8i8 ||
|
return (SimpleTy == CS_DATA_TYPE_v64i1 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v4i16 || SimpleTy == CS_DATA_TYPE_v2i32 ||
|
SimpleTy == CS_DATA_TYPE_v8i8 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v1i64 || SimpleTy == CS_DATA_TYPE_v4f16 ||
|
SimpleTy == CS_DATA_TYPE_v4i16 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v4bf16 || SimpleTy == CS_DATA_TYPE_v2f32 ||
|
SimpleTy == CS_DATA_TYPE_v2i32 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v1i64 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v4f16 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v4bf16 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v2f32 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v1f64);
|
SimpleTy == CS_DATA_TYPE_v1f64);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if this is a 128-bit vector type.
|
/// Return true if this is a 128-bit vector type.
|
||||||
inline bool is128BitVector(cs_data_type SimpleTy)
|
inline bool is128BitVector(cs_data_type SimpleTy)
|
||||||
{
|
{
|
||||||
return (SimpleTy == CS_DATA_TYPE_v128i1 || SimpleTy == CS_DATA_TYPE_v16i8 ||
|
return (SimpleTy == CS_DATA_TYPE_v128i1 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v8i16 || SimpleTy == CS_DATA_TYPE_v4i32 ||
|
SimpleTy == CS_DATA_TYPE_v16i8 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v2i64 || SimpleTy == CS_DATA_TYPE_v1i128 ||
|
SimpleTy == CS_DATA_TYPE_v8i16 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v8f16 || SimpleTy == CS_DATA_TYPE_v8bf16 ||
|
SimpleTy == CS_DATA_TYPE_v4i32 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v4f32 || SimpleTy == CS_DATA_TYPE_v2f64);
|
SimpleTy == CS_DATA_TYPE_v2i64 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v1i128 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v8f16 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v8bf16 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v4f32 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v2f64);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if this is a 256-bit vector type.
|
/// Return true if this is a 256-bit vector type.
|
||||||
|
@ -414,44 +437,58 @@ inline bool is256BitVector(cs_data_type SimpleTy)
|
||||||
{
|
{
|
||||||
return (SimpleTy == CS_DATA_TYPE_v16f16 ||
|
return (SimpleTy == CS_DATA_TYPE_v16f16 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v16bf16 ||
|
SimpleTy == CS_DATA_TYPE_v16bf16 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v8f32 || SimpleTy == CS_DATA_TYPE_v4f64 ||
|
SimpleTy == CS_DATA_TYPE_v8f32 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v32i8 || SimpleTy == CS_DATA_TYPE_v16i16 ||
|
SimpleTy == CS_DATA_TYPE_v4f64 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v8i32 || SimpleTy == CS_DATA_TYPE_v4i64 ||
|
SimpleTy == CS_DATA_TYPE_v32i8 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v16i16 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v8i32 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v4i64 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v256i1 ||
|
SimpleTy == CS_DATA_TYPE_v256i1 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v128i2 || SimpleTy == CS_DATA_TYPE_v64i4);
|
SimpleTy == CS_DATA_TYPE_v128i2 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v64i4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if this is a 512-bit vector type.
|
/// Return true if this is a 512-bit vector type.
|
||||||
inline bool is512BitVector(cs_data_type SimpleTy)
|
inline bool is512BitVector(cs_data_type SimpleTy)
|
||||||
{
|
{
|
||||||
return (
|
return (SimpleTy == CS_DATA_TYPE_v32f16 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v32f16 || SimpleTy == CS_DATA_TYPE_v32bf16 ||
|
SimpleTy == CS_DATA_TYPE_v32bf16 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v16f32 || SimpleTy == CS_DATA_TYPE_v8f64 ||
|
SimpleTy == CS_DATA_TYPE_v16f32 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v512i1 || SimpleTy == CS_DATA_TYPE_v256i2 ||
|
SimpleTy == CS_DATA_TYPE_v8f64 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v128i4 || SimpleTy == CS_DATA_TYPE_v64i8 ||
|
SimpleTy == CS_DATA_TYPE_v512i1 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v32i16 || SimpleTy == CS_DATA_TYPE_v16i32 ||
|
SimpleTy == CS_DATA_TYPE_v256i2 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v128i4 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v64i8 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v32i16 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v16i32 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v8i64);
|
SimpleTy == CS_DATA_TYPE_v8i64);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if this is a 1024-bit vector type.
|
/// Return true if this is a 1024-bit vector type.
|
||||||
inline bool is1024BitVector(cs_data_type SimpleTy)
|
inline bool is1024BitVector(cs_data_type SimpleTy)
|
||||||
{
|
{
|
||||||
return (
|
return (SimpleTy == CS_DATA_TYPE_v1024i1 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v1024i1 || SimpleTy == CS_DATA_TYPE_v128i8 ||
|
SimpleTy == CS_DATA_TYPE_v128i8 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v64i16 || SimpleTy == CS_DATA_TYPE_v32i32 ||
|
SimpleTy == CS_DATA_TYPE_v64i16 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v16i64 || SimpleTy == CS_DATA_TYPE_v64f16 ||
|
SimpleTy == CS_DATA_TYPE_v32i32 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v32f32 || SimpleTy == CS_DATA_TYPE_v16f64 ||
|
SimpleTy == CS_DATA_TYPE_v16i64 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v64f16 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v32f32 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v16f64 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v64bf16);
|
SimpleTy == CS_DATA_TYPE_v64bf16);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if this is a 2048-bit vector type.
|
/// Return true if this is a 2048-bit vector type.
|
||||||
inline bool is2048BitVector(cs_data_type SimpleTy)
|
inline bool is2048BitVector(cs_data_type SimpleTy)
|
||||||
{
|
{
|
||||||
return (
|
return (SimpleTy == CS_DATA_TYPE_v256i8 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v256i8 || SimpleTy == CS_DATA_TYPE_v128i16 ||
|
SimpleTy == CS_DATA_TYPE_v128i16 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v64i32 || SimpleTy == CS_DATA_TYPE_v32i64 ||
|
SimpleTy == CS_DATA_TYPE_v64i32 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v128f16 || SimpleTy == CS_DATA_TYPE_v64f32 ||
|
SimpleTy == CS_DATA_TYPE_v32i64 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v32f64 || SimpleTy == CS_DATA_TYPE_v128bf16 ||
|
SimpleTy == CS_DATA_TYPE_v128f16 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v64f32 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v32f64 ||
|
||||||
|
SimpleTy == CS_DATA_TYPE_v128bf16 ||
|
||||||
SimpleTy == CS_DATA_TYPE_v2048i1);
|
SimpleTy == CS_DATA_TYPE_v2048i1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,8 @@ typedef enum cs_op_type {
|
||||||
CS_OP_REG, ///< Register operand.
|
CS_OP_REG, ///< Register operand.
|
||||||
CS_OP_IMM, ///< Immediate operand.
|
CS_OP_IMM, ///< Immediate operand.
|
||||||
CS_OP_FP, ///< Floating-Point operand.
|
CS_OP_FP, ///< Floating-Point operand.
|
||||||
CS_OP_MEM = 0x80, ///< Memory operand. Can be ORed with another operand type.
|
CS_OP_MEM =
|
||||||
|
0x80, ///< Memory operand. Can be ORed with another operand type.
|
||||||
} cs_op_type;
|
} cs_op_type;
|
||||||
|
|
||||||
/// Common instruction operand access types - to be consistent across all architectures.
|
/// Common instruction operand access types - to be consistent across all architectures.
|
||||||
|
@ -335,10 +336,12 @@ typedef struct cs_opt_skipdata {
|
||||||
/// if cs_detail changes, in particular if a field is added after the union,
|
/// if cs_detail changes, in particular if a field is added after the union,
|
||||||
/// then update arch/ARCH/ARCHDisassembler.c accordingly
|
/// then update arch/ARCH/ARCHDisassembler.c accordingly
|
||||||
typedef struct cs_detail {
|
typedef struct cs_detail {
|
||||||
uint16_t regs_read[MAX_IMPL_R_REGS]; ///< list of implicit registers read by this insn
|
uint16_t regs_read
|
||||||
|
[MAX_IMPL_R_REGS]; ///< list of implicit registers read by this insn
|
||||||
uint8_t regs_read_count; ///< number of implicit registers read by this insn
|
uint8_t regs_read_count; ///< number of implicit registers read by this insn
|
||||||
|
|
||||||
uint16_t regs_write[MAX_IMPL_W_REGS]; ///< list of implicit registers modified by this insn
|
uint16_t regs_write
|
||||||
|
[MAX_IMPL_W_REGS]; ///< list of implicit registers modified by this insn
|
||||||
uint8_t regs_write_count; ///< number of implicit registers modified by this insn
|
uint8_t regs_write_count; ///< number of implicit registers modified by this insn
|
||||||
|
|
||||||
uint8_t groups[MAX_NUM_GROUPS]; ///< list of group this instruction belong to
|
uint8_t groups[MAX_NUM_GROUPS]; ///< list of group this instruction belong to
|
||||||
|
|
4
utils.c
4
utils.c
|
@ -121,8 +121,8 @@ uint32_t readBytes32(MCInst *MI, const uint8_t *Bytes)
|
||||||
Insn = (Bytes[3] << 0) | (Bytes[2] << 8) | (Bytes[1] << 16) |
|
Insn = (Bytes[3] << 0) | (Bytes[2] << 8) | (Bytes[1] << 16) |
|
||||||
((uint32_t)Bytes[0] << 24);
|
((uint32_t)Bytes[0] << 24);
|
||||||
else
|
else
|
||||||
Insn = ((uint32_t)Bytes[3] << 24) | (Bytes[2] << 16) | (Bytes[1] << 8) |
|
Insn = ((uint32_t)Bytes[3] << 24) | (Bytes[2] << 16) |
|
||||||
(Bytes[0] << 0);
|
(Bytes[1] << 8) | (Bytes[0] << 0);
|
||||||
return Insn;
|
return Insn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue