Mesa (master): i965: Create a "brw_last_inst" convenience macro.

Kenneth Graunke kwg at kemper.freedesktop.org
Mon Jun 2 22:09:30 UTC 2014


Module: Mesa
Branch: master
Commit: 42c292006c94b0b84645448af958fdb6235acbfb
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=42c292006c94b0b84645448af958fdb6235acbfb

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Tue May 27 23:27:01 2014 -0700

i965: Create a "brw_last_inst" convenience macro.

Often times, we want to emit an instruction, then set one field on it,
such as predication or a conditional modifier.  Normally, we'd have to
declare "struct brw_instruction *inst;" and then use "inst =
brw_FOO(...)" to emit the instruction, which can hurt readability.

The new "brw_last_inst" macro refers to the most recently emitted
instruction, so you can just do:

    brw_ADD(...)
    brw_last_inst->header.predicate_control = BRW_PREDICATE_NORMAL;

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Matt Turner <mattst88 at gmail.com>

---

 src/mesa/drivers/dri/i965/brw_eu.h |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h
index baa135b..9b36e05 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -46,6 +46,12 @@ extern "C" {
 
 #define BRW_EU_MAX_INSN_STACK 5
 
+/* A helper for accessing the last instruction emitted.  This makes it easy
+ * to set various bits on an instruction without having to create temporary
+ * variable and assign the emitted instruction to those.
+ */
+#define brw_last_inst (&p->store[p->nr_insn - 1])
+
 struct brw_compile {
    struct brw_instruction *store;
    int store_size;




More information about the mesa-commit mailing list