mirror of
https://github.com/pound-emu/pound.git
synced 2025-12-12 01:36:57 +00:00
jit/ir: Remove instruction linked list
The linked list was implemented to store instructions in a basic block. Instructions will now be stored in arrays to keep logic simple and straight-foward. Signed-off-by: Ronald Caesar <github43132@proton.me>
This commit is contained in:
parent
21c0f0bdef
commit
d61fbe3514
2 changed files with 0 additions and 96 deletions
|
|
@ -112,51 +112,4 @@ instruction_get_opcode_name (const instruction_t *instruction)
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
instruction_list_append (instruction_list_t *list, instruction_t *instruction)
|
|
||||||
{
|
|
||||||
PVM_ASSERT(nullptr != list);
|
|
||||||
PVM_ASSERT(nullptr != instruction);
|
|
||||||
|
|
||||||
instruction->next = nullptr;
|
|
||||||
instruction->previous = list->tail;
|
|
||||||
if (nullptr != list->tail)
|
|
||||||
{
|
|
||||||
list->tail->next = instruction;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
list->head = instruction;
|
|
||||||
}
|
|
||||||
list->tail = instruction;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
instruction_list_remove (instruction_list_t *list, instruction_t *instruction)
|
|
||||||
{
|
|
||||||
PVM_ASSERT(nullptr != list);
|
|
||||||
PVM_ASSERT(nullptr != instruction);
|
|
||||||
|
|
||||||
if (nullptr != instruction->previous)
|
|
||||||
{
|
|
||||||
instruction->previous->next = instruction->next;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
list->head = instruction->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nullptr != instruction->next)
|
|
||||||
{
|
|
||||||
instruction->next->previous = instruction->previous;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
list->tail = instruction->previous;
|
|
||||||
}
|
|
||||||
|
|
||||||
instruction->next = nullptr;
|
|
||||||
instruction->previous = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,29 +22,8 @@ typedef struct instruction_t
|
||||||
|
|
||||||
// An array of arguments for this instruction.
|
// An array of arguments for this instruction.
|
||||||
value_t args[MAX_IR_ARGS];
|
value_t args[MAX_IR_ARGS];
|
||||||
|
|
||||||
// Pointer to the next instruction in the intrusive list.
|
|
||||||
struct instruction_t *next;
|
|
||||||
|
|
||||||
// Pointer to the previous instruction the intrusive list.
|
|
||||||
struct instruction_t *previous;
|
|
||||||
} instruction_t;
|
} instruction_t;
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Represents a double-linked list of IR instructions.
|
|
||||||
*
|
|
||||||
* This structure holds the head and tail pointers of an intrusive list
|
|
||||||
* composed of `instruction_t` nodes. It is used to store sequences
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
// Pointer to the first instruction in the list.
|
|
||||||
instruction_t *head;
|
|
||||||
|
|
||||||
// Pointer to the last instruction in the list.
|
|
||||||
instruction_t *tail;
|
|
||||||
} instruction_list_t;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Gets a pointer to the argument at a specific index.
|
* @brief Gets a pointer to the argument at a specific index.
|
||||||
*
|
*
|
||||||
|
|
@ -147,33 +126,5 @@ type_t instruction_get_return_type(instruction_t *instruction);
|
||||||
* @pre The global `g_opcodes` array must be initialized and accessible.
|
* @pre The global `g_opcodes` array must be initialized and accessible.
|
||||||
*/
|
*/
|
||||||
const char *instruction_get_opcode_name(instruction_t *instruction);
|
const char *instruction_get_opcode_name(instruction_t *instruction);
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Appends an instruction to the tail of an instruction list.
|
|
||||||
*
|
|
||||||
* The instruction is added to the end of the list. If the list is empty,
|
|
||||||
* the instruction becomes both the head and the tail.
|
|
||||||
*
|
|
||||||
* @param list Pointer to the instruction list to modify.
|
|
||||||
* @param instruction Pointer to the `instruction_t` node to append.
|
|
||||||
*
|
|
||||||
* @pre `list` must not be NULL.
|
|
||||||
* @pre `instruction` must not be NULL.
|
|
||||||
*/
|
|
||||||
void instruction_list_append(instruction_list_t *list,
|
|
||||||
instruction_t *instruction);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Removes an instruction from an instruction list.
|
|
||||||
*
|
|
||||||
* @param list Pointer to the instruction list to modify.
|
|
||||||
* @param instruction Pointer to the `instruction_t` node to remove.
|
|
||||||
*
|
|
||||||
* @pre `list` must not be NULL.
|
|
||||||
* @pre `instruction` must not be NULL.
|
|
||||||
* @pre `instruction` must be a member of `list`.
|
|
||||||
*/
|
|
||||||
void instruction_list_remove(instruction_list_t *list,
|
|
||||||
instruction_t *instruction);
|
|
||||||
}
|
}
|
||||||
#endif // POUND_JIT_IR_INSTRUCTION_H
|
#endif // POUND_JIT_IR_INSTRUCTION_H
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue