rabbitizer/include/instructions/RabbitizerInstrDescriptor.h

132 lines
4.4 KiB
C
Raw Normal View History

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"
#include "RabbitizerOperandType.h"
2022-06-03 13:46:51 -04:00
#include "RabbitizerInstrId.h"
#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;
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 {
RabbitizerOperandType operands[4];
2022-06-03 13:46:51 -04:00
RabbitizerInstrType instrType;
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;
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
bool isPseudo;
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
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
bool RabbitizerInstrDescriptor_canBeHi(const RabbitizerInstrDescriptor *self);
2022-07-09 19:19:53 -04:00
NODISCARD NON_NULL(1) PURE
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
bool RabbitizerInstrDescriptor_isPseudo(const RabbitizerInstrDescriptor *self);
2022-07-09 19:19:53 -04:00
NODISCARD NON_NULL(1) PURE
RabbitizerArchitectureVersion RabbitizerInstrDescriptor_getArchitectureVersion(const RabbitizerInstrDescriptor *self);
2022-06-03 13:46:51 -04:00
#endif