From 46e5b2a497216133be656b38ebfcf96da64b7744 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Sun, 29 Jun 2014 17:50:20 -0700 Subject: [PATCH] i965: Make a brw_conditional_mod enum. Reviewed-by: Topi Pohjolainen --- .../drivers/dri/i965/brw_blorp_blit_eu.cpp | 2 +- src/mesa/drivers/dri/i965/brw_blorp_blit_eu.h | 7 ++--- src/mesa/drivers/dri/i965/brw_defines.h | 26 ++++++++++--------- src/mesa/drivers/dri/i965/brw_eu.c | 2 +- src/mesa/drivers/dri/i965/brw_eu.h | 4 +-- src/mesa/drivers/dri/i965/brw_eu_emit.c | 2 +- src/mesa/drivers/dri/i965/brw_fs.cpp | 6 +++-- src/mesa/drivers/dri/i965/brw_fs.h | 9 ++++--- .../dri/i965/brw_fs_copy_propagation.cpp | 2 +- src/mesa/drivers/dri/i965/brw_fs_fp.cpp | 4 +-- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 4 +-- src/mesa/drivers/dri/i965/brw_shader.cpp | 2 +- src/mesa/drivers/dri/i965/brw_shader.h | 4 +-- src/mesa/drivers/dri/i965/brw_vec4.h | 10 ++++--- .../dri/i965/brw_vec4_copy_propagation.cpp | 2 +- .../drivers/dri/i965/brw_vec4_visitor.cpp | 8 +++--- src/mesa/drivers/dri/i965/brw_vec4_vp.cpp | 2 +- src/mesa/drivers/dri/i965/gen8_instruction.c | 1 + 18 files changed, 54 insertions(+), 43 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp index a2e008b9597..c1676a9db44 100644 --- a/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp +++ b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp @@ -117,7 +117,7 @@ brw_blorp_eu_emitter::emit_combine(enum opcode combine_opcode, } fs_inst * -brw_blorp_eu_emitter::emit_cmp(int op, +brw_blorp_eu_emitter::emit_cmp(enum brw_conditional_mod op, const struct brw_reg &x, const struct brw_reg &y) { diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.h b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.h index bc927fedc50..0459a7e1bd5 100644 --- a/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.h +++ b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.h @@ -59,7 +59,7 @@ protected: inline void emit_cond_mov(const struct brw_reg &x, const struct brw_reg &y, - int op, + enum brw_conditional_mod op, const struct brw_reg &dst, const struct brw_reg &src) { @@ -160,7 +160,7 @@ protected: insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_RNDD, dst, src)); } - inline void emit_cmp_if(int op, + inline void emit_cmp_if(enum brw_conditional_mod op, const struct brw_reg &x, const struct brw_reg &y) { @@ -179,7 +179,8 @@ protected: } private: - fs_inst *emit_cmp(int op, const struct brw_reg &x, const struct brw_reg &y); + fs_inst *emit_cmp(enum brw_conditional_mod op, const struct brw_reg &x, + const struct brw_reg &y); void *mem_ctx; exec_list insts; diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h index 858d9af43e3..34c39069f98 100644 --- a/src/mesa/drivers/dri/i965/brw_defines.h +++ b/src/mesa/drivers/dri/i965/brw_defines.h @@ -654,18 +654,20 @@ enum brw_compression { #define GEN6_COMPRESSION_1H 0 #define GEN6_COMPRESSION_2H 2 -#define BRW_CONDITIONAL_NONE 0 -#define BRW_CONDITIONAL_Z 1 -#define BRW_CONDITIONAL_NZ 2 -#define BRW_CONDITIONAL_EQ 1 /* Z */ -#define BRW_CONDITIONAL_NEQ 2 /* NZ */ -#define BRW_CONDITIONAL_G 3 -#define BRW_CONDITIONAL_GE 4 -#define BRW_CONDITIONAL_L 5 -#define BRW_CONDITIONAL_LE 6 -#define BRW_CONDITIONAL_R 7 -#define BRW_CONDITIONAL_O 8 -#define BRW_CONDITIONAL_U 9 +enum PACKED brw_conditional_mod { + BRW_CONDITIONAL_NONE = 0, + BRW_CONDITIONAL_Z = 1, + BRW_CONDITIONAL_NZ = 2, + BRW_CONDITIONAL_EQ = 1, /* Z */ + BRW_CONDITIONAL_NEQ = 2, /* NZ */ + BRW_CONDITIONAL_G = 3, + BRW_CONDITIONAL_GE = 4, + BRW_CONDITIONAL_L = 5, + BRW_CONDITIONAL_LE = 6, + BRW_CONDITIONAL_R = 7, + BRW_CONDITIONAL_O = 8, + BRW_CONDITIONAL_U = 9, +}; #define BRW_DEBUG_NONE 0 #define BRW_DEBUG_BREAKPOINT 1 diff --git a/src/mesa/drivers/dri/i965/brw_eu.c b/src/mesa/drivers/dri/i965/brw_eu.c index 6a1e78511e6..f4c74952a17 100644 --- a/src/mesa/drivers/dri/i965/brw_eu.c +++ b/src/mesa/drivers/dri/i965/brw_eu.c @@ -68,7 +68,7 @@ brw_reg_type_letters(unsigned type) /* Returns the corresponding conditional mod for swapping src0 and * src1 in e.g. CMP. */ -uint32_t +enum brw_conditional_mod brw_swap_cmod(uint32_t cmod) { switch (cmod) { diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h index 59b9232feed..48ef2984f9b 100644 --- a/src/mesa/drivers/dri/i965/brw_eu.h +++ b/src/mesa/drivers/dri/i965/brw_eu.h @@ -320,7 +320,7 @@ void brw_shader_time_add(struct brw_compile *p, * channel. */ brw_inst *brw_IF(struct brw_compile *p, unsigned execute_size); -brw_inst *gen6_IF(struct brw_compile *p, uint32_t conditional, +brw_inst *gen6_IF(struct brw_compile *p, enum brw_conditional_mod conditional, struct brw_reg src0, struct brw_reg src1); void brw_ELSE(struct brw_compile *p); @@ -404,7 +404,7 @@ void brw_set_src1(struct brw_compile *p, brw_inst *insn, struct brw_reg reg); void brw_set_uip_jip(struct brw_compile *p); -uint32_t brw_swap_cmod(uint32_t cmod); +enum brw_conditional_mod brw_swap_cmod(uint32_t cmod); /* brw_eu_compact.c */ void brw_init_compaction_tables(struct brw_context *brw); diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c index 44ae7006013..cd5bc9f2af0 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c @@ -1241,7 +1241,7 @@ brw_IF(struct brw_compile *p, unsigned execute_size) * embedded comparison (conditional modifier). It is not used on gen7. */ brw_inst * -gen6_IF(struct brw_compile *p, uint32_t conditional, +gen6_IF(struct brw_compile *p, enum brw_conditional_mod conditional, struct brw_reg src0, struct brw_reg src1) { const struct brw_context *brw = p->brw; diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 2a7c00e7892..d14d20f632b 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -198,7 +198,8 @@ fs_visitor::IF(uint32_t predicate) /** Gen6 IF with embedded comparison. */ fs_inst * -fs_visitor::IF(const fs_reg &src0, const fs_reg &src1, uint32_t condition) +fs_visitor::IF(const fs_reg &src0, const fs_reg &src1, + enum brw_conditional_mod condition) { assert(brw->gen == 6); fs_inst *inst = new(mem_ctx) fs_inst(BRW_OPCODE_IF, @@ -213,7 +214,8 @@ fs_visitor::IF(const fs_reg &src0, const fs_reg &src1, uint32_t condition) * the flag register with the packed 16 bits of the result. */ fs_inst * -fs_visitor::CMP(fs_reg dst, fs_reg src0, fs_reg src1, uint32_t condition) +fs_visitor::CMP(fs_reg dst, fs_reg src0, fs_reg src1, + enum brw_conditional_mod condition) { fs_inst *inst; diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index da4d373508a..bffdb2cc5ea 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -273,9 +273,10 @@ public: fs_inst *OR(const fs_reg &dst, const fs_reg &src0, const fs_reg &src1); fs_inst *XOR(const fs_reg &dst, const fs_reg &src0, const fs_reg &src1); fs_inst *IF(uint32_t predicate); - fs_inst *IF(const fs_reg &src0, const fs_reg &src1, uint32_t condition); + fs_inst *IF(const fs_reg &src0, const fs_reg &src1, + enum brw_conditional_mod condition); fs_inst *CMP(fs_reg dst, fs_reg src0, fs_reg src1, - uint32_t condition); + enum brw_conditional_mod condition); fs_inst *LRP(const fs_reg &dst, const fs_reg &a, const fs_reg &y, const fs_reg &x); fs_inst *DEP_RESOLVE_MOV(int grf); @@ -385,7 +386,7 @@ public: fs_inst *emit_math(enum opcode op, fs_reg dst, fs_reg src0, fs_reg src1); void emit_lrp(const fs_reg &dst, const fs_reg &x, const fs_reg &y, const fs_reg &a); - void emit_minmax(uint32_t conditionalmod, const fs_reg &dst, + void emit_minmax(enum brw_conditional_mod conditionalmod, const fs_reg &dst, const fs_reg &src0, const fs_reg &src1); bool try_emit_saturate(ir_expression *ir); bool try_emit_mad(ir_expression *ir); @@ -417,7 +418,7 @@ public: void emit_fp_minmax(const struct prog_instruction *fpi, fs_reg dst, fs_reg src0, fs_reg src1); - void emit_fp_sop(uint32_t conditional_mod, + void emit_fp_sop(enum brw_conditional_mod conditional_mod, const struct prog_instruction *fpi, fs_reg dst, fs_reg src0, fs_reg src1, fs_reg one); diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp index 3452a9547e8..28e59c6c807 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp @@ -442,7 +442,7 @@ try_constant_propagate(struct brw_context *brw, fs_inst *inst, inst->src[i] = entry->src; progress = true; } else if (i == 0 && inst->src[1].file != IMM) { - uint32_t new_cmod; + enum brw_conditional_mod new_cmod; new_cmod = brw_swap_cmod(inst->conditional_mod); if (new_cmod != ~0u) { diff --git a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp index 5eaea77c7b1..0c5daa7dd68 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp @@ -57,7 +57,7 @@ void fs_visitor::emit_fp_minmax(const prog_instruction *fpi, fs_reg dst, fs_reg src0, fs_reg src1) { - uint32_t conditionalmod; + enum brw_conditional_mod conditionalmod; if (fpi->Opcode == OPCODE_MIN) conditionalmod = BRW_CONDITIONAL_L; else @@ -72,7 +72,7 @@ fs_visitor::emit_fp_minmax(const prog_instruction *fpi, } void -fs_visitor::emit_fp_sop(uint32_t conditional_mod, +fs_visitor::emit_fp_sop(enum brw_conditional_mod conditional_mod, const struct prog_instruction *fpi, fs_reg dst, fs_reg src0, fs_reg src1, fs_reg one) diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index cfa67925e4a..8e8affabd40 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -251,7 +251,7 @@ fs_visitor::emit_lrp(const fs_reg &dst, const fs_reg &x, const fs_reg &y, } void -fs_visitor::emit_minmax(uint32_t conditionalmod, const fs_reg &dst, +fs_visitor::emit_minmax(enum brw_conditional_mod conditionalmod, const fs_reg &dst, const fs_reg &src0, const fs_reg &src1) { fs_inst *inst; @@ -2692,7 +2692,7 @@ fs_visitor::emit_color_write(int target, int index, int first_color_mrf) } } -static int +static enum brw_conditional_mod cond_for_alpha_func(GLenum func) { switch(func) { diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp index 58ebd331ef1..d7e127b9659 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.cpp +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp @@ -311,7 +311,7 @@ brw_type_for_base_type(const struct glsl_type *type) return BRW_REGISTER_TYPE_F; } -uint32_t +enum brw_conditional_mod brw_conditional_for_comparison(unsigned int op) { switch (op) { diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h index 7205a8584bd..7c84ab40616 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.h +++ b/src/mesa/drivers/dri/i965/brw_shader.h @@ -118,7 +118,7 @@ public: uint8_t mlen; /**< SEND message length */ int8_t base_mrf; /**< First MRF in the SEND message, if mlen is nonzero. */ uint8_t target; /**< MRT target. */ - uint8_t conditional_mod; /**< BRW_CONDITIONAL_* */ + enum brw_conditional_mod conditional_mod; /**< BRW_CONDITIONAL_* */ bool force_writemask_all:1; bool no_dd_clear:1; @@ -180,6 +180,6 @@ void annotation_finalize(struct annotation_info *annotation, unsigned offset); #endif /* __cplusplus */ enum brw_reg_type brw_type_for_base_type(const struct glsl_type *type); -uint32_t brw_conditional_for_comparison(unsigned int op); +enum brw_conditional_mod brw_conditional_for_comparison(unsigned int op); uint32_t brw_math_function(enum opcode op); const char *brw_instruction_name(enum opcode op); diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h index 21df5524013..d61909d3d22 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_vec4.h @@ -441,8 +441,9 @@ public: vec4_instruction *ASR(const dst_reg &dst, const src_reg &src0, const src_reg &src1); vec4_instruction *CMP(dst_reg dst, src_reg src0, src_reg src1, - uint32_t condition); - vec4_instruction *IF(src_reg src0, src_reg src1, uint32_t condition); + enum brw_conditional_mod condition); + vec4_instruction *IF(src_reg src0, src_reg src1, + enum brw_conditional_mod condition); vec4_instruction *IF(uint32_t predicate); vec4_instruction *PULL_CONSTANT_LOAD(const dst_reg &dst, const src_reg &index); @@ -479,14 +480,15 @@ public: /** Walks an exec_list of ir_instruction and sends it through this visitor. */ void visit_instructions(const exec_list *list); - void emit_vp_sop(uint32_t condmod, dst_reg dst, + void emit_vp_sop(enum brw_conditional_mod condmod, dst_reg dst, src_reg src0, src_reg src1, src_reg one); void emit_bool_to_cond_code(ir_rvalue *ir, uint32_t *predicate); void emit_bool_comparison(unsigned int op, dst_reg dst, src_reg src0, src_reg src1); void emit_if_gen6(ir_if *ir); - void emit_minmax(uint32_t condmod, dst_reg dst, src_reg src0, src_reg src1); + void emit_minmax(enum brw_conditional_mod conditionalmod, dst_reg dst, + src_reg src0, src_reg src1); void emit_lrp(const dst_reg &dst, const src_reg &x, const src_reg &y, const src_reg &a); diff --git a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp index b6dc07f25d4..2c41d0208f2 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp @@ -162,7 +162,7 @@ try_constant_propagate(struct brw_context *brw, vec4_instruction *inst, inst->src[arg] = value; return true; } else if (arg == 0 && inst->src[1].file != IMM) { - uint32_t new_cmod; + enum brw_conditional_mod new_cmod; new_cmod = brw_swap_cmod(inst->conditional_mod); if (new_cmod != ~0u) { diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index 5051d9fa80b..c5f4b5c9b3d 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -195,7 +195,8 @@ vec4_visitor::IF(uint32_t predicate) /** Gen6 IF with embedded comparison. */ vec4_instruction * -vec4_visitor::IF(src_reg src0, src_reg src1, uint32_t condition) +vec4_visitor::IF(src_reg src0, src_reg src1, + enum brw_conditional_mod condition) { assert(brw->gen == 6); @@ -217,7 +218,8 @@ vec4_visitor::IF(src_reg src0, src_reg src1, uint32_t condition) * the flag register with the packed 16 bits of the result. */ vec4_instruction * -vec4_visitor::CMP(dst_reg dst, src_reg src0, src_reg src1, uint32_t condition) +vec4_visitor::CMP(dst_reg dst, src_reg src0, src_reg src1, + enum brw_conditional_mod condition) { vec4_instruction *inst; @@ -1185,7 +1187,7 @@ vec4_visitor::emit_bool_comparison(unsigned int op, } void -vec4_visitor::emit_minmax(uint32_t conditionalmod, dst_reg dst, +vec4_visitor::emit_minmax(enum brw_conditional_mod conditionalmod, dst_reg dst, src_reg src0, src_reg src1) { vec4_instruction *inst; diff --git a/src/mesa/drivers/dri/i965/brw_vec4_vp.cpp b/src/mesa/drivers/dri/i965/brw_vec4_vp.cpp index b62f8097c0a..f9c23cae2bf 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_vp.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_vp.cpp @@ -37,7 +37,7 @@ extern "C" { using namespace brw; void -vec4_visitor::emit_vp_sop(uint32_t conditional_mod, +vec4_visitor::emit_vp_sop(enum brw_conditional_mod conditional_mod, dst_reg dst, src_reg src0, src_reg src1, src_reg one) { diff --git a/src/mesa/drivers/dri/i965/gen8_instruction.c b/src/mesa/drivers/dri/i965/gen8_instruction.c index c9cbab639fe..47955e12722 100644 --- a/src/mesa/drivers/dri/i965/gen8_instruction.c +++ b/src/mesa/drivers/dri/i965/gen8_instruction.c @@ -28,6 +28,7 @@ * and set various fields. This is the actual hardware format. */ +#include "main/compiler.h" #include "brw_defines.h" #include "gen8_instruction.h" -- 2.30.2