From be600b009a8c4508a488f71b9eaf5e6901dff245 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Mon, 16 Nov 2020 17:23:59 +0100 Subject: [PATCH] aco: add a new Operand flag to indicate that is 24-bit To indicate that the upper 8-bits are always 0 to optimize more MADs. Signed-off-by: Samuel Pitoiset Reviewed-by: Rhys Perry Part-of: --- src/amd/compiler/aco_builder_h.py | 5 +++++ src/amd/compiler/aco_ir.h | 13 ++++++++++++- src/amd/compiler/aco_print_ir.cpp | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/amd/compiler/aco_builder_h.py b/src/amd/compiler/aco_builder_h.py index 27f477856c1..f33e78e33ae 100644 --- a/src/amd/compiler/aco_builder_h.py +++ b/src/amd/compiler/aco_builder_h.py @@ -358,6 +358,11 @@ public: return op; } + Operand set24bit(Operand op) { + op.set24bit(true); + return op; + } + /* hand-written helpers */ Temp as_uniform(Op op) { diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h index 58b92310985..149dc0b1945 100644 --- a/src/amd/compiler/aco_ir.h +++ b/src/amd/compiler/aco_ir.h @@ -420,7 +420,7 @@ public: constexpr Operand() : reg_(PhysReg{128}), isTemp_(false), isFixed_(true), isConstant_(false), isKill_(false), isUndef_(true), isFirstKill_(false), constSize(0), - isLateKill_(false), is16bit_(false) {} + isLateKill_(false), is16bit_(false), is24bit_(false) {} explicit Operand(Temp r) noexcept { @@ -757,6 +757,16 @@ public: return is16bit_; } + constexpr void set24bit(bool flag) noexcept + { + is24bit_ = flag; + } + + constexpr bool is24bit() const noexcept + { + return is24bit_; + } + private: union { uint32_t i; @@ -775,6 +785,7 @@ private: uint8_t constSize:2; uint8_t isLateKill_:1; uint8_t is16bit_:1; + uint8_t is24bit_:1; }; /* can't initialize bit-fields in c++11, so work around using a union */ uint16_t control_ = 0; diff --git a/src/amd/compiler/aco_print_ir.cpp b/src/amd/compiler/aco_print_ir.cpp index 611879564c4..9d483eaae9a 100644 --- a/src/amd/compiler/aco_print_ir.cpp +++ b/src/amd/compiler/aco_print_ir.cpp @@ -170,6 +170,8 @@ void aco_print_operand(const Operand *operand, FILE *output) fprintf(output, "(latekill)"); if (operand->is16bit()) fprintf(output, "(is16bit)"); + if (operand->is24bit()) + fprintf(output, "(is24bit)"); fprintf(output, "%%%d", operand->tempId());