2022-06-03 13:46:51 -04:00
|
|
|
/* SPDX-FileCopyrightText: © 2022 Decompollaborate */
|
|
|
|
/* SPDX-License-Identifier: MIT */
|
|
|
|
|
|
|
|
#ifndef RABBITIZER_INSTRDESCRIPTOR_H
|
|
|
|
#define RABBITIZER_INSTRDESCRIPTOR_H
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2022-07-09 19:19:53 -04:00
|
|
|
#include "common/Utils.h"
|
2022-06-07 23:30:01 -04:00
|
|
|
#include "RabbitizerOperandType.h"
|
2022-06-03 13:46:51 -04:00
|
|
|
#include "RabbitizerInstrId.h"
|
2022-08-27 12:22:48 -04:00
|
|
|
#include "RabbitizerInstrSuffix.h"
|
2022-06-03 13:46:51 -04:00
|
|
|
|
|
|
|
typedef enum RabbitizerInstrType {
|
|
|
|
RABBITIZER_INSTR_TYPE_UNKNOWN,
|
|
|
|
RABBITIZER_INSTR_TYPE_J,
|
|
|
|
RABBITIZER_INSTR_TYPE_I,
|
|
|
|
RABBITIZER_INSTR_TYPE_R,
|
|
|
|
RABBITIZER_INSTR_TYPE_REGIMM,
|
|
|
|
RABBITIZER_INSTR_TYPE_MAX,
|
|
|
|
} RabbitizerInstrType;
|
|
|
|
|
2022-07-01 12:07:45 -04:00
|
|
|
typedef enum RabbitizerArchitectureVersion {
|
|
|
|
RABBITIZER_ARCHVERSION_INVALID=-1,
|
|
|
|
RABBITIZER_ARCHVERSION_UNKNOWN,
|
|
|
|
RABBITIZER_ARCHVERSION_MIPS_I,
|
|
|
|
RABBITIZER_ARCHVERSION_MIPS_II,
|
|
|
|
RABBITIZER_ARCHVERSION_MIPS_III,
|
|
|
|
RABBITIZER_ARCHVERSION_MIPS_IV
|
|
|
|
} RabbitizerArchitectureVersion;
|
|
|
|
|
2022-06-03 13:46:51 -04:00
|
|
|
typedef struct RabbitizerInstrDescriptor {
|
2022-06-07 23:30:01 -04:00
|
|
|
RabbitizerOperandType operands[4];
|
2022-06-03 13:46:51 -04:00
|
|
|
RabbitizerInstrType instrType;
|
|
|
|
|
2022-08-27 12:22:48 -04:00
|
|
|
RabbitizerInstrSuffix instrSuffix;
|
|
|
|
|
2022-06-03 13:46:51 -04:00
|
|
|
bool isBranch;
|
|
|
|
bool isBranchLikely;
|
|
|
|
bool isJump;
|
|
|
|
bool isTrap;
|
|
|
|
|
|
|
|
bool isFloat;
|
|
|
|
bool isDouble;
|
|
|
|
|
|
|
|
bool isUnsigned;
|
|
|
|
|
|
|
|
bool modifiesRt;
|
|
|
|
bool modifiesRd;
|
|
|
|
|
2022-06-08 02:17:35 -04:00
|
|
|
bool notEmitedByCompilers;
|
|
|
|
|
2022-07-07 15:48:10 -04:00
|
|
|
bool canBeHi;
|
|
|
|
bool canBeLo;
|
2022-06-08 02:17:35 -04:00
|
|
|
bool doesLink; // "and link" family of instructions
|
|
|
|
bool doesDereference;
|
2022-07-05 13:32:24 -04:00
|
|
|
bool doesLoad; // loads data from memory
|
|
|
|
bool doesStore; // stores data to memory
|
2022-06-11 17:49:33 -04:00
|
|
|
bool maybeIsMove;
|
2022-06-08 02:17:35 -04:00
|
|
|
|
2022-07-01 12:07:45 -04:00
|
|
|
bool isPseudo;
|
|
|
|
|
2022-08-27 12:22:48 -04:00
|
|
|
RabbitizerArchitectureVersion architectureVersion; // TODO: consider removing
|
2022-06-03 13:46:51 -04:00
|
|
|
} RabbitizerInstrDescriptor;
|
|
|
|
|
2022-06-03 14:19:43 -04:00
|
|
|
// TODO: less redundant name
|
2022-06-03 20:19:58 -04:00
|
|
|
extern const RabbitizerInstrDescriptor RabbitizerInstrDescriptor_Descriptors[];
|
2022-06-03 13:46:51 -04:00
|
|
|
|
2022-06-04 02:17:25 -04:00
|
|
|
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-06-08 22:44:43 -04:00
|
|
|
bool RabbitizerInstrDescriptor_isUnknownType(const RabbitizerInstrDescriptor *self);
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-06-05 13:19:45 -04:00
|
|
|
bool RabbitizerInstrDescriptor_isJType(const RabbitizerInstrDescriptor *self);
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-06-05 13:19:45 -04:00
|
|
|
bool RabbitizerInstrDescriptor_isIType(const RabbitizerInstrDescriptor *self);
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-06-05 13:19:45 -04:00
|
|
|
bool RabbitizerInstrDescriptor_isRType(const RabbitizerInstrDescriptor *self);
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-06-08 22:44:43 -04:00
|
|
|
bool RabbitizerInstrDescriptor_isRegimmType(const RabbitizerInstrDescriptor *self);
|
2022-06-04 02:17:25 -04:00
|
|
|
|
2022-08-27 12:22:48 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
|
|
|
RabbitizerInstrSuffix RabbitizerInstrDescriptor_instrSuffix(const RabbitizerInstrDescriptor *self);
|
|
|
|
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-06-05 13:19:45 -04:00
|
|
|
bool RabbitizerInstrDescriptor_isBranch(const RabbitizerInstrDescriptor *self);
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-06-05 13:19:45 -04:00
|
|
|
bool RabbitizerInstrDescriptor_isBranchLikely(const RabbitizerInstrDescriptor *self);
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-06-05 13:19:45 -04:00
|
|
|
bool RabbitizerInstrDescriptor_isJump(const RabbitizerInstrDescriptor *self);
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-06-05 13:19:45 -04:00
|
|
|
bool RabbitizerInstrDescriptor_isTrap(const RabbitizerInstrDescriptor *self);
|
2022-06-04 02:17:25 -04:00
|
|
|
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-06-05 13:19:45 -04:00
|
|
|
bool RabbitizerInstrDescriptor_isFloat(const RabbitizerInstrDescriptor *self);
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-06-05 13:19:45 -04:00
|
|
|
bool RabbitizerInstrDescriptor_isDouble(const RabbitizerInstrDescriptor *self);
|
2022-06-04 02:17:25 -04:00
|
|
|
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-06-05 13:19:45 -04:00
|
|
|
bool RabbitizerInstrDescriptor_isUnsigned(const RabbitizerInstrDescriptor *self);
|
2022-06-04 02:17:25 -04:00
|
|
|
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-06-05 13:19:45 -04:00
|
|
|
bool RabbitizerInstrDescriptor_modifiesRt(const RabbitizerInstrDescriptor *self);
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-06-05 13:19:45 -04:00
|
|
|
bool RabbitizerInstrDescriptor_modifiesRd(const RabbitizerInstrDescriptor *self);
|
2022-06-04 02:17:25 -04:00
|
|
|
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-06-08 02:17:35 -04:00
|
|
|
bool RabbitizerInstrDescriptor_notEmitedByCompilers(const RabbitizerInstrDescriptor *self);
|
|
|
|
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-07-07 15:48:10 -04:00
|
|
|
bool RabbitizerInstrDescriptor_canBeHi(const RabbitizerInstrDescriptor *self);
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-07-07 15:48:10 -04:00
|
|
|
bool RabbitizerInstrDescriptor_canBeLo(const RabbitizerInstrDescriptor *self);
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-06-08 02:17:35 -04:00
|
|
|
bool RabbitizerInstrDescriptor_doesLink(const RabbitizerInstrDescriptor *self);
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-06-08 02:17:35 -04:00
|
|
|
bool RabbitizerInstrDescriptor_doesDereference(const RabbitizerInstrDescriptor *self);
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-07-05 13:32:24 -04:00
|
|
|
bool RabbitizerInstrDescriptor_doesLoad(const RabbitizerInstrDescriptor *self);
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-07-05 13:32:24 -04:00
|
|
|
bool RabbitizerInstrDescriptor_doesStore(const RabbitizerInstrDescriptor *self);
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-06-11 17:49:33 -04:00
|
|
|
bool RabbitizerInstrDescriptor_maybeIsMove(const RabbitizerInstrDescriptor *self);
|
2022-06-08 02:17:35 -04:00
|
|
|
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-07-01 12:57:58 -04:00
|
|
|
bool RabbitizerInstrDescriptor_isPseudo(const RabbitizerInstrDescriptor *self);
|
|
|
|
|
2022-07-09 19:19:53 -04:00
|
|
|
NODISCARD NON_NULL(1) PURE
|
2022-07-01 12:57:58 -04:00
|
|
|
RabbitizerArchitectureVersion RabbitizerInstrDescriptor_getArchitectureVersion(const RabbitizerInstrDescriptor *self);
|
|
|
|
|
2022-06-03 13:46:51 -04:00
|
|
|
#endif
|