summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2010-07-06 17:41:02 -0700
committerIan Romanick <[email protected]>2010-07-06 17:44:37 -0700
commitca088cc277ce9f986693c857f3961dc0e1a4d91c (patch)
treebaec2a0f395913a7439c2c72803be0604cef377e /src
parentf14e596f11b4e44c75a880536efb1e8c5a72da7d (diff)
glsl2: Clone methods return the type of the thing being cloned
This is as opposed to returning the type of the base class of the hierarchy.
Diffstat (limited to 'src')
-rw-r--r--src/glsl/ast_to_hir.cpp10
-rw-r--r--src/glsl/ir.h38
-rw-r--r--src/glsl/ir_clone.cpp34
-rw-r--r--src/glsl/ir_constant_expression.cpp2
-rw-r--r--src/glsl/ir_function_inlining.cpp2
5 files changed, 45 insertions, 41 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 3bd0bd65913..f5e93b02547 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -961,7 +961,7 @@ ast_expression::hir(exec_list *instructions,
op[0], op[1]);
result = do_assignment(instructions, state,
- (ir_rvalue *)op[0]->clone(NULL), temp_rhs,
+ op[0]->clone(NULL), temp_rhs,
this->subexpressions[0]->get_location());
type = result->type;
error_emitted = (op[0]->type->is_error());
@@ -987,7 +987,7 @@ ast_expression::hir(exec_list *instructions,
op[0], op[1]);
result = do_assignment(instructions, state,
- (ir_rvalue *)op[0]->clone(NULL), temp_rhs,
+ op[0]->clone(NULL), temp_rhs,
this->subexpressions[0]->get_location());
type = result->type;
error_emitted = type->is_error();
@@ -1107,7 +1107,7 @@ ast_expression::hir(exec_list *instructions,
op[0], op[1]);
result = do_assignment(instructions, state,
- (ir_rvalue *)op[0]->clone(NULL), temp_rhs,
+ op[0]->clone(NULL), temp_rhs,
this->subexpressions[0]->get_location());
type = result->type;
error_emitted = op[0]->type->is_error();
@@ -1133,10 +1133,10 @@ ast_expression::hir(exec_list *instructions,
/* Get a temporary of a copy of the lvalue before it's modified.
* This may get thrown away later.
*/
- result = get_lvalue_copy(instructions, (ir_rvalue *)op[0]->clone(NULL));
+ result = get_lvalue_copy(instructions, op[0]->clone(NULL));
(void)do_assignment(instructions, state,
- (ir_rvalue *)op[0]->clone(NULL), temp_rhs,
+ op[0]->clone(NULL), temp_rhs,
this->subexpressions[0]->get_location());
type = result->type;
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index c19bd417c33..500a8c7a006 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -94,6 +94,8 @@ protected:
class ir_rvalue : public ir_instruction {
public:
+ virtual ir_rvalue *clone(struct hash_table *) const = 0;
+
virtual ir_rvalue * as_rvalue()
{
return this;
@@ -154,7 +156,7 @@ class ir_variable : public ir_instruction {
public:
ir_variable(const struct glsl_type *, const char *);
- virtual ir_instruction *clone(struct hash_table *ht) const;
+ virtual ir_variable *clone(struct hash_table *ht) const;
virtual ir_variable *as_variable()
{
@@ -258,7 +260,7 @@ class ir_function_signature : public ir_instruction {
public:
ir_function_signature(const glsl_type *return_type);
- virtual ir_instruction *clone(struct hash_table *ht) const;
+ virtual ir_function_signature *clone(struct hash_table *ht) const;
virtual void accept(ir_visitor *v)
{
@@ -324,7 +326,7 @@ class ir_function : public ir_instruction {
public:
ir_function(const char *name);
- virtual ir_instruction *clone(struct hash_table *ht) const;
+ virtual ir_function *clone(struct hash_table *ht) const;
virtual ir_function *as_function()
{
@@ -394,7 +396,7 @@ public:
/* empty */
}
- virtual ir_instruction *clone(struct hash_table *ht) const;
+ virtual ir_if *clone(struct hash_table *ht) const;
virtual ir_if *as_if()
{
@@ -426,7 +428,7 @@ public:
/* empty */
}
- virtual ir_instruction *clone(struct hash_table *ht) const;
+ virtual ir_loop *clone(struct hash_table *ht) const;
virtual void accept(ir_visitor *v)
{
@@ -467,7 +469,7 @@ class ir_assignment : public ir_rvalue {
public:
ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition);
- virtual ir_instruction *clone(struct hash_table *ht) const;
+ virtual ir_assignment *clone(struct hash_table *ht) const;
virtual void accept(ir_visitor *v)
{
@@ -601,7 +603,7 @@ public:
ir_expression(int op, const struct glsl_type *type,
ir_rvalue *, ir_rvalue *);
- virtual ir_instruction *clone(struct hash_table *ht) const;
+ virtual ir_expression *clone(struct hash_table *ht) const;
static unsigned int get_num_operands(ir_expression_operation);
unsigned int get_num_operands() const
@@ -644,7 +646,7 @@ public:
actual_parameters->move_nodes_to(& this->actual_parameters);
}
- virtual ir_instruction *clone(struct hash_table *ht) const;
+ virtual ir_call *clone(struct hash_table *ht) const;
virtual ir_call *as_call()
{
@@ -734,7 +736,7 @@ public:
/* empty */
}
- virtual ir_instruction *clone(struct hash_table *) const;
+ virtual ir_return *clone(struct hash_table *) const;
virtual ir_return *as_return()
{
@@ -778,7 +780,7 @@ public:
this->loop = loop;
}
- virtual ir_instruction *clone(struct hash_table *) const;
+ virtual ir_loop_jump *clone(struct hash_table *) const;
virtual void accept(ir_visitor *v)
{
@@ -819,7 +821,7 @@ public:
this->condition = cond;
}
- virtual ir_instruction *clone(struct hash_table *ht) const;
+ virtual ir_discard *clone(struct hash_table *ht) const;
virtual void accept(ir_visitor *v)
{
@@ -871,7 +873,7 @@ public:
/* empty */
}
- virtual ir_instruction *clone(struct hash_table *) const;
+ virtual ir_texture *clone(struct hash_table *) const;
virtual void accept(ir_visitor *v)
{
@@ -961,7 +963,7 @@ public:
ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask);
- virtual ir_instruction *clone(struct hash_table *) const;
+ virtual ir_swizzle *clone(struct hash_table *) const;
virtual ir_swizzle *as_swizzle()
{
@@ -1005,6 +1007,8 @@ private:
class ir_dereference : public ir_rvalue {
public:
+ virtual ir_dereference *clone(struct hash_table *) const = 0;
+
virtual ir_dereference *as_dereference()
{
return this;
@@ -1023,7 +1027,7 @@ class ir_dereference_variable : public ir_dereference {
public:
ir_dereference_variable(ir_variable *var);
- virtual ir_instruction *clone(struct hash_table *) const;
+ virtual ir_dereference_variable *clone(struct hash_table *) const;
virtual ir_dereference_variable *as_dereference_variable()
{
@@ -1069,7 +1073,7 @@ public:
ir_dereference_array(ir_variable *var, ir_rvalue *array_index);
- virtual ir_instruction *clone(struct hash_table *) const;
+ virtual ir_dereference_array *clone(struct hash_table *) const;
virtual ir_dereference_array *as_dereference_array()
{
@@ -1105,7 +1109,7 @@ public:
ir_dereference_record(ir_variable *var, const char *field);
- virtual ir_instruction *clone(struct hash_table *) const;
+ virtual ir_dereference_record *clone(struct hash_table *) const;
/**
* Get the variable that is ultimately referenced by an r-value
@@ -1163,7 +1167,7 @@ public:
*/
ir_constant(const ir_constant *c, unsigned i);
- virtual ir_instruction *clone(struct hash_table *) const;
+ virtual ir_constant *clone(struct hash_table *) const;
virtual ir_constant *as_constant()
{
diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp
index 74cc858bda4..cf21c24d732 100644
--- a/src/glsl/ir_clone.cpp
+++ b/src/glsl/ir_clone.cpp
@@ -35,7 +35,7 @@ extern "C" {
* This will probably be made \c virtual and moved to the base class
* eventually.
*/
-ir_instruction *
+ir_variable *
ir_variable::clone(struct hash_table *ht) const
{
void *ctx = talloc_parent(this);
@@ -55,14 +55,14 @@ ir_variable::clone(struct hash_table *ht) const
return var;
}
-ir_instruction *
+ir_swizzle *
ir_swizzle::clone(struct hash_table *ht) const
{
void *ctx = talloc_parent(this);
return new(ctx) ir_swizzle((ir_rvalue *)this->val->clone(ht), this->mask);
}
-ir_instruction *
+ir_return *
ir_return::clone(struct hash_table *ht) const
{
void *ctx = talloc_parent(this);
@@ -74,7 +74,7 @@ ir_return::clone(struct hash_table *ht) const
return new(ctx) ir_return(new_value);
}
-ir_instruction *
+ir_discard *
ir_discard::clone(struct hash_table *ht) const
{
void *ctx = talloc_parent(this);
@@ -86,7 +86,7 @@ ir_discard::clone(struct hash_table *ht) const
return new(ctx) ir_discard(new_condition);
}
-ir_instruction *
+ir_loop_jump *
ir_loop_jump::clone(struct hash_table *ht) const
{
void *ctx = talloc_parent(this);
@@ -95,7 +95,7 @@ ir_loop_jump::clone(struct hash_table *ht) const
return new(ctx) ir_loop_jump(this->mode);
}
-ir_instruction *
+ir_if *
ir_if::clone(struct hash_table *ht) const
{
void *ctx = talloc_parent(this);
@@ -114,7 +114,7 @@ ir_if::clone(struct hash_table *ht) const
return new_if;
}
-ir_instruction *
+ir_loop *
ir_loop::clone(struct hash_table *ht) const
{
void *ctx = talloc_parent(this);
@@ -136,7 +136,7 @@ ir_loop::clone(struct hash_table *ht) const
return new_loop;
}
-ir_instruction *
+ir_call *
ir_call::clone(struct hash_table *ht) const
{
void *ctx = talloc_parent(this);
@@ -150,7 +150,7 @@ ir_call::clone(struct hash_table *ht) const
return new(ctx) ir_call(this->callee, &new_parameters);
}
-ir_instruction *
+ir_expression *
ir_expression::clone(struct hash_table *ht) const
{
void *ctx = talloc_parent(this);
@@ -164,7 +164,7 @@ ir_expression::clone(struct hash_table *ht) const
return new(ctx) ir_expression(this->operation, this->type, op[0], op[1]);
}
-ir_instruction *
+ir_dereference_variable *
ir_dereference_variable::clone(struct hash_table *ht) const
{
void *ctx = talloc_parent(this);
@@ -181,7 +181,7 @@ ir_dereference_variable::clone(struct hash_table *ht) const
return new(ctx) ir_dereference_variable(new_var);
}
-ir_instruction *
+ir_dereference_array *
ir_dereference_array::clone(struct hash_table *ht) const
{
void *ctx = talloc_parent(this);
@@ -189,7 +189,7 @@ ir_dereference_array::clone(struct hash_table *ht) const
(ir_rvalue *)this->array_index->clone(ht));
}
-ir_instruction *
+ir_dereference_record *
ir_dereference_record::clone(struct hash_table *ht) const
{
void *ctx = talloc_parent(this);
@@ -197,7 +197,7 @@ ir_dereference_record::clone(struct hash_table *ht) const
this->field);
}
-ir_instruction *
+ir_texture *
ir_texture::clone(struct hash_table *ht) const
{
void *ctx = talloc_parent(this);
@@ -236,7 +236,7 @@ ir_texture::clone(struct hash_table *ht) const
return new_tex;
}
-ir_instruction *
+ir_assignment *
ir_assignment::clone(struct hash_table *ht) const
{
ir_rvalue *new_condition = NULL;
@@ -250,7 +250,7 @@ ir_assignment::clone(struct hash_table *ht) const
new_condition);
}
-ir_instruction *
+ir_function *
ir_function::clone(struct hash_table *ht) const
{
(void)ht;
@@ -258,7 +258,7 @@ ir_function::clone(struct hash_table *ht) const
abort();
}
-ir_instruction *
+ir_function_signature *
ir_function_signature::clone(struct hash_table *ht) const
{
(void)ht;
@@ -266,7 +266,7 @@ ir_function_signature::clone(struct hash_table *ht) const
abort();
}
-ir_instruction *
+ir_constant *
ir_constant::clone(struct hash_table *ht) const
{
void *ctx = talloc_parent(this);
diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp
index 11c810bc484..541398a91c7 100644
--- a/src/glsl/ir_constant_expression.cpp
+++ b/src/glsl/ir_constant_expression.cpp
@@ -626,7 +626,7 @@ ir_constant_visitor::visit(ir_dereference_variable *ir)
ir_variable *var = ir->variable_referenced();
if (var && var->constant_value)
- value = (ir_constant *)var->constant_value->clone(NULL);
+ value = var->constant_value->clone(NULL);
}
diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp
index b3d1f1d1674..6fe1264b0a4 100644
--- a/src/glsl/ir_function_inlining.cpp
+++ b/src/glsl/ir_function_inlining.cpp
@@ -137,7 +137,7 @@ ir_call::generate_inline(ir_instruction *next_ir)
ir_rvalue *param = (ir_rvalue *) param_iter.get();
/* Generate a new variable for the parameter. */
- parameters[i] = (ir_variable *)sig_param->clone(ht);
+ parameters[i] = sig_param->clone(ht);
parameters[i]->mode = ir_var_auto;
next_ir->insert_before(parameters[i]);