nv50/ir: add setFlagsDef/Src helper

Will be used by nv50 target.
This commit is contained in:
Christoph Bumiller
2012-03-28 23:50:32 +02:00
parent 286abcb51e
commit 56cf2da022
4 changed files with 29 additions and 3 deletions
@@ -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;
@@ -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;
}
@@ -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;
@@ -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;