OSDN Git Service

nv50/ir: add setFlagsDef/Src helper
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Wed, 28 Mar 2012 21:50:32 +0000 (23:50 +0200)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Sat, 14 Apr 2012 19:54:00 +0000 (21:54 +0200)
Will be used by nv50 target.

src/gallium/drivers/nv50/codegen/nv50_ir.h
src/gallium/drivers/nv50/codegen/nv50_ir_build_util.cpp
src/gallium/drivers/nv50/codegen/nv50_ir_build_util.h
src/gallium/drivers/nv50/codegen/nv50_ir_inlines.h

index 04ea5e6..eb9f0ff 100644 (file)
@@ -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;
 
index 53a73b4..bdde9ea 100644 (file)
@@ -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;
 }
index 0bb853a..f815cf0 100644 (file)
@@ -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;
index 0352caf..6d0848e 100644 (file)
@@ -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;