i965: Pass pointer and end of assembly to brw_validate_instructions
authorMatt Turner <mattst88@gmail.com>
Sat, 29 Apr 2017 00:05:44 +0000 (17:05 -0700)
committerMatt Turner <mattst88@gmail.com>
Mon, 15 May 2017 18:42:47 +0000 (11:42 -0700)
This will allow us to more easily run brw_validate_instructions() on
shader programs we find in GPU hang error states.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
src/intel/compiler/brw_eu.h
src/intel/compiler/brw_eu_validate.c
src/intel/compiler/brw_fs_generator.cpp
src/intel/compiler/brw_vec4_generator.cpp
src/intel/compiler/test_eu_validate.cpp

index f4225952333e8d8b250e199c4c2542cf5e42d3ea..87c69a479cf7d8e64c2d4f54d85235fd92669ccb 100644 (file)
@@ -548,7 +548,8 @@ void brw_debug_compact_uncompact(const struct gen_device_info *devinfo,
                                  brw_inst *orig, brw_inst *uncompacted);
 
 /* brw_eu_validate.c */
-bool brw_validate_instructions(const struct brw_codegen *p, int start_offset,
+bool brw_validate_instructions(const struct gen_device_info *devinfo,
+                               void *assembly, int start_offset, int end_offset,
                                struct annotation_info *annotation);
 
 static inline int
index a632242e0f8bb629a0df9ae1ff5f31e6a7894add..ba3fe0d85dffb573d18c8d33b4bb947ce971f514 100644 (file)
@@ -1030,17 +1030,16 @@ region_alignment_rules(const struct gen_device_info *devinfo,
 }
 
 bool
-brw_validate_instructions(const struct brw_codegen *p, int start_offset,
+brw_validate_instructions(const struct gen_device_info *devinfo,
+                          void *assembly, int start_offset, int end_offset,
                           struct annotation_info *annotation)
 {
-   const struct gen_device_info *devinfo = p->devinfo;
-   const void *store = p->store;
    bool valid = true;
 
-   for (int src_offset = start_offset; src_offset < p->next_insn_offset;
+   for (int src_offset = start_offset; src_offset < end_offset;
         src_offset += sizeof(brw_inst)) {
       struct string error_msg = { .str = NULL, .len = 0 };
-      const brw_inst *inst = store + src_offset;
+      const brw_inst *inst = assembly + src_offset;
 
       if (is_unsupported_inst(devinfo, inst)) {
          ERROR("Instruction not supported on this Gen");
index a7f95cc76b8c3592b2590bd59f49d1018ba6a706..2ade486705baf77645ef4db281befa79946c54f3 100644 (file)
@@ -2167,10 +2167,16 @@ fs_generator::generate_code(const cfg_t *cfg, int dispatch_width)
    annotation_finalize(&annotation, p->next_insn_offset);
 
 #ifndef NDEBUG
-   bool validated = brw_validate_instructions(p, start_offset, &annotation);
+   bool validated = brw_validate_instructions(devinfo, p->store,
+                                              start_offset,
+                                              p->next_insn_offset,
+                                              &annotation);
 #else
    if (unlikely(debug_flag))
-      brw_validate_instructions(p, start_offset, &annotation);
+      brw_validate_instructions(devinfo, p->store,
+                                start_offset,
+                                p->next_insn_offset,
+                                &annotation);
 #endif
 
    int before_size = p->next_insn_offset - start_offset;
index 8505f6934991128f6275aa2123d896a7d6c8b44c..334933d15a64e4e68980fb723faa77856fef89d2 100644 (file)
@@ -2180,10 +2180,14 @@ generate_code(struct brw_codegen *p,
    annotation_finalize(&annotation, p->next_insn_offset);
 
 #ifndef NDEBUG
-   bool validated = brw_validate_instructions(p, 0, &annotation);
+   bool validated = brw_validate_instructions(devinfo, p->store,
+                                              0, p->next_insn_offset,
+                                              &annotation);
 #else
    if (unlikely(debug_flag))
-      brw_validate_instructions(p, 0, &annotation);
+      brw_validate_instructions(devinfo, p->store,
+                                0, p->next_insn_offset,
+                                &annotation);
 #endif
 
    int before_size = p->next_insn_offset;
index 76652dc43d093684b23419086bdea8154dadf596..ed67c4d4228febb229fc973699dfc1c4f032523d 100644 (file)
@@ -118,7 +118,8 @@ validate(struct brw_codegen *p)
       annotation.ann[annotation.ann_count].offset = p->next_insn_offset;
    }
 
-   bool ret = brw_validate_instructions(p, 0, &annotation);
+   bool ret = brw_validate_instructions(devinfo, p->store, 0,
+                                        p->next_insn_offset, &annotation);
 
    if (print) {
       dump_assembly(p->store, annotation.ann_count, annotation.ann, p->devinfo);