intel/elk_asm: Add BranchCtrl support

We emit it for gfx8, so the assembler should support it too.

Signed-off-by: Sviatoslav Peleshko <sviatoslav.peleshko@globallogic.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31747>
This commit is contained in:
Sviatoslav Peleshko 2024-10-19 16:37:22 +03:00 committed by Marge Bot
parent cd4c328408
commit 3a962a28e7
5 changed files with 36 additions and 5 deletions

View file

@ -72,6 +72,7 @@ struct options {
unsigned access_mode:1;
unsigned compression_control:2;
unsigned thread_control:2;
unsigned branch_control:1;
unsigned no_dd_check:1; // Dependency control
unsigned no_dd_clear:1; // Dependency control
unsigned mask_control:1;

View file

@ -64,8 +64,8 @@ elk_has_uip(const struct intel_device_info *devinfo, enum elk_opcode opcode)
opcode == ELK_OPCODE_HALT;
}
static bool
has_branch_ctrl(const struct intel_device_info *devinfo, enum elk_opcode opcode)
bool
elk_has_branch_ctrl(const struct intel_device_info *devinfo, enum elk_opcode opcode)
{
if (devinfo->ver < 8)
return false;
@ -2000,7 +2000,7 @@ elk_disassemble_inst(FILE *file, const struct elk_isa_info *isa,
err |= control(file, "thread control", thread_ctrl,
elk_inst_thread_control(devinfo, inst),
&space);
if (has_branch_ctrl(devinfo, opcode)) {
if (elk_has_branch_ctrl(devinfo, opcode)) {
err |= control(file, "branch ctrl", branch_ctrl,
elk_inst_branch_control(devinfo, inst), &space);
} else if (devinfo->ver >= 6) {

View file

@ -175,6 +175,7 @@ void elk_init_codegen(const struct elk_isa_info *isa,
struct elk_codegen *p, void *mem_ctx);
bool elk_has_jip(const struct intel_device_info *devinfo, enum elk_opcode opcode);
bool elk_has_uip(const struct intel_device_info *devinfo, enum elk_opcode opcode);
bool elk_has_branch_ctrl(const struct intel_device_info *devinfo, enum elk_opcode opcode);
const struct elk_shader_reloc *elk_get_shader_relocs(struct elk_codegen *p,
unsigned *num_relocs);
const unsigned *elk_get_program( struct elk_codegen *p, unsigned *sz );

View file

@ -294,9 +294,18 @@ i965_asm_set_instruction_options(struct elk_codegen *p,
options.no_dd_clear);
elk_inst_set_debug_control(p->devinfo, elk_last_inst,
options.debug_control);
if (p->devinfo->ver >= 6)
if (elk_has_branch_ctrl(p->devinfo, elk_inst_opcode(p->isa, elk_last_inst))) {
if (options.acc_wr_control)
error(NULL, "Instruction does not support AccWrEnable\n");
elk_inst_set_branch_control(p->devinfo, elk_last_inst,
options.branch_control);
} else if (options.branch_control) {
error(NULL, "Instruction does not support BranchCtrl\n");
} else if (p->devinfo->ver >= 6) {
elk_inst_set_acc_wr_control(p->devinfo, elk_last_inst,
options.acc_wr_control);
}
elk_inst_set_cmpt_control(p->devinfo, elk_last_inst,
options.compaction);
}
@ -455,6 +464,9 @@ add_label(struct elk_codegen *p, const char* label_name, enum instr_label_type t
/* thread control */
%token ATOMIC SWITCH
/* branch control */
%token BRANCH_CTRL
/* quater control */
%token QTR_2Q QTR_3Q QTR_4Q QTR_2H QTR_2N QTR_3N QTR_4N QTR_5N
%token QTR_6N QTR_7N QTR_8N
@ -566,6 +578,9 @@ add_instruction_option(struct options *options, struct instoption opt)
case ATOMIC:
options->thread_control |= ELK_THREAD_ATOMIC;
break;
case BRANCH_CTRL:
options->branch_control = true;
break;
case NODDCHK:
options->no_dd_check = true;
break;
@ -2284,7 +2299,12 @@ instoption_list:
instoption:
ALIGN1 { $$.uint_value = ALIGN1;}
| ALIGN16 { $$.uint_value = ALIGN16; }
| ACCWREN { $$.uint_value = ACCWREN; }
| ACCWREN
{
if (p->devinfo->ver < 6)
error(&@1, "AccWrEnable not supported before Gfx6\n");
$$.uint_value = ACCWREN;
}
| SECHALF { $$.uint_value = SECHALF; }
| COMPR { $$.uint_value = COMPR; }
| COMPR4 { $$.uint_value = COMPR4; }
@ -2295,6 +2315,12 @@ instoption:
| EOT { $$.uint_value = EOT; }
| SWITCH { $$.uint_value = SWITCH; }
| ATOMIC { $$.uint_value = ATOMIC; }
| BRANCH_CTRL
{
if (p->devinfo->ver < 8)
error(&@1, "BranchCtrl not supported before Gfx8\n");
$$.uint_value = BRANCH_CTRL;
}
| CMPTCTRL { $$.uint_value = CMPTCTRL; }
| WECTRL { $$.uint_value = WECTRL; }
| QTR_2Q { $$.uint_value = QTR_2Q; }

View file

@ -277,6 +277,9 @@ nomask { return MASK_DISABLE; }
atomic { return ATOMIC; }
switch { return SWITCH; }
/* Branch control */
BranchCtrl { return BRANCH_CTRL; }
/* compression control */
compr { return COMPR; }
compr4 { return COMPR4; }