[Mesa-dev] [PATCH 05/23] i965: Make instruction compaction take a device_info instead of a context
Matt Turner
mattst88 at gmail.com
Fri Apr 17 22:10:05 PDT 2015
On Fri, Apr 17, 2015 at 7:11 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
> ---
> src/mesa/drivers/dri/i965/brw_eu.c | 2 +-
> src/mesa/drivers/dri/i965/brw_eu.h | 12 +-
> src/mesa/drivers/dri/i965/brw_eu_compact.c | 198 ++++++++++++++--------------
> src/mesa/drivers/dri/i965/test_eu_compact.c | 4 +-
> 4 files changed, 107 insertions(+), 109 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_eu.c b/src/mesa/drivers/dri/i965/brw_eu.c
> index fb2d7b3..1aae9b2 100644
> --- a/src/mesa/drivers/dri/i965/brw_eu.c
> +++ b/src/mesa/drivers/dri/i965/brw_eu.c
> @@ -275,7 +275,7 @@ brw_disassemble(struct brw_context *brw,
> ((uint32_t *)insn)[0]);
> }
>
> - brw_uncompact_instruction(brw, &uncompacted, compacted);
> + brw_uncompact_instruction(brw->intelScreen->devinfo, &uncompacted, compacted);
Probably need to line wrap.
> insn = &uncompacted;
> offset += 8;
> } else {
> diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h
> index 0e67d61..b9566ca 100644
> --- a/src/mesa/drivers/dri/i965/brw_eu.h
> +++ b/src/mesa/drivers/dri/i965/brw_eu.h
> @@ -465,13 +465,13 @@ enum brw_conditional_mod brw_swap_cmod(uint32_t cmod);
> void brw_init_compaction_tables(struct brw_context *brw);
> void brw_compact_instructions(struct brw_compile *p, int start_offset,
> int num_annotations, struct annotation *annotation);
> -void brw_uncompact_instruction(struct brw_context *brw, brw_inst *dst,
> - brw_compact_inst *src);
> -bool brw_try_compact_instruction(struct brw_context *brw, brw_compact_inst *dst,
> - brw_inst *src);
> +void brw_uncompact_instruction(const struct brw_device_info *devinfo,
> + brw_inst *dst, brw_compact_inst *src);
> +bool brw_try_compact_instruction(const struct brw_device_info *devinfo,
> + brw_compact_inst *dst, brw_inst *src);
>
> -void brw_debug_compact_uncompact(struct brw_context *brw, brw_inst *orig,
> - brw_inst *uncompacted);
> +void brw_debug_compact_uncompact(struct brw_context *brw,
> + brw_inst *orig, brw_inst *uncompacted);
>
> static inline int
> next_offset(const struct brw_device_info *devinfo, void *store, int offset)
> diff --git a/src/mesa/drivers/dri/i965/brw_eu_compact.c b/src/mesa/drivers/dri/i965/brw_eu_compact.c
> index 23aac0a..4432b88 100644
> --- a/src/mesa/drivers/dri/i965/brw_eu_compact.c
> +++ b/src/mesa/drivers/dri/i965/brw_eu_compact.c
> @@ -670,9 +670,10 @@ static const uint16_t *subreg_table;
> static const uint16_t *src_index_table;
>
> static bool
> -set_control_index(struct brw_context *brw, brw_compact_inst *dst, brw_inst *src)
> +set_control_index(const struct brw_device_info *devinfo,
> + brw_compact_inst *dst, brw_inst *src)
> {
> - uint32_t uncompacted = brw->gen >= 8 /* 17b/G45; 19b/IVB+ */
> + uint32_t uncompacted = devinfo->gen >= 8 /* 17b/G45; 19b/IVB+ */
Align this comment with the ones below.
> ? (brw_inst_bits(src, 33, 31) << 16) | /* 3b */
> (brw_inst_bits(src, 23, 12) << 4) | /* 12b */
> (brw_inst_bits(src, 10, 9) << 2) | /* 2b */
> @@ -684,7 +685,7 @@ set_control_index(struct brw_context *brw, brw_compact_inst *dst, brw_inst *src)
> /* On gen7, the flag register and subregister numbers are integrated into
> * the control index.
> */
> - if (brw->gen == 7)
> + if (devinfo->gen == 7)
> uncompacted |= brw_inst_bits(src, 90, 89) << 17; /* 2b */
>
> for (int i = 0; i < 32; i++) {
> @@ -698,10 +699,10 @@ set_control_index(struct brw_context *brw, brw_compact_inst *dst, brw_inst *src)
> }
>
> static bool
> -set_datatype_index(struct brw_context *brw, brw_compact_inst *dst,
> +set_datatype_index(const struct brw_device_info *devinfo, brw_compact_inst *dst,
> brw_inst *src)
> {
> - uint32_t uncompacted = brw->gen >= 8 /* 18b/G45+; 21b/BDW+ */
> + uint32_t uncompacted = devinfo->gen >= 8 /* 18b/G45+; 21b/BDW+ */
Same.
> ? (brw_inst_bits(src, 63, 61) << 18) | /* 3b */
> (brw_inst_bits(src, 94, 89) << 12) | /* 6b */
> (brw_inst_bits(src, 46, 35)) /* 12b */
> @@ -719,8 +720,8 @@ set_datatype_index(struct brw_context *brw, brw_compact_inst *dst,
> }
>
> static bool
> -set_subreg_index(struct brw_context *brw, brw_compact_inst *dst, brw_inst *src,
> - bool is_immediate)
> +set_subreg_index(const struct brw_device_info *devinfo, brw_compact_inst *dst,
> + brw_inst *src, bool is_immediate)
> {
> uint16_t uncompacted = /* 15b */
> (brw_inst_bits(src, 52, 48) << 0) | /* 5b */
> @@ -754,7 +755,8 @@ get_src_index(uint16_t uncompacted,
> }
>
> static bool
> -set_src0_index(struct brw_context *brw, brw_compact_inst *dst, brw_inst *src)
> +set_src0_index(const struct brw_device_info *devinfo,
> + brw_compact_inst *dst, brw_inst *src)
> {
> uint16_t compacted;
> uint16_t uncompacted = brw_inst_bits(src, 88, 77); /* 12b */
> @@ -768,13 +770,13 @@ set_src0_index(struct brw_context *brw, brw_compact_inst *dst, brw_inst *src)
> }
>
> static bool
> -set_src1_index(struct brw_context *brw, brw_compact_inst *dst, brw_inst *src,
> - bool is_immediate)
> +set_src1_index(const struct brw_device_info *devinfo, brw_compact_inst *dst,
> + brw_inst *src, bool is_immediate)
> {
> uint16_t compacted;
>
> if (is_immediate) {
> - compacted = (brw_inst_imm_ud(brw->intelScreen->devinfo, src) >> 8) & 0x1f;
> + compacted = (brw_inst_imm_ud(devinfo, src) >> 8) & 0x1f;
> } else {
> uint16_t uncompacted = brw_inst_bits(src, 120, 109); /* 12b */
>
> @@ -788,15 +790,16 @@ set_src1_index(struct brw_context *brw, brw_compact_inst *dst, brw_inst *src,
> }
>
> static bool
> -set_3src_control_index(struct brw_context *brw, brw_compact_inst *dst, brw_inst *src)
> +set_3src_control_index(const struct brw_device_info *devinfo,
> + brw_compact_inst *dst, brw_inst *src)
> {
> - assert(brw->gen >= 8);
> + assert(devinfo->gen >= 8);
>
> uint32_t uncompacted = /* 24b/BDW; 26b/CHV */
> (brw_inst_bits(src, 34, 32) << 21) | /* 3b */
> (brw_inst_bits(src, 28, 8)); /* 21b */
>
> - if (brw->gen >= 9 || brw->is_cherryview)
> + if (devinfo->gen >= 9 || devinfo->is_cherryview)
> uncompacted |= brw_inst_bits(src, 36, 35) << 24; /* 2b */
>
> for (int i = 0; i < ARRAY_SIZE(gen8_3src_control_index_table); i++) {
> @@ -810,9 +813,10 @@ set_3src_control_index(struct brw_context *brw, brw_compact_inst *dst, brw_inst
> }
>
> static bool
> -set_3src_source_index(struct brw_context *brw, brw_compact_inst *dst, brw_inst *src)
> +set_3src_source_index(const struct brw_device_info *devinfo,
> + brw_compact_inst *dst, brw_inst *src)
> {
> - assert(brw->gen >= 8);
> + assert(devinfo->gen >= 8);
>
> uint64_t uncompacted = /* 46b/BDW; 49b/CHV */
> (brw_inst_bits(src, 83, 83) << 43) | /* 1b */
> @@ -821,7 +825,7 @@ set_3src_source_index(struct brw_context *brw, brw_compact_inst *dst, brw_inst *
> (brw_inst_bits(src, 72, 65) << 19) | /* 8b */
> (brw_inst_bits(src, 55, 37)); /* 19b */
>
> - if (brw->gen >= 9 || brw->is_cherryview) {
> + if (devinfo->gen >= 9 || devinfo->is_cherryview) {
> uncompacted |=
> (brw_inst_bits(src, 126, 125) << 47) | /* 2b */
> (brw_inst_bits(src, 105, 104) << 45) | /* 2b */
> @@ -843,7 +847,7 @@ set_3src_source_index(struct brw_context *brw, brw_compact_inst *dst, brw_inst *
> }
>
> static bool
> -has_unmapped_bits(struct brw_context *brw, brw_inst *src)
> +has_unmapped_bits(const struct brw_device_info *devinfo, brw_inst *src)
> {
> /* Check for instruction bits that don't map to any of the fields of the
> * compacted instruction. The instruction cannot be compacted if any of
> @@ -854,31 +858,31 @@ has_unmapped_bits(struct brw_context *brw, brw_inst *src)
> * - Imm64[27:31] (bits 91-95 on Gen7, bit 95 on Gen8)
> * - UIP[31] (bit 95 on Gen8)
> */
> - if (brw->gen >= 8) {
> + if (devinfo->gen >= 8) {
> assert(!brw_inst_bits(src, 7, 7));
> return brw_inst_bits(src, 95, 95) ||
> brw_inst_bits(src, 47, 47) ||
> brw_inst_bits(src, 11, 11);
> } else {
> assert(!brw_inst_bits(src, 7, 7) &&
> - !(brw->gen < 7 && brw_inst_bits(src, 90, 90)));
> + !(devinfo->gen < 7 && brw_inst_bits(src, 90, 90)));
> return brw_inst_bits(src, 95, 91) ||
> brw_inst_bits(src, 47, 47);
> }
> }
>
> static bool
> -has_3src_unmapped_bits(struct brw_context *brw, brw_inst *src)
> +has_3src_unmapped_bits(const struct brw_device_info *devinfo, brw_inst *src)
> {
> /* Check for three-source instruction bits that don't map to any of the
> * fields of the compacted instruction. All of them seem to be reserved
> * bits currently.
> */
> - if (brw->gen >= 9 || brw->is_cherryview) {
> + if (devinfo->gen >= 9 || devinfo->is_cherryview) {
> assert(!brw_inst_bits(src, 127, 127) &&
> !brw_inst_bits(src, 7, 7));
> } else {
> - assert(brw->gen >= 8);
> + assert(devinfo->gen >= 8);
> assert(!brw_inst_bits(src, 127, 126) &&
> !brw_inst_bits(src, 105, 105) &&
> !brw_inst_bits(src, 84, 84) &&
> @@ -890,24 +894,23 @@ has_3src_unmapped_bits(struct brw_context *brw, brw_inst *src)
> }
>
> static bool
> -brw_try_compact_3src_instruction(struct brw_context *brw, brw_compact_inst *dst,
> - brw_inst *src)
> +brw_try_compact_3src_instruction(const struct brw_device_info *devinfo,
> + brw_compact_inst *dst, brw_inst *src)
> {
> - assert(brw->gen >= 8);
> + assert(devinfo->gen >= 8);
>
> - if (has_3src_unmapped_bits(brw, src))
> + if (has_3src_unmapped_bits(devinfo, src))
> return false;
>
> - const struct brw_device_info *devinfo = brw->intelScreen->devinfo;
> #define compact(field) \
> brw_compact_inst_set_3src_##field(dst, brw_inst_3src_##field(devinfo, src))
>
> compact(opcode);
>
> - if (!set_3src_control_index(brw, dst, src))
> + if (!set_3src_control_index(devinfo, dst, src))
> return false;
>
> - if (!set_3src_source_index(brw, dst, src))
> + if (!set_3src_source_index(devinfo, dst, src))
> return false;
>
> compact(dst_reg_nr);
> @@ -959,18 +962,17 @@ is_3src(uint32_t op)
> * brw_compact_instructions().
> */
> bool
> -brw_try_compact_instruction(struct brw_context *brw, brw_compact_inst *dst,
> - brw_inst *src)
> +brw_try_compact_instruction(const struct brw_device_info *devinfo,
> + brw_compact_inst *dst, brw_inst *src)
> {
> - const struct brw_device_info *devinfo = brw->intelScreen->devinfo;
> brw_compact_inst temp;
>
> assert(brw_inst_cmpt_control(devinfo, src) == 0);
>
> if (is_3src(brw_inst_opcode(devinfo, src))) {
> - if (brw->gen >= 8) {
> + if (devinfo->gen >= 8) {
> memset(&temp, 0, sizeof(temp));
> - if (brw_try_compact_3src_instruction(brw, &temp, src)) {
> + if (brw_try_compact_3src_instruction(devinfo, &temp, src)) {
> *dst = temp;
> return true;
> } else {
> @@ -985,34 +987,34 @@ brw_try_compact_instruction(struct brw_context *brw, brw_compact_inst *dst,
> brw_inst_src0_reg_file(devinfo, src) == BRW_IMMEDIATE_VALUE ||
> brw_inst_src1_reg_file(devinfo, src) == BRW_IMMEDIATE_VALUE;
> if (is_immediate &&
> - (brw->gen < 6 || !is_compactable_immediate(brw_inst_imm_ud(devinfo, src)))) {
> + (devinfo->gen < 6 || !is_compactable_immediate(brw_inst_imm_ud(devinfo, src)))) {
Probably line wrap, and others below...
More information about the mesa-dev
mailing list