#define BRW_CFG_H
#include "brw_ir.h"
+#ifdef __cplusplus
+#include "brw_ir_analysis.h"
+#endif
struct bblock_t;
enum bblock_link_kind kind) const;
bool can_combine_with(const bblock_t *that) const;
void combine_with(bblock_t *that);
- void dump(backend_shader *s) const;
+ void dump() const;
backend_instruction *start();
const backend_instruction *start() const;
struct exec_node link;
struct cfg_t *cfg;
- struct bblock_t *idom;
int start_ip;
int end_ip;
struct exec_list parents;
struct exec_list children;
int num;
-
- unsigned cycle_count;
};
static inline struct backend_instruction *
#ifdef __cplusplus
DECLARE_RALLOC_CXX_OPERATORS(cfg_t)
- cfg_t(exec_list *instructions);
+ cfg_t(const backend_shader *s, exec_list *instructions);
~cfg_t();
void remove_block(bblock_t *block);
+ bblock_t *first_block();
+ const bblock_t *first_block() const;
+ bblock_t *last_block();
+ const bblock_t *last_block() const;
+
bblock_t *new_block();
void set_next_block(bblock_t **cur, bblock_t *block, int ip);
void make_block_array();
- void calculate_idom();
- static bblock_t *intersect(bblock_t *b1, bblock_t *b2);
- void dump(backend_shader *s);
+ void dump();
void dump_cfg();
- void dump_domtree();
#endif
+ const struct backend_shader *s;
void *mem_ctx;
/** Ordered list (by ip) of basic blocks */
struct exec_list block_list;
struct bblock_t **blocks;
int num_blocks;
+};
- bool idom_dirty;
+static inline struct bblock_t *
+cfg_first_block(struct cfg_t *cfg)
+{
+ return (struct bblock_t *)exec_list_get_head(&cfg->block_list);
+}
- unsigned cycle_count;
-};
+static inline const struct bblock_t *
+cfg_first_block_const(const struct cfg_t *cfg)
+{
+ return (const struct bblock_t *)exec_list_get_head_const(&cfg->block_list);
+}
+
+static inline struct bblock_t *
+cfg_last_block(struct cfg_t *cfg)
+{
+ return (struct bblock_t *)exec_list_get_tail(&cfg->block_list);
+}
+
+static inline const struct bblock_t *
+cfg_last_block_const(const struct cfg_t *cfg)
+{
+ return (const struct bblock_t *)exec_list_get_tail_const(&cfg->block_list);
+}
+
+#ifdef __cplusplus
+inline bblock_t *
+cfg_t::first_block()
+{
+ return cfg_first_block(this);
+}
+
+const inline bblock_t *
+cfg_t::first_block() const
+{
+ return cfg_first_block_const(this);
+}
+
+inline bblock_t *
+cfg_t::last_block()
+{
+ return cfg_last_block(this);
+}
+
+const inline bblock_t *
+cfg_t::last_block() const
+{
+ return cfg_last_block_const(this);
+}
+#endif
/* Note that this is implemented with a double for loop -- break will
* break from the inner loop only!
!__scan_inst->is_head_sentinel(); \
__scan_inst = (__type *)__scan_inst->prev)
+#ifdef __cplusplus
+namespace brw {
+ /**
+ * Immediate dominator tree analysis of a shader.
+ */
+ struct idom_tree {
+ idom_tree(const backend_shader *s);
+ ~idom_tree();
+
+ bool
+ validate(const backend_shader *) const
+ {
+ /* FINISHME */
+ return true;
+ }
+
+ analysis_dependency_class
+ dependency_class() const
+ {
+ return DEPENDENCY_BLOCKS;
+ }
+
+ const bblock_t *
+ parent(const bblock_t *b) const
+ {
+ assert(unsigned(b->num) < num_parents);
+ return parents[b->num];
+ }
+
+ bblock_t *
+ parent(bblock_t *b) const
+ {
+ assert(unsigned(b->num) < num_parents);
+ return parents[b->num];
+ }
+
+ bblock_t *
+ intersect(bblock_t *b1, bblock_t *b2) const;
+
+ void
+ dump() const;
+
+ private:
+ unsigned num_parents;
+ bblock_t **parents;
+ };
+}
+#endif
+
#endif /* BRW_CFG_H */