summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/nv50
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/nv50')
-rw-r--r--src/gallium/drivers/nv50/codegen/nv50_ir_ssa.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_ssa.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_ssa.cpp
index 43cb74991f1..175e9b5a4c6 100644
--- a/src/gallium/drivers/nv50/codegen/nv50_ir_ssa.cpp
+++ b/src/gallium/drivers/nv50/codegen/nv50_ir_ssa.cpp
@@ -293,11 +293,12 @@ public:
inline LValue *getStackTop(Value *);
+ LValue *mkUndefined(Value *);
+
private:
Stack *stack;
Function *func;
Program *prog;
- Instruction *undef;
};
bool
@@ -402,12 +403,6 @@ Function::convertToSSA()
RenamePass::RenamePass(Function *fn) : func(fn), prog(fn->getProgram())
{
- BasicBlock *root = BasicBlock::get(func->cfg.getRoot());
-
- undef = new_Instruction(func, OP_NOP, TYPE_U32);
- undef->setDef(0, new_LValue(func, FILE_GPR));
- root->insertHead(undef);
-
stack = new Stack[func->allLValues.getSize()];
}
@@ -425,6 +420,18 @@ RenamePass::getStackTop(Value *val)
return reinterpret_cast<LValue *>(stack[val->id].peek().u.p);
}
+LValue *
+RenamePass::mkUndefined(Value *val)
+{
+ LValue *lval = val->asLValue();
+ assert(lval);
+ LValue *ud = new_LValue(func, lval);
+ Instruction *nop = new_Instruction(func, OP_NOP, typeOfSize(lval->reg.size));
+ nop->setDef(0, ud);
+ BasicBlock::get(func->cfg.getRoot())->insertHead(nop);
+ return ud;
+}
+
bool RenamePass::run()
{
if (!stack)
@@ -463,7 +470,7 @@ void RenamePass::search(BasicBlock *bb)
continue;
lval = getStackTop(lval);
if (!lval)
- lval = static_cast<LValue *>(undef->getDef(0));
+ lval = mkUndefined(stmt->getSrc(s));
stmt->setSrc(s, lval);
}
}
@@ -494,7 +501,7 @@ void RenamePass::search(BasicBlock *bb)
for (phi = sb->getPhi(); phi && phi->op == OP_PHI; phi = phi->next) {
lval = getStackTop(phi->getSrc(p));
if (!lval)
- lval = undef->getDef(0)->asLValue();
+ lval = mkUndefined(phi->getSrc(p));
phi->setSrc(p, lval);
}
}
@@ -510,12 +517,14 @@ void RenamePass::search(BasicBlock *bb)
continue;
lval = getStackTop(lval);
if (!lval)
- lval = static_cast<LValue *>(undef->getDef(0));
+ lval = mkUndefined(it->get());
it->set(lval);
}
}
for (Instruction *stmt = bb->getFirst(); stmt; stmt = stmt->next) {
+ if (stmt->op == OP_NOP)
+ continue;
for (d = 0; stmt->defExists(d); ++d)
stack[stmt->def(d).preSSA()->id].pop();
}