From d6148f6d34854cb5456b9f500312748669ab61f5 Mon Sep 17 00:00:00 2001 From: Themis Demetriades Date: Fri, 31 May 2024 17:30:19 +0100 Subject: [PATCH] Add data structure for DP instructions w/ S --- src/a64instruction_DP.h | 7 ++++ src/a64instruction_DPImmediate.h | 36 +++++++------------- src/a64instruction_DPRegister.h | 58 ++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 24 deletions(-) create mode 100644 src/a64instruction_DP.h create mode 100644 src/a64instruction_DPRegister.h diff --git a/src/a64instruction_DP.h b/src/a64instruction_DP.h new file mode 100644 index 0000000..113f589 --- /dev/null +++ b/src/a64instruction_DP.h @@ -0,0 +1,7 @@ +// Denotes the type of arithmetic operations supported by the architecture +typedef enum { + a64inst_ADD = 0, + a64inst_ADDS = 1, + a64inst_SUB = 2, + a64inst_SUBS = 3 +} a64inst_arithmOp; diff --git a/src/a64instruction_DPImmediate.h b/src/a64instruction_DPImmediate.h index b504772..2c02c2f 100644 --- a/src/a64instruction_DPImmediate.h +++ b/src/a64instruction_DPImmediate.h @@ -1,50 +1,38 @@ #include #include "a64instruction_global.h" +#include "a64instruction_DP.h" // Denotes the type of data processing operation typedef enum { - a64inst_arithm, - a64inst_wideMov + a64inst_DPI_ARITHM, + a64inst_DPI_WIDEMOV } a64inst_DPIOpType; -// Denotes the type of register being referred to -typedef enum { - a64inst_W = 0, - a64inst_R = 1 -} a64inst_regType; - -// Denotes the type of arithmetic operations supported by the architecture -typedef enum { - a64inst_add = 0, - a64inst_adds = 1, - a64inst_sub = 2, - a64inst_subs = 3 -} a64inst_arithmOp; - // Denotes the type of wide move operations supported by the architecture typedef enum { - a64inst_movn = 0, - a64inst_undefined = 1, - a64inst_movz = 2, - a64inst_movk = 3 + a64inst_MOVN = 0, + a64inst_UNDEFINED = 1, + a64inst_MOVZ = 2, + a64inst_MOVK = 3 } a64inst_wideMovOp; -// Holds data specific to arithmetic data processing instructions +// Holds data specific to arithmetic immediate data processing instructions typedef struct { bool shiftImmediate; uint16_t immediate; a64inst_regSpecifier src; } a64inst_DPImmediate_ArithmData; -// Holds data specific to wide move data processing instructions +// Holds data specific to wide move immediate data processing instructions typedef struct { - int x; //TEMPORARY FOR COMPILATION! + uint8_t shiftScalar; + uint16_t immediate; } a64inst_DPImmediate_WideMovData; // Holds data for immediate data processing instructions typedef struct { - a64inst_DPIOpType DPIOpType; a64inst_regType regType; + a64inst_DPIOpType DPIOpType; union { a64inst_arithmOp arithmOp; a64inst_wideMovOp movOp; diff --git a/src/a64instruction_DPRegister.h b/src/a64instruction_DPRegister.h new file mode 100644 index 0000000..d0252ee --- /dev/null +++ b/src/a64instruction_DPRegister.h @@ -0,0 +1,58 @@ +#include +#include "a64instruction_global.h" +#include "a64instruction_DP.h" + +// Denotes the type of data processing operation +typedef enum { + a64inst_DPR_ARITHMLOGIC, + a64inst_DPR_MULTIPLY +} a64inst_DPROpType; + +// Denotes the logical operations supported by the architecture +typedef enum { + a64inst_AND = 0, + a64inst_OR = 1, + a64inst_XOR = 2, + a64inst_AND_FLAGGED = 3 +} a64inst_logicOp; + +// Denotes the different kinds of shifts supported by the architecture +typedef enum { + a64inst_LSL = 0, + a64inst_LSR = 1, + a64inst_ASR = 2, + a64inst_ROR = 3 +} a64inst_ShiftType; + +// Holds data specific to arithmetic/logic register data processing instructions +typedef struct { + enum { + a64inst_DPR_ARITHM = 0, + a64inst_DPR_LOGIC = 1 + } type; + a64inst_ShiftType shiftType; + bool negShiftedSrc2; // Guaranteed to be 0 for arithmetic instructions +} a64inst_DPRegister_ArithmLogicData; + +// Holds data specific to multiply register data processing instructions +typedef struct { + bool negProd; + a64inst_regSpecifier summand; +} a64inst_DPRegister_MultiplyData; + +// Holds data for register data processing instructions +typedef struct { + a64inst_regType regType; + a64inst_DPROpType DPROpType; + union { + a64inst_logicOp logicOp; + a64inst_arithmOp arithmOp; + } processOpId; + a64inst_regSpecifier src2; + union { + a64inst_DPRegister_ArithmLogicData arithmLogicData; + a64inst_DPRegister_MultiplyData multiplydata; + } processOpData; + a64inst_regSpecifier src1; + a64inst_regSpecifier dest; +} a64inst_DPRegisterData;