summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2018-03-05 10:20:32 -0700
committerBrian Paul <[email protected]>2018-03-23 09:03:26 -0600
commitec478cf9c31c3775a21cd7b5b4b5cdd9263bde9e (patch)
tree955a1cce7d0d622e5d615291e218df0395981b8a /src
parentccecb2bbd3aa080657e62fec6e2561d785e05e79 (diff)
st/mesa,tgsi: use enum tgsi_opcode
Need to update the tgsi code and st_glsl_to_tgsi code at the same time to prevent compile break since C++ is much pickier about implicit enum/unsigned casting. Bump size of glsl_to_tgsi_instruction::op to 10 bits to be sure to avoid MSVC signed enum overflow issue. No change in class size. Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_info.c10
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_info.h10
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.c10
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.h28
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp55
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi_private.h2
6 files changed, 58 insertions, 57 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c
index a2046822a5c..4aa658785cf 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_info.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_info.c
@@ -51,7 +51,7 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] =
#undef OPCODE_GAP
const struct tgsi_opcode_info *
-tgsi_get_opcode_info( uint opcode )
+tgsi_get_opcode_info(enum tgsi_opcode opcode)
{
static boolean firsttime = 1;
@@ -85,7 +85,7 @@ static const char * const opcode_names[TGSI_OPCODE_LAST] =
#undef OPCODE_GAP
const char *
-tgsi_get_opcode_name( uint opcode )
+tgsi_get_opcode_name(enum tgsi_opcode opcode)
{
if (opcode >= ARRAY_SIZE(opcode_names))
return "UNK_OOB";
@@ -120,7 +120,7 @@ tgsi_get_processor_name(enum pipe_shader_type processor)
* MOV and UCMP is special so return VOID
*/
static inline enum tgsi_opcode_type
-tgsi_opcode_infer_type( uint opcode )
+tgsi_opcode_infer_type(enum tgsi_opcode opcode)
{
switch (opcode) {
case TGSI_OPCODE_MOV:
@@ -246,7 +246,7 @@ tgsi_opcode_infer_type( uint opcode )
* infer the source type of a TGSI opcode.
*/
enum tgsi_opcode_type
-tgsi_opcode_infer_src_type(uint opcode, uint src_idx)
+tgsi_opcode_infer_src_type(enum tgsi_opcode opcode, uint src_idx)
{
if (src_idx == 1 &&
(opcode == TGSI_OPCODE_DLDEXP || opcode == TGSI_OPCODE_LDEXP))
@@ -317,7 +317,7 @@ tgsi_opcode_infer_src_type(uint opcode, uint src_idx)
* infer the destination type of a TGSI opcode.
*/
enum tgsi_opcode_type
-tgsi_opcode_infer_dst_type( uint opcode, uint dst_idx )
+tgsi_opcode_infer_dst_type(enum tgsi_opcode opcode, uint dst_idx)
{
if (dst_idx == 1 && opcode == TGSI_OPCODE_DFRACEXP)
return TGSI_TYPE_SIGNED;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.h b/src/gallium/auxiliary/tgsi/tgsi_info.h
index 2c97bb62dee..f0bf27ea08b 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_info.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_info.h
@@ -79,14 +79,14 @@ struct tgsi_opcode_info
unsigned pre_dedent:1;
unsigned post_indent:1;
enum tgsi_output_mode output_mode:4;
- unsigned opcode:8;
+ enum tgsi_opcode opcode:10;
};
const struct tgsi_opcode_info *
-tgsi_get_opcode_info( uint opcode );
+tgsi_get_opcode_info(enum tgsi_opcode opcode);
const char *
-tgsi_get_opcode_name( uint opcode );
+tgsi_get_opcode_name(enum tgsi_opcode opcode);
const char *
tgsi_get_processor_name(enum pipe_shader_type processor);
@@ -111,10 +111,10 @@ static inline bool tgsi_type_is_64bit(enum tgsi_opcode_type type)
}
enum tgsi_opcode_type
-tgsi_opcode_infer_src_type( uint opcode, uint src_idx );
+tgsi_opcode_infer_src_type(enum tgsi_opcode opcode, uint src_idx);
enum tgsi_opcode_type
-tgsi_opcode_infer_dst_type( uint opcode, uint dst_idx );
+tgsi_opcode_infer_dst_type(enum tgsi_opcode opcode, uint dst_idx);
#if defined __cplusplus
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 41281dabc40..393e0150017 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -1234,7 +1234,7 @@ ureg_emit_dst( struct ureg_program *ureg,
}
-static void validate( unsigned opcode,
+static void validate( enum tgsi_opcode opcode,
unsigned nr_dst,
unsigned nr_src )
{
@@ -1250,7 +1250,7 @@ static void validate( unsigned opcode,
struct ureg_emit_insn_result
ureg_emit_insn(struct ureg_program *ureg,
- unsigned opcode,
+ enum tgsi_opcode opcode,
boolean saturate,
unsigned precise,
unsigned num_dst,
@@ -1392,7 +1392,7 @@ ureg_fixup_insn_size(struct ureg_program *ureg,
void
ureg_insn(struct ureg_program *ureg,
- unsigned opcode,
+ enum tgsi_opcode opcode,
const struct ureg_dst *dst,
unsigned nr_dst,
const struct ureg_src *src,
@@ -1427,7 +1427,7 @@ ureg_insn(struct ureg_program *ureg,
void
ureg_tex_insn(struct ureg_program *ureg,
- unsigned opcode,
+ enum tgsi_opcode opcode,
const struct ureg_dst *dst,
unsigned nr_dst,
enum tgsi_texture_type target,
@@ -1472,7 +1472,7 @@ ureg_tex_insn(struct ureg_program *ureg,
void
ureg_memory_insn(struct ureg_program *ureg,
- unsigned opcode,
+ enum tgsi_opcode opcode,
const struct ureg_dst *dst,
unsigned nr_dst,
const struct ureg_src *src,
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index e8ebae94357..7eef94a65e9 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -550,7 +550,7 @@ ureg_fixup_label(struct ureg_program *ureg,
*/
void
ureg_insn(struct ureg_program *ureg,
- unsigned opcode,
+ enum tgsi_opcode opcode,
const struct ureg_dst *dst,
unsigned nr_dst,
const struct ureg_src *src,
@@ -560,7 +560,7 @@ ureg_insn(struct ureg_program *ureg,
void
ureg_tex_insn(struct ureg_program *ureg,
- unsigned opcode,
+ enum tgsi_opcode opcode,
const struct ureg_dst *dst,
unsigned nr_dst,
enum tgsi_texture_type target,
@@ -573,7 +573,7 @@ ureg_tex_insn(struct ureg_program *ureg,
void
ureg_memory_insn(struct ureg_program *ureg,
- unsigned opcode,
+ enum tgsi_opcode opcode,
const struct ureg_dst *dst,
unsigned nr_dst,
const struct ureg_src *src,
@@ -593,7 +593,7 @@ struct ureg_emit_insn_result {
struct ureg_emit_insn_result
ureg_emit_insn(struct ureg_program *ureg,
- unsigned opcode,
+ enum tgsi_opcode opcode,
boolean saturate,
unsigned precise,
unsigned num_dst,
@@ -638,7 +638,7 @@ ureg_fixup_insn_size(struct ureg_program *ureg,
#define OP00( op ) \
static inline void ureg_##op( struct ureg_program *ureg ) \
{ \
- unsigned opcode = TGSI_OPCODE_##op; \
+ enum tgsi_opcode opcode = TGSI_OPCODE_##op; \
struct ureg_emit_insn_result insn; \
insn = ureg_emit_insn(ureg, \
opcode, \
@@ -653,7 +653,7 @@ static inline void ureg_##op( struct ureg_program *ureg ) \
static inline void ureg_##op( struct ureg_program *ureg, \
struct ureg_src src ) \
{ \
- unsigned opcode = TGSI_OPCODE_##op; \
+ enum tgsi_opcode opcode = TGSI_OPCODE_##op; \
struct ureg_emit_insn_result insn; \
insn = ureg_emit_insn(ureg, \
opcode, \
@@ -669,7 +669,7 @@ static inline void ureg_##op( struct ureg_program *ureg, \
static inline void ureg_##op( struct ureg_program *ureg, \
unsigned *label_token ) \
{ \
- unsigned opcode = TGSI_OPCODE_##op; \
+ enum tgsi_opcode opcode = TGSI_OPCODE_##op; \
struct ureg_emit_insn_result insn; \
insn = ureg_emit_insn(ureg, \
opcode, \
@@ -686,7 +686,7 @@ static inline void ureg_##op( struct ureg_program *ureg, \
struct ureg_src src, \
unsigned *label_token ) \
{ \
- unsigned opcode = TGSI_OPCODE_##op; \
+ enum tgsi_opcode opcode = TGSI_OPCODE_##op; \
struct ureg_emit_insn_result insn; \
insn = ureg_emit_insn(ureg, \
opcode, \
@@ -703,7 +703,7 @@ static inline void ureg_##op( struct ureg_program *ureg, \
static inline void ureg_##op( struct ureg_program *ureg, \
struct ureg_dst dst ) \
{ \
- unsigned opcode = TGSI_OPCODE_##op; \
+ enum tgsi_opcode opcode = TGSI_OPCODE_##op; \
struct ureg_emit_insn_result insn; \
if (ureg_dst_is_empty(dst)) \
return; \
@@ -723,7 +723,7 @@ static inline void ureg_##op( struct ureg_program *ureg, \
struct ureg_dst dst, \
struct ureg_src src ) \
{ \
- unsigned opcode = TGSI_OPCODE_##op; \
+ enum tgsi_opcode opcode = TGSI_OPCODE_##op; \
struct ureg_emit_insn_result insn; \
if (ureg_dst_is_empty(dst)) \
return; \
@@ -744,7 +744,7 @@ static inline void ureg_##op( struct ureg_program *ureg, \
struct ureg_src src0, \
struct ureg_src src1 ) \
{ \
- unsigned opcode = TGSI_OPCODE_##op; \
+ enum tgsi_opcode opcode = TGSI_OPCODE_##op; \
struct ureg_emit_insn_result insn; \
if (ureg_dst_is_empty(dst)) \
return; \
@@ -767,7 +767,7 @@ static inline void ureg_##op( struct ureg_program *ureg, \
struct ureg_src src0, \
struct ureg_src src1 ) \
{ \
- unsigned opcode = TGSI_OPCODE_##op; \
+ enum tgsi_opcode opcode = TGSI_OPCODE_##op; \
enum tgsi_return_type return_type = TGSI_RETURN_TYPE_UNKNOWN; \
struct ureg_emit_insn_result insn; \
if (ureg_dst_is_empty(dst)) \
@@ -793,7 +793,7 @@ static inline void ureg_##op( struct ureg_program *ureg, \
struct ureg_src src1, \
struct ureg_src src2 ) \
{ \
- unsigned opcode = TGSI_OPCODE_##op; \
+ enum tgsi_opcode opcode = TGSI_OPCODE_##op; \
struct ureg_emit_insn_result insn; \
if (ureg_dst_is_empty(dst)) \
return; \
@@ -819,7 +819,7 @@ static inline void ureg_##op( struct ureg_program *ureg, \
struct ureg_src src2, \
struct ureg_src src3 ) \
{ \
- unsigned opcode = TGSI_OPCODE_##op; \
+ enum tgsi_opcode opcode = TGSI_OPCODE_##op; \
enum tgsi_return_type return_type = TGSI_RETURN_TYPE_UNKNOWN; \
struct ureg_emit_insn_result insn; \
if (ureg_dst_is_empty(dst)) \
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index f0f68ac02c6..fc53811be40 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -255,7 +255,7 @@ public:
void visit_membar_intrinsic(ir_call *);
void visit_shared_intrinsic(ir_call *);
void visit_image_intrinsic(ir_call *);
- void visit_generic_intrinsic(ir_call *, unsigned op);
+ void visit_generic_intrinsic(ir_call *, enum tgsi_opcode op);
st_src_reg result;
@@ -269,23 +269,23 @@ public:
/** List of glsl_to_tgsi_instruction */
exec_list instructions;
- glsl_to_tgsi_instruction *emit_asm(ir_instruction *ir, unsigned op,
+ glsl_to_tgsi_instruction *emit_asm(ir_instruction *ir, enum tgsi_opcode op,
st_dst_reg dst = undef_dst,
st_src_reg src0 = undef_src,
st_src_reg src1 = undef_src,
st_src_reg src2 = undef_src,
st_src_reg src3 = undef_src);
- glsl_to_tgsi_instruction *emit_asm(ir_instruction *ir, unsigned op,
+ glsl_to_tgsi_instruction *emit_asm(ir_instruction *ir, enum tgsi_opcode op,
st_dst_reg dst, st_dst_reg dst1,
st_src_reg src0 = undef_src,
st_src_reg src1 = undef_src,
st_src_reg src2 = undef_src,
st_src_reg src3 = undef_src);
- unsigned get_opcode(unsigned op,
- st_dst_reg dst,
- st_src_reg src0, st_src_reg src1);
+ enum tgsi_opcode get_opcode(enum tgsi_opcode op,
+ st_dst_reg dst,
+ st_src_reg src0, st_src_reg src1);
/**
* Emit the correct dot-product instruction for the type of arguments
@@ -296,10 +296,10 @@ public:
st_src_reg src1,
unsigned elements);
- void emit_scalar(ir_instruction *ir, unsigned op,
+ void emit_scalar(ir_instruction *ir, enum tgsi_opcode op,
st_dst_reg dst, st_src_reg src0);
- void emit_scalar(ir_instruction *ir, unsigned op,
+ void emit_scalar(ir_instruction *ir, enum tgsi_opcode op,
st_dst_reg dst, st_src_reg src0, st_src_reg src1);
void emit_arl(ir_instruction *ir, st_dst_reg dst, st_src_reg src0);
@@ -386,7 +386,7 @@ swizzle_for_size(int size)
glsl_to_tgsi_instruction *
-glsl_to_tgsi_visitor::emit_asm(ir_instruction *ir, unsigned op,
+glsl_to_tgsi_visitor::emit_asm(ir_instruction *ir, enum tgsi_opcode op,
st_dst_reg dst, st_dst_reg dst1,
st_src_reg src0, st_src_reg src1,
st_src_reg src2, st_src_reg src3)
@@ -627,7 +627,7 @@ glsl_to_tgsi_visitor::emit_asm(ir_instruction *ir, unsigned op,
}
glsl_to_tgsi_instruction *
-glsl_to_tgsi_visitor::emit_asm(ir_instruction *ir, unsigned op,
+glsl_to_tgsi_visitor::emit_asm(ir_instruction *ir, enum tgsi_opcode op,
st_dst_reg dst,
st_src_reg src0, st_src_reg src1,
st_src_reg src2, st_src_reg src3)
@@ -639,8 +639,8 @@ glsl_to_tgsi_visitor::emit_asm(ir_instruction *ir, unsigned op,
* Determines whether to use an integer, unsigned integer, or float opcode
* based on the operands and input opcode, then emits the result.
*/
-unsigned
-glsl_to_tgsi_visitor::get_opcode(unsigned op,
+enum tgsi_opcode
+glsl_to_tgsi_visitor::get_opcode(enum tgsi_opcode op,
st_dst_reg dst,
st_src_reg src0, st_src_reg src1)
{
@@ -751,7 +751,7 @@ glsl_to_tgsi_visitor::emit_dp(ir_instruction *ir,
st_dst_reg dst, st_src_reg src0, st_src_reg src1,
unsigned elements)
{
- static const unsigned dot_opcodes[] = {
+ static const enum tgsi_opcode dot_opcodes[] = {
TGSI_OPCODE_DP2, TGSI_OPCODE_DP3, TGSI_OPCODE_DP4
};
@@ -767,7 +767,7 @@ glsl_to_tgsi_visitor::emit_dp(ir_instruction *ir,
* to produce dest channels.
*/
void
-glsl_to_tgsi_visitor::emit_scalar(ir_instruction *ir, unsigned op,
+glsl_to_tgsi_visitor::emit_scalar(ir_instruction *ir, enum tgsi_opcode op,
st_dst_reg dst,
st_src_reg orig_src0, st_src_reg orig_src1)
{
@@ -811,7 +811,7 @@ glsl_to_tgsi_visitor::emit_scalar(ir_instruction *ir, unsigned op,
}
void
-glsl_to_tgsi_visitor::emit_scalar(ir_instruction *ir, unsigned op,
+glsl_to_tgsi_visitor::emit_scalar(ir_instruction *ir, enum tgsi_opcode op,
st_dst_reg dst, st_src_reg src0)
{
st_src_reg undef = undef_src;
@@ -825,7 +825,7 @@ void
glsl_to_tgsi_visitor::emit_arl(ir_instruction *ir,
st_dst_reg dst, st_src_reg src0)
{
- int op = TGSI_OPCODE_ARL;
+ enum tgsi_opcode op = TGSI_OPCODE_ARL;
if (src0.type == GLSL_TYPE_INT || src0.type == GLSL_TYPE_UINT) {
if (!this->need_uarl && src0.is_legal_tgsi_address_operand())
@@ -983,7 +983,7 @@ add_buffer_to_load_and_stores(glsl_to_tgsi_instruction *inst, st_src_reg *buf,
* emit_asm() might have actually split the op into pieces, e.g. for
* double stores. We have to go back and fix up all the generated ops.
*/
- unsigned op = inst->op;
+ enum tgsi_opcode op = inst->op;
do {
inst->resource = *buf;
if (access)
@@ -1909,8 +1909,8 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op)
case ir_binop_lshift:
case ir_binop_rshift:
if (native_integers) {
- unsigned opcode = ir->operation == ir_binop_lshift ? TGSI_OPCODE_SHL
- : TGSI_OPCODE_ISHR;
+ enum tgsi_opcode opcode = ir->operation == ir_binop_lshift
+ ? TGSI_OPCODE_SHL : TGSI_OPCODE_ISHR;
st_src_reg count;
if (glsl_base_type_is_64bit(op[0].type)) {
@@ -3377,7 +3377,7 @@ glsl_to_tgsi_visitor::visit_atomic_counter_intrinsic(ir_call *ir)
val->accept(this);
st_src_reg data = this->result, data2 = undef_src;
- unsigned opcode;
+ enum tgsi_opcode opcode;
switch (ir->callee->intrinsic_id) {
case ir_intrinsic_atomic_counter_add:
opcode = TGSI_OPCODE_ATOMUADD;
@@ -3480,7 +3480,7 @@ glsl_to_tgsi_visitor::visit_ssbo_intrinsic(ir_call *ir)
val->accept(this);
st_src_reg data = this->result, data2 = undef_src;
- unsigned opcode;
+ enum tgsi_opcode opcode;
switch (ir->callee->intrinsic_id) {
case ir_intrinsic_ssbo_atomic_add:
opcode = TGSI_OPCODE_ATOMUADD;
@@ -3612,7 +3612,7 @@ glsl_to_tgsi_visitor::visit_shared_intrinsic(ir_call *ir)
val->accept(this);
st_src_reg data = this->result, data2 = undef_src;
- unsigned opcode;
+ enum tgsi_opcode opcode;
switch (ir->callee->intrinsic_id) {
case ir_intrinsic_shared_atomic_add:
opcode = TGSI_OPCODE_ATOMUADD;
@@ -3797,7 +3797,7 @@ glsl_to_tgsi_visitor::visit_image_intrinsic(ir_call *ir)
assert(param->is_tail_sentinel());
- unsigned opcode;
+ enum tgsi_opcode opcode;
switch (ir->callee->intrinsic_id) {
case ir_intrinsic_image_load:
opcode = TGSI_OPCODE_LOAD;
@@ -3862,7 +3862,7 @@ glsl_to_tgsi_visitor::visit_image_intrinsic(ir_call *ir)
}
void
-glsl_to_tgsi_visitor::visit_generic_intrinsic(ir_call *ir, unsigned op)
+glsl_to_tgsi_visitor::visit_generic_intrinsic(ir_call *ir, enum tgsi_opcode op)
{
ir->return_deref->accept(this);
st_dst_reg dst = st_dst_reg(this->result);
@@ -4115,7 +4115,7 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
st_src_reg levels_src, reladdr;
st_dst_reg result_dst, coord_dst, cube_sc_dst;
glsl_to_tgsi_instruction *inst = NULL;
- unsigned opcode = TGSI_OPCODE_NOP;
+ enum tgsi_opcode opcode = TGSI_OPCODE_NOP;
const glsl_type *sampler_type = ir->sampler->type;
unsigned sampler_array_size = 1, sampler_base = 0;
bool is_cube_array = false, is_cube_shadow = false;
@@ -4458,7 +4458,7 @@ glsl_to_tgsi_visitor::visit(ir_discard *ir)
void
glsl_to_tgsi_visitor::visit(ir_if *ir)
{
- unsigned if_opcode;
+ enum tgsi_opcode if_opcode;
glsl_to_tgsi_instruction *if_inst;
ir->condition->accept(this);
@@ -6323,7 +6323,8 @@ st_translate_program(
(gl_texture_index) (NUM_TEXTURE_TARGETS - 1));
ASSERT_BITFIELD_SIZE(glsl_to_tgsi_instruction, image_format,
(enum pipe_format) (PIPE_FORMAT_COUNT - 1));
- ASSERT_BITFIELD_SIZE(glsl_to_tgsi_instruction, op, TGSI_OPCODE_LAST - 1);
+ ASSERT_BITFIELD_SIZE(glsl_to_tgsi_instruction, op,
+ (enum tgsi_opcode) (TGSI_OPCODE_LAST - 1));
t = CALLOC_STRUCT(st_translate);
if (!t) {
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_private.h b/src/mesa/state_tracker/st_glsl_to_tgsi_private.h
index 832ea00e274..19dde16ed91 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi_private.h
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_private.h
@@ -131,7 +131,7 @@ public:
/** Pointer to the ir source this tree came fe02549fdrom for debugging */
ir_instruction *ir;
- unsigned op:8; /**< TGSI opcode */
+ enum tgsi_opcode op:10; /**< TGSI opcode */
unsigned precise:1;
unsigned saturate:1;
unsigned is_64bit_expanded:1;