From ca38c1f1f1cb3d2d25eee2e0806cec452b31d164 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 27 Feb 2020 13:04:39 +0100 Subject: [PATCH] aco: add builder function for subdword copy() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Rhys Perry Reviewed-By: Timur Kristóf Part-of: --- src/amd/compiler/aco_builder_h.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/amd/compiler/aco_builder_h.py b/src/amd/compiler/aco_builder_h.py index 65eee5ebd1d..9e4e64101b8 100644 --- a/src/amd/compiler/aco_builder_h.py +++ b/src/amd/compiler/aco_builder_h.py @@ -352,6 +352,7 @@ public: Result copy(Definition dst, Op op_) { Operand op = op_.op; + assert(op.bytes() == dst.bytes()); if (dst.regClass() == s1 && op.size() == 1 && op.isLiteral()) { uint32_t imm = op.constantValue(); if (imm == 0x3e22f983) { @@ -372,15 +373,24 @@ public: } } - if (dst.regClass() == s2) { + if (dst.regClass() == s1) { + return sop1(aco_opcode::s_mov_b32, dst, op); + } else if (dst.regClass() == s2) { return sop1(aco_opcode::s_mov_b64, dst, op); - } else if (op.size() > 1) { - return pseudo(aco_opcode::p_create_vector, dst, op); } else if (dst.regClass() == v1 || dst.regClass() == v1.as_linear()) { return vop1(aco_opcode::v_mov_b32, dst, op); + } else if (op.bytes() > 2) { + return pseudo(aco_opcode::p_create_vector, dst, op); + } else if (dst.regClass().is_subdword()) { + aco_ptr sdwa{create_instruction(aco_opcode::v_mov_b32, asSDWA(Format::VOP1), 1, 1)}; + sdwa->operands[0] = op; + sdwa->definitions[0] = dst; + sdwa->sel[0] = op.bytes() == 1 ? sdwa_ubyte : sdwa_uword; + sdwa->dst_sel = dst.bytes() == 1 ? sdwa_ubyte : sdwa_uword; + sdwa->dst_preserve = true; + return insert(std::move(sdwa)); } else { - assert(dst.regClass() == s1); - return sop1(aco_opcode::s_mov_b32, dst, op); + unreachable("Unhandled case in bld.copy()"); } } -- 2.30.2