<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 26, 2016 at 8:46 PM, Francisco Jerez <span dir="ltr"><<a href="mailto:currojerez@riseup.net" target="_blank">currojerez@riseup.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">---<br>
src/mesa/drivers/dri/i965/brw_fs.cpp | 54 +++++++++++++++++++++++++++++------<br>
src/mesa/drivers/dri/i965/brw_ir_fs.h | 25 ++++++++++++++--<br>
2 files changed, 68 insertions(+), 11 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
index 32fa816..c95da29 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
@@ -907,19 +907,55 @@ fs_inst::regs_read(int arg) const<br>
return 0;<br>
}<br>
<br>
-bool<br>
-fs_inst::reads_flag() const<br>
+namespace {<br>
+ /* Return the subset of flag registers that an instruction could<br>
+ * potentially read or write based on the execution controls and flag<br>
+ * subregister number of the instruction.<br>
+ */<br>
+ uint32_t<br>
+ flag_mask(const fs_inst *inst)<br>
+ {<br>
+ const unsigned start = inst->flag_subreg * 16 + inst->group;<br>
+ const unsigned end = start + inst->exec_size;<br>
+ return ((1 << DIV_ROUND_UP(end, 8)) - 1) & ~((1 << (start / 8)) - 1);<br>
+ }<br>
+}<br>
+<br>
+uint32_t<br></blockquote><div><br></div><div>Should these return a uint8_t or maybe just unsigned instead? Explicitly returning a uint32_t makes it look like it's the 32 possible 1-bit flag values where, in reality, it's the 4 possible flag subregisters.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+fs_inst::flags_read(const brw_device_info *devinfo) const<br>
{<br>
- return predicate;<br>
+ /* XXX - This doesn't consider explicit uses of the flag register as source<br>
+ * region.<br>
+ */<br>
+ if (predicate == BRW_PREDICATE_ALIGN1_ANYV ||<br>
+ predicate == BRW_PREDICATE_ALIGN1_ALLV) {<br>
+ /* The vertical predication modes combine corresponding bits from<br>
+ * f0.0 and f1.0 on Gen7+, and f0.0 and f0.1 on older hardware.<br>
+ */<br>
+ const unsigned shift = devinfo->gen >= 7 ? 4 : 2;<br>
+ return flag_mask(this) << shift | flag_mask(this);<br>
+<br>
+ } else if (predicate) {<br>
+ return flag_mask(this);<br>
+<br></blockquote><div><br></div><div>Do we need this blank line or the one above? I'd delete them personally.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ } else {<br>
+ return 0;<br>
+ }<br>
}<br>
<br>
-bool<br>
-fs_inst::writes_flag() const<br>
+uint32_t<br>
+fs_inst::flags_written() const<br>
{<br>
- return (conditional_mod && (opcode != BRW_OPCODE_SEL &&<br>
- opcode != BRW_OPCODE_IF &&<br>
- opcode != BRW_OPCODE_WHILE)) ||<br>
- opcode == FS_OPCODE_MOV_DISPATCH_TO_FLAGS;<br>
+ /* XXX - This doesn't consider explicit uses of the flag register as<br>
+ * destination region.<br>
+ */<br>
+ if ((conditional_mod && (opcode != BRW_OPCODE_SEL &&<br>
+ opcode != BRW_OPCODE_IF &&<br>
+ opcode != BRW_OPCODE_WHILE)) ||<br>
+ opcode == FS_OPCODE_MOV_DISPATCH_TO_FLAGS)<br>
+ return flag_mask(this);<br>
+ else<br>
+ return 0;<br></blockquote><div><br></div><div>It would be nice if this if had braces. I know it's just a one-liner when it comes to the body of the if/else but the condition is complex enough it's kind of hard to see where the condition ends and the body begins.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
}<br>
<br>
/**<br>
diff --git a/src/mesa/drivers/dri/i965/brw_ir_fs.h b/src/mesa/drivers/dri/i965/brw_ir_fs.h<br>
index d7ca406..1bac3bb 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_ir_fs.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_ir_fs.h<br>
@@ -274,8 +274,29 @@ public:<br>
bool has_side_effects() const;<br>
bool has_source_and_destination_hazard() const;<br>
<br>
- bool reads_flag() const;<br>
- bool writes_flag() const;<br>
+ /**<br>
+ * Return the subset of flag registers read by the instruction as a bitset<br>
+ * with byte granularity.<br>
+ */<br>
+ uint32_t flags_read(const brw_device_info *devinfo) const;<br>
+<br>
+ /**<br>
+ * Return the subset of flag registers updated by the instruction (either<br>
+ * partially or fully) as a bitset with byte granularity.<br>
+ */<br>
+ uint32_t flags_written() const;<br>
+<br>
+ bool reads_flag() const<br>
+ {<br>
+ /* XXX - Will get rid of this hack shortly. */<br>
+ const brw_device_info devinfo = {};<br>
+ return flags_read(&devinfo);<br>
+ }<br>
+<br>
+ bool writes_flag() const<br>
+ {<br>
+ return flags_written();<br>
+ }<br>
<br>
fs_reg dst;<br>
fs_reg *src;<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.7.3<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>