From 036be42d6fe86721e11de935de4c04254c6ce228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 11 Jun 2021 14:55:09 +0200 Subject: [PATCH] aco: refactor SDWA opcode validation Reviewed-by: Tony Wasserka Part-of: --- src/amd/compiler/aco_validate.cpp | 35 ++++++++++++++++++------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/amd/compiler/aco_validate.cpp b/src/amd/compiler/aco_validate.cpp index 2a89dac6807..400d58e5765 100644 --- a/src/amd/compiler/aco_validate.cpp +++ b/src/amd/compiler/aco_validate.cpp @@ -170,21 +170,26 @@ bool validate_ir(Program* program) "2nd definition must be fixed to vcc with SDWA", instr.get()); } - check(instr->opcode != aco_opcode::v_madmk_f32 && - instr->opcode != aco_opcode::v_madak_f32 && - instr->opcode != aco_opcode::v_madmk_f16 && - instr->opcode != aco_opcode::v_madak_f16 && - instr->opcode != aco_opcode::v_readfirstlane_b32 && - instr->opcode != aco_opcode::v_clrexcp && - instr->opcode != aco_opcode::v_swap_b32, - "SDWA can't be used with this opcode", instr.get()); - if (program->chip_class != GFX8) { - check(instr->opcode != aco_opcode::v_mac_f32 && - instr->opcode != aco_opcode::v_mac_f16 && - instr->opcode != aco_opcode::v_fmac_f32 && - instr->opcode != aco_opcode::v_fmac_f16, - "SDWA can't be used with this opcode", instr.get()); - } + const bool sdwa_opcodes = + instr->opcode != aco_opcode::v_fmac_f32 && + instr->opcode != aco_opcode::v_fmac_f16 && + instr->opcode != aco_opcode::v_fmamk_f32 && + instr->opcode != aco_opcode::v_fmaak_f32 && + instr->opcode != aco_opcode::v_fmamk_f16 && + instr->opcode != aco_opcode::v_fmaak_f16 && + instr->opcode != aco_opcode::v_madmk_f32 && + instr->opcode != aco_opcode::v_madak_f32 && + instr->opcode != aco_opcode::v_madmk_f16 && + instr->opcode != aco_opcode::v_madak_f16 && + instr->opcode != aco_opcode::v_readfirstlane_b32 && + instr->opcode != aco_opcode::v_clrexcp && instr->opcode != aco_opcode::v_swap_b32; + + const bool feature_mac = + program->chip_class == GFX8 && + (instr->opcode == aco_opcode::v_mac_f32 && + instr->opcode == aco_opcode::v_mac_f16); + + check(sdwa_opcodes || feature_mac, "SDWA can't be used with this opcode", instr.get()); if (instr->definitions[0].regClass().is_subdword()) check((sdwa.dst_sel & sdwa_asuint) == (sdwa_isra | instr->definitions[0].bytes()), "Unexpected SDWA sel for sub-dword definition", instr.get());