From 56cf2da02226aee6b7476675c0e05ac7c218756e Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Wed, 28 Mar 2012 23:50:32 +0200 Subject: [PATCH] nv50/ir: add setFlagsDef/Src helper Will be used by nv50 target. --- src/gallium/drivers/nv50/codegen/nv50_ir.h | 3 +++ .../drivers/nv50/codegen/nv50_ir_build_util.cpp | 3 +++ .../drivers/nv50/codegen/nv50_ir_build_util.h | 6 +++--- src/gallium/drivers/nv50/codegen/nv50_ir_inlines.h | 20 ++++++++++++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir.h b/src/gallium/drivers/nv50/codegen/nv50_ir.h index 04ea5e6..eb9f0ff 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir.h +++ b/src/gallium/drivers/nv50/codegen/nv50_ir.h @@ -637,6 +637,9 @@ public: inline Value *getPredicate() const; bool writesPredicate() const; + inline void setFlagsSrc(int s, Value *); + inline void setFlagsDef(int d, Value *); + unsigned int defCount(unsigned int mask) const; unsigned int srcCount(unsigned int mask) const; diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_build_util.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_build_util.cpp index 53a73b4..bdde9ea 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir_build_util.cpp +++ b/src/gallium/drivers/nv50/codegen/nv50_ir_build_util.cpp @@ -221,6 +221,9 @@ BuildUtil::mkCmp(operation op, CondCode cc, DataType ty, Value *dst, if (src2) insn->setSrc(2, src2); + if (dst->reg.file == FILE_FLAGS) + insn->flagsDef = 0; + insert(insn); return insn; } diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_build_util.h b/src/gallium/drivers/nv50/codegen/nv50_ir_build_util.h index 0bb853a..f815cf0 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir_build_util.h +++ b/src/gallium/drivers/nv50/codegen/nv50_ir_build_util.h @@ -44,7 +44,7 @@ public: inline void insert(Instruction *); inline void remove(Instruction *i) { assert(i->bb == bb); bb->remove(i); } - inline LValue *getScratch(int size = 4); + inline LValue *getScratch(int size = 4, DataFile = FILE_GPR); inline LValue *getSSA(int size = 4); // scratch value for a single assignment inline Instruction *mkOp(operation, DataType, Value *); @@ -186,9 +186,9 @@ BuildUtil::setPosition(Instruction *i, bool after) } LValue * -BuildUtil::getScratch(int size) +BuildUtil::getScratch(int size, DataFile f) { - LValue *lval = new_LValue(func, FILE_GPR); + LValue *lval = new_LValue(func, f); if (size != 4) lval->reg.size = size; return lval; diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_inlines.h b/src/gallium/drivers/nv50/codegen/nv50_ir_inlines.h index 0352caf..6d0848e 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir_inlines.h +++ b/src/gallium/drivers/nv50/codegen/nv50_ir_inlines.h @@ -215,6 +215,26 @@ Value *Instruction::getPredicate() const return (predSrc >= 0) ? getSrc(predSrc) : NULL; } +void Instruction::setFlagsDef(int d, Value *val) +{ + if (val) { + if (flagsDef < 0) + flagsDef = d; + setDef(flagsDef, val); + } else { + if (flagsDef >= 0) { + setDef(flagsDef, NULL); + flagsDef = -1; + } + } +} + +void Instruction::setFlagsSrc(int s, Value *val) +{ + flagsSrc = s; + setSrc(flagsSrc, val); +} + Value *TexInstruction::getIndirectR() const { return tex.rIndirectSrc >= 0 ? getSrc(tex.rIndirectSrc) : NULL; -- 2.7.4