2022-06-03 17:46:51 +00:00
|
|
|
/* SPDX-FileCopyrightText: © 2022 Decompollaborate */
|
|
|
|
/* SPDX-License-Identifier: MIT */
|
|
|
|
|
|
|
|
#ifndef RABBITIZER_INSTRDESCRIPTOR_H
|
|
|
|
#define RABBITIZER_INSTRDESCRIPTOR_H
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2022-06-08 03:30:01 +00:00
|
|
|
#include "RabbitizerOperandType.h"
|
2022-06-03 17:46:51 +00:00
|
|
|
#include "RabbitizerInstrId.h"
|
|
|
|
|
|
|
|
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 16:07:45 +00: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 17:46:51 +00:00
|
|
|
typedef struct RabbitizerInstrDescriptor {
|
2022-06-08 03:30:01 +00:00
|
|
|
RabbitizerOperandType operands[4];
|
2022-06-03 17:46:51 +00:00
|
|
|
RabbitizerInstrType instrType;
|
|
|
|
|
|
|
|
bool isBranch;
|
|
|
|
bool isBranchLikely;
|
|
|
|
bool isJump;
|
|
|
|
bool isTrap;
|
|
|
|
|
|
|
|
bool isFloat;
|
|
|
|
bool isDouble;
|
|
|
|
|
|
|
|
bool isUnsigned;
|
|
|
|
|
|
|
|
bool modifiesRt;
|
|
|
|
bool modifiesRd;
|
|
|
|
|
2022-06-08 06:17:35 +00:00
|
|
|
bool notEmitedByCompilers;
|
|
|
|
|
|
|
|
bool isHiPair;
|
|
|
|
bool isLoPair;
|
|
|
|
bool doesLink; // "and link" family of instructions
|
|
|
|
bool doesDereference;
|
2022-07-05 17:32:24 +00:00
|
|
|
bool doesLoad; // loads data from memory
|
|
|
|
bool doesStore; // stores data to memory
|
2022-06-11 21:49:33 +00:00
|
|
|
bool maybeIsMove;
|
2022-06-08 06:17:35 +00:00
|
|
|
|
2022-07-01 16:07:45 +00:00
|
|
|
bool isPseudo;
|
|
|
|
|
2022-07-01 16:57:58 +00:00
|
|
|
RabbitizerArchitectureVersion architectureVersion;
|
2022-06-03 17:46:51 +00:00
|
|
|
} RabbitizerInstrDescriptor;
|
|
|
|
|
2022-06-03 18:19:43 +00:00
|
|
|
// TODO: less redundant name
|
2022-06-04 00:19:58 +00:00
|
|
|
extern const RabbitizerInstrDescriptor RabbitizerInstrDescriptor_Descriptors[];
|
2022-06-03 17:46:51 +00:00
|
|
|
|
2022-06-04 06:17:25 +00:00
|
|
|
|
2022-06-09 02:44:43 +00:00
|
|
|
bool RabbitizerInstrDescriptor_isUnknownType(const RabbitizerInstrDescriptor *self);
|
2022-06-05 17:19:45 +00:00
|
|
|
bool RabbitizerInstrDescriptor_isJType(const RabbitizerInstrDescriptor *self);
|
|
|
|
bool RabbitizerInstrDescriptor_isIType(const RabbitizerInstrDescriptor *self);
|
|
|
|
bool RabbitizerInstrDescriptor_isRType(const RabbitizerInstrDescriptor *self);
|
2022-06-09 02:44:43 +00:00
|
|
|
bool RabbitizerInstrDescriptor_isRegimmType(const RabbitizerInstrDescriptor *self);
|
2022-06-04 06:17:25 +00:00
|
|
|
|
2022-06-05 17:19:45 +00:00
|
|
|
bool RabbitizerInstrDescriptor_isBranch(const RabbitizerInstrDescriptor *self);
|
|
|
|
bool RabbitizerInstrDescriptor_isBranchLikely(const RabbitizerInstrDescriptor *self);
|
|
|
|
bool RabbitizerInstrDescriptor_isJump(const RabbitizerInstrDescriptor *self);
|
|
|
|
bool RabbitizerInstrDescriptor_isTrap(const RabbitizerInstrDescriptor *self);
|
2022-06-04 06:17:25 +00:00
|
|
|
|
2022-06-05 17:19:45 +00:00
|
|
|
bool RabbitizerInstrDescriptor_isFloat(const RabbitizerInstrDescriptor *self);
|
|
|
|
bool RabbitizerInstrDescriptor_isDouble(const RabbitizerInstrDescriptor *self);
|
2022-06-04 06:17:25 +00:00
|
|
|
|
2022-06-05 17:19:45 +00:00
|
|
|
bool RabbitizerInstrDescriptor_isUnsigned(const RabbitizerInstrDescriptor *self);
|
2022-06-04 06:17:25 +00:00
|
|
|
|
2022-06-05 17:19:45 +00:00
|
|
|
bool RabbitizerInstrDescriptor_modifiesRt(const RabbitizerInstrDescriptor *self);
|
|
|
|
bool RabbitizerInstrDescriptor_modifiesRd(const RabbitizerInstrDescriptor *self);
|
2022-06-04 06:17:25 +00:00
|
|
|
|
2022-06-08 06:17:35 +00:00
|
|
|
bool RabbitizerInstrDescriptor_notEmitedByCompilers(const RabbitizerInstrDescriptor *self);
|
|
|
|
|
|
|
|
bool RabbitizerInstrDescriptor_isHiPair(const RabbitizerInstrDescriptor *self);
|
|
|
|
bool RabbitizerInstrDescriptor_isLoPair(const RabbitizerInstrDescriptor *self);
|
|
|
|
bool RabbitizerInstrDescriptor_doesLink(const RabbitizerInstrDescriptor *self);
|
|
|
|
bool RabbitizerInstrDescriptor_doesDereference(const RabbitizerInstrDescriptor *self);
|
2022-07-05 17:32:24 +00:00
|
|
|
bool RabbitizerInstrDescriptor_doesLoad(const RabbitizerInstrDescriptor *self);
|
|
|
|
bool RabbitizerInstrDescriptor_doesStore(const RabbitizerInstrDescriptor *self);
|
2022-06-11 21:49:33 +00:00
|
|
|
bool RabbitizerInstrDescriptor_maybeIsMove(const RabbitizerInstrDescriptor *self);
|
2022-06-08 06:17:35 +00:00
|
|
|
|
2022-07-01 16:57:58 +00:00
|
|
|
bool RabbitizerInstrDescriptor_isPseudo(const RabbitizerInstrDescriptor *self);
|
|
|
|
|
|
|
|
RabbitizerArchitectureVersion RabbitizerInstrDescriptor_getArchitectureVersion(const RabbitizerInstrDescriptor *self);
|
|
|
|
|
2022-06-03 17:46:51 +00:00
|
|
|
#endif
|