From 054fab5b48ed8657da8549b9e1276acf4705f42c Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Fri, 6 Apr 2012 19:18:05 +0200 Subject: [PATCH] nv50/ir: fix reg file conflicts with undefined-value placeholders --- .../drivers/nv50/codegen/nv50_ir_ssa.cpp | 29 ++++++++++++------- 1 file 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(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(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(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(); } -- 2.30.2