[19/23] intel/eu: Fix up various type conversions in brw_eu.c that are illegal C++.

Submitted by Francisco Jerez on June 12, 2018, 2:26 a.m.

Details

Message ID 20180612022615.3653-20-currojerez@riseup.net
State New
Headers show
Series "intel/eu: Define SET_BITS helper more easily reusable than SET_FIELD." ( rev: 6 5 4 3 2 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Francisco Jerez June 12, 2018, 2:26 a.m.
---
 src/intel/compiler/brw_eu.c               | 12 ++++++------
 src/intel/compiler/brw_eu.h               |  6 +++---
 src/intel/compiler/brw_vec4_generator.cpp |  2 +-
 src/intel/compiler/test_eu_compact.cpp    |  4 ++--
 4 files changed, 12 insertions(+), 12 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/intel/compiler/brw_eu.c b/src/intel/compiler/brw_eu.c
index 6ef0a6a577c..80f05240b42 100644
--- a/src/intel/compiler/brw_eu.c
+++ b/src/intel/compiler/brw_eu.c
@@ -39,7 +39,7 @@ 
 
 /* Returns a conditional modifier that negates the condition. */
 enum brw_conditional_mod
-brw_negate_cmod(uint32_t cmod)
+brw_negate_cmod(enum brw_conditional_mod cmod)
 {
    switch (cmod) {
    case BRW_CONDITIONAL_Z:
@@ -55,7 +55,7 @@  brw_negate_cmod(uint32_t cmod)
    case BRW_CONDITIONAL_LE:
       return BRW_CONDITIONAL_G;
    default:
-      return ~0;
+      unreachable("Can't negate this cmod");
    }
 }
 
@@ -63,7 +63,7 @@  brw_negate_cmod(uint32_t cmod)
  * src1 in e.g. CMP.
  */
 enum brw_conditional_mod
-brw_swap_cmod(uint32_t cmod)
+brw_swap_cmod(enum brw_conditional_mod cmod)
 {
    switch (cmod) {
    case BRW_CONDITIONAL_Z:
@@ -150,7 +150,7 @@  brw_set_default_exec_size(struct brw_codegen *p, unsigned value)
    p->current->exec_size = value;
 }
 
-void brw_set_default_predicate_control( struct brw_codegen *p, unsigned pc )
+void brw_set_default_predicate_control(struct brw_codegen *p, enum brw_predicate pc)
 {
    p->current->predicate = pc;
 }
@@ -356,14 +356,14 @@  brw_disassemble(const struct gen_device_info *devinfo,
    bool dump_hex = (INTEL_DEBUG & DEBUG_HEX) != 0;
 
    for (int offset = start; offset < end;) {
-      const brw_inst *insn = assembly + offset;
+      const brw_inst *insn = (const brw_inst *)((char *)assembly + offset);
       brw_inst uncompacted;
       bool compacted = brw_inst_cmpt_control(devinfo, insn);
       if (0)
          fprintf(out, "0x%08x: ", offset);
 
       if (compacted) {
-         brw_compact_inst *compacted = (void *)insn;
+         brw_compact_inst *compacted = (brw_compact_inst *)insn;
 	 if (dump_hex) {
 	    fprintf(out, "0x%08x 0x%08x                       ",
 		    ((uint32_t *)insn)[1],
diff --git a/src/intel/compiler/brw_eu.h b/src/intel/compiler/brw_eu.h
index 7ffd3c30665..0fc32ef0750 100644
--- a/src/intel/compiler/brw_eu.h
+++ b/src/intel/compiler/brw_eu.h
@@ -150,7 +150,7 @@  void brw_inst_set_group(const struct gen_device_info *devinfo,
                         brw_inst *inst, unsigned group);
 void brw_set_default_group(struct brw_codegen *p, unsigned group);
 void brw_set_default_compression_control(struct brw_codegen *p, enum brw_compression c);
-void brw_set_default_predicate_control( struct brw_codegen *p, unsigned pc );
+void brw_set_default_predicate_control(struct brw_codegen *p, enum brw_predicate pc);
 void brw_set_default_predicate_inverse(struct brw_codegen *p, bool predicate_inverse);
 void brw_set_default_flag_reg(struct brw_codegen *p, int reg, int subreg);
 void brw_set_default_acc_write_control(struct brw_codegen *p, unsigned value);
@@ -686,8 +686,8 @@  brw_set_desc(struct brw_codegen *p, brw_inst *insn, unsigned desc)
 
 void brw_set_uip_jip(struct brw_codegen *p, int start_offset);
 
-enum brw_conditional_mod brw_negate_cmod(uint32_t cmod);
-enum brw_conditional_mod brw_swap_cmod(uint32_t cmod);
+enum brw_conditional_mod brw_negate_cmod(enum brw_conditional_mod cmod);
+enum brw_conditional_mod brw_swap_cmod(enum brw_conditional_mod cmod);
 
 /* brw_eu_compact.c */
 void brw_init_compaction_tables(const struct gen_device_info *devinfo);
diff --git a/src/intel/compiler/brw_vec4_generator.cpp b/src/intel/compiler/brw_vec4_generator.cpp
index d506b675776..8e08391fd5f 100644
--- a/src/intel/compiler/brw_vec4_generator.cpp
+++ b/src/intel/compiler/brw_vec4_generator.cpp
@@ -1192,7 +1192,7 @@  generate_scratch_write(struct brw_codegen *p,
    /* If the instruction is predicated, we'll predicate the send, not
     * the header setup.
     */
-   brw_set_default_predicate_control(p, false);
+   brw_set_default_predicate_control(p, BRW_PREDICATE_NONE);
 
    gen6_resolve_implied_move(p, &header, inst->base_mrf);
 
diff --git a/src/intel/compiler/test_eu_compact.cpp b/src/intel/compiler/test_eu_compact.cpp
index f6924abd368..702762c194a 100644
--- a/src/intel/compiler/test_eu_compact.cpp
+++ b/src/intel/compiler/test_eu_compact.cpp
@@ -243,7 +243,7 @@  gen_f0_0_MOV_GRF_GRF(struct brw_codegen *p)
    struct brw_reg g2 = brw_vec8_grf(2, 0);
 
    brw_push_insn_state(p);
-   brw_set_default_predicate_control(p, true);
+   brw_set_default_predicate_control(p, BRW_PREDICATE_NORMAL);
    brw_MOV(p, g0, g2);
    brw_pop_insn_state(p);
 }
@@ -259,7 +259,7 @@  gen_f0_1_MOV_GRF_GRF(struct brw_codegen *p)
    struct brw_reg g2 = brw_vec8_grf(2, 0);
 
    brw_push_insn_state(p);
-   brw_set_default_predicate_control(p, true);
+   brw_set_default_predicate_control(p, BRW_PREDICATE_NORMAL);
    brw_inst *mov = brw_MOV(p, g0, g2);
    brw_inst_set_flag_subreg_nr(p->devinfo, mov, 1);
    brw_pop_insn_state(p);

Comments

On Monday, June 11, 2018 7:26:11 PM PDT Francisco Jerez wrote:
> diff --git a/src/intel/compiler/brw_eu.c b/src/intel/compiler/brw_eu.c
> index 6ef0a6a577c..80f05240b42 100644
> --- a/src/intel/compiler/brw_eu.c
> +++ b/src/intel/compiler/brw_eu.c
> @@ -356,14 +356,14 @@ brw_disassemble(const struct gen_device_info *devinfo,
>     bool dump_hex = (INTEL_DEBUG & DEBUG_HEX) != 0;
>  
>     for (int offset = start; offset < end;) {
> -      const brw_inst *insn = assembly + offset;
> +      const brw_inst *insn = (const brw_inst *)((char *)assembly + offset);

This isn't standard C either, but void * math is a pretty common
compiler extension that's been around forever.  Personally, I'd
prefer that we keep using it, as it's much more readable.
Kenneth Graunke <kenneth@whitecape.org> writes:

> On Monday, June 11, 2018 7:26:11 PM PDT Francisco Jerez wrote:
>> diff --git a/src/intel/compiler/brw_eu.c b/src/intel/compiler/brw_eu.c
>> index 6ef0a6a577c..80f05240b42 100644
>> --- a/src/intel/compiler/brw_eu.c
>> +++ b/src/intel/compiler/brw_eu.c
>> @@ -356,14 +356,14 @@ brw_disassemble(const struct gen_device_info *devinfo,
>>     bool dump_hex = (INTEL_DEBUG & DEBUG_HEX) != 0;
>>  
>>     for (int offset = start; offset < end;) {
>> -      const brw_inst *insn = assembly + offset;
>> +      const brw_inst *insn = (const brw_inst *)((char *)assembly + offset);
>
> This isn't standard C either, but void * math is a pretty common
> compiler extension that's been around forever.  Personally, I'd
> prefer that we keep using it, as it's much more readable.

*Shrug*, using void pointer arithmetic here will cause GCC to emit a
warning "pointer of type ‘void *’ used in arithmetic".