diff options
author | Eric Anholt <eric@anholt.net> | 2010-04-16 16:43:47 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2010-04-19 15:33:52 -0700 |
commit | 7d21104a8b92c139051e9a224c5d863802a8ade6 (patch) | |
tree | 9fbd9d256c6bd64063439c0adfbd95ec5561a64d /ir.h | |
parent | 71df19f5ef6e78beb5160801f81468184b75447e (diff) |
Remove dead code assignments and variable declarations.
This pass only works on assignments where the variable is never
referenced. There is no code flow analysis, so it can't do a better
job of avoiding redundant assignments.
For now, the optimizer only does do_dead_code_unlinked(), so it won't
trim the builtin variable list or initializers outside of the scope of
functions. This is because we don't have the visibility into other
functions that might get linked in in order to eliminate work on
global variables.
Diffstat (limited to 'ir.h')
-rw-r--r-- | ir.h | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -54,11 +54,13 @@ public: virtual class ir_variable * as_variable() { return NULL; } virtual class ir_dereference * as_dereference() { return NULL; } virtual class ir_rvalue * as_rvalue() { return NULL; } + virtual class ir_label * as_label() { return NULL; } virtual class ir_loop * as_loop() { return NULL; } virtual class ir_assignment * as_assignment() { return NULL; } virtual class ir_call * as_call() { return NULL; } virtual class ir_return * as_return() { return NULL; } virtual class ir_if * as_if() { return NULL; } + virtual class ir_swizzle * as_swizzle() { return NULL; } /*@}*/ protected: @@ -185,6 +187,11 @@ class ir_label : public ir_instruction { public: ir_label(const char *label, ir_function_signature *signature); + virtual ir_label *as_label() + { + return this; + } + virtual void accept(ir_visitor *v) { v->visit(this); @@ -681,6 +688,11 @@ public: /* empty */ } + virtual ir_swizzle *as_swizzle() + { + return this; + } + ir_swizzle *clone() { return new ir_swizzle(this->val, this->mask); |