agx: Factor out allows_16bit_immediate check

The optimizer needs this information to inline immediates effectively.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21430>
This commit is contained in:
Alyssa Rosenzweig
2023-02-18 17:05:57 -05:00
committed by Marge Bot
parent 445ca949cd
commit c9728b41d5
4 changed files with 17 additions and 3 deletions

View File

@@ -808,6 +808,7 @@ agx_validate(UNUSED agx_context *ctx, UNUSED const char *after_str)
unsigned agx_read_registers(agx_instr *I, unsigned s); unsigned agx_read_registers(agx_instr *I, unsigned s);
unsigned agx_write_registers(agx_instr *I, unsigned d); unsigned agx_write_registers(agx_instr *I, unsigned d);
bool agx_allows_16bit_immediate(agx_instr *I);
struct agx_copy { struct agx_copy {
/* Base register destination of the copy */ /* Base register destination of the copy */

View File

@@ -0,0 +1,14 @@
/*
* Copyright 2022 Alyssa Rosenzweig
* SPDX-License-Identifier: MIT
*/
#include "agx_compiler.h"
bool
agx_allows_16bit_immediate(agx_instr *I)
{
return (I->op == AGX_OPCODE_DEVICE_LOAD) ||
(I->op == AGX_OPCODE_DEVICE_STORE) ||
(I->op == AGX_OPCODE_UNIFORM_STORE) || (I->op == AGX_OPCODE_ATOMIC);
}

View File

@@ -103,9 +103,7 @@ agx_validate_sources(agx_instr *I)
agx_validate_assert(!src.cache); agx_validate_assert(!src.cache);
agx_validate_assert(!src.discard); agx_validate_assert(!src.discard);
bool ldst = (I->op == AGX_OPCODE_DEVICE_LOAD) || bool ldst = agx_allows_16bit_immediate(I);
(I->op == AGX_OPCODE_UNIFORM_STORE) ||
(I->op == AGX_OPCODE_ATOMIC);
/* Immediates are encoded as 8-bit (16-bit for memory load/store). For /* Immediates are encoded as 8-bit (16-bit for memory load/store). For
* integers, they extend to 16-bit. For floating point, they are 8-bit * integers, they extend to 16-bit. For floating point, they are 8-bit

View File

@@ -37,6 +37,7 @@ libasahi_agx_files = files(
'agx_lower_uniform_sources.c', 'agx_lower_uniform_sources.c',
'agx_pack.c', 'agx_pack.c',
'agx_print.c', 'agx_print.c',
'agx_ir.c',
'agx_opt_cse.c', 'agx_opt_cse.c',
'agx_optimizer.c', 'agx_optimizer.c',
'agx_register_allocate.c', 'agx_register_allocate.c',