aco: simplify operands_offset calculation in create_instruction()

Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18112>
This commit is contained in:
Daniel Schürmann 2022-09-27 14:45:16 +02:00 committed by Marge Bot
parent a778f3edd3
commit 0b76e22a96

View file

@ -1787,13 +1787,13 @@ create_instruction(aco_opcode opcode, Format format, uint32_t num_operands,
{
std::size_t size =
sizeof(T) + num_operands * sizeof(Operand) + num_definitions * sizeof(Definition);
char* data = (char*)calloc(1, size);
void* data = calloc(1, size);
T* inst = (T*)data;
inst->opcode = opcode;
inst->format = format;
uint16_t operands_offset = data + sizeof(T) - (char*)&inst->operands;
uint16_t operands_offset = sizeof(T) - offsetof(Instruction, operands);
inst->operands = aco::span<Operand>(operands_offset, num_operands);
uint16_t definitions_offset = (char*)inst->operands.end() - (char*)&inst->definitions;
inst->definitions = aco::span<Definition>(definitions_offset, num_definitions);