From 27f1f5537d4c7ff1cb753e19dbd885924f25be8f Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Thu, 27 Jan 2022 14:18:04 +0000 Subject: [PATCH] aco/tests: implement sub-dword program inputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/tests/helpers.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/amd/compiler/tests/helpers.cpp b/src/amd/compiler/tests/helpers.cpp index 0b9ce051271..fd18ee2cd21 100644 --- a/src/amd/compiler/tests/helpers.cpp +++ b/src/amd/compiler/tests/helpers.cpp @@ -113,11 +113,21 @@ bool setup_cs(const char *input_spec, enum chip_class chip_class, create_program(chip_class, compute_cs, wave_size, family); if (input_spec) { - unsigned num_inputs = DIV_ROUND_UP(strlen(input_spec), 3u); - aco_ptr startpgm{create_instruction(aco_opcode::p_startpgm, Format::PSEUDO, 0, num_inputs)}; - for (unsigned i = 0; i < num_inputs; i++) { - RegClass cls(input_spec[i * 3] == 'v' ? RegType::vgpr : RegType::sgpr, input_spec[i * 3 + 1] - '0'); - inputs[i] = bld.tmp(cls); + std::vector input_classes; + while (input_spec[0]) { + RegType type = input_spec[0] == 'v' ? RegType::vgpr : RegType::sgpr; + unsigned size = input_spec[1] - '0'; + bool in_bytes = input_spec[2] == 'b'; + input_classes.push_back(RegClass::get(type, size * (in_bytes ? 1 : 4))); + + input_spec += 2 + in_bytes; + while (input_spec[0] == ' ') input_spec++; + } + + aco_ptr startpgm{create_instruction( + aco_opcode::p_startpgm, Format::PSEUDO, 0, input_classes.size())}; + for (unsigned i = 0; i < input_classes.size(); i++) { + inputs[i] = bld.tmp(input_classes[i]); startpgm->definitions[i] = Definition(inputs[i]); } bld.insert(std::move(startpgm));