summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/nv50/codegen/nv50_ir.cpp
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2012-04-09 20:43:28 +0200
committerChristoph Bumiller <[email protected]>2012-04-14 21:54:01 +0200
commitd6d1f0e4a25c9fbefce7485d77617855a8ea956a (patch)
tree281fa283f8e584035a9b7e912a5a6f3796e81f5c /src/gallium/drivers/nv50/codegen/nv50_ir.cpp
parent14d5f975a65c57830077dabf2f95261afbc51773 (diff)
nv50/ir/opt: Don't lose modifiers during constant folding.
Diffstat (limited to 'src/gallium/drivers/nv50/codegen/nv50_ir.cpp')
-rw-r--r--src/gallium/drivers/nv50/codegen/nv50_ir.cpp40
1 files changed, 33 insertions, 7 deletions
diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir.cpp
index 862293e39b2..cbab1ec1406 100644
--- a/src/gallium/drivers/nv50/codegen/nv50_ir.cpp
+++ b/src/gallium/drivers/nv50/codegen/nv50_ir.cpp
@@ -77,19 +77,38 @@ ValueRef::~ValueRef()
this->set(NULL);
}
-ImmediateValue *ValueRef::getImmediate() const
+bool ValueRef::getImmediate(ImmediateValue &imm) const
{
- Value *src = value;
+ const ValueRef *src = this;
+ Modifier m;
+ DataType type = src->insn->sType;
while (src) {
- if (src->reg.file == FILE_IMMEDIATE)
- return src->asImm();
+ if (src->mod) {
+ if (src->insn->sType != type)
+ break;
+ m *= src->mod;
+ }
+ if (src->getFile() == FILE_IMMEDIATE) {
+ imm = *(src->value->asImm());
+ // The immediate's type isn't required to match its use, it's
+ // more of a hint; applying a modifier makes use of that hint.
+ imm.reg.type = type;
+ m.applyTo(imm);
+ return true;
+ }
- Instruction *insn = src->getUniqueInsn();
+ Instruction *insn = src->value->getUniqueInsn();
- src = (insn && insn->op == OP_MOV) ? insn->getSrc(0) : NULL;
+ if (insn && insn->op == OP_MOV) {
+ src = &insn->src(0);
+ if (src->mod)
+ WARN("OP_MOV with modifier encountered !\n");
+ } else {
+ src = NULL;
+ }
}
- return NULL;
+ return false;
}
ValueDef::ValueDef(Value *v) : value(NULL), insn(NULL)
@@ -483,6 +502,13 @@ ImmediateValue::compare(CondCode cc, float fval) const
}
}
+ImmediateValue&
+ImmediateValue::operator=(const ImmediateValue &that)
+{
+ this->reg = that.reg;
+ return (*this);
+}
+
bool
Value::interfers(const Value *that) const
{