mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-01 03:10:09 +01:00
aco: move create_instruction() to aco_ir.cpp
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28370>
This commit is contained in:
parent
a863c7951e
commit
db29984c25
2 changed files with 25 additions and 26 deletions
|
|
@ -1392,7 +1392,7 @@ Instruction::isTrans() const noexcept
|
|||
instr_info.classes[(int)opcode] == instr_class::valu_double_transcendental;
|
||||
}
|
||||
|
||||
size_t
|
||||
static size_t
|
||||
get_instr_data_size(Format format)
|
||||
{
|
||||
switch (format) {
|
||||
|
|
@ -1430,4 +1430,26 @@ get_instr_data_size(Format format)
|
|||
}
|
||||
}
|
||||
|
||||
Instruction*
|
||||
create_instruction(aco_opcode opcode, Format format, uint32_t num_operands,
|
||||
uint32_t num_definitions)
|
||||
{
|
||||
size_t size = get_instr_data_size(format);
|
||||
size_t total_size = size + num_operands * sizeof(Operand) + num_definitions * sizeof(Definition);
|
||||
|
||||
void* data = instruction_buffer->allocate(total_size, alignof(uint32_t));
|
||||
memset(data, 0, total_size);
|
||||
Instruction* inst = (Instruction*)data;
|
||||
|
||||
inst->opcode = opcode;
|
||||
inst->format = format;
|
||||
|
||||
uint16_t operands_offset = size - 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);
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
||||
} // namespace aco
|
||||
|
|
|
|||
|
|
@ -1659,8 +1659,6 @@ VALU_instruction::swapOperands(unsigned idx0, unsigned idx1)
|
|||
this->opsel_hi[idx0].swap(this->opsel_hi[idx1]);
|
||||
}
|
||||
|
||||
extern thread_local aco::monotonic_buffer_resource* instruction_buffer;
|
||||
|
||||
struct instr_deleter_functor {
|
||||
/* Don't yet free any instructions. They will be de-allocated
|
||||
* all at once after compilation finished.
|
||||
|
|
@ -1670,29 +1668,8 @@ struct instr_deleter_functor {
|
|||
|
||||
template <typename T> using aco_ptr = std::unique_ptr<T, instr_deleter_functor>;
|
||||
|
||||
size_t get_instr_data_size(Format format);
|
||||
|
||||
inline Instruction*
|
||||
create_instruction(aco_opcode opcode, Format format, uint32_t num_operands,
|
||||
uint32_t num_definitions)
|
||||
{
|
||||
size_t size = get_instr_data_size(format);
|
||||
size_t total_size = size + num_operands * sizeof(Operand) + num_definitions * sizeof(Definition);
|
||||
|
||||
void* data = instruction_buffer->allocate(total_size, alignof(uint32_t));
|
||||
memset(data, 0, total_size);
|
||||
Instruction* inst = (Instruction*)data;
|
||||
|
||||
inst->opcode = opcode;
|
||||
inst->format = format;
|
||||
|
||||
uint16_t operands_offset = size - 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);
|
||||
|
||||
return inst;
|
||||
}
|
||||
Instruction* create_instruction(aco_opcode opcode, Format format, uint32_t num_operands,
|
||||
uint32_t num_definitions);
|
||||
|
||||
constexpr bool
|
||||
Instruction::usesModifiers() const noexcept
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue