2015-06-29 14:08:51 -07:00
|
|
|
/*
|
2019-01-24 11:51:14 -08:00
|
|
|
* Copyright © 2015-2019 Intel Corporation
|
2015-06-29 14:08:51 -07:00
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** @file brw_eu_validate.c
|
|
|
|
|
*
|
|
|
|
|
* This file implements a pass that validates shader assembly.
|
2019-01-24 11:51:14 -08:00
|
|
|
*
|
|
|
|
|
* The restrictions implemented herein are intended to verify that instructions
|
|
|
|
|
* in shader assembly do not violate restrictions documented in the graphics
|
|
|
|
|
* programming reference manuals.
|
|
|
|
|
*
|
|
|
|
|
* The restrictions are difficult for humans to quickly verify due to their
|
|
|
|
|
* complexity and abundance.
|
|
|
|
|
*
|
|
|
|
|
* It is critical that this code is thoroughly unit tested because false
|
|
|
|
|
* results will lead developers astray, which is worse than having no validator
|
|
|
|
|
* at all. Functional changes to this file without corresponding unit tests (in
|
|
|
|
|
* test_eu_validate.cpp) will be rejected.
|
2015-06-29 14:08:51 -07:00
|
|
|
*/
|
|
|
|
|
|
2018-09-14 12:57:32 -07:00
|
|
|
#include <stdlib.h>
|
2015-06-29 14:08:51 -07:00
|
|
|
#include "brw_eu.h"
|
2024-01-24 22:57:44 -08:00
|
|
|
#include "brw_disasm_info.h"
|
2015-06-29 14:08:51 -07:00
|
|
|
|
|
|
|
|
/* We're going to do lots of string concatenation, so this should help. */
|
|
|
|
|
struct string {
|
|
|
|
|
char *str;
|
|
|
|
|
size_t len;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
cat(struct string *dest, const struct string src)
|
|
|
|
|
{
|
|
|
|
|
dest->str = realloc(dest->str, dest->len + src.len + 1);
|
|
|
|
|
memcpy(dest->str + dest->len, src.str, src.len);
|
2015-11-13 13:36:43 +02:00
|
|
|
dest->str[dest->len + src.len] = '\0';
|
2015-06-29 14:08:51 -07:00
|
|
|
dest->len = dest->len + src.len;
|
|
|
|
|
}
|
|
|
|
|
#define CAT(dest, src) cat(&dest, (struct string){src, strlen(src)})
|
|
|
|
|
|
2017-09-18 14:07:20 -07:00
|
|
|
static bool
|
|
|
|
|
contains(const struct string haystack, const struct string needle)
|
|
|
|
|
{
|
2017-10-17 15:41:25 -07:00
|
|
|
return haystack.str && memmem(haystack.str, haystack.len,
|
|
|
|
|
needle.str, needle.len) != NULL;
|
2017-09-18 14:07:20 -07:00
|
|
|
}
|
|
|
|
|
#define CONTAINS(haystack, needle) \
|
|
|
|
|
contains(haystack, (struct string){needle, strlen(needle)})
|
|
|
|
|
|
2016-11-15 16:06:51 -08:00
|
|
|
#define error(str) "\tERROR: " str "\n"
|
|
|
|
|
#define ERROR_INDENT "\t "
|
2015-06-29 14:08:51 -07:00
|
|
|
|
2016-11-08 15:42:01 -08:00
|
|
|
#define ERROR(msg) ERROR_IF(true, msg)
|
2017-09-18 14:07:20 -07:00
|
|
|
#define ERROR_IF(cond, msg) \
|
|
|
|
|
do { \
|
|
|
|
|
if ((cond) && !CONTAINS(error_msg, error(msg))) { \
|
|
|
|
|
CAT(error_msg, error(msg)); \
|
|
|
|
|
} \
|
2015-06-29 14:08:51 -07:00
|
|
|
} while(0)
|
|
|
|
|
|
2016-11-06 21:10:29 -08:00
|
|
|
#define CHECK(func, args...) \
|
|
|
|
|
do { \
|
2022-06-29 14:13:31 -07:00
|
|
|
struct string __msg = func(isa, inst, ##args); \
|
2016-11-06 21:10:29 -08:00
|
|
|
if (__msg.str) { \
|
|
|
|
|
cat(&error_msg, __msg); \
|
|
|
|
|
free(__msg.str); \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
2017-08-29 18:25:54 -07:00
|
|
|
#define STRIDE(stride) (stride != 0 ? 1 << ((stride) - 1) : 0)
|
|
|
|
|
#define WIDTH(width) (1 << (width))
|
|
|
|
|
|
2016-11-09 12:00:43 -08:00
|
|
|
static bool
|
2022-06-29 14:13:31 -07:00
|
|
|
inst_is_send(const struct brw_isa_info *isa, const brw_inst *inst)
|
2016-11-09 12:00:43 -08:00
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
switch (brw_inst_opcode(isa, inst)) {
|
2016-11-09 12:00:43 -08:00
|
|
|
case BRW_OPCODE_SEND:
|
|
|
|
|
case BRW_OPCODE_SENDC:
|
|
|
|
|
case BRW_OPCODE_SENDS:
|
|
|
|
|
case BRW_OPCODE_SENDSC:
|
|
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-15 15:17:06 -06:00
|
|
|
static bool
|
2022-06-29 14:13:31 -07:00
|
|
|
inst_is_split_send(const struct brw_isa_info *isa, const brw_inst *inst)
|
2018-11-15 15:17:06 -06:00
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
|
|
|
|
|
2021-03-29 14:41:58 -07:00
|
|
|
if (devinfo->ver >= 12) {
|
2022-06-29 14:13:31 -07:00
|
|
|
return inst_is_send(isa, inst);
|
2019-02-05 21:54:38 -08:00
|
|
|
} else {
|
2022-06-29 14:13:31 -07:00
|
|
|
switch (brw_inst_opcode(isa, inst)) {
|
2019-02-05 21:54:38 -08:00
|
|
|
case BRW_OPCODE_SENDS:
|
|
|
|
|
case BRW_OPCODE_SENDSC:
|
|
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2018-11-15 15:17:06 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-21 10:26:57 -08:00
|
|
|
static unsigned
|
|
|
|
|
signed_type(unsigned type)
|
|
|
|
|
{
|
|
|
|
|
switch (type) {
|
2017-07-26 21:08:20 -07:00
|
|
|
case BRW_REGISTER_TYPE_UD: return BRW_REGISTER_TYPE_D;
|
|
|
|
|
case BRW_REGISTER_TYPE_UW: return BRW_REGISTER_TYPE_W;
|
|
|
|
|
case BRW_REGISTER_TYPE_UB: return BRW_REGISTER_TYPE_B;
|
|
|
|
|
case BRW_REGISTER_TYPE_UQ: return BRW_REGISTER_TYPE_Q;
|
|
|
|
|
default: return type;
|
2016-11-21 10:26:57 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-05 21:54:38 -08:00
|
|
|
static enum brw_reg_type
|
2022-06-29 14:13:31 -07:00
|
|
|
inst_dst_type(const struct brw_isa_info *isa, const brw_inst *inst)
|
2019-02-05 21:54:38 -08:00
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
|
|
|
|
|
|
|
|
|
return (devinfo->ver < 12 || !inst_is_send(isa, inst)) ?
|
2019-02-05 21:54:38 -08:00
|
|
|
brw_inst_dst_type(devinfo, inst) : BRW_REGISTER_TYPE_D;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-21 10:26:57 -08:00
|
|
|
static bool
|
2022-06-29 14:13:31 -07:00
|
|
|
inst_is_raw_move(const struct brw_isa_info *isa, const brw_inst *inst)
|
2016-11-21 10:26:57 -08:00
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
|
|
|
|
|
|
|
|
|
unsigned dst_type = signed_type(inst_dst_type(isa, inst));
|
2017-07-26 21:08:20 -07:00
|
|
|
unsigned src_type = signed_type(brw_inst_src0_type(devinfo, inst));
|
2016-11-21 10:26:57 -08:00
|
|
|
|
2017-08-01 12:21:54 -07:00
|
|
|
if (brw_inst_src0_reg_file(devinfo, inst) == BRW_IMMEDIATE_VALUE) {
|
|
|
|
|
/* FIXME: not strictly true */
|
2017-07-26 21:08:20 -07:00
|
|
|
if (brw_inst_src0_type(devinfo, inst) == BRW_REGISTER_TYPE_VF ||
|
|
|
|
|
brw_inst_src0_type(devinfo, inst) == BRW_REGISTER_TYPE_UV ||
|
|
|
|
|
brw_inst_src0_type(devinfo, inst) == BRW_REGISTER_TYPE_V) {
|
2017-08-01 12:21:54 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else if (brw_inst_src0_negate(devinfo, inst) ||
|
|
|
|
|
brw_inst_src0_abs(devinfo, inst)) {
|
2016-11-21 10:26:57 -08:00
|
|
|
return false;
|
2017-08-01 12:21:54 -07:00
|
|
|
}
|
2016-11-21 10:26:57 -08:00
|
|
|
|
2022-06-29 14:13:31 -07:00
|
|
|
return brw_inst_opcode(isa, inst) == BRW_OPCODE_MOV &&
|
2016-11-21 10:26:57 -08:00
|
|
|
brw_inst_saturate(devinfo, inst) == 0 &&
|
|
|
|
|
dst_type == src_type;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-05 20:49:48 -07:00
|
|
|
static bool
|
2021-04-05 13:19:39 -07:00
|
|
|
dst_is_null(const struct intel_device_info *devinfo, const brw_inst *inst)
|
2016-11-05 20:49:48 -07:00
|
|
|
{
|
|
|
|
|
return brw_inst_dst_reg_file(devinfo, inst) == BRW_ARCHITECTURE_REGISTER_FILE &&
|
|
|
|
|
brw_inst_dst_da_reg_nr(devinfo, inst) == BRW_ARF_NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-29 14:08:51 -07:00
|
|
|
static bool
|
2021-04-05 13:19:39 -07:00
|
|
|
src0_is_null(const struct intel_device_info *devinfo, const brw_inst *inst)
|
2015-06-29 14:08:51 -07:00
|
|
|
{
|
2018-04-17 17:12:05 -07:00
|
|
|
return brw_inst_src0_address_mode(devinfo, inst) == BRW_ADDRESS_DIRECT &&
|
|
|
|
|
brw_inst_src0_reg_file(devinfo, inst) == BRW_ARCHITECTURE_REGISTER_FILE &&
|
2015-06-29 14:08:51 -07:00
|
|
|
brw_inst_src0_da_reg_nr(devinfo, inst) == BRW_ARF_NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool
|
2021-04-05 13:19:39 -07:00
|
|
|
src1_is_null(const struct intel_device_info *devinfo, const brw_inst *inst)
|
2015-06-29 14:08:51 -07:00
|
|
|
{
|
|
|
|
|
return brw_inst_src1_reg_file(devinfo, inst) == BRW_ARCHITECTURE_REGISTER_FILE &&
|
|
|
|
|
brw_inst_src1_da_reg_nr(devinfo, inst) == BRW_ARF_NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 09:13:22 +01:00
|
|
|
static bool
|
2021-04-05 13:19:39 -07:00
|
|
|
src0_is_acc(const struct intel_device_info *devinfo, const brw_inst *inst)
|
2019-02-06 09:13:22 +01:00
|
|
|
{
|
|
|
|
|
return brw_inst_src0_reg_file(devinfo, inst) == BRW_ARCHITECTURE_REGISTER_FILE &&
|
|
|
|
|
(brw_inst_src0_da_reg_nr(devinfo, inst) & 0xF0) == BRW_ARF_ACCUMULATOR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool
|
2021-04-05 13:19:39 -07:00
|
|
|
src1_is_acc(const struct intel_device_info *devinfo, const brw_inst *inst)
|
2019-02-06 09:13:22 +01:00
|
|
|
{
|
|
|
|
|
return brw_inst_src1_reg_file(devinfo, inst) == BRW_ARCHITECTURE_REGISTER_FILE &&
|
|
|
|
|
(brw_inst_src1_da_reg_nr(devinfo, inst) & 0xF0) == BRW_ARF_ACCUMULATOR;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-15 16:06:51 -08:00
|
|
|
static bool
|
2021-04-12 20:17:16 -07:00
|
|
|
src0_has_scalar_region(const struct intel_device_info *devinfo,
|
|
|
|
|
const brw_inst *inst)
|
2016-11-15 16:06:51 -08:00
|
|
|
{
|
|
|
|
|
return brw_inst_src0_vstride(devinfo, inst) == BRW_VERTICAL_STRIDE_0 &&
|
|
|
|
|
brw_inst_src0_width(devinfo, inst) == BRW_WIDTH_1 &&
|
|
|
|
|
brw_inst_src0_hstride(devinfo, inst) == BRW_HORIZONTAL_STRIDE_0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool
|
2021-04-12 20:17:16 -07:00
|
|
|
src1_has_scalar_region(const struct intel_device_info *devinfo,
|
|
|
|
|
const brw_inst *inst)
|
2016-11-15 16:06:51 -08:00
|
|
|
{
|
|
|
|
|
return brw_inst_src1_vstride(devinfo, inst) == BRW_VERTICAL_STRIDE_0 &&
|
|
|
|
|
brw_inst_src1_width(devinfo, inst) == BRW_WIDTH_1 &&
|
|
|
|
|
brw_inst_src1_hstride(devinfo, inst) == BRW_HORIZONTAL_STRIDE_0;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-02 14:44:16 -08:00
|
|
|
static struct string
|
2022-06-29 14:13:31 -07:00
|
|
|
invalid_values(const struct brw_isa_info *isa, const brw_inst *inst)
|
2020-01-02 14:44:16 -08:00
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
|
|
|
|
|
2022-12-08 15:39:01 -08:00
|
|
|
unsigned num_sources = brw_num_sources_from_inst(isa, inst);
|
2020-01-02 14:44:16 -08:00
|
|
|
struct string error_msg = { .str = NULL, .len = 0 };
|
|
|
|
|
|
|
|
|
|
switch ((enum brw_execution_size) brw_inst_exec_size(devinfo, inst)) {
|
|
|
|
|
case BRW_EXECUTE_1:
|
|
|
|
|
case BRW_EXECUTE_2:
|
|
|
|
|
case BRW_EXECUTE_4:
|
|
|
|
|
case BRW_EXECUTE_8:
|
|
|
|
|
case BRW_EXECUTE_16:
|
|
|
|
|
case BRW_EXECUTE_32:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
ERROR("invalid execution size");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-11 11:47:14 +03:00
|
|
|
if (error_msg.str)
|
|
|
|
|
return error_msg;
|
|
|
|
|
|
|
|
|
|
if (devinfo->ver >= 12) {
|
|
|
|
|
unsigned group_size = 1 << brw_inst_exec_size(devinfo, inst);
|
|
|
|
|
unsigned qtr_ctrl = brw_inst_qtr_control(devinfo, inst);
|
2024-01-10 23:51:43 -08:00
|
|
|
unsigned nib_ctrl =
|
|
|
|
|
devinfo->ver == 12 ? brw_inst_nib_control(devinfo, inst) : 0;
|
2023-10-11 11:47:14 +03:00
|
|
|
|
|
|
|
|
unsigned chan_off = (qtr_ctrl * 2 + nib_ctrl) << 2;
|
|
|
|
|
ERROR_IF(chan_off % group_size != 0,
|
|
|
|
|
"The execution size must be a factor of the chosen offset");
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-29 14:13:31 -07:00
|
|
|
if (inst_is_send(isa, inst))
|
2020-01-02 14:44:16 -08:00
|
|
|
return error_msg;
|
|
|
|
|
|
|
|
|
|
if (error_msg.str)
|
|
|
|
|
return error_msg;
|
|
|
|
|
|
|
|
|
|
if (num_sources == 3) {
|
|
|
|
|
if (brw_inst_access_mode(devinfo, inst) == BRW_ALIGN_1) {
|
2021-03-29 14:41:58 -07:00
|
|
|
if (devinfo->ver >= 10) {
|
2020-01-02 14:44:16 -08:00
|
|
|
ERROR_IF(brw_inst_3src_a1_dst_type (devinfo, inst) == INVALID_REG_TYPE ||
|
|
|
|
|
brw_inst_3src_a1_src0_type(devinfo, inst) == INVALID_REG_TYPE ||
|
|
|
|
|
brw_inst_3src_a1_src1_type(devinfo, inst) == INVALID_REG_TYPE ||
|
|
|
|
|
brw_inst_3src_a1_src2_type(devinfo, inst) == INVALID_REG_TYPE,
|
|
|
|
|
"invalid register type encoding");
|
|
|
|
|
} else {
|
|
|
|
|
ERROR("Align1 mode not allowed on Gen < 10");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ERROR_IF(brw_inst_3src_a16_dst_type(devinfo, inst) == INVALID_REG_TYPE ||
|
|
|
|
|
brw_inst_3src_a16_src_type(devinfo, inst) == INVALID_REG_TYPE,
|
|
|
|
|
"invalid register type encoding");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ERROR_IF(brw_inst_dst_type (devinfo, inst) == INVALID_REG_TYPE ||
|
|
|
|
|
(num_sources > 0 &&
|
|
|
|
|
brw_inst_src0_type(devinfo, inst) == INVALID_REG_TYPE) ||
|
|
|
|
|
(num_sources > 1 &&
|
|
|
|
|
brw_inst_src1_type(devinfo, inst) == INVALID_REG_TYPE),
|
|
|
|
|
"invalid register type encoding");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return error_msg;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-06 21:20:16 -08:00
|
|
|
static struct string
|
2022-06-29 14:13:31 -07:00
|
|
|
sources_not_null(const struct brw_isa_info *isa,
|
2016-11-06 21:20:16 -08:00
|
|
|
const brw_inst *inst)
|
|
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
2022-12-08 15:39:01 -08:00
|
|
|
unsigned num_sources = brw_num_sources_from_inst(isa, inst);
|
2016-11-06 21:20:16 -08:00
|
|
|
struct string error_msg = { .str = NULL, .len = 0 };
|
|
|
|
|
|
|
|
|
|
/* Nothing to test. 3-src instructions can only have GRF sources, and
|
|
|
|
|
* there's no bit to control the file.
|
|
|
|
|
*/
|
|
|
|
|
if (num_sources == 3)
|
|
|
|
|
return (struct string){};
|
|
|
|
|
|
2018-11-15 15:17:06 -06:00
|
|
|
/* Nothing to test. Split sends can only encode a file in sources that are
|
|
|
|
|
* allowed to be NULL.
|
|
|
|
|
*/
|
2022-06-29 14:13:31 -07:00
|
|
|
if (inst_is_split_send(isa, inst))
|
2018-11-15 15:17:06 -06:00
|
|
|
return (struct string){};
|
|
|
|
|
|
2022-06-29 14:13:31 -07:00
|
|
|
if (num_sources >= 1 && brw_inst_opcode(isa, inst) != BRW_OPCODE_SYNC)
|
2016-11-06 21:20:16 -08:00
|
|
|
ERROR_IF(src0_is_null(devinfo, inst), "src0 is null");
|
|
|
|
|
|
|
|
|
|
if (num_sources == 2)
|
|
|
|
|
ERROR_IF(src1_is_null(devinfo, inst), "src1 is null");
|
|
|
|
|
|
|
|
|
|
return error_msg;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-19 05:09:35 -07:00
|
|
|
static struct string
|
2022-06-29 14:13:31 -07:00
|
|
|
alignment_supported(const struct brw_isa_info *isa,
|
2019-06-19 05:09:35 -07:00
|
|
|
const brw_inst *inst)
|
|
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
2019-06-19 05:09:35 -07:00
|
|
|
struct string error_msg = { .str = NULL, .len = 0 };
|
|
|
|
|
|
2021-03-29 14:41:58 -07:00
|
|
|
ERROR_IF(devinfo->ver >= 11 && brw_inst_access_mode(devinfo, inst) == BRW_ALIGN_16,
|
2019-06-19 05:09:35 -07:00
|
|
|
"Align16 not supported");
|
|
|
|
|
|
|
|
|
|
return error_msg;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 09:13:22 +01:00
|
|
|
static bool
|
2022-06-29 14:13:31 -07:00
|
|
|
inst_uses_src_acc(const struct brw_isa_info *isa,
|
|
|
|
|
const brw_inst *inst)
|
2019-02-06 09:13:22 +01:00
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
|
|
|
|
|
2019-02-06 09:13:22 +01:00
|
|
|
/* Check instructions that use implicit accumulator sources */
|
2022-06-29 14:13:31 -07:00
|
|
|
switch (brw_inst_opcode(isa, inst)) {
|
2019-02-06 09:13:22 +01:00
|
|
|
case BRW_OPCODE_MAC:
|
|
|
|
|
case BRW_OPCODE_MACH:
|
|
|
|
|
case BRW_OPCODE_SADA2:
|
|
|
|
|
return true;
|
2018-01-23 19:23:20 -08:00
|
|
|
default:
|
|
|
|
|
break;
|
2019-02-06 09:13:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* FIXME: support 3-src instructions */
|
2022-12-08 15:39:01 -08:00
|
|
|
unsigned num_sources = brw_num_sources_from_inst(isa, inst);
|
2019-02-06 09:13:22 +01:00
|
|
|
assert(num_sources < 3);
|
|
|
|
|
|
|
|
|
|
return src0_is_acc(devinfo, inst) || (num_sources > 1 && src1_is_acc(devinfo, inst));
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-06 21:23:34 -08:00
|
|
|
static struct string
|
2022-06-29 14:13:31 -07:00
|
|
|
send_restrictions(const struct brw_isa_info *isa,
|
2016-11-06 21:23:34 -08:00
|
|
|
const brw_inst *inst)
|
|
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
|
|
|
|
|
2016-11-06 21:23:34 -08:00
|
|
|
struct string error_msg = { .str = NULL, .len = 0 };
|
|
|
|
|
|
2022-06-29 14:13:31 -07:00
|
|
|
if (inst_is_split_send(isa, inst)) {
|
2018-11-15 15:17:06 -06:00
|
|
|
ERROR_IF(brw_inst_send_src1_reg_file(devinfo, inst) == BRW_ARCHITECTURE_REGISTER_FILE &&
|
|
|
|
|
brw_inst_send_src1_reg_nr(devinfo, inst) != BRW_ARF_NULL,
|
|
|
|
|
"src1 of split send must be a GRF or NULL");
|
|
|
|
|
|
|
|
|
|
ERROR_IF(brw_inst_eot(devinfo, inst) &&
|
|
|
|
|
brw_inst_src0_da_reg_nr(devinfo, inst) < 112,
|
|
|
|
|
"send with EOT must use g112-g127");
|
|
|
|
|
ERROR_IF(brw_inst_eot(devinfo, inst) &&
|
|
|
|
|
brw_inst_send_src1_reg_file(devinfo, inst) == BRW_GENERAL_REGISTER_FILE &&
|
|
|
|
|
brw_inst_send_src1_reg_nr(devinfo, inst) < 112,
|
|
|
|
|
"send with EOT must use g112-g127");
|
|
|
|
|
|
2022-07-24 13:05:57 +03:00
|
|
|
if (brw_inst_send_src0_reg_file(devinfo, inst) == BRW_GENERAL_REGISTER_FILE &&
|
|
|
|
|
brw_inst_send_src1_reg_file(devinfo, inst) == BRW_GENERAL_REGISTER_FILE) {
|
2018-11-15 15:17:06 -06:00
|
|
|
/* Assume minimums if we don't know */
|
|
|
|
|
unsigned mlen = 1;
|
|
|
|
|
if (!brw_inst_send_sel_reg32_desc(devinfo, inst)) {
|
|
|
|
|
const uint32_t desc = brw_inst_send_desc(devinfo, inst);
|
2022-07-07 01:00:19 -07:00
|
|
|
mlen = brw_message_desc_mlen(devinfo, desc) / reg_unit(devinfo);
|
2018-11-15 15:17:06 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned ex_mlen = 1;
|
|
|
|
|
if (!brw_inst_send_sel_reg32_ex_desc(devinfo, inst)) {
|
2019-02-05 23:22:06 -08:00
|
|
|
const uint32_t ex_desc = brw_inst_sends_ex_desc(devinfo, inst);
|
2022-07-07 01:00:19 -07:00
|
|
|
ex_mlen = brw_message_ex_desc_ex_mlen(devinfo, ex_desc) /
|
|
|
|
|
reg_unit(devinfo);
|
2018-11-15 15:17:06 -06:00
|
|
|
}
|
|
|
|
|
const unsigned src0_reg_nr = brw_inst_src0_da_reg_nr(devinfo, inst);
|
|
|
|
|
const unsigned src1_reg_nr = brw_inst_send_src1_reg_nr(devinfo, inst);
|
|
|
|
|
ERROR_IF((src0_reg_nr <= src1_reg_nr &&
|
|
|
|
|
src1_reg_nr < src0_reg_nr + mlen) ||
|
|
|
|
|
(src1_reg_nr <= src0_reg_nr &&
|
|
|
|
|
src0_reg_nr < src1_reg_nr + ex_mlen),
|
|
|
|
|
"split send payloads must not overlap");
|
|
|
|
|
}
|
2022-06-29 14:13:31 -07:00
|
|
|
} else if (inst_is_send(isa, inst)) {
|
2016-11-06 21:23:34 -08:00
|
|
|
ERROR_IF(brw_inst_src0_address_mode(devinfo, inst) != BRW_ADDRESS_DIRECT,
|
|
|
|
|
"send must use direct addressing");
|
|
|
|
|
|
2024-02-16 13:38:19 -08:00
|
|
|
ERROR_IF(brw_inst_send_src0_reg_file(devinfo, inst) != BRW_GENERAL_REGISTER_FILE,
|
|
|
|
|
"send from non-GRF");
|
|
|
|
|
ERROR_IF(brw_inst_eot(devinfo, inst) &&
|
|
|
|
|
brw_inst_src0_da_reg_nr(devinfo, inst) < 112,
|
|
|
|
|
"send with EOT must use g112-g127");
|
2018-03-26 14:59:46 +02:00
|
|
|
|
2024-02-16 13:38:19 -08:00
|
|
|
ERROR_IF(!dst_is_null(devinfo, inst) &&
|
|
|
|
|
(brw_inst_dst_da_reg_nr(devinfo, inst) +
|
|
|
|
|
brw_inst_rlen(devinfo, inst) > 127) &&
|
|
|
|
|
(brw_inst_src0_da_reg_nr(devinfo, inst) +
|
|
|
|
|
brw_inst_mlen(devinfo, inst) >
|
|
|
|
|
brw_inst_dst_da_reg_nr(devinfo, inst)),
|
|
|
|
|
"r127 must not be used for return address when there is "
|
|
|
|
|
"a src and dest overlap");
|
2016-11-06 21:23:34 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return error_msg;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-29 15:59:37 -07:00
|
|
|
static bool
|
2022-06-29 14:13:31 -07:00
|
|
|
is_unsupported_inst(const struct brw_isa_info *isa,
|
2015-06-29 15:59:37 -07:00
|
|
|
const brw_inst *inst)
|
|
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
return brw_inst_opcode(isa, inst) == BRW_OPCODE_ILLEGAL;
|
2015-06-29 15:59:37 -07:00
|
|
|
}
|
|
|
|
|
|
2019-02-05 13:50:09 +01:00
|
|
|
/**
|
|
|
|
|
* Returns whether a combination of two types would qualify as mixed float
|
|
|
|
|
* operation mode
|
|
|
|
|
*/
|
|
|
|
|
static inline bool
|
|
|
|
|
types_are_mixed_float(enum brw_reg_type t0, enum brw_reg_type t1)
|
|
|
|
|
{
|
|
|
|
|
return (t0 == BRW_REGISTER_TYPE_F && t1 == BRW_REGISTER_TYPE_HF) ||
|
|
|
|
|
(t1 == BRW_REGISTER_TYPE_F && t0 == BRW_REGISTER_TYPE_HF);
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-26 21:08:20 -07:00
|
|
|
static enum brw_reg_type
|
|
|
|
|
execution_type_for_type(enum brw_reg_type type)
|
2016-11-09 12:00:43 -08:00
|
|
|
{
|
|
|
|
|
switch (type) {
|
2017-06-14 11:03:19 -07:00
|
|
|
case BRW_REGISTER_TYPE_NF:
|
2017-07-26 21:08:20 -07:00
|
|
|
case BRW_REGISTER_TYPE_DF:
|
|
|
|
|
case BRW_REGISTER_TYPE_F:
|
|
|
|
|
case BRW_REGISTER_TYPE_HF:
|
2016-11-09 12:00:43 -08:00
|
|
|
return type;
|
2017-07-26 21:08:20 -07:00
|
|
|
|
|
|
|
|
case BRW_REGISTER_TYPE_VF:
|
|
|
|
|
return BRW_REGISTER_TYPE_F;
|
|
|
|
|
|
|
|
|
|
case BRW_REGISTER_TYPE_Q:
|
|
|
|
|
case BRW_REGISTER_TYPE_UQ:
|
|
|
|
|
return BRW_REGISTER_TYPE_Q;
|
|
|
|
|
|
|
|
|
|
case BRW_REGISTER_TYPE_D:
|
|
|
|
|
case BRW_REGISTER_TYPE_UD:
|
|
|
|
|
return BRW_REGISTER_TYPE_D;
|
|
|
|
|
|
|
|
|
|
case BRW_REGISTER_TYPE_W:
|
|
|
|
|
case BRW_REGISTER_TYPE_UW:
|
|
|
|
|
case BRW_REGISTER_TYPE_B:
|
|
|
|
|
case BRW_REGISTER_TYPE_UB:
|
|
|
|
|
case BRW_REGISTER_TYPE_V:
|
|
|
|
|
case BRW_REGISTER_TYPE_UV:
|
|
|
|
|
return BRW_REGISTER_TYPE_W;
|
2016-11-09 12:00:43 -08:00
|
|
|
}
|
2017-07-26 21:08:20 -07:00
|
|
|
unreachable("not reached");
|
2016-11-09 12:00:43 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the execution type of an instruction \p inst
|
|
|
|
|
*/
|
2017-07-26 21:08:20 -07:00
|
|
|
static enum brw_reg_type
|
2022-06-29 14:13:31 -07:00
|
|
|
execution_type(const struct brw_isa_info *isa, const brw_inst *inst)
|
2016-11-09 12:00:43 -08:00
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
|
|
|
|
|
2022-12-08 15:39:01 -08:00
|
|
|
unsigned num_sources = brw_num_sources_from_inst(isa, inst);
|
2017-07-26 21:08:20 -07:00
|
|
|
enum brw_reg_type src0_exec_type, src1_exec_type;
|
2016-11-09 12:00:43 -08:00
|
|
|
|
|
|
|
|
/* Execution data type is independent of destination data type, except in
|
2019-02-05 13:50:09 +01:00
|
|
|
* mixed F/HF instructions.
|
2016-11-09 12:00:43 -08:00
|
|
|
*/
|
2022-06-29 14:13:31 -07:00
|
|
|
enum brw_reg_type dst_exec_type = inst_dst_type(isa, inst);
|
2016-11-09 12:00:43 -08:00
|
|
|
|
2017-08-31 15:41:43 -07:00
|
|
|
src0_exec_type = execution_type_for_type(brw_inst_src0_type(devinfo, inst));
|
2016-11-09 12:00:43 -08:00
|
|
|
if (num_sources == 1) {
|
2019-02-05 13:50:09 +01:00
|
|
|
if (src0_exec_type == BRW_REGISTER_TYPE_HF)
|
2016-11-09 12:00:43 -08:00
|
|
|
return dst_exec_type;
|
|
|
|
|
return src0_exec_type;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-31 15:41:43 -07:00
|
|
|
src1_exec_type = execution_type_for_type(brw_inst_src1_type(devinfo, inst));
|
2019-02-05 13:50:09 +01:00
|
|
|
if (types_are_mixed_float(src0_exec_type, src1_exec_type) ||
|
|
|
|
|
types_are_mixed_float(src0_exec_type, dst_exec_type) ||
|
|
|
|
|
types_are_mixed_float(src1_exec_type, dst_exec_type)) {
|
|
|
|
|
return BRW_REGISTER_TYPE_F;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-09 12:00:43 -08:00
|
|
|
if (src0_exec_type == src1_exec_type)
|
|
|
|
|
return src0_exec_type;
|
|
|
|
|
|
2020-01-02 14:54:34 -08:00
|
|
|
if (src0_exec_type == BRW_REGISTER_TYPE_NF ||
|
|
|
|
|
src1_exec_type == BRW_REGISTER_TYPE_NF)
|
|
|
|
|
return BRW_REGISTER_TYPE_NF;
|
|
|
|
|
|
2017-07-26 21:08:20 -07:00
|
|
|
if (src0_exec_type == BRW_REGISTER_TYPE_Q ||
|
|
|
|
|
src1_exec_type == BRW_REGISTER_TYPE_Q)
|
|
|
|
|
return BRW_REGISTER_TYPE_Q;
|
2016-11-09 12:00:43 -08:00
|
|
|
|
2017-07-26 21:08:20 -07:00
|
|
|
if (src0_exec_type == BRW_REGISTER_TYPE_D ||
|
|
|
|
|
src1_exec_type == BRW_REGISTER_TYPE_D)
|
|
|
|
|
return BRW_REGISTER_TYPE_D;
|
2016-11-09 12:00:43 -08:00
|
|
|
|
2017-07-26 21:08:20 -07:00
|
|
|
if (src0_exec_type == BRW_REGISTER_TYPE_W ||
|
|
|
|
|
src1_exec_type == BRW_REGISTER_TYPE_W)
|
|
|
|
|
return BRW_REGISTER_TYPE_W;
|
2016-11-09 12:00:43 -08:00
|
|
|
|
2017-07-26 21:08:20 -07:00
|
|
|
if (src0_exec_type == BRW_REGISTER_TYPE_DF ||
|
|
|
|
|
src1_exec_type == BRW_REGISTER_TYPE_DF)
|
|
|
|
|
return BRW_REGISTER_TYPE_DF;
|
2016-11-09 12:00:43 -08:00
|
|
|
|
2019-02-05 13:50:09 +01:00
|
|
|
unreachable("not reached");
|
2016-11-09 12:00:43 -08:00
|
|
|
}
|
|
|
|
|
|
2016-11-15 16:06:51 -08:00
|
|
|
/**
|
|
|
|
|
* Returns whether a region is packed
|
|
|
|
|
*
|
|
|
|
|
* A region is packed if its elements are adjacent in memory, with no
|
|
|
|
|
* intervening space, no overlap, and no replicated values.
|
|
|
|
|
*/
|
|
|
|
|
static bool
|
|
|
|
|
is_packed(unsigned vstride, unsigned width, unsigned hstride)
|
|
|
|
|
{
|
|
|
|
|
if (vstride == width) {
|
|
|
|
|
if (vstride == 1) {
|
|
|
|
|
return hstride == 0;
|
|
|
|
|
} else {
|
|
|
|
|
return hstride == 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
intel/eu: Fix XeHP register region validation for hstride == 0
Recently, we started using <1;1,0> register regions for consecutive
channels, rather than the <8;8,1> we've traditionally used, as the
<1;1,0> encoding can be compacted on XeHP. Since then, one of the
EU validator rules has been flagging tons of instructions as errors:
mov(16) g114<1>F g112<1,1,0>UD { align1 1H I@2 compacted };
ERROR: Register Regioning patterns where register data bit locations are changed between source and destination are not supported except for broadcast of a scalar.
Our code for this restriction checked three things:
#1: vstride != width * hstride ||
#2: src_stride != dst_stride ||
#3: subreg != dst_subreg
Destination regions are always linear (no replicated values, nor
any overlapping components), as they only have hstride. Rule #1 is
requiring that the source region be linear as well. Rules #2-3 are
straightforward: the subregister must match (for the first channel to
line up), and the source/destination strides must match (for any
subsequent channels to line up).
Unfortunately, rules #1-2 weren't working when horizontal stride was 0.
In that case, regions are linear if width == 1, and the stride between
consecutive channels is given by vertical stride instead.
So we adjust our src_stride calculation from
src_stride = hstride * type_size;
to:
src_stride = (hstride ? hstride : vstride) * type_size;
and adjust rule #1 to allow hstride == 0 as long as width == 1.
While here, we also update the text of the rule to match the latest
documentation, which apparently clarifies that it's the location of
the LSB of the channel which matters.
Fixes: 3f50dde8b35 ("intel/eu: Teach EU validator about FP/DP pipeline regioning restrictions.")
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17624>
2022-07-19 01:21:06 -07:00
|
|
|
/**
|
|
|
|
|
* Returns whether a region is linear
|
|
|
|
|
*
|
|
|
|
|
* A region is linear if its elements do not overlap and are not replicated.
|
|
|
|
|
* Unlike a packed region, intervening space (i.e. strided values) is allowed.
|
|
|
|
|
*/
|
|
|
|
|
static bool
|
|
|
|
|
is_linear(unsigned vstride, unsigned width, unsigned hstride)
|
|
|
|
|
{
|
|
|
|
|
return vstride == width * hstride ||
|
|
|
|
|
(hstride == 0 && width == 1);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-01 11:41:33 +01:00
|
|
|
/**
|
|
|
|
|
* Returns whether an instruction is an explicit or implicit conversion
|
|
|
|
|
* to/from half-float.
|
|
|
|
|
*/
|
|
|
|
|
static bool
|
2022-06-29 14:13:31 -07:00
|
|
|
is_half_float_conversion(const struct brw_isa_info *isa,
|
2019-02-01 11:41:33 +01:00
|
|
|
const brw_inst *inst)
|
|
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
|
|
|
|
|
2019-02-01 11:41:33 +01:00
|
|
|
enum brw_reg_type dst_type = brw_inst_dst_type(devinfo, inst);
|
|
|
|
|
|
2022-12-08 15:39:01 -08:00
|
|
|
unsigned num_sources = brw_num_sources_from_inst(isa, inst);
|
2019-02-01 11:41:33 +01:00
|
|
|
enum brw_reg_type src0_type = brw_inst_src0_type(devinfo, inst);
|
|
|
|
|
|
|
|
|
|
if (dst_type != src0_type &&
|
|
|
|
|
(dst_type == BRW_REGISTER_TYPE_HF || src0_type == BRW_REGISTER_TYPE_HF)) {
|
|
|
|
|
return true;
|
|
|
|
|
} else if (num_sources > 1) {
|
|
|
|
|
enum brw_reg_type src1_type = brw_inst_src1_type(devinfo, inst);
|
|
|
|
|
return dst_type != src1_type &&
|
|
|
|
|
(dst_type == BRW_REGISTER_TYPE_HF ||
|
|
|
|
|
src1_type == BRW_REGISTER_TYPE_HF);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Returns whether an instruction is using mixed float operation mode
|
|
|
|
|
*/
|
|
|
|
|
static bool
|
2022-06-29 14:13:31 -07:00
|
|
|
is_mixed_float(const struct brw_isa_info *isa, const brw_inst *inst)
|
2019-02-01 11:41:33 +01:00
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
|
|
|
|
|
|
|
|
|
if (inst_is_send(isa, inst))
|
2019-02-01 11:41:33 +01:00
|
|
|
return false;
|
|
|
|
|
|
2022-06-29 14:13:31 -07:00
|
|
|
unsigned opcode = brw_inst_opcode(isa, inst);
|
|
|
|
|
const struct opcode_desc *desc = brw_opcode_desc(isa, opcode);
|
2019-02-01 11:41:33 +01:00
|
|
|
if (desc->ndst == 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/* FIXME: support 3-src instructions */
|
2022-12-08 15:39:01 -08:00
|
|
|
unsigned num_sources = brw_num_sources_from_inst(isa, inst);
|
2019-02-01 11:41:33 +01:00
|
|
|
assert(num_sources < 3);
|
|
|
|
|
|
|
|
|
|
enum brw_reg_type dst_type = brw_inst_dst_type(devinfo, inst);
|
|
|
|
|
enum brw_reg_type src0_type = brw_inst_src0_type(devinfo, inst);
|
|
|
|
|
|
|
|
|
|
if (num_sources == 1)
|
|
|
|
|
return types_are_mixed_float(src0_type, dst_type);
|
|
|
|
|
|
|
|
|
|
enum brw_reg_type src1_type = brw_inst_src1_type(devinfo, inst);
|
|
|
|
|
|
|
|
|
|
return types_are_mixed_float(src0_type, src1_type) ||
|
|
|
|
|
types_are_mixed_float(src0_type, dst_type) ||
|
|
|
|
|
types_are_mixed_float(src1_type, dst_type);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-08 09:20:56 +01:00
|
|
|
/**
|
|
|
|
|
* Returns whether an instruction is an explicit or implicit conversion
|
|
|
|
|
* to/from byte.
|
|
|
|
|
*/
|
|
|
|
|
static bool
|
2022-06-29 14:13:31 -07:00
|
|
|
is_byte_conversion(const struct brw_isa_info *isa,
|
2019-02-08 09:20:56 +01:00
|
|
|
const brw_inst *inst)
|
|
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
|
|
|
|
|
2019-02-08 09:20:56 +01:00
|
|
|
enum brw_reg_type dst_type = brw_inst_dst_type(devinfo, inst);
|
|
|
|
|
|
2022-12-08 15:39:01 -08:00
|
|
|
unsigned num_sources = brw_num_sources_from_inst(isa, inst);
|
2019-02-08 09:20:56 +01:00
|
|
|
enum brw_reg_type src0_type = brw_inst_src0_type(devinfo, inst);
|
|
|
|
|
|
|
|
|
|
if (dst_type != src0_type &&
|
|
|
|
|
(type_sz(dst_type) == 1 || type_sz(src0_type) == 1)) {
|
|
|
|
|
return true;
|
|
|
|
|
} else if (num_sources > 1) {
|
|
|
|
|
enum brw_reg_type src1_type = brw_inst_src1_type(devinfo, inst);
|
|
|
|
|
return dst_type != src1_type &&
|
|
|
|
|
(type_sz(dst_type) == 1 || type_sz(src1_type) == 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-09 12:00:43 -08:00
|
|
|
/**
|
|
|
|
|
* Checks restrictions listed in "General Restrictions Based on Operand Types"
|
|
|
|
|
* in the "Register Region Restrictions" section.
|
|
|
|
|
*/
|
|
|
|
|
static struct string
|
2022-06-29 14:13:31 -07:00
|
|
|
general_restrictions_based_on_operand_types(const struct brw_isa_info *isa,
|
2016-11-09 12:00:43 -08:00
|
|
|
const brw_inst *inst)
|
|
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
|
|
|
|
|
2016-11-09 12:00:43 -08:00
|
|
|
const struct opcode_desc *desc =
|
2022-06-29 14:13:31 -07:00
|
|
|
brw_opcode_desc(isa, brw_inst_opcode(isa, inst));
|
2022-12-08 15:39:01 -08:00
|
|
|
unsigned num_sources = brw_num_sources_from_inst(isa, inst);
|
2016-11-09 12:00:43 -08:00
|
|
|
unsigned exec_size = 1 << brw_inst_exec_size(devinfo, inst);
|
|
|
|
|
struct string error_msg = { .str = NULL, .len = 0 };
|
|
|
|
|
|
2022-06-29 14:13:31 -07:00
|
|
|
if (inst_is_send(isa, inst))
|
2020-01-29 16:23:25 -06:00
|
|
|
return error_msg;
|
|
|
|
|
|
2021-03-29 14:41:58 -07:00
|
|
|
if (devinfo->ver >= 11) {
|
2023-09-20 12:42:24 -07:00
|
|
|
/* A register type of B or UB for DPAS actually means 4 bytes packed into
|
|
|
|
|
* a D or UD, so it is allowed.
|
|
|
|
|
*/
|
|
|
|
|
if (num_sources == 3 && brw_inst_opcode(isa, inst) != BRW_OPCODE_DPAS) {
|
2019-06-19 05:09:35 -07:00
|
|
|
ERROR_IF(brw_reg_type_to_size(brw_inst_3src_a1_src1_type(devinfo, inst)) == 1 ||
|
|
|
|
|
brw_reg_type_to_size(brw_inst_3src_a1_src2_type(devinfo, inst)) == 1,
|
|
|
|
|
"Byte data type is not supported for src1/2 register regioning. This includes "
|
|
|
|
|
"byte broadcast as well.");
|
|
|
|
|
}
|
|
|
|
|
if (num_sources == 2) {
|
|
|
|
|
ERROR_IF(brw_reg_type_to_size(brw_inst_src1_type(devinfo, inst)) == 1,
|
|
|
|
|
"Byte data type is not supported for src1 register regioning. This includes "
|
|
|
|
|
"byte broadcast as well.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-11 00:23:44 +03:00
|
|
|
enum brw_reg_type dst_type;
|
|
|
|
|
|
|
|
|
|
if (num_sources == 3) {
|
|
|
|
|
if (brw_inst_access_mode(devinfo, inst) == BRW_ALIGN_1)
|
|
|
|
|
dst_type = brw_inst_3src_a1_dst_type(devinfo, inst);
|
|
|
|
|
else
|
|
|
|
|
dst_type = brw_inst_3src_a16_dst_type(devinfo, inst);
|
|
|
|
|
} else {
|
2022-06-29 14:13:31 -07:00
|
|
|
dst_type = inst_dst_type(isa, inst);
|
2022-06-11 00:23:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ERROR_IF(dst_type == BRW_REGISTER_TYPE_DF &&
|
|
|
|
|
!devinfo->has_64bit_float,
|
|
|
|
|
"64-bit float destination, but platform does not support it");
|
|
|
|
|
|
|
|
|
|
ERROR_IF((dst_type == BRW_REGISTER_TYPE_Q ||
|
|
|
|
|
dst_type == BRW_REGISTER_TYPE_UQ) &&
|
|
|
|
|
!devinfo->has_64bit_int,
|
|
|
|
|
"64-bit int destination, but platform does not support it");
|
|
|
|
|
|
|
|
|
|
for (unsigned s = 0; s < num_sources; s++) {
|
|
|
|
|
enum brw_reg_type src_type;
|
|
|
|
|
if (num_sources == 3) {
|
|
|
|
|
if (brw_inst_access_mode(devinfo, inst) == BRW_ALIGN_1) {
|
|
|
|
|
switch (s) {
|
|
|
|
|
case 0: src_type = brw_inst_3src_a1_src0_type(devinfo, inst); break;
|
|
|
|
|
case 1: src_type = brw_inst_3src_a1_src1_type(devinfo, inst); break;
|
|
|
|
|
case 2: src_type = brw_inst_3src_a1_src2_type(devinfo, inst); break;
|
|
|
|
|
default: unreachable("invalid src");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
src_type = brw_inst_3src_a16_src_type(devinfo, inst);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
switch (s) {
|
|
|
|
|
case 0: src_type = brw_inst_src0_type(devinfo, inst); break;
|
|
|
|
|
case 1: src_type = brw_inst_src1_type(devinfo, inst); break;
|
|
|
|
|
default: unreachable("invalid src");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ERROR_IF(src_type == BRW_REGISTER_TYPE_DF &&
|
|
|
|
|
!devinfo->has_64bit_float,
|
|
|
|
|
"64-bit float source, but platform does not support it");
|
|
|
|
|
|
|
|
|
|
ERROR_IF((src_type == BRW_REGISTER_TYPE_Q ||
|
|
|
|
|
src_type == BRW_REGISTER_TYPE_UQ) &&
|
|
|
|
|
!devinfo->has_64bit_int,
|
|
|
|
|
"64-bit int source, but platform does not support it");
|
2024-01-15 16:12:21 -08:00
|
|
|
if (brw_inst_access_mode(devinfo, inst) == BRW_ALIGN_16 &&
|
|
|
|
|
num_sources == 3 && type_sz(src_type) > 4) {
|
|
|
|
|
/* From the Broadwell PRM, Volume 7 "3D Media GPGPU", page 944:
|
|
|
|
|
*
|
|
|
|
|
* "This is applicable to 32b datatypes and 16b datatype. 64b
|
|
|
|
|
* datatypes cannot use the replicate control."
|
|
|
|
|
*/
|
|
|
|
|
switch (s) {
|
|
|
|
|
case 0:
|
|
|
|
|
ERROR_IF(brw_inst_3src_a16_src0_rep_ctrl(devinfo, inst),
|
|
|
|
|
"RepCtrl must be zero for 64-bit source 0");
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
ERROR_IF(brw_inst_3src_a16_src1_rep_ctrl(devinfo, inst),
|
|
|
|
|
"RepCtrl must be zero for 64-bit source 1");
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
ERROR_IF(brw_inst_3src_a16_src2_rep_ctrl(devinfo, inst),
|
|
|
|
|
"RepCtrl must be zero for 64-bit source 2");
|
|
|
|
|
break;
|
|
|
|
|
default: unreachable("invalid src");
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-11 00:23:44 +03:00
|
|
|
}
|
|
|
|
|
|
2016-11-09 12:00:43 -08:00
|
|
|
if (num_sources == 3)
|
2019-06-19 05:09:35 -07:00
|
|
|
return error_msg;
|
2016-11-09 12:00:43 -08:00
|
|
|
|
|
|
|
|
if (exec_size == 1)
|
2019-06-19 05:09:35 -07:00
|
|
|
return error_msg;
|
2016-11-09 12:00:43 -08:00
|
|
|
|
|
|
|
|
if (desc->ndst == 0)
|
2019-06-19 05:09:35 -07:00
|
|
|
return error_msg;
|
2016-11-09 12:00:43 -08:00
|
|
|
|
|
|
|
|
/* The PRMs say:
|
|
|
|
|
*
|
|
|
|
|
* Where n is the largest element size in bytes for any source or
|
|
|
|
|
* destination operand type, ExecSize * n must be <= 64.
|
|
|
|
|
*
|
|
|
|
|
* But we do not attempt to enforce it, because it is implied by other
|
|
|
|
|
* rules:
|
|
|
|
|
*
|
|
|
|
|
* - that the destination stride must match the execution data type
|
|
|
|
|
* - sources may not span more than two adjacent GRF registers
|
|
|
|
|
* - destination may not span more than two adjacent GRF registers
|
|
|
|
|
*
|
|
|
|
|
* In fact, checking it would weaken testing of the other rules.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-08-29 18:25:54 -07:00
|
|
|
unsigned dst_stride = STRIDE(brw_inst_dst_hstride(devinfo, inst));
|
2016-11-21 10:26:57 -08:00
|
|
|
bool dst_type_is_byte =
|
2022-06-29 14:13:31 -07:00
|
|
|
inst_dst_type(isa, inst) == BRW_REGISTER_TYPE_B ||
|
|
|
|
|
inst_dst_type(isa, inst) == BRW_REGISTER_TYPE_UB;
|
2016-11-21 10:26:57 -08:00
|
|
|
|
|
|
|
|
if (dst_type_is_byte) {
|
|
|
|
|
if (is_packed(exec_size * dst_stride, exec_size, dst_stride)) {
|
2022-06-29 14:13:31 -07:00
|
|
|
if (!inst_is_raw_move(isa, inst))
|
2016-11-21 10:26:57 -08:00
|
|
|
ERROR("Only raw MOV supports a packed-byte destination");
|
2019-06-19 05:09:35 -07:00
|
|
|
return error_msg;
|
2016-11-21 10:26:57 -08:00
|
|
|
}
|
|
|
|
|
}
|
2016-11-09 12:00:43 -08:00
|
|
|
|
2022-06-29 14:13:31 -07:00
|
|
|
unsigned exec_type = execution_type(isa, inst);
|
2017-07-26 21:08:20 -07:00
|
|
|
unsigned exec_type_size = brw_reg_type_to_size(exec_type);
|
|
|
|
|
unsigned dst_type_size = brw_reg_type_to_size(dst_type);
|
2016-11-09 12:00:43 -08:00
|
|
|
|
2022-06-29 14:13:31 -07:00
|
|
|
if (is_byte_conversion(isa, inst)) {
|
2019-02-08 09:20:56 +01:00
|
|
|
/* From the BDW+ PRM, Volume 2a, Command Reference, Instructions - MOV:
|
|
|
|
|
*
|
|
|
|
|
* "There is no direct conversion from B/UB to DF or DF to B/UB.
|
|
|
|
|
* There is no direct conversion from B/UB to Q/UQ or Q/UQ to B/UB."
|
|
|
|
|
*
|
|
|
|
|
* Even if these restrictions are listed for the MOV instruction, we
|
|
|
|
|
* validate this more generally, since there is the possibility
|
|
|
|
|
* of implicit conversions from other instructions.
|
|
|
|
|
*/
|
|
|
|
|
enum brw_reg_type src0_type = brw_inst_src0_type(devinfo, inst);
|
|
|
|
|
enum brw_reg_type src1_type = num_sources > 1 ?
|
|
|
|
|
brw_inst_src1_type(devinfo, inst) : 0;
|
|
|
|
|
|
|
|
|
|
ERROR_IF(type_sz(dst_type) == 1 &&
|
|
|
|
|
(type_sz(src0_type) == 8 ||
|
|
|
|
|
(num_sources > 1 && type_sz(src1_type) == 8)),
|
|
|
|
|
"There are no direct conversions between 64-bit types and B/UB");
|
|
|
|
|
|
|
|
|
|
ERROR_IF(type_sz(dst_type) == 8 &&
|
|
|
|
|
(type_sz(src0_type) == 1 ||
|
|
|
|
|
(num_sources > 1 && type_sz(src1_type) == 1)),
|
|
|
|
|
"There are no direct conversions between 64-bit types and B/UB");
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-29 14:13:31 -07:00
|
|
|
if (is_half_float_conversion(isa, inst)) {
|
2019-02-01 11:41:33 +01:00
|
|
|
/**
|
|
|
|
|
* A helper to validate used in the validation of the following restriction
|
|
|
|
|
* from the BDW+ PRM, Volume 2a, Command Reference, Instructions - MOV:
|
|
|
|
|
*
|
|
|
|
|
* "There is no direct conversion from HF to DF or DF to HF.
|
|
|
|
|
* There is no direct conversion from HF to Q/UQ or Q/UQ to HF."
|
|
|
|
|
*
|
|
|
|
|
* Even if these restrictions are listed for the MOV instruction, we
|
|
|
|
|
* validate this more generally, since there is the possibility
|
|
|
|
|
* of implicit conversions from other instructions, such us implicit
|
|
|
|
|
* conversion from integer to HF with the ADD instruction in SKL+.
|
|
|
|
|
*/
|
|
|
|
|
enum brw_reg_type src0_type = brw_inst_src0_type(devinfo, inst);
|
|
|
|
|
enum brw_reg_type src1_type = num_sources > 1 ?
|
|
|
|
|
brw_inst_src1_type(devinfo, inst) : 0;
|
|
|
|
|
ERROR_IF(dst_type == BRW_REGISTER_TYPE_HF &&
|
|
|
|
|
(type_sz(src0_type) == 8 ||
|
|
|
|
|
(num_sources > 1 && type_sz(src1_type) == 8)),
|
|
|
|
|
"There are no direct conversions between 64-bit types and HF");
|
|
|
|
|
|
|
|
|
|
ERROR_IF(type_sz(dst_type) == 8 &&
|
|
|
|
|
(src0_type == BRW_REGISTER_TYPE_HF ||
|
|
|
|
|
(num_sources > 1 && src1_type == BRW_REGISTER_TYPE_HF)),
|
|
|
|
|
"There are no direct conversions between 64-bit types and HF");
|
|
|
|
|
|
|
|
|
|
/* From the BDW+ PRM:
|
|
|
|
|
*
|
|
|
|
|
* "Conversion between Integer and HF (Half Float) must be
|
|
|
|
|
* DWord-aligned and strided by a DWord on the destination."
|
|
|
|
|
*
|
|
|
|
|
* Also, the above restrictions seems to be expanded on CHV and SKL+ by:
|
|
|
|
|
*
|
|
|
|
|
* "There is a relaxed alignment rule for word destinations. When
|
|
|
|
|
* the destination type is word (UW, W, HF), destination data types
|
|
|
|
|
* can be aligned to either the lowest word or the second lowest
|
|
|
|
|
* word of the execution channel. This means the destination data
|
|
|
|
|
* words can be either all in the even word locations or all in the
|
|
|
|
|
* odd word locations."
|
|
|
|
|
*
|
|
|
|
|
* We do not implement the second rule as is though, since empirical
|
|
|
|
|
* testing shows inconsistencies:
|
|
|
|
|
* - It suggests that packed 16-bit is not allowed, which is not true.
|
|
|
|
|
* - It suggests that conversions from Q/DF to W (which need to be
|
|
|
|
|
* 64-bit aligned on the destination) are not possible, which is
|
|
|
|
|
* not true.
|
|
|
|
|
*
|
|
|
|
|
* So from this rule we only validate the implication that conversions
|
|
|
|
|
* from F to HF need to be DWord strided (except in Align1 mixed
|
|
|
|
|
* float mode where packed fp16 destination is allowed so long as the
|
|
|
|
|
* destination is oword-aligned).
|
|
|
|
|
*
|
|
|
|
|
* Finally, we only validate this for Align1 because Align16 always
|
|
|
|
|
* requires packed destinations, so these restrictions can't possibly
|
|
|
|
|
* apply to Align16 mode.
|
|
|
|
|
*/
|
|
|
|
|
if (brw_inst_access_mode(devinfo, inst) == BRW_ALIGN_1) {
|
|
|
|
|
if ((dst_type == BRW_REGISTER_TYPE_HF &&
|
|
|
|
|
(brw_reg_type_is_integer(src0_type) ||
|
|
|
|
|
(num_sources > 1 && brw_reg_type_is_integer(src1_type)))) ||
|
|
|
|
|
(brw_reg_type_is_integer(dst_type) &&
|
|
|
|
|
(src0_type == BRW_REGISTER_TYPE_HF ||
|
|
|
|
|
(num_sources > 1 && src1_type == BRW_REGISTER_TYPE_HF)))) {
|
|
|
|
|
ERROR_IF(dst_stride * dst_type_size != 4,
|
|
|
|
|
"Conversions between integer and half-float must be "
|
|
|
|
|
"strided by a DWord on the destination");
|
|
|
|
|
|
|
|
|
|
unsigned subreg = brw_inst_dst_da1_subreg_nr(devinfo, inst);
|
|
|
|
|
ERROR_IF(subreg % 4 != 0,
|
|
|
|
|
"Conversions between integer and half-float must be "
|
|
|
|
|
"aligned to a DWord on the destination");
|
2024-02-16 13:38:19 -08:00
|
|
|
} else if (dst_type == BRW_REGISTER_TYPE_HF) {
|
2019-02-01 11:41:33 +01:00
|
|
|
unsigned subreg = brw_inst_dst_da1_subreg_nr(devinfo, inst);
|
|
|
|
|
ERROR_IF(dst_stride != 2 &&
|
2022-06-29 14:13:31 -07:00
|
|
|
!(is_mixed_float(isa, inst) &&
|
2019-02-01 11:41:33 +01:00
|
|
|
dst_stride == 1 && subreg % 16 == 0),
|
|
|
|
|
"Conversions to HF must have either all words in even "
|
|
|
|
|
"word locations or all words in odd word locations or "
|
|
|
|
|
"be mixed-float with Oword-aligned packed destination");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* There are special regioning rules for mixed-float mode in CHV and SKL that
|
|
|
|
|
* override the general rule for the ratio of sizes of the destination type
|
|
|
|
|
* and the execution type. We will add validation for those in a later patch.
|
|
|
|
|
*/
|
2024-02-16 13:38:19 -08:00
|
|
|
bool validate_dst_size_and_exec_size_ratio = !is_mixed_float(isa, inst);
|
2019-02-01 11:41:33 +01:00
|
|
|
|
|
|
|
|
if (validate_dst_size_and_exec_size_ratio &&
|
|
|
|
|
exec_type_size > dst_type_size) {
|
2022-06-29 14:13:31 -07:00
|
|
|
if (!(dst_type_is_byte && inst_is_raw_move(isa, inst))) {
|
2018-07-09 02:00:34 +02:00
|
|
|
ERROR_IF(dst_stride * dst_type_size != exec_type_size,
|
|
|
|
|
"Destination stride must be equal to the ratio of the sizes "
|
|
|
|
|
"of the execution data type to the destination type");
|
|
|
|
|
}
|
2016-11-09 12:00:43 -08:00
|
|
|
|
2016-11-21 10:26:57 -08:00
|
|
|
unsigned subreg = brw_inst_dst_da1_subreg_nr(devinfo, inst);
|
|
|
|
|
|
2016-11-09 12:00:43 -08:00
|
|
|
if (brw_inst_access_mode(devinfo, inst) == BRW_ALIGN_1 &&
|
|
|
|
|
brw_inst_dst_address_mode(devinfo, inst) == BRW_ADDRESS_DIRECT) {
|
2016-11-21 10:26:57 -08:00
|
|
|
/* The i965 PRM says:
|
|
|
|
|
*
|
|
|
|
|
* Implementation Restriction: The relaxed alignment rule for byte
|
|
|
|
|
* destination (#10.5) is not supported.
|
|
|
|
|
*/
|
2024-02-16 13:38:19 -08:00
|
|
|
if (dst_type_is_byte) {
|
2016-11-21 10:26:57 -08:00
|
|
|
ERROR_IF(subreg % exec_type_size != 0 &&
|
|
|
|
|
subreg % exec_type_size != 1,
|
|
|
|
|
"Destination subreg must be aligned to the size of the "
|
|
|
|
|
"execution data type (or to the next lowest byte for byte "
|
|
|
|
|
"destinations)");
|
|
|
|
|
} else {
|
|
|
|
|
ERROR_IF(subreg % exec_type_size != 0,
|
|
|
|
|
"Destination subreg must be aligned to the size of the "
|
|
|
|
|
"execution data type");
|
|
|
|
|
}
|
2016-11-09 12:00:43 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return error_msg;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-05 20:49:48 -07:00
|
|
|
/**
|
|
|
|
|
* Checks restrictions listed in "General Restrictions on Regioning Parameters"
|
|
|
|
|
* in the "Register Region Restrictions" section.
|
|
|
|
|
*/
|
|
|
|
|
static struct string
|
2022-06-29 14:13:31 -07:00
|
|
|
general_restrictions_on_region_parameters(const struct brw_isa_info *isa,
|
2016-11-05 20:49:48 -07:00
|
|
|
const brw_inst *inst)
|
|
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
|
|
|
|
|
2016-11-05 20:49:48 -07:00
|
|
|
const struct opcode_desc *desc =
|
2022-06-29 14:13:31 -07:00
|
|
|
brw_opcode_desc(isa, brw_inst_opcode(isa, inst));
|
2022-12-08 15:39:01 -08:00
|
|
|
unsigned num_sources = brw_num_sources_from_inst(isa, inst);
|
2016-11-05 20:49:48 -07:00
|
|
|
unsigned exec_size = 1 << brw_inst_exec_size(devinfo, inst);
|
|
|
|
|
struct string error_msg = { .str = NULL, .len = 0 };
|
|
|
|
|
|
|
|
|
|
if (num_sources == 3)
|
|
|
|
|
return (struct string){};
|
|
|
|
|
|
2018-11-15 15:17:06 -06:00
|
|
|
/* Split sends don't have the bits in the instruction to encode regions so
|
|
|
|
|
* there's nothing to check.
|
|
|
|
|
*/
|
2022-06-29 14:13:31 -07:00
|
|
|
if (inst_is_split_send(isa, inst))
|
2018-11-15 15:17:06 -06:00
|
|
|
return (struct string){};
|
|
|
|
|
|
2016-11-05 20:49:48 -07:00
|
|
|
if (brw_inst_access_mode(devinfo, inst) == BRW_ALIGN_16) {
|
|
|
|
|
if (desc->ndst != 0 && !dst_is_null(devinfo, inst))
|
|
|
|
|
ERROR_IF(brw_inst_dst_hstride(devinfo, inst) != BRW_HORIZONTAL_STRIDE_1,
|
|
|
|
|
"Destination Horizontal Stride must be 1");
|
|
|
|
|
|
|
|
|
|
if (num_sources >= 1) {
|
2024-02-16 13:38:19 -08:00
|
|
|
ERROR_IF(brw_inst_src0_reg_file(devinfo, inst) != BRW_IMMEDIATE_VALUE &&
|
|
|
|
|
brw_inst_src0_vstride(devinfo, inst) != BRW_VERTICAL_STRIDE_0 &&
|
|
|
|
|
brw_inst_src0_vstride(devinfo, inst) != BRW_VERTICAL_STRIDE_2 &&
|
|
|
|
|
brw_inst_src0_vstride(devinfo, inst) != BRW_VERTICAL_STRIDE_4,
|
|
|
|
|
"In Align16 mode, only VertStride of 0, 2, or 4 is allowed");
|
2016-11-05 20:49:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (num_sources == 2) {
|
2024-02-16 13:38:19 -08:00
|
|
|
ERROR_IF(brw_inst_src1_reg_file(devinfo, inst) != BRW_IMMEDIATE_VALUE &&
|
|
|
|
|
brw_inst_src1_vstride(devinfo, inst) != BRW_VERTICAL_STRIDE_0 &&
|
|
|
|
|
brw_inst_src1_vstride(devinfo, inst) != BRW_VERTICAL_STRIDE_2 &&
|
|
|
|
|
brw_inst_src1_vstride(devinfo, inst) != BRW_VERTICAL_STRIDE_4,
|
|
|
|
|
"In Align16 mode, only VertStride of 0, 2, or 4 is allowed");
|
2016-11-05 20:49:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return error_msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < num_sources; i++) {
|
|
|
|
|
unsigned vstride, width, hstride, element_size, subreg;
|
2017-07-26 21:08:20 -07:00
|
|
|
enum brw_reg_type type;
|
2016-11-05 20:49:48 -07:00
|
|
|
|
|
|
|
|
#define DO_SRC(n) \
|
|
|
|
|
if (brw_inst_src ## n ## _reg_file(devinfo, inst) == \
|
|
|
|
|
BRW_IMMEDIATE_VALUE) \
|
|
|
|
|
continue; \
|
|
|
|
|
\
|
2017-08-29 18:25:54 -07:00
|
|
|
vstride = STRIDE(brw_inst_src ## n ## _vstride(devinfo, inst)); \
|
|
|
|
|
width = WIDTH(brw_inst_src ## n ## _width(devinfo, inst)); \
|
|
|
|
|
hstride = STRIDE(brw_inst_src ## n ## _hstride(devinfo, inst)); \
|
2017-07-26 21:08:20 -07:00
|
|
|
type = brw_inst_src ## n ## _type(devinfo, inst); \
|
|
|
|
|
element_size = brw_reg_type_to_size(type); \
|
2016-11-05 20:49:48 -07:00
|
|
|
subreg = brw_inst_src ## n ## _da1_subreg_nr(devinfo, inst)
|
|
|
|
|
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
DO_SRC(0);
|
2017-08-25 19:22:51 -07:00
|
|
|
} else {
|
2016-11-05 20:49:48 -07:00
|
|
|
DO_SRC(1);
|
|
|
|
|
}
|
|
|
|
|
#undef DO_SRC
|
|
|
|
|
|
|
|
|
|
/* ExecSize must be greater than or equal to Width. */
|
|
|
|
|
ERROR_IF(exec_size < width, "ExecSize must be greater than or equal "
|
|
|
|
|
"to Width");
|
|
|
|
|
|
|
|
|
|
/* If ExecSize = Width and HorzStride ≠ 0,
|
|
|
|
|
* VertStride must be set to Width * HorzStride.
|
|
|
|
|
*/
|
|
|
|
|
if (exec_size == width && hstride != 0) {
|
|
|
|
|
ERROR_IF(vstride != width * hstride,
|
|
|
|
|
"If ExecSize = Width and HorzStride ≠ 0, "
|
|
|
|
|
"VertStride must be set to Width * HorzStride");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If Width = 1, HorzStride must be 0 regardless of the values of
|
|
|
|
|
* ExecSize and VertStride.
|
|
|
|
|
*/
|
|
|
|
|
if (width == 1) {
|
|
|
|
|
ERROR_IF(hstride != 0,
|
|
|
|
|
"If Width = 1, HorzStride must be 0 regardless "
|
|
|
|
|
"of the values of ExecSize and VertStride");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If ExecSize = Width = 1, both VertStride and HorzStride must be 0. */
|
|
|
|
|
if (exec_size == 1 && width == 1) {
|
|
|
|
|
ERROR_IF(vstride != 0 || hstride != 0,
|
|
|
|
|
"If ExecSize = Width = 1, both VertStride "
|
|
|
|
|
"and HorzStride must be 0");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If VertStride = HorzStride = 0, Width must be 1 regardless of the
|
|
|
|
|
* value of ExecSize.
|
|
|
|
|
*/
|
|
|
|
|
if (vstride == 0 && hstride == 0) {
|
|
|
|
|
ERROR_IF(width != 1,
|
|
|
|
|
"If VertStride = HorzStride = 0, Width must be "
|
|
|
|
|
"1 regardless of the value of ExecSize");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* VertStride must be used to cross GRF register boundaries. This rule
|
|
|
|
|
* implies that elements within a 'Width' cannot cross GRF boundaries.
|
|
|
|
|
*/
|
2017-05-08 18:55:06 +01:00
|
|
|
const uint64_t mask = (1ULL << element_size) - 1;
|
2016-11-05 20:49:48 -07:00
|
|
|
unsigned rowbase = subreg;
|
|
|
|
|
|
|
|
|
|
for (int y = 0; y < exec_size / width; y++) {
|
|
|
|
|
uint64_t access_mask = 0;
|
|
|
|
|
unsigned offset = rowbase;
|
|
|
|
|
|
|
|
|
|
for (int x = 0; x < width; x++) {
|
intel/compiler: Don't left-shift by >= the number of bits of the type
To avoid it, use the modulo of the number of bits in the value being
shifted, which is presumably what ended up happening on x86.
Flagged by UBSan:
../src/intel/compiler/brw_eu_validate.c:974:33: runtime error: shift exponent 64 is too large for 64-bit type 'long unsigned int'
#0 0x561abb612ab3 in general_restrictions_on_region_parameters ../src/intel/compiler/brw_eu_validate.c:974
#1 0x561abb617574 in brw_validate_instructions ../src/intel/compiler/brw_eu_validate.c:1851
#2 0x561abb53bd31 in validate ../src/intel/compiler/test_eu_validate.cpp:106
#3 0x561abb555369 in validation_test_source_cannot_span_more_than_2_registers_Test::TestBody() ../src/intel/compiler/test_eu_validate.cpp:486
#4 0x561abb742651 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2402
#5 0x561abb72e64d in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2438
#6 0x561abb6d5451 in testing::Test::Run() ../src/gtest/src/gtest.cc:2474
#7 0x561abb6d7b2a in testing::TestInfo::Run() ../src/gtest/src/gtest.cc:2656
#8 0x561abb6da2b8 in testing::TestCase::Run() ../src/gtest/src/gtest.cc:2774
#9 0x561abb6f5c92 in testing::internal::UnitTestImpl::RunAllTests() ../src/gtest/src/gtest.cc:4649
#10 0x561abb74626a in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2402
#11 0x561abb732025 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2438
#12 0x561abb6ed2b4 in testing::UnitTest::Run() ../src/gtest/src/gtest.cc:4257
#13 0x561abb768b3b in RUN_ALL_TESTS() ../src/gtest/include/gtest/gtest.h:2233
#14 0x561abb7689fb in main ../src/gtest/src/gtest_main.cc:37
#15 0x7f525e5a9bba in __libc_start_main ../csu/libc-start.c:308
#16 0x561abb538ed9 in _start (/home/daenzer/src/mesa-git/mesa/build-amd64-sanitize/src/intel/compiler/eu_validate+0x1b8ed9)
Reviewed-by: Adam Jackson <ajax@redhat.com>
2019-09-25 11:17:11 +02:00
|
|
|
access_mask |= mask << (offset % 64);
|
2016-11-05 20:49:48 -07:00
|
|
|
offset += hstride * element_size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rowbase += vstride * element_size;
|
|
|
|
|
|
|
|
|
|
if ((uint32_t)access_mask != 0 && (access_mask >> 32) != 0) {
|
|
|
|
|
ERROR("VertStride must be used to cross GRF register boundaries");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Dst.HorzStride must not be 0. */
|
|
|
|
|
if (desc->ndst != 0 && !dst_is_null(devinfo, inst)) {
|
|
|
|
|
ERROR_IF(brw_inst_dst_hstride(devinfo, inst) == BRW_HORIZONTAL_STRIDE_0,
|
|
|
|
|
"Destination Horizontal Stride must not be 0");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return error_msg;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 09:13:22 +01:00
|
|
|
static struct string
|
2022-06-29 14:13:31 -07:00
|
|
|
special_restrictions_for_mixed_float_mode(const struct brw_isa_info *isa,
|
2019-02-06 09:13:22 +01:00
|
|
|
const brw_inst *inst)
|
|
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
|
|
|
|
|
2019-02-06 09:13:22 +01:00
|
|
|
struct string error_msg = { .str = NULL, .len = 0 };
|
|
|
|
|
|
2022-06-29 14:13:31 -07:00
|
|
|
const unsigned opcode = brw_inst_opcode(isa, inst);
|
2022-12-08 15:39:01 -08:00
|
|
|
const unsigned num_sources = brw_num_sources_from_inst(isa, inst);
|
2019-02-06 09:13:22 +01:00
|
|
|
if (num_sources >= 3)
|
|
|
|
|
return error_msg;
|
|
|
|
|
|
2022-06-29 14:13:31 -07:00
|
|
|
if (!is_mixed_float(isa, inst))
|
2019-02-06 09:13:22 +01:00
|
|
|
return error_msg;
|
|
|
|
|
|
|
|
|
|
unsigned exec_size = 1 << brw_inst_exec_size(devinfo, inst);
|
|
|
|
|
bool is_align16 = brw_inst_access_mode(devinfo, inst) == BRW_ALIGN_16;
|
|
|
|
|
|
|
|
|
|
enum brw_reg_type src0_type = brw_inst_src0_type(devinfo, inst);
|
|
|
|
|
enum brw_reg_type src1_type = num_sources > 1 ?
|
|
|
|
|
brw_inst_src1_type(devinfo, inst) : 0;
|
|
|
|
|
enum brw_reg_type dst_type = brw_inst_dst_type(devinfo, inst);
|
|
|
|
|
|
|
|
|
|
unsigned dst_stride = STRIDE(brw_inst_dst_hstride(devinfo, inst));
|
|
|
|
|
bool dst_is_packed = is_packed(exec_size * dst_stride, exec_size, dst_stride);
|
|
|
|
|
|
|
|
|
|
/* From the SKL PRM, Special Restrictions for Handling Mixed Mode
|
|
|
|
|
* Float Operations:
|
|
|
|
|
*
|
|
|
|
|
* "Indirect addressing on source is not supported when source and
|
|
|
|
|
* destination data types are mixed float."
|
|
|
|
|
*/
|
|
|
|
|
ERROR_IF(brw_inst_src0_address_mode(devinfo, inst) != BRW_ADDRESS_DIRECT ||
|
|
|
|
|
(num_sources > 1 &&
|
|
|
|
|
brw_inst_src1_address_mode(devinfo, inst) != BRW_ADDRESS_DIRECT),
|
|
|
|
|
"Indirect addressing on source is not supported when source and "
|
|
|
|
|
"destination data types are mixed float");
|
|
|
|
|
|
|
|
|
|
/* From the SKL PRM, Special Restrictions for Handling Mixed Mode
|
|
|
|
|
* Float Operations:
|
|
|
|
|
*
|
|
|
|
|
* "No SIMD16 in mixed mode when destination is f32. Instruction
|
|
|
|
|
* execution size must be no more than 8."
|
|
|
|
|
*/
|
intel/brw: Allow SIMD16 F and HF type conversion moves
On DG2, the lowering generated for these MOV instructions is
**awful**. The original SIMD16 MOV
{ 18} 67: mov(16) vgrf54+0.0:HF, vgrf46+0.0:F NoMask group0
is lowered to SIMD8 MOVs:
{ 18} 118: mov(8) vgrf54+0.0:HF, vgrf46+0.0:F NoMask group0
{ 18} 119: mov(8) vgrf54+0.16:HF, vgrf46+1.0:F NoMask group8
These MOVs violate Gfx12.5 region restrictions, so these are further
lowered:
{ 17} 119: mov(8) vgrf83<2>:HF, vgrf46+0.0:F NoMask group0
{ 19} 120: mov(8) vgrf54+0.0:UW, vgrf83<2>:UW NoMask group0
{ 19} 122: mov(8) vgrf84<2>:HF, vgrf46+1.0:F NoMask group8
{ 19} 123: mov(8) vgrf54+0.16:UW, vgrf84<2>:UW NoMask group8
The shader-db and fossil-db results are nothing to get excited
about. However, the affect on vk_cooperative_matrix_perf is substantial. In one subtest
shader: shaders/shmemfp16.spv
cooperativeMatrixProps = 8x8x16 A = float16_t B = float16_t C = float16_t D = float16_t scope = subgroup
TILE_M=128 TILE_N=128, TILE_K=32 BLayout=0
performance on my DG2 improved by ~60% due to a MASSIVE reduction in spills and fills:
-Native code for unnamed compute shader (null) (src_hash 0x00000000) (sha1 c6a41b1c4e7aa2da327a39a70ed36c822a4b172f)
-SIMD32 shader: 32484 instructions. 1 loops. 1893868 cycles. 737:1820 spills:fills, 442 sends, scheduled with mode none. Promoted 1 constants. Compacted 519744 to 492224 bytes (5%)
- START B0 (20782 cycles)
+Native code for unnamed compute shader (null) (src_hash 0x00000000) (sha1 621e960daad5b5579b176717f24a315e7ea560a1)
+SIMD32 shader: 23918 instructions. 1 loops. 1089894 cycles. 432:1166 spills:fills, 442 sends, scheduled with mode none. Promoted 1 constants. Compacted 382688 to 353232 bytes (8%)
shader-db:
All Gfx9 and later platforms had similar results. (Meteor Lake shown)
total instructions in shared programs: 19656270 -> 19653981 (-0.01%)
instructions in affected programs: 61810 -> 59521 (-3.70%)
helped: 116 / HURT: 0
total cycles in shared programs: 823368888 -> 823375854 (<.01%)
cycles in affected programs: 1165284 -> 1172250 (0.60%)
helped: 51 / HURT: 57
fossil-db:
DG2 and Meteor Lake had similar results. (Meteor Lake shown)
*** Shaders only in 'before' results are ignored:
fossil-db/steam-dxvk/total_war_warhammer3/2a3ed2ca632a7cb7/fs.32,
fossil-db/steam-dxvk/total_war_warhammer3/18b9d4a3b1961616/fs.32,
fossil-db/steam-dxvk/total_war_warhammer3/04ac9f3146a6db19/fs.32,
fossil-db/steam-dxvk/total_war_warhammer3/f37ebec6aa1b379a/fs.32,
fossil-db/steam-dxvk/total_war_warhammer3/255c987feb0d4310/fs.32, and 25
more
from 1 apps: fossil-db/steam-dxvk/total_war_warhammer3
Totals:
Instrs: 160946537 -> 160928389 (-0.01%); split: -0.01%, +0.00%
Cycles: 14125908620 -> 14125873958 (-0.00%); split: -0.00%, +0.00%
Totals from 1002 (0.15% of 652134) affected shaders:
Instrs: 411261 -> 393113 (-4.41%); split: -4.41%, +0.00%
Cycles: 16676735 -> 16642073 (-0.21%); split: -0.48%, +0.27%
Tiger Lake
Totals:
Instrs: 164511816 -> 164497202 (-0.01%); split: -0.01%, +0.00%
Cycles: 13801675722 -> 13801629397 (-0.00%); split: -0.00%, +0.00%
Subgroup size: 7955168 -> 7955152 (-0.00%)
Send messages: 8544494 -> 8544486 (-0.00%)
Totals from 997 (0.15% of 651454) affected shaders:
Instrs: 460820 -> 446206 (-3.17%); split: -3.17%, +0.00%
Cycles: 16265514 -> 16219189 (-0.28%); split: -0.84%, +0.56%
Subgroup size: 17552 -> 17536 (-0.09%)
Send messages: 26045 -> 26037 (-0.03%)
Ice Lake
Totals:
Instrs: 165504747 -> 165489970 (-0.01%); split: -0.01%, +0.00%
Cycles: 15145244554 -> 15145149627 (-0.00%); split: -0.00%, +0.00%
Subgroup size: 8107032 -> 8107016 (-0.00%)
Send messages: 8598680 -> 8598672 (-0.00%)
Spill count: 45427 -> 45423 (-0.01%)
Fill count: 74749 -> 74747 (-0.00%)
Totals from 1125 (0.17% of 656115) affected shaders:
Instrs: 521676 -> 506899 (-2.83%); split: -2.83%, +0.00%
Cycles: 19555434 -> 19460507 (-0.49%); split: -0.59%, +0.10%
Subgroup size: 21616 -> 21600 (-0.07%)
Send messages: 28623 -> 28615 (-0.03%)
Spill count: 603 -> 599 (-0.66%)
Fill count: 1362 -> 1360 (-0.15%)
Skylake
*** Shaders only in 'after' results are ignored:
fossil-db/steam-native/red_dead_redemption2/cef460b80bad8485/fs.16,
fossil-db/steam-native/red_dead_redemption2/cd5fe081e2e5529d/fs.16
from 1 apps: fossil-db/steam-native/red_dead_redemption2
Totals:
Instrs: 141607617 -> 141593776 (-0.01%); split: -0.01%, +0.00%
Cycles: 14257812441 -> 14257661671 (-0.00%); split: -0.00%, +0.00%
Subgroup size: 7743752 -> 7743736 (-0.00%)
Send messages: 7552728 -> 7552720 (-0.00%)
Spill count: 43660 -> 43661 (+0.00%)
Fill count: 71301 -> 71303 (+0.00%)
Totals from 1017 (0.16% of 636964) affected shaders:
Instrs: 392454 -> 378613 (-3.53%); split: -3.53%, +0.00%
Cycles: 16622974 -> 16472204 (-0.91%); split: -1.04%, +0.13%
Subgroup size: 19840 -> 19824 (-0.08%)
Send messages: 23021 -> 23013 (-0.03%)
Spill count: 484 -> 485 (+0.21%)
Fill count: 1155 -> 1157 (+0.17%)
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28281>
2023-10-17 09:48:38 -07:00
|
|
|
ERROR_IF(exec_size > 8 && dst_type == BRW_REGISTER_TYPE_F &&
|
|
|
|
|
opcode != BRW_OPCODE_MOV,
|
2019-02-06 09:13:22 +01:00
|
|
|
"Mixed float mode with 32-bit float destination is limited "
|
|
|
|
|
"to SIMD8");
|
|
|
|
|
|
|
|
|
|
if (is_align16) {
|
|
|
|
|
/* From the SKL PRM, Special Restrictions for Handling Mixed Mode
|
|
|
|
|
* Float Operations:
|
|
|
|
|
*
|
|
|
|
|
* "In Align16 mode, when half float and float data types are mixed
|
|
|
|
|
* between source operands OR between source and destination operands,
|
|
|
|
|
* the register content are assumed to be packed."
|
|
|
|
|
*
|
|
|
|
|
* Since Align16 doesn't have a concept of horizontal stride (or width),
|
|
|
|
|
* it means that vertical stride must always be 4, since 0 and 2 would
|
|
|
|
|
* lead to replicated data, and any other value is disallowed in Align16.
|
|
|
|
|
*/
|
|
|
|
|
ERROR_IF(brw_inst_src0_vstride(devinfo, inst) != BRW_VERTICAL_STRIDE_4,
|
|
|
|
|
"Align16 mixed float mode assumes packed data (vstride must be 4");
|
|
|
|
|
|
|
|
|
|
ERROR_IF(num_sources >= 2 &&
|
|
|
|
|
brw_inst_src1_vstride(devinfo, inst) != BRW_VERTICAL_STRIDE_4,
|
|
|
|
|
"Align16 mixed float mode assumes packed data (vstride must be 4");
|
|
|
|
|
|
|
|
|
|
/* From the SKL PRM, Special Restrictions for Handling Mixed Mode
|
|
|
|
|
* Float Operations:
|
|
|
|
|
*
|
|
|
|
|
* "For Align16 mixed mode, both input and output packed f16 data
|
|
|
|
|
* must be oword aligned, no oword crossing in packed f16."
|
|
|
|
|
*
|
|
|
|
|
* The previous rule requires that Align16 operands are always packed,
|
|
|
|
|
* and since there is only one bit for Align16 subnr, which represents
|
|
|
|
|
* offsets 0B and 16B, this rule is always enforced and we don't need to
|
|
|
|
|
* validate it.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* From the SKL PRM, Special Restrictions for Handling Mixed Mode
|
|
|
|
|
* Float Operations:
|
|
|
|
|
*
|
|
|
|
|
* "No SIMD16 in mixed mode when destination is packed f16 for both
|
|
|
|
|
* Align1 and Align16."
|
|
|
|
|
*
|
|
|
|
|
* And:
|
|
|
|
|
*
|
|
|
|
|
* "In Align16 mode, when half float and float data types are mixed
|
|
|
|
|
* between source operands OR between source and destination operands,
|
|
|
|
|
* the register content are assumed to be packed."
|
|
|
|
|
*
|
|
|
|
|
* Which implies that SIMD16 is not available in Align16. This is further
|
|
|
|
|
* confirmed by:
|
|
|
|
|
*
|
|
|
|
|
* "For Align16 mixed mode, both input and output packed f16 data
|
|
|
|
|
* must be oword aligned, no oword crossing in packed f16"
|
|
|
|
|
*
|
|
|
|
|
* Since oword-aligned packed f16 data would cross oword boundaries when
|
|
|
|
|
* the execution size is larger than 8.
|
|
|
|
|
*/
|
|
|
|
|
ERROR_IF(exec_size > 8, "Align16 mixed float mode is limited to SIMD8");
|
|
|
|
|
|
|
|
|
|
/* From the SKL PRM, Special Restrictions for Handling Mixed Mode
|
|
|
|
|
* Float Operations:
|
|
|
|
|
*
|
|
|
|
|
* "No accumulator read access for Align16 mixed float."
|
|
|
|
|
*/
|
2022-06-29 14:13:31 -07:00
|
|
|
ERROR_IF(inst_uses_src_acc(isa, inst),
|
2019-02-06 09:13:22 +01:00
|
|
|
"No accumulator read access for Align16 mixed float");
|
|
|
|
|
} else {
|
|
|
|
|
assert(!is_align16);
|
|
|
|
|
|
|
|
|
|
/* From the SKL PRM, Special Restrictions for Handling Mixed Mode
|
|
|
|
|
* Float Operations:
|
|
|
|
|
*
|
|
|
|
|
* "No SIMD16 in mixed mode when destination is packed f16 for both
|
|
|
|
|
* Align1 and Align16."
|
|
|
|
|
*/
|
|
|
|
|
ERROR_IF(exec_size > 8 && dst_is_packed &&
|
intel/brw: Allow SIMD16 F and HF type conversion moves
On DG2, the lowering generated for these MOV instructions is
**awful**. The original SIMD16 MOV
{ 18} 67: mov(16) vgrf54+0.0:HF, vgrf46+0.0:F NoMask group0
is lowered to SIMD8 MOVs:
{ 18} 118: mov(8) vgrf54+0.0:HF, vgrf46+0.0:F NoMask group0
{ 18} 119: mov(8) vgrf54+0.16:HF, vgrf46+1.0:F NoMask group8
These MOVs violate Gfx12.5 region restrictions, so these are further
lowered:
{ 17} 119: mov(8) vgrf83<2>:HF, vgrf46+0.0:F NoMask group0
{ 19} 120: mov(8) vgrf54+0.0:UW, vgrf83<2>:UW NoMask group0
{ 19} 122: mov(8) vgrf84<2>:HF, vgrf46+1.0:F NoMask group8
{ 19} 123: mov(8) vgrf54+0.16:UW, vgrf84<2>:UW NoMask group8
The shader-db and fossil-db results are nothing to get excited
about. However, the affect on vk_cooperative_matrix_perf is substantial. In one subtest
shader: shaders/shmemfp16.spv
cooperativeMatrixProps = 8x8x16 A = float16_t B = float16_t C = float16_t D = float16_t scope = subgroup
TILE_M=128 TILE_N=128, TILE_K=32 BLayout=0
performance on my DG2 improved by ~60% due to a MASSIVE reduction in spills and fills:
-Native code for unnamed compute shader (null) (src_hash 0x00000000) (sha1 c6a41b1c4e7aa2da327a39a70ed36c822a4b172f)
-SIMD32 shader: 32484 instructions. 1 loops. 1893868 cycles. 737:1820 spills:fills, 442 sends, scheduled with mode none. Promoted 1 constants. Compacted 519744 to 492224 bytes (5%)
- START B0 (20782 cycles)
+Native code for unnamed compute shader (null) (src_hash 0x00000000) (sha1 621e960daad5b5579b176717f24a315e7ea560a1)
+SIMD32 shader: 23918 instructions. 1 loops. 1089894 cycles. 432:1166 spills:fills, 442 sends, scheduled with mode none. Promoted 1 constants. Compacted 382688 to 353232 bytes (8%)
shader-db:
All Gfx9 and later platforms had similar results. (Meteor Lake shown)
total instructions in shared programs: 19656270 -> 19653981 (-0.01%)
instructions in affected programs: 61810 -> 59521 (-3.70%)
helped: 116 / HURT: 0
total cycles in shared programs: 823368888 -> 823375854 (<.01%)
cycles in affected programs: 1165284 -> 1172250 (0.60%)
helped: 51 / HURT: 57
fossil-db:
DG2 and Meteor Lake had similar results. (Meteor Lake shown)
*** Shaders only in 'before' results are ignored:
fossil-db/steam-dxvk/total_war_warhammer3/2a3ed2ca632a7cb7/fs.32,
fossil-db/steam-dxvk/total_war_warhammer3/18b9d4a3b1961616/fs.32,
fossil-db/steam-dxvk/total_war_warhammer3/04ac9f3146a6db19/fs.32,
fossil-db/steam-dxvk/total_war_warhammer3/f37ebec6aa1b379a/fs.32,
fossil-db/steam-dxvk/total_war_warhammer3/255c987feb0d4310/fs.32, and 25
more
from 1 apps: fossil-db/steam-dxvk/total_war_warhammer3
Totals:
Instrs: 160946537 -> 160928389 (-0.01%); split: -0.01%, +0.00%
Cycles: 14125908620 -> 14125873958 (-0.00%); split: -0.00%, +0.00%
Totals from 1002 (0.15% of 652134) affected shaders:
Instrs: 411261 -> 393113 (-4.41%); split: -4.41%, +0.00%
Cycles: 16676735 -> 16642073 (-0.21%); split: -0.48%, +0.27%
Tiger Lake
Totals:
Instrs: 164511816 -> 164497202 (-0.01%); split: -0.01%, +0.00%
Cycles: 13801675722 -> 13801629397 (-0.00%); split: -0.00%, +0.00%
Subgroup size: 7955168 -> 7955152 (-0.00%)
Send messages: 8544494 -> 8544486 (-0.00%)
Totals from 997 (0.15% of 651454) affected shaders:
Instrs: 460820 -> 446206 (-3.17%); split: -3.17%, +0.00%
Cycles: 16265514 -> 16219189 (-0.28%); split: -0.84%, +0.56%
Subgroup size: 17552 -> 17536 (-0.09%)
Send messages: 26045 -> 26037 (-0.03%)
Ice Lake
Totals:
Instrs: 165504747 -> 165489970 (-0.01%); split: -0.01%, +0.00%
Cycles: 15145244554 -> 15145149627 (-0.00%); split: -0.00%, +0.00%
Subgroup size: 8107032 -> 8107016 (-0.00%)
Send messages: 8598680 -> 8598672 (-0.00%)
Spill count: 45427 -> 45423 (-0.01%)
Fill count: 74749 -> 74747 (-0.00%)
Totals from 1125 (0.17% of 656115) affected shaders:
Instrs: 521676 -> 506899 (-2.83%); split: -2.83%, +0.00%
Cycles: 19555434 -> 19460507 (-0.49%); split: -0.59%, +0.10%
Subgroup size: 21616 -> 21600 (-0.07%)
Send messages: 28623 -> 28615 (-0.03%)
Spill count: 603 -> 599 (-0.66%)
Fill count: 1362 -> 1360 (-0.15%)
Skylake
*** Shaders only in 'after' results are ignored:
fossil-db/steam-native/red_dead_redemption2/cef460b80bad8485/fs.16,
fossil-db/steam-native/red_dead_redemption2/cd5fe081e2e5529d/fs.16
from 1 apps: fossil-db/steam-native/red_dead_redemption2
Totals:
Instrs: 141607617 -> 141593776 (-0.01%); split: -0.01%, +0.00%
Cycles: 14257812441 -> 14257661671 (-0.00%); split: -0.00%, +0.00%
Subgroup size: 7743752 -> 7743736 (-0.00%)
Send messages: 7552728 -> 7552720 (-0.00%)
Spill count: 43660 -> 43661 (+0.00%)
Fill count: 71301 -> 71303 (+0.00%)
Totals from 1017 (0.16% of 636964) affected shaders:
Instrs: 392454 -> 378613 (-3.53%); split: -3.53%, +0.00%
Cycles: 16622974 -> 16472204 (-0.91%); split: -1.04%, +0.13%
Subgroup size: 19840 -> 19824 (-0.08%)
Send messages: 23021 -> 23013 (-0.03%)
Spill count: 484 -> 485 (+0.21%)
Fill count: 1155 -> 1157 (+0.17%)
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28281>
2023-10-17 09:48:38 -07:00
|
|
|
dst_type == BRW_REGISTER_TYPE_HF &&
|
|
|
|
|
opcode != BRW_OPCODE_MOV,
|
2019-02-06 09:13:22 +01:00
|
|
|
"Align1 mixed float mode is limited to SIMD8 when destination "
|
|
|
|
|
"is packed half-float");
|
|
|
|
|
|
|
|
|
|
/* From the SKL PRM, Special Restrictions for Handling Mixed Mode
|
|
|
|
|
* Float Operations:
|
|
|
|
|
*
|
|
|
|
|
* "Math operations for mixed mode:
|
|
|
|
|
* - In Align1, f16 inputs need to be strided"
|
|
|
|
|
*/
|
|
|
|
|
if (opcode == BRW_OPCODE_MATH) {
|
|
|
|
|
if (src0_type == BRW_REGISTER_TYPE_HF) {
|
|
|
|
|
ERROR_IF(STRIDE(brw_inst_src0_hstride(devinfo, inst)) <= 1,
|
|
|
|
|
"Align1 mixed mode math needs strided half-float inputs");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (num_sources >= 2 && src1_type == BRW_REGISTER_TYPE_HF) {
|
|
|
|
|
ERROR_IF(STRIDE(brw_inst_src1_hstride(devinfo, inst)) <= 1,
|
|
|
|
|
"Align1 mixed mode math needs strided half-float inputs");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dst_type == BRW_REGISTER_TYPE_HF && dst_stride == 1) {
|
|
|
|
|
/* From the SKL PRM, Special Restrictions for Handling Mixed Mode
|
|
|
|
|
* Float Operations:
|
|
|
|
|
*
|
|
|
|
|
* "In Align1, destination stride can be smaller than execution
|
|
|
|
|
* type. When destination is stride of 1, 16 bit packed data is
|
|
|
|
|
* updated on the destination. However, output packed f16 data
|
|
|
|
|
* must be oword aligned, no oword crossing in packed f16."
|
|
|
|
|
*
|
|
|
|
|
* The requirement of not crossing oword boundaries for 16-bit oword
|
|
|
|
|
* aligned data means that execution size is limited to 8.
|
|
|
|
|
*/
|
|
|
|
|
unsigned subreg;
|
|
|
|
|
if (brw_inst_dst_address_mode(devinfo, inst) == BRW_ADDRESS_DIRECT)
|
|
|
|
|
subreg = brw_inst_dst_da1_subreg_nr(devinfo, inst);
|
|
|
|
|
else
|
|
|
|
|
subreg = brw_inst_dst_ia_subreg_nr(devinfo, inst);
|
|
|
|
|
ERROR_IF(subreg % 16 != 0,
|
|
|
|
|
"Align1 mixed mode packed half-float output must be "
|
|
|
|
|
"oword aligned");
|
|
|
|
|
ERROR_IF(exec_size > 8,
|
|
|
|
|
"Align1 mixed mode packed half-float output must not "
|
|
|
|
|
"cross oword boundaries (max exec size is 8)");
|
|
|
|
|
|
|
|
|
|
/* From the SKL PRM, Special Restrictions for Handling Mixed Mode
|
|
|
|
|
* Float Operations:
|
|
|
|
|
*
|
|
|
|
|
* "When source is float or half float from accumulator register and
|
|
|
|
|
* destination is half float with a stride of 1, the source must
|
|
|
|
|
* register aligned. i.e., source must have offset zero."
|
|
|
|
|
*
|
|
|
|
|
* Align16 mixed float mode doesn't allow accumulator access on sources,
|
|
|
|
|
* so we only need to check this for Align1.
|
|
|
|
|
*/
|
|
|
|
|
if (src0_is_acc(devinfo, inst) &&
|
|
|
|
|
(src0_type == BRW_REGISTER_TYPE_F ||
|
|
|
|
|
src0_type == BRW_REGISTER_TYPE_HF)) {
|
|
|
|
|
ERROR_IF(brw_inst_src0_da1_subreg_nr(devinfo, inst) != 0,
|
|
|
|
|
"Mixed float mode requires register-aligned accumulator "
|
|
|
|
|
"source reads when destination is packed half-float");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (num_sources > 1 &&
|
|
|
|
|
src1_is_acc(devinfo, inst) &&
|
|
|
|
|
(src1_type == BRW_REGISTER_TYPE_F ||
|
|
|
|
|
src1_type == BRW_REGISTER_TYPE_HF)) {
|
|
|
|
|
ERROR_IF(brw_inst_src1_da1_subreg_nr(devinfo, inst) != 0,
|
|
|
|
|
"Mixed float mode requires register-aligned accumulator "
|
|
|
|
|
"source reads when destination is packed half-float");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* From the SKL PRM, Special Restrictions for Handling Mixed Mode
|
|
|
|
|
* Float Operations:
|
|
|
|
|
*
|
|
|
|
|
* "No swizzle is allowed when an accumulator is used as an implicit
|
|
|
|
|
* source or an explicit source in an instruction. i.e. when
|
|
|
|
|
* destination is half float with an implicit accumulator source,
|
|
|
|
|
* destination stride needs to be 2."
|
|
|
|
|
*
|
|
|
|
|
* FIXME: it is not quite clear what the first sentence actually means
|
|
|
|
|
* or its link to the implication described after it, so we only
|
|
|
|
|
* validate the explicit implication, which is clearly described.
|
|
|
|
|
*/
|
|
|
|
|
if (dst_type == BRW_REGISTER_TYPE_HF &&
|
2022-06-29 14:13:31 -07:00
|
|
|
inst_uses_src_acc(isa, inst)) {
|
2019-02-06 09:13:22 +01:00
|
|
|
ERROR_IF(dst_stride != 2,
|
|
|
|
|
"Mixed float mode with implicit/explicit accumulator "
|
|
|
|
|
"source and half-float destination requires a stride "
|
|
|
|
|
"of 2 on the destination");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return error_msg;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-15 16:06:51 -08:00
|
|
|
/**
|
|
|
|
|
* Creates an \p access_mask for an \p exec_size, \p element_size, and a region
|
|
|
|
|
*
|
|
|
|
|
* An \p access_mask is a 32-element array of uint64_t, where each uint64_t is
|
|
|
|
|
* a bitmask of bytes accessed by the region.
|
|
|
|
|
*
|
|
|
|
|
* For instance the access mask of the source gX.1<4,2,2>F in an exec_size = 4
|
|
|
|
|
* instruction would be
|
|
|
|
|
*
|
|
|
|
|
* access_mask[0] = 0x00000000000000F0
|
|
|
|
|
* access_mask[1] = 0x000000000000F000
|
|
|
|
|
* access_mask[2] = 0x0000000000F00000
|
|
|
|
|
* access_mask[3] = 0x00000000F0000000
|
|
|
|
|
* access_mask[4-31] = 0
|
|
|
|
|
*
|
|
|
|
|
* because the first execution channel accesses bytes 7-4 and the second
|
|
|
|
|
* execution channel accesses bytes 15-12, etc.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
align1_access_mask(uint64_t access_mask[static 32],
|
|
|
|
|
unsigned exec_size, unsigned element_size, unsigned subreg,
|
|
|
|
|
unsigned vstride, unsigned width, unsigned hstride)
|
|
|
|
|
{
|
2017-05-08 18:55:06 +01:00
|
|
|
const uint64_t mask = (1ULL << element_size) - 1;
|
2016-11-15 16:06:51 -08:00
|
|
|
unsigned rowbase = subreg;
|
|
|
|
|
unsigned element = 0;
|
|
|
|
|
|
|
|
|
|
for (int y = 0; y < exec_size / width; y++) {
|
|
|
|
|
unsigned offset = rowbase;
|
|
|
|
|
|
|
|
|
|
for (int x = 0; x < width; x++) {
|
intel/compiler: Don't left-shift by >= the number of bits of the type
To avoid it, use the modulo of the number of bits in the value being
shifted, which is presumably what ended up happening on x86.
Flagged by UBSan:
../src/intel/compiler/brw_eu_validate.c:974:33: runtime error: shift exponent 64 is too large for 64-bit type 'long unsigned int'
#0 0x561abb612ab3 in general_restrictions_on_region_parameters ../src/intel/compiler/brw_eu_validate.c:974
#1 0x561abb617574 in brw_validate_instructions ../src/intel/compiler/brw_eu_validate.c:1851
#2 0x561abb53bd31 in validate ../src/intel/compiler/test_eu_validate.cpp:106
#3 0x561abb555369 in validation_test_source_cannot_span_more_than_2_registers_Test::TestBody() ../src/intel/compiler/test_eu_validate.cpp:486
#4 0x561abb742651 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2402
#5 0x561abb72e64d in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2438
#6 0x561abb6d5451 in testing::Test::Run() ../src/gtest/src/gtest.cc:2474
#7 0x561abb6d7b2a in testing::TestInfo::Run() ../src/gtest/src/gtest.cc:2656
#8 0x561abb6da2b8 in testing::TestCase::Run() ../src/gtest/src/gtest.cc:2774
#9 0x561abb6f5c92 in testing::internal::UnitTestImpl::RunAllTests() ../src/gtest/src/gtest.cc:4649
#10 0x561abb74626a in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2402
#11 0x561abb732025 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2438
#12 0x561abb6ed2b4 in testing::UnitTest::Run() ../src/gtest/src/gtest.cc:4257
#13 0x561abb768b3b in RUN_ALL_TESTS() ../src/gtest/include/gtest/gtest.h:2233
#14 0x561abb7689fb in main ../src/gtest/src/gtest_main.cc:37
#15 0x7f525e5a9bba in __libc_start_main ../csu/libc-start.c:308
#16 0x561abb538ed9 in _start (/home/daenzer/src/mesa-git/mesa/build-amd64-sanitize/src/intel/compiler/eu_validate+0x1b8ed9)
Reviewed-by: Adam Jackson <ajax@redhat.com>
2019-09-25 11:17:11 +02:00
|
|
|
access_mask[element++] = mask << (offset % 64);
|
2016-11-15 16:06:51 -08:00
|
|
|
offset += hstride * element_size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rowbase += vstride * element_size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert(element == 0 || element == exec_size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the number of registers accessed according to the \p access_mask
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
registers_read(const uint64_t access_mask[static 32])
|
|
|
|
|
{
|
|
|
|
|
int regs_read = 0;
|
|
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < 32; i++) {
|
|
|
|
|
if (access_mask[i] > 0xFFFFFFFF) {
|
|
|
|
|
return 2;
|
|
|
|
|
} else if (access_mask[i]) {
|
|
|
|
|
regs_read = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return regs_read;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks restrictions listed in "Region Alignment Rules" in the "Register
|
|
|
|
|
* Region Restrictions" section.
|
|
|
|
|
*/
|
|
|
|
|
static struct string
|
2022-06-29 14:13:31 -07:00
|
|
|
region_alignment_rules(const struct brw_isa_info *isa,
|
2016-11-15 16:06:51 -08:00
|
|
|
const brw_inst *inst)
|
|
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
2016-11-15 16:06:51 -08:00
|
|
|
const struct opcode_desc *desc =
|
2022-06-29 14:13:31 -07:00
|
|
|
brw_opcode_desc(isa, brw_inst_opcode(isa, inst));
|
2022-12-08 15:39:01 -08:00
|
|
|
unsigned num_sources = brw_num_sources_from_inst(isa, inst);
|
2016-11-15 16:06:51 -08:00
|
|
|
unsigned exec_size = 1 << brw_inst_exec_size(devinfo, inst);
|
|
|
|
|
uint64_t dst_access_mask[32], src0_access_mask[32], src1_access_mask[32];
|
|
|
|
|
struct string error_msg = { .str = NULL, .len = 0 };
|
|
|
|
|
|
|
|
|
|
if (num_sources == 3)
|
|
|
|
|
return (struct string){};
|
|
|
|
|
|
|
|
|
|
if (brw_inst_access_mode(devinfo, inst) == BRW_ALIGN_16)
|
|
|
|
|
return (struct string){};
|
|
|
|
|
|
2022-06-29 14:13:31 -07:00
|
|
|
if (inst_is_send(isa, inst))
|
2016-11-15 16:06:51 -08:00
|
|
|
return (struct string){};
|
|
|
|
|
|
|
|
|
|
memset(dst_access_mask, 0, sizeof(dst_access_mask));
|
|
|
|
|
memset(src0_access_mask, 0, sizeof(src0_access_mask));
|
|
|
|
|
memset(src1_access_mask, 0, sizeof(src1_access_mask));
|
|
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < num_sources; i++) {
|
|
|
|
|
unsigned vstride, width, hstride, element_size, subreg;
|
2017-07-26 21:08:20 -07:00
|
|
|
enum brw_reg_type type;
|
2016-11-15 16:06:51 -08:00
|
|
|
|
|
|
|
|
/* In Direct Addressing mode, a source cannot span more than 2 adjacent
|
|
|
|
|
* GRF registers.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#define DO_SRC(n) \
|
|
|
|
|
if (brw_inst_src ## n ## _address_mode(devinfo, inst) != \
|
|
|
|
|
BRW_ADDRESS_DIRECT) \
|
|
|
|
|
continue; \
|
|
|
|
|
\
|
|
|
|
|
if (brw_inst_src ## n ## _reg_file(devinfo, inst) == \
|
|
|
|
|
BRW_IMMEDIATE_VALUE) \
|
|
|
|
|
continue; \
|
|
|
|
|
\
|
2017-08-29 18:25:54 -07:00
|
|
|
vstride = STRIDE(brw_inst_src ## n ## _vstride(devinfo, inst)); \
|
|
|
|
|
width = WIDTH(brw_inst_src ## n ## _width(devinfo, inst)); \
|
|
|
|
|
hstride = STRIDE(brw_inst_src ## n ## _hstride(devinfo, inst)); \
|
2017-07-26 21:08:20 -07:00
|
|
|
type = brw_inst_src ## n ## _type(devinfo, inst); \
|
|
|
|
|
element_size = brw_reg_type_to_size(type); \
|
2016-11-15 16:06:51 -08:00
|
|
|
subreg = brw_inst_src ## n ## _da1_subreg_nr(devinfo, inst); \
|
|
|
|
|
align1_access_mask(src ## n ## _access_mask, \
|
|
|
|
|
exec_size, element_size, subreg, \
|
|
|
|
|
vstride, width, hstride)
|
|
|
|
|
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
DO_SRC(0);
|
2017-08-25 19:22:51 -07:00
|
|
|
} else {
|
2016-11-15 16:06:51 -08:00
|
|
|
DO_SRC(1);
|
|
|
|
|
}
|
|
|
|
|
#undef DO_SRC
|
|
|
|
|
|
|
|
|
|
unsigned num_vstride = exec_size / width;
|
|
|
|
|
unsigned num_hstride = width;
|
|
|
|
|
unsigned vstride_elements = (num_vstride - 1) * vstride;
|
|
|
|
|
unsigned hstride_elements = (num_hstride - 1) * hstride;
|
|
|
|
|
unsigned offset = (vstride_elements + hstride_elements) * element_size +
|
|
|
|
|
subreg;
|
2022-07-15 19:11:04 -07:00
|
|
|
ERROR_IF(offset >= 64 * reg_unit(devinfo),
|
2016-11-15 16:06:51 -08:00
|
|
|
"A source cannot span more than 2 adjacent GRF registers");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (desc->ndst == 0 || dst_is_null(devinfo, inst))
|
|
|
|
|
return error_msg;
|
|
|
|
|
|
2017-08-29 18:25:54 -07:00
|
|
|
unsigned stride = STRIDE(brw_inst_dst_hstride(devinfo, inst));
|
2022-06-29 14:13:31 -07:00
|
|
|
enum brw_reg_type dst_type = inst_dst_type(isa, inst);
|
2017-07-26 21:08:20 -07:00
|
|
|
unsigned element_size = brw_reg_type_to_size(dst_type);
|
2016-11-15 16:06:51 -08:00
|
|
|
unsigned subreg = brw_inst_dst_da1_subreg_nr(devinfo, inst);
|
|
|
|
|
unsigned offset = ((exec_size - 1) * stride * element_size) + subreg;
|
2022-07-15 19:11:04 -07:00
|
|
|
ERROR_IF(offset >= 64 * reg_unit(devinfo),
|
2016-11-15 16:06:51 -08:00
|
|
|
"A destination cannot span more than 2 adjacent GRF registers");
|
|
|
|
|
|
|
|
|
|
if (error_msg.str)
|
|
|
|
|
return error_msg;
|
|
|
|
|
|
|
|
|
|
align1_access_mask(dst_access_mask, exec_size, element_size, subreg,
|
|
|
|
|
exec_size == 1 ? 0 : exec_size * stride,
|
|
|
|
|
exec_size == 1 ? 1 : exec_size,
|
|
|
|
|
exec_size == 1 ? 0 : stride);
|
|
|
|
|
|
|
|
|
|
unsigned dst_regs = registers_read(dst_access_mask);
|
|
|
|
|
|
2024-02-16 13:38:19 -08:00
|
|
|
/* The SKL PRM says:
|
2016-11-15 16:06:51 -08:00
|
|
|
*
|
|
|
|
|
* When destination of MATH instruction spans two registers, the
|
|
|
|
|
* destination elements must be evenly split between the two registers.
|
|
|
|
|
*
|
|
|
|
|
* It is not known whether this restriction applies to KBL other Gens after
|
|
|
|
|
* SKL.
|
|
|
|
|
*/
|
2024-02-16 13:38:19 -08:00
|
|
|
if (brw_inst_opcode(isa, inst) == BRW_OPCODE_MATH) {
|
2016-11-15 16:06:51 -08:00
|
|
|
if (dst_regs == 2) {
|
|
|
|
|
unsigned upper_reg_writes = 0, lower_reg_writes = 0;
|
|
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < exec_size; i++) {
|
|
|
|
|
if (dst_access_mask[i] > 0xFFFFFFFF) {
|
|
|
|
|
upper_reg_writes++;
|
|
|
|
|
} else {
|
|
|
|
|
assert(dst_access_mask[i] != 0);
|
|
|
|
|
lower_reg_writes++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ERROR_IF(upper_reg_writes != lower_reg_writes,
|
|
|
|
|
"Writes must be evenly split between the two "
|
|
|
|
|
"destination registers");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return error_msg;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-27 18:29:50 -07:00
|
|
|
static struct string
|
2022-06-29 14:13:31 -07:00
|
|
|
vector_immediate_restrictions(const struct brw_isa_info *isa,
|
2017-07-27 18:29:50 -07:00
|
|
|
const brw_inst *inst)
|
|
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
|
|
|
|
|
2022-12-08 15:39:01 -08:00
|
|
|
unsigned num_sources = brw_num_sources_from_inst(isa, inst);
|
2017-07-27 18:29:50 -07:00
|
|
|
struct string error_msg = { .str = NULL, .len = 0 };
|
|
|
|
|
|
2022-08-18 13:27:21 -07:00
|
|
|
if (num_sources == 3 || num_sources == 0 ||
|
|
|
|
|
(devinfo->ver >= 12 && inst_is_send(isa, inst)))
|
2017-07-27 18:29:50 -07:00
|
|
|
return (struct string){};
|
|
|
|
|
|
|
|
|
|
unsigned file = num_sources == 1 ?
|
|
|
|
|
brw_inst_src0_reg_file(devinfo, inst) :
|
|
|
|
|
brw_inst_src1_reg_file(devinfo, inst);
|
|
|
|
|
if (file != BRW_IMMEDIATE_VALUE)
|
|
|
|
|
return (struct string){};
|
|
|
|
|
|
2022-06-29 14:13:31 -07:00
|
|
|
enum brw_reg_type dst_type = inst_dst_type(isa, inst);
|
2017-07-26 21:08:20 -07:00
|
|
|
unsigned dst_type_size = brw_reg_type_to_size(dst_type);
|
2017-07-27 18:29:50 -07:00
|
|
|
unsigned dst_subreg = brw_inst_access_mode(devinfo, inst) == BRW_ALIGN_1 ?
|
|
|
|
|
brw_inst_dst_da1_subreg_nr(devinfo, inst) : 0;
|
2017-08-29 18:25:54 -07:00
|
|
|
unsigned dst_stride = STRIDE(brw_inst_dst_hstride(devinfo, inst));
|
2017-07-26 21:08:20 -07:00
|
|
|
enum brw_reg_type type = num_sources == 1 ?
|
|
|
|
|
brw_inst_src0_type(devinfo, inst) :
|
|
|
|
|
brw_inst_src1_type(devinfo, inst);
|
2017-07-27 18:29:50 -07:00
|
|
|
|
|
|
|
|
/* The PRMs say:
|
|
|
|
|
*
|
|
|
|
|
* When an immediate vector is used in an instruction, the destination
|
|
|
|
|
* must be 128-bit aligned with destination horizontal stride equivalent
|
|
|
|
|
* to a word for an immediate integer vector (v) and equivalent to a
|
|
|
|
|
* DWord for an immediate float vector (vf).
|
|
|
|
|
*
|
|
|
|
|
* The text has not been updated for the addition of the immediate unsigned
|
|
|
|
|
* integer vector type (uv) on SNB, but presumably the same restriction
|
|
|
|
|
* applies.
|
|
|
|
|
*/
|
|
|
|
|
switch (type) {
|
2017-07-26 21:08:20 -07:00
|
|
|
case BRW_REGISTER_TYPE_V:
|
|
|
|
|
case BRW_REGISTER_TYPE_UV:
|
|
|
|
|
case BRW_REGISTER_TYPE_VF:
|
2017-07-27 18:29:50 -07:00
|
|
|
ERROR_IF(dst_subreg % (128 / 8) != 0,
|
|
|
|
|
"Destination must be 128-bit aligned in order to use immediate "
|
|
|
|
|
"vector types");
|
|
|
|
|
|
2017-07-26 21:08:20 -07:00
|
|
|
if (type == BRW_REGISTER_TYPE_VF) {
|
2017-07-27 18:29:50 -07:00
|
|
|
ERROR_IF(dst_type_size * dst_stride != 4,
|
|
|
|
|
"Destination must have stride equivalent to dword in order "
|
|
|
|
|
"to use the VF type");
|
|
|
|
|
} else {
|
|
|
|
|
ERROR_IF(dst_type_size * dst_stride != 2,
|
|
|
|
|
"Destination must have stride equivalent to word in order "
|
|
|
|
|
"to use the V or UV type");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return error_msg;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-29 18:29:29 -07:00
|
|
|
static struct string
|
|
|
|
|
special_requirements_for_handling_double_precision_data_types(
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct brw_isa_info *isa,
|
2017-08-29 18:29:29 -07:00
|
|
|
const brw_inst *inst)
|
|
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
|
|
|
|
|
2022-12-08 15:39:01 -08:00
|
|
|
unsigned num_sources = brw_num_sources_from_inst(isa, inst);
|
2017-08-29 18:29:29 -07:00
|
|
|
struct string error_msg = { .str = NULL, .len = 0 };
|
|
|
|
|
|
|
|
|
|
if (num_sources == 3 || num_sources == 0)
|
|
|
|
|
return (struct string){};
|
|
|
|
|
|
2018-11-15 15:17:06 -06:00
|
|
|
/* Split sends don't have types so there's no doubles there. */
|
2022-06-29 14:13:31 -07:00
|
|
|
if (inst_is_split_send(isa, inst))
|
2018-11-15 15:17:06 -06:00
|
|
|
return (struct string){};
|
|
|
|
|
|
2022-06-29 14:13:31 -07:00
|
|
|
enum brw_reg_type exec_type = execution_type(isa, inst);
|
2017-08-29 18:29:29 -07:00
|
|
|
unsigned exec_type_size = brw_reg_type_to_size(exec_type);
|
|
|
|
|
|
|
|
|
|
enum brw_reg_file dst_file = brw_inst_dst_reg_file(devinfo, inst);
|
2022-06-29 14:13:31 -07:00
|
|
|
enum brw_reg_type dst_type = inst_dst_type(isa, inst);
|
2017-08-29 18:29:29 -07:00
|
|
|
unsigned dst_type_size = brw_reg_type_to_size(dst_type);
|
|
|
|
|
unsigned dst_hstride = STRIDE(brw_inst_dst_hstride(devinfo, inst));
|
|
|
|
|
unsigned dst_reg = brw_inst_dst_da_reg_nr(devinfo, inst);
|
|
|
|
|
unsigned dst_subreg = brw_inst_dst_da1_subreg_nr(devinfo, inst);
|
|
|
|
|
unsigned dst_address_mode = brw_inst_dst_address_mode(devinfo, inst);
|
|
|
|
|
|
|
|
|
|
bool is_integer_dword_multiply =
|
2022-06-29 14:13:31 -07:00
|
|
|
brw_inst_opcode(isa, inst) == BRW_OPCODE_MUL &&
|
2017-08-29 18:29:29 -07:00
|
|
|
(brw_inst_src0_type(devinfo, inst) == BRW_REGISTER_TYPE_D ||
|
|
|
|
|
brw_inst_src0_type(devinfo, inst) == BRW_REGISTER_TYPE_UD) &&
|
|
|
|
|
(brw_inst_src1_type(devinfo, inst) == BRW_REGISTER_TYPE_D ||
|
|
|
|
|
brw_inst_src1_type(devinfo, inst) == BRW_REGISTER_TYPE_UD);
|
|
|
|
|
|
2021-04-06 13:05:30 -07:00
|
|
|
const bool is_double_precision =
|
|
|
|
|
dst_type_size == 8 || exec_type_size == 8 || is_integer_dword_multiply;
|
2017-08-29 18:29:29 -07:00
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < num_sources; i++) {
|
|
|
|
|
unsigned vstride, width, hstride, type_size, reg, subreg, address_mode;
|
|
|
|
|
bool is_scalar_region;
|
|
|
|
|
enum brw_reg_file file;
|
|
|
|
|
enum brw_reg_type type;
|
|
|
|
|
|
|
|
|
|
#define DO_SRC(n) \
|
|
|
|
|
if (brw_inst_src ## n ## _reg_file(devinfo, inst) == \
|
|
|
|
|
BRW_IMMEDIATE_VALUE) \
|
|
|
|
|
continue; \
|
|
|
|
|
\
|
|
|
|
|
is_scalar_region = src ## n ## _has_scalar_region(devinfo, inst); \
|
|
|
|
|
vstride = STRIDE(brw_inst_src ## n ## _vstride(devinfo, inst)); \
|
|
|
|
|
width = WIDTH(brw_inst_src ## n ## _width(devinfo, inst)); \
|
|
|
|
|
hstride = STRIDE(brw_inst_src ## n ## _hstride(devinfo, inst)); \
|
|
|
|
|
file = brw_inst_src ## n ## _reg_file(devinfo, inst); \
|
|
|
|
|
type = brw_inst_src ## n ## _type(devinfo, inst); \
|
|
|
|
|
type_size = brw_reg_type_to_size(type); \
|
|
|
|
|
reg = brw_inst_src ## n ## _da_reg_nr(devinfo, inst); \
|
|
|
|
|
subreg = brw_inst_src ## n ## _da1_subreg_nr(devinfo, inst); \
|
|
|
|
|
address_mode = brw_inst_src ## n ## _address_mode(devinfo, inst)
|
|
|
|
|
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
DO_SRC(0);
|
|
|
|
|
} else {
|
|
|
|
|
DO_SRC(1);
|
|
|
|
|
}
|
|
|
|
|
#undef DO_SRC
|
|
|
|
|
|
intel/eu: Fix XeHP register region validation for hstride == 0
Recently, we started using <1;1,0> register regions for consecutive
channels, rather than the <8;8,1> we've traditionally used, as the
<1;1,0> encoding can be compacted on XeHP. Since then, one of the
EU validator rules has been flagging tons of instructions as errors:
mov(16) g114<1>F g112<1,1,0>UD { align1 1H I@2 compacted };
ERROR: Register Regioning patterns where register data bit locations are changed between source and destination are not supported except for broadcast of a scalar.
Our code for this restriction checked three things:
#1: vstride != width * hstride ||
#2: src_stride != dst_stride ||
#3: subreg != dst_subreg
Destination regions are always linear (no replicated values, nor
any overlapping components), as they only have hstride. Rule #1 is
requiring that the source region be linear as well. Rules #2-3 are
straightforward: the subregister must match (for the first channel to
line up), and the source/destination strides must match (for any
subsequent channels to line up).
Unfortunately, rules #1-2 weren't working when horizontal stride was 0.
In that case, regions are linear if width == 1, and the stride between
consecutive channels is given by vertical stride instead.
So we adjust our src_stride calculation from
src_stride = hstride * type_size;
to:
src_stride = (hstride ? hstride : vstride) * type_size;
and adjust rule #1 to allow hstride == 0 as long as width == 1.
While here, we also update the text of the rule to match the latest
documentation, which apparently clarifies that it's the location of
the LSB of the channel which matters.
Fixes: 3f50dde8b35 ("intel/eu: Teach EU validator about FP/DP pipeline regioning restrictions.")
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17624>
2022-07-19 01:21:06 -07:00
|
|
|
const unsigned src_stride = (hstride ? hstride : vstride) * type_size;
|
2021-04-06 13:05:30 -07:00
|
|
|
const unsigned dst_stride = dst_hstride * dst_type_size;
|
|
|
|
|
|
2017-08-29 18:29:29 -07:00
|
|
|
/* The PRMs say that for CHV, BXT:
|
|
|
|
|
*
|
|
|
|
|
* When source or destination datatype is 64b or operation is integer
|
|
|
|
|
* DWord multiply, regioning in Align1 must follow these rules:
|
|
|
|
|
*
|
|
|
|
|
* 1. Source and Destination horizontal stride must be aligned to the
|
|
|
|
|
* same qword.
|
|
|
|
|
* 2. Regioning must ensure Src.Vstride = Src.Width * Src.Hstride.
|
|
|
|
|
* 3. Source and Destination offset must be the same, except the case
|
|
|
|
|
* of scalar source.
|
|
|
|
|
*
|
|
|
|
|
* We assume that the restriction applies to GLK as well.
|
|
|
|
|
*/
|
2021-04-06 13:05:30 -07:00
|
|
|
if (is_double_precision &&
|
|
|
|
|
brw_inst_access_mode(devinfo, inst) == BRW_ALIGN_1 &&
|
2024-02-16 13:38:19 -08:00
|
|
|
intel_device_info_is_9lp(devinfo)) {
|
2017-08-29 18:29:29 -07:00
|
|
|
ERROR_IF(!is_scalar_region &&
|
|
|
|
|
(src_stride % 8 != 0 ||
|
|
|
|
|
dst_stride % 8 != 0 ||
|
|
|
|
|
src_stride != dst_stride),
|
|
|
|
|
"Source and destination horizontal stride must equal and a "
|
|
|
|
|
"multiple of a qword when the execution type is 64-bit");
|
|
|
|
|
|
|
|
|
|
ERROR_IF(vstride != width * hstride,
|
|
|
|
|
"Vstride must be Width * Hstride when the execution type is "
|
|
|
|
|
"64-bit");
|
|
|
|
|
|
|
|
|
|
ERROR_IF(!is_scalar_region && dst_subreg != subreg,
|
|
|
|
|
"Source and destination offset must be the same when the "
|
|
|
|
|
"execution type is 64-bit");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The PRMs say that for CHV, BXT:
|
|
|
|
|
*
|
|
|
|
|
* When source or destination datatype is 64b or operation is integer
|
|
|
|
|
* DWord multiply, indirect addressing must not be used.
|
|
|
|
|
*
|
|
|
|
|
* We assume that the restriction applies to GLK as well.
|
|
|
|
|
*/
|
2021-04-06 13:05:30 -07:00
|
|
|
if (is_double_precision &&
|
2024-02-16 13:38:19 -08:00
|
|
|
intel_device_info_is_9lp(devinfo)) {
|
2017-08-29 18:29:29 -07:00
|
|
|
ERROR_IF(BRW_ADDRESS_REGISTER_INDIRECT_REGISTER == address_mode ||
|
|
|
|
|
BRW_ADDRESS_REGISTER_INDIRECT_REGISTER == dst_address_mode,
|
|
|
|
|
"Indirect addressing is not allowed when the execution type "
|
|
|
|
|
"is 64-bit");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The PRMs say that for CHV, BXT:
|
|
|
|
|
*
|
|
|
|
|
* ARF registers must never be used with 64b datatype or when
|
|
|
|
|
* operation is integer DWord multiply.
|
|
|
|
|
*
|
|
|
|
|
* We assume that the restriction applies to GLK as well.
|
|
|
|
|
*
|
|
|
|
|
* We assume that the restriction does not apply to the null register.
|
|
|
|
|
*/
|
2021-04-06 13:05:30 -07:00
|
|
|
if (is_double_precision &&
|
2024-02-16 13:38:19 -08:00
|
|
|
intel_device_info_is_9lp(devinfo)) {
|
2022-06-29 14:13:31 -07:00
|
|
|
ERROR_IF(brw_inst_opcode(isa, inst) == BRW_OPCODE_MAC ||
|
2017-08-29 18:29:29 -07:00
|
|
|
brw_inst_acc_wr_control(devinfo, inst) ||
|
|
|
|
|
(BRW_ARCHITECTURE_REGISTER_FILE == file &&
|
|
|
|
|
reg != BRW_ARF_NULL) ||
|
|
|
|
|
(BRW_ARCHITECTURE_REGISTER_FILE == dst_file &&
|
|
|
|
|
dst_reg != BRW_ARF_NULL),
|
|
|
|
|
"Architecture registers cannot be used when the execution "
|
|
|
|
|
"type is 64-bit");
|
|
|
|
|
}
|
2021-04-06 13:05:30 -07:00
|
|
|
|
|
|
|
|
/* From the hardware spec section "Register Region Restrictions":
|
intel/eu: Clarify spec citations for XeHP region restrictions
When this rule started causing issues, I looked it up in the
documentation, and found the rule for 64-bit destinations and
integer DWord multiplication, but there was no mention of floating
point destinations, as the text in brackets suggested. The actual
restriction text had been updated, so this led to some confusion
where I thought the conditions had been changed in newer docs.
However, what's actually going on is that there are two separate
conditions, each listed in separate rows of the table. One lists
64-bit destinations or integer DWord multiplication, and the other
mentions floating-point destinations. In both cases, the actual
restrictions are identical, so we handle them together in the code.
Try to update the comment to avoid future confusion.
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17624>
2022-07-19 01:59:15 -07:00
|
|
|
*
|
|
|
|
|
* There are two rules:
|
|
|
|
|
*
|
|
|
|
|
* "In case of all floating point data types used in destination:" and
|
2021-04-06 13:05:30 -07:00
|
|
|
*
|
|
|
|
|
* "In case where source or destination datatype is 64b or operation is
|
intel/eu: Clarify spec citations for XeHP region restrictions
When this rule started causing issues, I looked it up in the
documentation, and found the rule for 64-bit destinations and
integer DWord multiplication, but there was no mention of floating
point destinations, as the text in brackets suggested. The actual
restriction text had been updated, so this led to some confusion
where I thought the conditions had been changed in newer docs.
However, what's actually going on is that there are two separate
conditions, each listed in separate rows of the table. One lists
64-bit destinations or integer DWord multiplication, and the other
mentions floating-point destinations. In both cases, the actual
restrictions are identical, so we handle them together in the code.
Try to update the comment to avoid future confusion.
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17624>
2022-07-19 01:59:15 -07:00
|
|
|
* integer DWord multiply:"
|
|
|
|
|
*
|
|
|
|
|
* both of which list the same restrictions:
|
2021-04-06 13:05:30 -07:00
|
|
|
*
|
intel/eu: Clarify spec citations for XeHP region restrictions
When this rule started causing issues, I looked it up in the
documentation, and found the rule for 64-bit destinations and
integer DWord multiplication, but there was no mention of floating
point destinations, as the text in brackets suggested. The actual
restriction text had been updated, so this led to some confusion
where I thought the conditions had been changed in newer docs.
However, what's actually going on is that there are two separate
conditions, each listed in separate rows of the table. One lists
64-bit destinations or integer DWord multiplication, and the other
mentions floating-point destinations. In both cases, the actual
restrictions are identical, so we handle them together in the code.
Try to update the comment to avoid future confusion.
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17624>
2022-07-19 01:59:15 -07:00
|
|
|
* "1. Register Regioning patterns where register data bit location
|
intel/eu: Fix XeHP register region validation for hstride == 0
Recently, we started using <1;1,0> register regions for consecutive
channels, rather than the <8;8,1> we've traditionally used, as the
<1;1,0> encoding can be compacted on XeHP. Since then, one of the
EU validator rules has been flagging tons of instructions as errors:
mov(16) g114<1>F g112<1,1,0>UD { align1 1H I@2 compacted };
ERROR: Register Regioning patterns where register data bit locations are changed between source and destination are not supported except for broadcast of a scalar.
Our code for this restriction checked three things:
#1: vstride != width * hstride ||
#2: src_stride != dst_stride ||
#3: subreg != dst_subreg
Destination regions are always linear (no replicated values, nor
any overlapping components), as they only have hstride. Rule #1 is
requiring that the source region be linear as well. Rules #2-3 are
straightforward: the subregister must match (for the first channel to
line up), and the source/destination strides must match (for any
subsequent channels to line up).
Unfortunately, rules #1-2 weren't working when horizontal stride was 0.
In that case, regions are linear if width == 1, and the stride between
consecutive channels is given by vertical stride instead.
So we adjust our src_stride calculation from
src_stride = hstride * type_size;
to:
src_stride = (hstride ? hstride : vstride) * type_size;
and adjust rule #1 to allow hstride == 0 as long as width == 1.
While here, we also update the text of the rule to match the latest
documentation, which apparently clarifies that it's the location of
the LSB of the channel which matters.
Fixes: 3f50dde8b35 ("intel/eu: Teach EU validator about FP/DP pipeline regioning restrictions.")
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17624>
2022-07-19 01:21:06 -07:00
|
|
|
* of the LSB of the channels are changed between source and
|
|
|
|
|
* destination are not supported on Src0 and Src1 except for
|
|
|
|
|
* broadcast of a scalar.
|
2021-04-06 13:05:30 -07:00
|
|
|
*
|
|
|
|
|
* 2. Explicit ARF registers except null and accumulator must not be
|
|
|
|
|
* used."
|
|
|
|
|
*/
|
|
|
|
|
if (devinfo->verx10 >= 125 &&
|
|
|
|
|
(brw_reg_type_is_floating_point(dst_type) ||
|
|
|
|
|
is_double_precision)) {
|
|
|
|
|
ERROR_IF(!is_scalar_region &&
|
2020-09-24 16:27:43 -05:00
|
|
|
BRW_ADDRESS_REGISTER_INDIRECT_REGISTER != address_mode &&
|
intel/eu: Fix XeHP register region validation for hstride == 0
Recently, we started using <1;1,0> register regions for consecutive
channels, rather than the <8;8,1> we've traditionally used, as the
<1;1,0> encoding can be compacted on XeHP. Since then, one of the
EU validator rules has been flagging tons of instructions as errors:
mov(16) g114<1>F g112<1,1,0>UD { align1 1H I@2 compacted };
ERROR: Register Regioning patterns where register data bit locations are changed between source and destination are not supported except for broadcast of a scalar.
Our code for this restriction checked three things:
#1: vstride != width * hstride ||
#2: src_stride != dst_stride ||
#3: subreg != dst_subreg
Destination regions are always linear (no replicated values, nor
any overlapping components), as they only have hstride. Rule #1 is
requiring that the source region be linear as well. Rules #2-3 are
straightforward: the subregister must match (for the first channel to
line up), and the source/destination strides must match (for any
subsequent channels to line up).
Unfortunately, rules #1-2 weren't working when horizontal stride was 0.
In that case, regions are linear if width == 1, and the stride between
consecutive channels is given by vertical stride instead.
So we adjust our src_stride calculation from
src_stride = hstride * type_size;
to:
src_stride = (hstride ? hstride : vstride) * type_size;
and adjust rule #1 to allow hstride == 0 as long as width == 1.
While here, we also update the text of the rule to match the latest
documentation, which apparently clarifies that it's the location of
the LSB of the channel which matters.
Fixes: 3f50dde8b35 ("intel/eu: Teach EU validator about FP/DP pipeline regioning restrictions.")
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17624>
2022-07-19 01:21:06 -07:00
|
|
|
(!is_linear(vstride, width, hstride) ||
|
2021-04-06 13:05:30 -07:00
|
|
|
src_stride != dst_stride ||
|
|
|
|
|
subreg != dst_subreg),
|
|
|
|
|
"Register Regioning patterns where register data bit "
|
intel/eu: Fix XeHP register region validation for hstride == 0
Recently, we started using <1;1,0> register regions for consecutive
channels, rather than the <8;8,1> we've traditionally used, as the
<1;1,0> encoding can be compacted on XeHP. Since then, one of the
EU validator rules has been flagging tons of instructions as errors:
mov(16) g114<1>F g112<1,1,0>UD { align1 1H I@2 compacted };
ERROR: Register Regioning patterns where register data bit locations are changed between source and destination are not supported except for broadcast of a scalar.
Our code for this restriction checked three things:
#1: vstride != width * hstride ||
#2: src_stride != dst_stride ||
#3: subreg != dst_subreg
Destination regions are always linear (no replicated values, nor
any overlapping components), as they only have hstride. Rule #1 is
requiring that the source region be linear as well. Rules #2-3 are
straightforward: the subregister must match (for the first channel to
line up), and the source/destination strides must match (for any
subsequent channels to line up).
Unfortunately, rules #1-2 weren't working when horizontal stride was 0.
In that case, regions are linear if width == 1, and the stride between
consecutive channels is given by vertical stride instead.
So we adjust our src_stride calculation from
src_stride = hstride * type_size;
to:
src_stride = (hstride ? hstride : vstride) * type_size;
and adjust rule #1 to allow hstride == 0 as long as width == 1.
While here, we also update the text of the rule to match the latest
documentation, which apparently clarifies that it's the location of
the LSB of the channel which matters.
Fixes: 3f50dde8b35 ("intel/eu: Teach EU validator about FP/DP pipeline regioning restrictions.")
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17624>
2022-07-19 01:21:06 -07:00
|
|
|
"location of the LSB of the channels are changed between "
|
|
|
|
|
"source and destination are not supported except for "
|
|
|
|
|
"broadcast of a scalar.");
|
2021-04-06 13:05:30 -07:00
|
|
|
|
2023-01-10 21:10:24 -08:00
|
|
|
ERROR_IF((address_mode == BRW_ADDRESS_DIRECT && file == BRW_ARCHITECTURE_REGISTER_FILE &&
|
2021-04-06 13:05:30 -07:00
|
|
|
reg != BRW_ARF_NULL && !(reg >= BRW_ARF_ACCUMULATOR && reg < BRW_ARF_FLAG)) ||
|
|
|
|
|
(dst_file == BRW_ARCHITECTURE_REGISTER_FILE &&
|
2023-08-09 14:03:57 -07:00
|
|
|
dst_reg != BRW_ARF_NULL && (dst_reg & 0xF0) != BRW_ARF_ACCUMULATOR),
|
2021-04-06 13:05:30 -07:00
|
|
|
"Explicit ARF registers except null and accumulator must not "
|
|
|
|
|
"be used.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* From the hardware spec section "Register Region Restrictions":
|
|
|
|
|
*
|
|
|
|
|
* "Vx1 and VxH indirect addressing for Float, Half-Float, Double-Float and
|
|
|
|
|
* Quad-Word data must not be used."
|
|
|
|
|
*/
|
|
|
|
|
if (devinfo->verx10 >= 125 &&
|
|
|
|
|
(brw_reg_type_is_floating_point(type) || type_sz(type) == 8)) {
|
|
|
|
|
ERROR_IF(address_mode == BRW_ADDRESS_REGISTER_INDIRECT_REGISTER &&
|
|
|
|
|
vstride == BRW_VERTICAL_STRIDE_ONE_DIMENSIONAL,
|
|
|
|
|
"Vx1 and VxH indirect addressing for Float, Half-Float, "
|
|
|
|
|
"Double-Float and Quad-Word data must not be used");
|
|
|
|
|
}
|
2017-08-29 18:29:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The PRMs say that for BDW, SKL:
|
|
|
|
|
*
|
|
|
|
|
* If Align16 is required for an operation with QW destination and non-QW
|
|
|
|
|
* source datatypes, the execution size cannot exceed 2.
|
|
|
|
|
*
|
2021-03-29 15:46:12 -07:00
|
|
|
* We assume that the restriction applies to all Gfx8+ parts.
|
2017-08-29 18:29:29 -07:00
|
|
|
*/
|
2024-02-16 13:38:19 -08:00
|
|
|
if (is_double_precision) {
|
2017-08-29 18:29:29 -07:00
|
|
|
enum brw_reg_type src0_type = brw_inst_src0_type(devinfo, inst);
|
2017-10-07 00:14:34 -07:00
|
|
|
enum brw_reg_type src1_type =
|
|
|
|
|
num_sources > 1 ? brw_inst_src1_type(devinfo, inst) : src0_type;
|
2017-08-29 18:29:29 -07:00
|
|
|
unsigned src0_type_size = brw_reg_type_to_size(src0_type);
|
|
|
|
|
unsigned src1_type_size = brw_reg_type_to_size(src1_type);
|
|
|
|
|
|
|
|
|
|
ERROR_IF(brw_inst_access_mode(devinfo, inst) == BRW_ALIGN_16 &&
|
|
|
|
|
dst_type_size == 8 &&
|
|
|
|
|
(src0_type_size != 8 || src1_type_size != 8) &&
|
|
|
|
|
brw_inst_exec_size(devinfo, inst) > BRW_EXECUTE_2,
|
|
|
|
|
"In Align16 exec size cannot exceed 2 with a QWord destination "
|
|
|
|
|
"and a non-QWord source");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The PRMs say that for CHV, BXT:
|
|
|
|
|
*
|
|
|
|
|
* When source or destination datatype is 64b or operation is integer
|
|
|
|
|
* DWord multiply, DepCtrl must not be used.
|
|
|
|
|
*
|
|
|
|
|
* We assume that the restriction applies to GLK as well.
|
|
|
|
|
*/
|
2021-04-06 13:05:30 -07:00
|
|
|
if (is_double_precision &&
|
2024-02-16 13:38:19 -08:00
|
|
|
intel_device_info_is_9lp(devinfo)) {
|
2017-08-29 18:29:29 -07:00
|
|
|
ERROR_IF(brw_inst_no_dd_check(devinfo, inst) ||
|
|
|
|
|
brw_inst_no_dd_clear(devinfo, inst),
|
|
|
|
|
"DepCtrl is not allowed when the execution type is 64-bit");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return error_msg;
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-07 14:09:25 -08:00
|
|
|
static struct string
|
2022-06-29 14:13:31 -07:00
|
|
|
instruction_restrictions(const struct brw_isa_info *isa,
|
2018-12-07 14:09:25 -08:00
|
|
|
const brw_inst *inst)
|
|
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
2018-12-07 14:09:25 -08:00
|
|
|
struct string error_msg = { .str = NULL, .len = 0 };
|
|
|
|
|
|
2021-03-29 17:15:41 -07:00
|
|
|
/* From Wa_1604601757:
|
2018-12-07 14:09:25 -08:00
|
|
|
*
|
|
|
|
|
* "When multiplying a DW and any lower precision integer, source modifier
|
|
|
|
|
* is not supported."
|
|
|
|
|
*/
|
2021-03-29 14:41:58 -07:00
|
|
|
if (devinfo->ver >= 12 &&
|
2022-06-29 14:13:31 -07:00
|
|
|
brw_inst_opcode(isa, inst) == BRW_OPCODE_MUL) {
|
|
|
|
|
enum brw_reg_type exec_type = execution_type(isa, inst);
|
2018-12-07 14:09:25 -08:00
|
|
|
const bool src0_valid = type_sz(brw_inst_src0_type(devinfo, inst)) == 4 ||
|
|
|
|
|
brw_inst_src0_reg_file(devinfo, inst) == BRW_IMMEDIATE_VALUE ||
|
|
|
|
|
!(brw_inst_src0_negate(devinfo, inst) ||
|
|
|
|
|
brw_inst_src0_abs(devinfo, inst));
|
|
|
|
|
const bool src1_valid = type_sz(brw_inst_src1_type(devinfo, inst)) == 4 ||
|
|
|
|
|
brw_inst_src1_reg_file(devinfo, inst) == BRW_IMMEDIATE_VALUE ||
|
|
|
|
|
!(brw_inst_src1_negate(devinfo, inst) ||
|
|
|
|
|
brw_inst_src1_abs(devinfo, inst));
|
|
|
|
|
|
|
|
|
|
ERROR_IF(!brw_reg_type_is_floating_point(exec_type) &&
|
|
|
|
|
type_sz(exec_type) == 4 && !(src0_valid && src1_valid),
|
|
|
|
|
"When multiplying a DW and any lower precision integer, source "
|
|
|
|
|
"modifier is not supported.");
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-29 14:13:31 -07:00
|
|
|
if (brw_inst_opcode(isa, inst) == BRW_OPCODE_CMP ||
|
|
|
|
|
brw_inst_opcode(isa, inst) == BRW_OPCODE_CMPN) {
|
2023-01-06 16:53:18 -08:00
|
|
|
ERROR_IF(brw_inst_cond_modifier(devinfo, inst) == BRW_CONDITIONAL_NONE,
|
|
|
|
|
"CMP (or CMPN) must have a condition.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (brw_inst_opcode(isa, inst) == BRW_OPCODE_SEL) {
|
2024-02-16 13:38:19 -08:00
|
|
|
ERROR_IF((brw_inst_cond_modifier(devinfo, inst) != BRW_CONDITIONAL_NONE) ==
|
|
|
|
|
(brw_inst_pred_control(devinfo, inst) != BRW_PREDICATE_NONE),
|
|
|
|
|
"SEL must either be predicated or have a condition modifiers");
|
2021-02-16 10:51:56 -08:00
|
|
|
}
|
|
|
|
|
|
2020-03-11 15:37:14 -07:00
|
|
|
if (brw_inst_opcode(isa, inst) == BRW_OPCODE_MUL) {
|
|
|
|
|
const enum brw_reg_type src0_type = brw_inst_src0_type(devinfo, inst);
|
|
|
|
|
const enum brw_reg_type src1_type = brw_inst_src1_type(devinfo, inst);
|
|
|
|
|
const enum brw_reg_type dst_type = inst_dst_type(isa, inst);
|
|
|
|
|
|
2024-02-16 13:38:19 -08:00
|
|
|
/* Page 966 (page 982 of the PDF) of Broadwell PRM volume 2a says:
|
|
|
|
|
*
|
|
|
|
|
* When multiplying a DW and any lower precision integer, the DW
|
|
|
|
|
* operand must on src0.
|
|
|
|
|
*
|
|
|
|
|
* Ivy Bridge, Haswell, Skylake, and Ice Lake PRMs contain the same
|
|
|
|
|
* text.
|
|
|
|
|
*/
|
|
|
|
|
ERROR_IF(brw_reg_type_is_integer(src1_type) &&
|
|
|
|
|
type_sz(src0_type) < 4 && type_sz(src1_type) == 4,
|
|
|
|
|
"When multiplying a DW and any lower precision integer, the "
|
|
|
|
|
"DW operand must be src0.");
|
2020-03-11 15:37:14 -07:00
|
|
|
|
2024-02-16 13:38:19 -08:00
|
|
|
/* Page 971 (page 987 of the PDF), section "Accumulator
|
|
|
|
|
* Restrictions," of the Broadwell PRM volume 7 says:
|
|
|
|
|
*
|
|
|
|
|
* Integer source operands cannot be accumulators.
|
|
|
|
|
*
|
|
|
|
|
* The Skylake and Ice Lake PRMs contain the same text.
|
|
|
|
|
*/
|
|
|
|
|
ERROR_IF((src0_is_acc(devinfo, inst) &&
|
|
|
|
|
brw_reg_type_is_integer(src0_type)) ||
|
|
|
|
|
(src1_is_acc(devinfo, inst) &&
|
|
|
|
|
brw_reg_type_is_integer(src1_type)),
|
|
|
|
|
"Integer source operands cannot be accumulators.");
|
2020-03-11 15:37:14 -07:00
|
|
|
|
|
|
|
|
/* Page 935 (page 951 of the PDF) of the Ice Lake PRM volume 2a says:
|
|
|
|
|
*
|
|
|
|
|
* When multiplying integer data types, if one of the sources is a
|
|
|
|
|
* DW, the resulting full precision data is stored in the
|
|
|
|
|
* accumulator. However, if the destination data type is either W or
|
|
|
|
|
* DW, the low bits of the result are written to the destination
|
|
|
|
|
* register and the remaining high bits are discarded. This results
|
|
|
|
|
* in undefined Overflow and Sign flags. Therefore, conditional
|
|
|
|
|
* modifiers and saturation (.sat) cannot be used in this case.
|
|
|
|
|
*
|
|
|
|
|
* Similar text appears in every version of the PRM.
|
|
|
|
|
*
|
|
|
|
|
* The wording of the last sentence is not very clear. It could either
|
|
|
|
|
* be interpreted as "conditional modifiers combined with saturation
|
|
|
|
|
* cannot be used" or "neither conditional modifiers nor saturation can
|
|
|
|
|
* be used." I have interpreted it as the latter primarily because that
|
|
|
|
|
* is the more restrictive interpretation.
|
|
|
|
|
*/
|
|
|
|
|
ERROR_IF((src0_type == BRW_REGISTER_TYPE_UD ||
|
|
|
|
|
src0_type == BRW_REGISTER_TYPE_D ||
|
|
|
|
|
src1_type == BRW_REGISTER_TYPE_UD ||
|
|
|
|
|
src1_type == BRW_REGISTER_TYPE_D) &&
|
|
|
|
|
(dst_type == BRW_REGISTER_TYPE_UD ||
|
|
|
|
|
dst_type == BRW_REGISTER_TYPE_D ||
|
|
|
|
|
dst_type == BRW_REGISTER_TYPE_UW ||
|
|
|
|
|
dst_type == BRW_REGISTER_TYPE_W) &&
|
|
|
|
|
(brw_inst_saturate(devinfo, inst) != 0 ||
|
|
|
|
|
brw_inst_cond_modifier(devinfo, inst) != BRW_CONDITIONAL_NONE),
|
|
|
|
|
"Neither Saturate nor conditional modifier allowed with DW "
|
|
|
|
|
"integer multiply.");
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-29 14:13:31 -07:00
|
|
|
if (brw_inst_opcode(isa, inst) == BRW_OPCODE_MATH) {
|
2021-08-24 10:50:42 +02:00
|
|
|
unsigned math_function = brw_inst_math_function(devinfo, inst);
|
|
|
|
|
switch (math_function) {
|
|
|
|
|
case BRW_MATH_FUNCTION_INT_DIV_QUOTIENT_AND_REMAINDER:
|
|
|
|
|
case BRW_MATH_FUNCTION_INT_DIV_QUOTIENT:
|
|
|
|
|
case BRW_MATH_FUNCTION_INT_DIV_REMAINDER: {
|
|
|
|
|
/* Page 442 of the Broadwell PRM Volume 2a "Extended Math Function" says:
|
|
|
|
|
* INT DIV function does not support source modifiers.
|
|
|
|
|
* Bspec 6647 extends it back to Ivy Bridge.
|
|
|
|
|
*/
|
|
|
|
|
bool src0_valid = !brw_inst_src0_negate(devinfo, inst) &&
|
|
|
|
|
!brw_inst_src0_abs(devinfo, inst);
|
|
|
|
|
bool src1_valid = !brw_inst_src1_negate(devinfo, inst) &&
|
|
|
|
|
!brw_inst_src1_abs(devinfo, inst);
|
|
|
|
|
ERROR_IF(!src0_valid || !src1_valid,
|
|
|
|
|
"INT DIV function does not support source modifiers.");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-29 14:13:31 -07:00
|
|
|
if (brw_inst_opcode(isa, inst) == BRW_OPCODE_DP4A) {
|
2021-02-23 18:46:53 -08:00
|
|
|
/* Page 396 (page 412 of the PDF) of the DG1 PRM volume 2a says:
|
|
|
|
|
*
|
|
|
|
|
* Only one of src0 or src1 operand may be an the (sic) accumulator
|
|
|
|
|
* register (acc#).
|
|
|
|
|
*/
|
|
|
|
|
ERROR_IF(src0_is_acc(devinfo, inst) && src1_is_acc(devinfo, inst),
|
|
|
|
|
"Only one of src0 or src1 operand may be an accumulator "
|
|
|
|
|
"register (acc#).");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-24 19:35:40 -07:00
|
|
|
if (brw_inst_opcode(isa, inst) == BRW_OPCODE_ADD3) {
|
|
|
|
|
const enum brw_reg_type dst_type = inst_dst_type(isa, inst);
|
|
|
|
|
|
|
|
|
|
ERROR_IF(dst_type != BRW_REGISTER_TYPE_D &&
|
|
|
|
|
dst_type != BRW_REGISTER_TYPE_UD &&
|
|
|
|
|
dst_type != BRW_REGISTER_TYPE_W &&
|
|
|
|
|
dst_type != BRW_REGISTER_TYPE_UW,
|
|
|
|
|
"Destination must be integer D, UD, W, or UW type.");
|
|
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < 3; i++) {
|
|
|
|
|
enum brw_reg_type src_type;
|
|
|
|
|
|
|
|
|
|
switch (i) {
|
|
|
|
|
case 0: src_type = brw_inst_3src_a1_src0_type(devinfo, inst); break;
|
|
|
|
|
case 1: src_type = brw_inst_3src_a1_src1_type(devinfo, inst); break;
|
|
|
|
|
case 2: src_type = brw_inst_3src_a1_src2_type(devinfo, inst); break;
|
|
|
|
|
default: unreachable("invalid src");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ERROR_IF(src_type != BRW_REGISTER_TYPE_D &&
|
|
|
|
|
src_type != BRW_REGISTER_TYPE_UD &&
|
|
|
|
|
src_type != BRW_REGISTER_TYPE_W &&
|
|
|
|
|
src_type != BRW_REGISTER_TYPE_UW,
|
|
|
|
|
"Source must be integer D, UD, W, or UW type.");
|
|
|
|
|
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
if (brw_inst_3src_a1_src0_is_imm(devinfo, inst)) {
|
|
|
|
|
ERROR_IF(src_type != BRW_REGISTER_TYPE_W &&
|
|
|
|
|
src_type != BRW_REGISTER_TYPE_UW,
|
|
|
|
|
"Immediate source must be integer W or UW type.");
|
|
|
|
|
}
|
|
|
|
|
} else if (i == 2) {
|
|
|
|
|
if (brw_inst_3src_a1_src2_is_imm(devinfo, inst)) {
|
|
|
|
|
ERROR_IF(src_type != BRW_REGISTER_TYPE_W &&
|
|
|
|
|
src_type != BRW_REGISTER_TYPE_UW,
|
|
|
|
|
"Immediate source must be integer W or UW type.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 13:09:08 -08:00
|
|
|
if (brw_inst_opcode(isa, inst) == BRW_OPCODE_OR ||
|
|
|
|
|
brw_inst_opcode(isa, inst) == BRW_OPCODE_AND ||
|
|
|
|
|
brw_inst_opcode(isa, inst) == BRW_OPCODE_XOR ||
|
|
|
|
|
brw_inst_opcode(isa, inst) == BRW_OPCODE_NOT) {
|
2024-02-16 13:38:19 -08:00
|
|
|
/* While the behavior of the negate source modifier is defined as
|
|
|
|
|
* logical not, the behavior of abs source modifier is not
|
|
|
|
|
* defined. Disallow it to be safe.
|
|
|
|
|
*/
|
|
|
|
|
ERROR_IF(brw_inst_src0_abs(devinfo, inst),
|
|
|
|
|
"Behavior of abs source modifier in logic ops is undefined.");
|
|
|
|
|
ERROR_IF(brw_inst_opcode(isa, inst) != BRW_OPCODE_NOT &&
|
|
|
|
|
brw_inst_src1_reg_file(devinfo, inst) != BRW_IMMEDIATE_VALUE &&
|
|
|
|
|
brw_inst_src1_abs(devinfo, inst),
|
|
|
|
|
"Behavior of abs source modifier in logic ops is undefined.");
|
|
|
|
|
|
|
|
|
|
/* Page 479 (page 495 of the PDF) of the Broadwell PRM volume 2a says:
|
|
|
|
|
*
|
|
|
|
|
* Source modifier is not allowed if source is an accumulator.
|
|
|
|
|
*
|
|
|
|
|
* The same text also appears for OR, NOT, and XOR instructions.
|
|
|
|
|
*/
|
|
|
|
|
ERROR_IF((brw_inst_src0_abs(devinfo, inst) ||
|
|
|
|
|
brw_inst_src0_negate(devinfo, inst)) &&
|
|
|
|
|
src0_is_acc(devinfo, inst),
|
|
|
|
|
"Source modifier is not allowed if source is an accumulator.");
|
|
|
|
|
ERROR_IF(brw_num_sources_from_inst(isa, inst) > 1 &&
|
|
|
|
|
(brw_inst_src1_abs(devinfo, inst) ||
|
|
|
|
|
brw_inst_src1_negate(devinfo, inst)) &&
|
|
|
|
|
src1_is_acc(devinfo, inst),
|
|
|
|
|
"Source modifier is not allowed if source is an accumulator.");
|
2022-12-01 13:09:08 -08:00
|
|
|
|
|
|
|
|
/* Page 479 (page 495 of the PDF) of the Broadwell PRM volume 2a says:
|
|
|
|
|
*
|
|
|
|
|
* This operation does not produce sign or overflow conditions. Only
|
|
|
|
|
* the .e/.z or .ne/.nz conditional modifiers should be used.
|
|
|
|
|
*
|
|
|
|
|
* The same text also appears for OR, NOT, and XOR instructions.
|
|
|
|
|
*
|
|
|
|
|
* Per the comment around nir_op_imod in brw_fs_nir.cpp, we have
|
|
|
|
|
* determined this to not be true. The only conditions that seem
|
|
|
|
|
* absolutely sketchy are O, R, and U. Some OpenGL shaders from Doom
|
|
|
|
|
* 2016 have been observed to generate and.g and operate correctly.
|
|
|
|
|
*/
|
|
|
|
|
const enum brw_conditional_mod cmod =
|
|
|
|
|
brw_inst_cond_modifier(devinfo, inst);
|
|
|
|
|
ERROR_IF(cmod == BRW_CONDITIONAL_O ||
|
|
|
|
|
cmod == BRW_CONDITIONAL_R ||
|
|
|
|
|
cmod == BRW_CONDITIONAL_U,
|
|
|
|
|
"O, R, and U conditional modifiers should not be used.");
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 13:21:12 -08:00
|
|
|
if (brw_inst_opcode(isa, inst) == BRW_OPCODE_BFI2) {
|
|
|
|
|
ERROR_IF(brw_inst_cond_modifier(devinfo, inst) != BRW_CONDITIONAL_NONE,
|
|
|
|
|
"BFI2 cannot have conditional modifier");
|
|
|
|
|
|
|
|
|
|
ERROR_IF(brw_inst_saturate(devinfo, inst),
|
|
|
|
|
"BFI2 cannot have saturate modifier");
|
|
|
|
|
|
|
|
|
|
enum brw_reg_type dst_type;
|
|
|
|
|
|
|
|
|
|
if (brw_inst_access_mode(devinfo, inst) == BRW_ALIGN_1)
|
|
|
|
|
dst_type = brw_inst_3src_a1_dst_type(devinfo, inst);
|
|
|
|
|
else
|
|
|
|
|
dst_type = brw_inst_3src_a16_dst_type(devinfo, inst);
|
|
|
|
|
|
|
|
|
|
ERROR_IF(dst_type != BRW_REGISTER_TYPE_D &&
|
|
|
|
|
dst_type != BRW_REGISTER_TYPE_UD,
|
|
|
|
|
"BFI2 destination type must be D or UD");
|
|
|
|
|
|
|
|
|
|
for (unsigned s = 0; s < 3; s++) {
|
|
|
|
|
enum brw_reg_type src_type;
|
|
|
|
|
|
|
|
|
|
if (brw_inst_access_mode(devinfo, inst) == BRW_ALIGN_1) {
|
|
|
|
|
switch (s) {
|
|
|
|
|
case 0: src_type = brw_inst_3src_a1_src0_type(devinfo, inst); break;
|
|
|
|
|
case 1: src_type = brw_inst_3src_a1_src1_type(devinfo, inst); break;
|
|
|
|
|
case 2: src_type = brw_inst_3src_a1_src2_type(devinfo, inst); break;
|
|
|
|
|
default: unreachable("invalid src");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
src_type = brw_inst_3src_a16_src_type(devinfo, inst);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ERROR_IF(src_type != dst_type,
|
|
|
|
|
"BFI2 source type must match destination type");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 13:32:02 -08:00
|
|
|
if (brw_inst_opcode(isa, inst) == BRW_OPCODE_CSEL) {
|
|
|
|
|
ERROR_IF(brw_inst_pred_control(devinfo, inst) != BRW_PREDICATE_NONE,
|
|
|
|
|
"CSEL cannot be predicated");
|
|
|
|
|
|
|
|
|
|
/* CSEL is CMP and SEL fused into one. The condition modifier, which
|
|
|
|
|
* does not actually modify the flags, controls the built-in comparison.
|
|
|
|
|
*/
|
|
|
|
|
ERROR_IF(brw_inst_cond_modifier(devinfo, inst) == BRW_CONDITIONAL_NONE,
|
|
|
|
|
"CSEL must have a condition.");
|
|
|
|
|
|
|
|
|
|
enum brw_reg_type dst_type;
|
|
|
|
|
|
|
|
|
|
if (brw_inst_access_mode(devinfo, inst) == BRW_ALIGN_1)
|
|
|
|
|
dst_type = brw_inst_3src_a1_dst_type(devinfo, inst);
|
|
|
|
|
else
|
|
|
|
|
dst_type = brw_inst_3src_a16_dst_type(devinfo, inst);
|
|
|
|
|
|
2024-02-16 13:38:19 -08:00
|
|
|
if (devinfo->ver == 9) {
|
2022-12-01 13:32:02 -08:00
|
|
|
ERROR_IF(dst_type != BRW_REGISTER_TYPE_F,
|
|
|
|
|
"CSEL destination type must be F");
|
|
|
|
|
} else {
|
|
|
|
|
ERROR_IF(dst_type != BRW_REGISTER_TYPE_F &&
|
|
|
|
|
dst_type != BRW_REGISTER_TYPE_HF &&
|
|
|
|
|
dst_type != BRW_REGISTER_TYPE_D &&
|
|
|
|
|
dst_type != BRW_REGISTER_TYPE_W,
|
|
|
|
|
"CSEL destination type must be F, HF, D, or W");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (unsigned s = 0; s < 3; s++) {
|
|
|
|
|
enum brw_reg_type src_type;
|
|
|
|
|
|
|
|
|
|
if (brw_inst_access_mode(devinfo, inst) == BRW_ALIGN_1) {
|
|
|
|
|
switch (s) {
|
|
|
|
|
case 0: src_type = brw_inst_3src_a1_src0_type(devinfo, inst); break;
|
|
|
|
|
case 1: src_type = brw_inst_3src_a1_src1_type(devinfo, inst); break;
|
|
|
|
|
case 2: src_type = brw_inst_3src_a1_src2_type(devinfo, inst); break;
|
|
|
|
|
default: unreachable("invalid src");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
src_type = brw_inst_3src_a16_src_type(devinfo, inst);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ERROR_IF(src_type != dst_type,
|
|
|
|
|
"CSEL source type must match destination type");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-25 17:40:01 -07:00
|
|
|
if (brw_inst_opcode(isa, inst) == BRW_OPCODE_DPAS) {
|
|
|
|
|
ERROR_IF(brw_inst_dpas_3src_sdepth(devinfo, inst) != BRW_SYSTOLIC_DEPTH_8,
|
|
|
|
|
"Systolic depth must be 8.");
|
|
|
|
|
|
|
|
|
|
const unsigned sdepth = 8;
|
|
|
|
|
|
|
|
|
|
const enum brw_reg_type dst_type =
|
|
|
|
|
brw_inst_dpas_3src_dst_type(devinfo, inst);
|
|
|
|
|
const enum brw_reg_type src0_type =
|
|
|
|
|
brw_inst_dpas_3src_src0_type(devinfo, inst);
|
|
|
|
|
const enum brw_reg_type src1_type =
|
|
|
|
|
brw_inst_dpas_3src_src1_type(devinfo, inst);
|
|
|
|
|
const enum brw_reg_type src2_type =
|
|
|
|
|
brw_inst_dpas_3src_src2_type(devinfo, inst);
|
|
|
|
|
|
|
|
|
|
const enum gfx12_sub_byte_precision src1_sub_byte =
|
|
|
|
|
brw_inst_dpas_3src_src1_subbyte(devinfo, inst);
|
|
|
|
|
|
|
|
|
|
if (src1_type != BRW_REGISTER_TYPE_B && src1_type != BRW_REGISTER_TYPE_UB) {
|
|
|
|
|
ERROR_IF(src1_sub_byte != BRW_SUB_BYTE_PRECISION_NONE,
|
|
|
|
|
"Sub-byte precision must be None for source type larger than Byte.");
|
|
|
|
|
} else {
|
|
|
|
|
ERROR_IF(src1_sub_byte != BRW_SUB_BYTE_PRECISION_NONE &&
|
|
|
|
|
src1_sub_byte != BRW_SUB_BYTE_PRECISION_4BIT &&
|
|
|
|
|
src1_sub_byte != BRW_SUB_BYTE_PRECISION_2BIT,
|
|
|
|
|
"Invalid sub-byte precision.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const enum gfx12_sub_byte_precision src2_sub_byte =
|
|
|
|
|
brw_inst_dpas_3src_src2_subbyte(devinfo, inst);
|
|
|
|
|
|
|
|
|
|
if (src2_type != BRW_REGISTER_TYPE_B && src2_type != BRW_REGISTER_TYPE_UB) {
|
|
|
|
|
ERROR_IF(src2_sub_byte != BRW_SUB_BYTE_PRECISION_NONE,
|
|
|
|
|
"Sub-byte precision must be None.");
|
|
|
|
|
} else {
|
|
|
|
|
ERROR_IF(src2_sub_byte != BRW_SUB_BYTE_PRECISION_NONE &&
|
|
|
|
|
src2_sub_byte != BRW_SUB_BYTE_PRECISION_4BIT &&
|
|
|
|
|
src2_sub_byte != BRW_SUB_BYTE_PRECISION_2BIT,
|
|
|
|
|
"Invalid sub-byte precision.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const unsigned src1_bits_per_element =
|
|
|
|
|
(8 * brw_reg_type_to_size(src1_type)) >>
|
|
|
|
|
brw_inst_dpas_3src_src1_subbyte(devinfo, inst);
|
|
|
|
|
|
|
|
|
|
const unsigned src2_bits_per_element =
|
|
|
|
|
(8 * brw_reg_type_to_size(src2_type)) >>
|
|
|
|
|
brw_inst_dpas_3src_src2_subbyte(devinfo, inst);
|
|
|
|
|
|
|
|
|
|
/* The MAX2(1, ...) is just to prevent possible division by 0 later. */
|
|
|
|
|
const unsigned ops_per_chan =
|
|
|
|
|
MAX2(1, 32 / MAX2(src1_bits_per_element, src2_bits_per_element));
|
|
|
|
|
|
2024-03-25 10:23:49 -07:00
|
|
|
if (devinfo->ver < 20) {
|
|
|
|
|
ERROR_IF(brw_inst_exec_size(devinfo, inst) != BRW_EXECUTE_8,
|
|
|
|
|
"DPAS execution size must be 8.");
|
|
|
|
|
} else {
|
|
|
|
|
ERROR_IF(brw_inst_exec_size(devinfo, inst) != BRW_EXECUTE_16,
|
|
|
|
|
"DPAS execution size must be 16.");
|
|
|
|
|
}
|
2023-09-25 17:40:01 -07:00
|
|
|
|
2024-03-25 10:23:49 -07:00
|
|
|
const unsigned exec_size = devinfo->ver < 20 ? 8 : 16;
|
2023-09-25 17:40:01 -07:00
|
|
|
|
|
|
|
|
const unsigned dst_subnr = brw_inst_dpas_3src_dst_subreg_nr(devinfo, inst);
|
|
|
|
|
const unsigned src0_subnr = brw_inst_dpas_3src_src0_subreg_nr(devinfo, inst);
|
|
|
|
|
const unsigned src1_subnr = brw_inst_dpas_3src_src1_subreg_nr(devinfo, inst);
|
|
|
|
|
const unsigned src2_subnr = brw_inst_dpas_3src_src2_subreg_nr(devinfo, inst);
|
|
|
|
|
|
|
|
|
|
/* Until HF is supported as dst type, this is effectively subnr == 0. */
|
|
|
|
|
ERROR_IF(dst_subnr % exec_size != 0,
|
|
|
|
|
"Destination subregister offset must be a multiple of ExecSize.");
|
|
|
|
|
|
|
|
|
|
/* Until HF is supported as src0 type, this is effectively subnr == 0. */
|
|
|
|
|
ERROR_IF(src0_subnr % exec_size != 0,
|
|
|
|
|
"Src0 subregister offset must be a multiple of ExecSize.");
|
|
|
|
|
|
|
|
|
|
ERROR_IF(src1_subnr != 0,
|
|
|
|
|
"Src1 subregister offsets must be 0.");
|
|
|
|
|
|
|
|
|
|
/* In nearly all cases, this effectively requires that src2.subnr be
|
|
|
|
|
* 0. It is only when src1 is 8 bits and src2 is 2 or 4 bits that the
|
|
|
|
|
* ops_per_chan value can allow non-zero src2.subnr.
|
|
|
|
|
*/
|
|
|
|
|
ERROR_IF(src2_subnr % (sdepth * ops_per_chan) != 0,
|
|
|
|
|
"Src2 subregister offset must be a multiple of SystolicDepth "
|
|
|
|
|
"times OPS_PER_CHAN.");
|
|
|
|
|
|
|
|
|
|
ERROR_IF(dst_subnr * type_sz(dst_type) >= REG_SIZE,
|
|
|
|
|
"Destination subregister specifies next register.");
|
|
|
|
|
|
|
|
|
|
ERROR_IF(src0_subnr * type_sz(src0_type) >= REG_SIZE,
|
|
|
|
|
"Src0 subregister specifies next register.");
|
|
|
|
|
|
|
|
|
|
ERROR_IF((src1_subnr * type_sz(src1_type) * src1_bits_per_element) / 8 >= REG_SIZE,
|
|
|
|
|
"Src1 subregister specifies next register.");
|
|
|
|
|
|
|
|
|
|
ERROR_IF((src2_subnr * type_sz(src2_type) * src2_bits_per_element) / 8 >= REG_SIZE,
|
|
|
|
|
"Src2 subregister specifies next register.");
|
|
|
|
|
|
|
|
|
|
if (brw_inst_3src_atomic_control(devinfo, inst)) {
|
|
|
|
|
/* FINISHME: When we start emitting DPAS with Atomic set, figure out
|
|
|
|
|
* a way to validate it. Also add a test in test_eu_validate.cpp.
|
|
|
|
|
*/
|
|
|
|
|
ERROR_IF(true,
|
|
|
|
|
"When instruction option Atomic is used it must be follwed by a "
|
|
|
|
|
"DPAS instruction.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (brw_inst_dpas_3src_exec_type(devinfo, inst) ==
|
|
|
|
|
BRW_ALIGN1_3SRC_EXEC_TYPE_FLOAT) {
|
|
|
|
|
ERROR_IF(dst_type != BRW_REGISTER_TYPE_F,
|
|
|
|
|
"DPAS destination type must be F.");
|
|
|
|
|
ERROR_IF(src0_type != BRW_REGISTER_TYPE_F,
|
|
|
|
|
"DPAS src0 type must be F.");
|
|
|
|
|
ERROR_IF(src1_type != BRW_REGISTER_TYPE_HF,
|
|
|
|
|
"DPAS src1 type must be HF.");
|
|
|
|
|
ERROR_IF(src2_type != BRW_REGISTER_TYPE_HF,
|
|
|
|
|
"DPAS src2 type must be HF.");
|
|
|
|
|
} else {
|
|
|
|
|
ERROR_IF(dst_type != BRW_REGISTER_TYPE_D &&
|
|
|
|
|
dst_type != BRW_REGISTER_TYPE_UD,
|
|
|
|
|
"DPAS destination type must be D or UD.");
|
|
|
|
|
ERROR_IF(src0_type != BRW_REGISTER_TYPE_D &&
|
|
|
|
|
src0_type != BRW_REGISTER_TYPE_UD,
|
|
|
|
|
"DPAS src0 type must be D or UD.");
|
|
|
|
|
ERROR_IF(src1_type != BRW_REGISTER_TYPE_B &&
|
|
|
|
|
src1_type != BRW_REGISTER_TYPE_UB,
|
|
|
|
|
"DPAS src1 base type must be B or UB.");
|
|
|
|
|
ERROR_IF(src2_type != BRW_REGISTER_TYPE_B &&
|
|
|
|
|
src2_type != BRW_REGISTER_TYPE_UB,
|
|
|
|
|
"DPAS src2 base type must be B or UB.");
|
|
|
|
|
|
|
|
|
|
if (brw_reg_type_is_unsigned_integer(dst_type)) {
|
|
|
|
|
ERROR_IF(!brw_reg_type_is_unsigned_integer(src0_type) ||
|
|
|
|
|
!brw_reg_type_is_unsigned_integer(src1_type) ||
|
|
|
|
|
!brw_reg_type_is_unsigned_integer(src2_type),
|
|
|
|
|
"If any source datatype is signed, destination datatype "
|
|
|
|
|
"must be signed.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* FINISHME: Additional restrictions mentioned in the Bspec that are not
|
|
|
|
|
* yet enforced here:
|
|
|
|
|
*
|
|
|
|
|
* - General Accumulator registers access is not supported. This is
|
|
|
|
|
* currently enforced in brw_dpas_three_src (brw_eu_emit.c).
|
|
|
|
|
*
|
|
|
|
|
* - Given any combination of datatypes in the sources of a DPAS
|
|
|
|
|
* instructions, the boundaries of a register should not be crossed.
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-07 14:09:25 -08:00
|
|
|
return error_msg;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-30 10:27:27 -05:00
|
|
|
static struct string
|
2022-06-29 14:13:31 -07:00
|
|
|
send_descriptor_restrictions(const struct brw_isa_info *isa,
|
2021-06-30 10:27:27 -05:00
|
|
|
const brw_inst *inst)
|
|
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
2021-06-30 10:27:27 -05:00
|
|
|
struct string error_msg = { .str = NULL, .len = 0 };
|
|
|
|
|
|
2022-06-29 14:13:31 -07:00
|
|
|
if (inst_is_split_send(isa, inst)) {
|
2021-06-30 10:27:27 -05:00
|
|
|
/* We can only validate immediate descriptors */
|
|
|
|
|
if (brw_inst_send_sel_reg32_desc(devinfo, inst))
|
|
|
|
|
return error_msg;
|
2022-06-29 14:13:31 -07:00
|
|
|
} else if (inst_is_send(isa, inst)) {
|
2021-06-30 10:27:27 -05:00
|
|
|
/* We can only validate immediate descriptors */
|
|
|
|
|
if (brw_inst_src1_reg_file(devinfo, inst) != BRW_IMMEDIATE_VALUE)
|
|
|
|
|
return error_msg;
|
|
|
|
|
} else {
|
|
|
|
|
return error_msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const uint32_t desc = brw_inst_send_desc(devinfo, inst);
|
|
|
|
|
|
|
|
|
|
switch (brw_inst_sfid(devinfo, inst)) {
|
2022-07-20 10:21:21 -07:00
|
|
|
case BRW_SFID_URB:
|
|
|
|
|
if (devinfo->ver < 20)
|
|
|
|
|
break;
|
|
|
|
|
FALLTHROUGH;
|
2021-06-30 10:27:27 -05:00
|
|
|
case GFX12_SFID_TGM:
|
|
|
|
|
case GFX12_SFID_SLM:
|
|
|
|
|
case GFX12_SFID_UGM:
|
|
|
|
|
ERROR_IF(!devinfo->has_lsc, "Platform does not support LSC");
|
|
|
|
|
|
2021-07-20 18:44:15 -05:00
|
|
|
ERROR_IF(lsc_opcode_has_transpose(lsc_msg_desc_opcode(devinfo, desc)) &&
|
|
|
|
|
lsc_msg_desc_transpose(devinfo, desc) &&
|
2021-06-30 10:27:27 -05:00
|
|
|
brw_inst_exec_size(devinfo, inst) != BRW_EXECUTE_1,
|
|
|
|
|
"Transposed vectors are restricted to Exec_Mask = 1.");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-20 10:21:21 -07:00
|
|
|
if (brw_inst_sfid(devinfo, inst) == BRW_SFID_URB && devinfo->ver < 20) {
|
2024-02-16 13:38:19 -08:00
|
|
|
ERROR_IF(!brw_inst_header_present(devinfo, inst),
|
2022-06-28 12:26:04 -07:00
|
|
|
"Header must be present for all URB messages.");
|
|
|
|
|
|
|
|
|
|
switch (brw_inst_urb_opcode(devinfo, inst)) {
|
|
|
|
|
case GFX7_URB_OPCODE_ATOMIC_INC:
|
2024-02-16 13:38:19 -08:00
|
|
|
case GFX7_URB_OPCODE_ATOMIC_MOV:
|
2022-06-28 12:26:04 -07:00
|
|
|
case GFX8_URB_OPCODE_ATOMIC_ADD:
|
2024-02-16 13:38:19 -08:00
|
|
|
case GFX8_URB_OPCODE_SIMD8_WRITE:
|
2022-06-28 12:26:04 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GFX8_URB_OPCODE_SIMD8_READ:
|
|
|
|
|
ERROR_IF(brw_inst_rlen(devinfo, inst) == 0,
|
|
|
|
|
"URB SIMD8 read message must read some data.");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GFX125_URB_OPCODE_FENCE:
|
|
|
|
|
ERROR_IF(devinfo->verx10 < 125,
|
|
|
|
|
"URB fence message only valid on gfx >= 12.5");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
ERROR_IF(true, "Invalid URB message");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-30 10:27:27 -05:00
|
|
|
return error_msg;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-11 16:11:34 -08:00
|
|
|
bool
|
2022-06-29 14:13:31 -07:00
|
|
|
brw_validate_instruction(const struct brw_isa_info *isa,
|
2019-11-11 15:19:07 -08:00
|
|
|
const brw_inst *inst, int offset,
|
2022-07-19 00:27:29 -07:00
|
|
|
unsigned inst_size,
|
2019-11-11 15:19:07 -08:00
|
|
|
struct disasm_info *disasm)
|
|
|
|
|
{
|
|
|
|
|
struct string error_msg = { .str = NULL, .len = 0 };
|
|
|
|
|
|
2022-06-29 14:13:31 -07:00
|
|
|
if (is_unsupported_inst(isa, inst)) {
|
2019-11-11 15:19:07 -08:00
|
|
|
ERROR("Instruction not supported on this Gen");
|
|
|
|
|
} else {
|
2020-01-02 14:44:16 -08:00
|
|
|
CHECK(invalid_values);
|
|
|
|
|
|
|
|
|
|
if (error_msg.str == NULL) {
|
|
|
|
|
CHECK(sources_not_null);
|
|
|
|
|
CHECK(send_restrictions);
|
|
|
|
|
CHECK(alignment_supported);
|
|
|
|
|
CHECK(general_restrictions_based_on_operand_types);
|
|
|
|
|
CHECK(general_restrictions_on_region_parameters);
|
|
|
|
|
CHECK(special_restrictions_for_mixed_float_mode);
|
|
|
|
|
CHECK(region_alignment_rules);
|
|
|
|
|
CHECK(vector_immediate_restrictions);
|
|
|
|
|
CHECK(special_requirements_for_handling_double_precision_data_types);
|
|
|
|
|
CHECK(instruction_restrictions);
|
2021-06-30 10:27:27 -05:00
|
|
|
CHECK(send_descriptor_restrictions);
|
2020-01-02 14:44:16 -08:00
|
|
|
}
|
2019-11-11 15:19:07 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (error_msg.str && disasm) {
|
2022-07-19 00:27:29 -07:00
|
|
|
disasm_insert_error(disasm, offset, inst_size, error_msg.str);
|
2019-11-11 15:19:07 -08:00
|
|
|
}
|
|
|
|
|
free(error_msg.str);
|
|
|
|
|
|
|
|
|
|
return error_msg.len == 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-29 14:08:51 -07:00
|
|
|
bool
|
2022-06-29 14:13:31 -07:00
|
|
|
brw_validate_instructions(const struct brw_isa_info *isa,
|
2017-09-25 13:34:08 +03:00
|
|
|
const void *assembly, int start_offset, int end_offset,
|
2017-11-15 17:08:42 -08:00
|
|
|
struct disasm_info *disasm)
|
2015-06-29 14:08:51 -07:00
|
|
|
{
|
2022-06-29 14:13:31 -07:00
|
|
|
const struct intel_device_info *devinfo = isa->devinfo;
|
2015-06-29 14:08:51 -07:00
|
|
|
bool valid = true;
|
|
|
|
|
|
2017-04-28 17:06:56 -07:00
|
|
|
for (int src_offset = start_offset; src_offset < end_offset;) {
|
2017-04-28 17:05:44 -07:00
|
|
|
const brw_inst *inst = assembly + src_offset;
|
2017-04-28 17:06:56 -07:00
|
|
|
bool is_compact = brw_inst_cmpt_control(devinfo, inst);
|
2019-11-11 15:19:07 -08:00
|
|
|
unsigned inst_size = is_compact ? sizeof(brw_compact_inst)
|
|
|
|
|
: sizeof(brw_inst);
|
2017-04-28 17:06:56 -07:00
|
|
|
brw_inst uncompacted;
|
|
|
|
|
|
|
|
|
|
if (is_compact) {
|
|
|
|
|
brw_compact_inst *compacted = (void *)inst;
|
2022-06-29 14:13:31 -07:00
|
|
|
brw_uncompact_instruction(isa, &uncompacted, compacted);
|
2017-04-28 17:06:56 -07:00
|
|
|
inst = &uncompacted;
|
|
|
|
|
}
|
2015-06-29 14:08:51 -07:00
|
|
|
|
2022-07-19 00:27:29 -07:00
|
|
|
bool v = brw_validate_instruction(isa, inst, src_offset,
|
|
|
|
|
inst_size, disasm);
|
2019-11-11 15:19:07 -08:00
|
|
|
valid = valid && v;
|
2016-06-09 12:36:55 -07:00
|
|
|
|
2019-11-11 15:19:07 -08:00
|
|
|
src_offset += inst_size;
|
2015-06-29 14:08:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return valid;
|
|
|
|
|
}
|