summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/nv50/codegen
diff options
context:
space:
mode:
authorChristoph Bumiller <[email protected]>2012-04-09 20:40:35 +0200
committerChristoph Bumiller <[email protected]>2012-04-14 21:54:00 +0200
commit9362d4bc0a03860ec386156cf499e855a9c2d2a5 (patch)
treee639c3f11986caec082d297891cdf5d26dc96314 /src/gallium/drivers/nv50/codegen
parent8cc2eca5df0116aa7fb8233a9ab6ad1c9e4203cd (diff)
nv50/ir: make Instruction::src/def container private
Diffstat (limited to 'src/gallium/drivers/nv50/codegen')
-rw-r--r--src/gallium/drivers/nv50/codegen/nv50_ir.cpp49
-rw-r--r--src/gallium/drivers/nv50/codegen/nv50_ir.h30
-rw-r--r--src/gallium/drivers/nv50/codegen/nv50_ir_from_tgsi.cpp4
-rw-r--r--src/gallium/drivers/nv50/codegen/nv50_ir_inlines.h4
-rw-r--r--src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp159
-rw-r--r--src/gallium/drivers/nv50/codegen/nv50_ir_print.cpp18
-rw-r--r--src/gallium/drivers/nv50/codegen/nv50_ir_ra.cpp12
-rw-r--r--src/gallium/drivers/nv50/codegen/nv50_ir_ssa.cpp12
8 files changed, 149 insertions, 139 deletions
diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir.cpp
index ebcdff4fb79..4e270c583f6 100644
--- a/src/gallium/drivers/nv50/codegen/nv50_ir.cpp
+++ b/src/gallium/drivers/nv50/codegen/nv50_ir.cpp
@@ -555,44 +555,44 @@ Instruction::~Instruction()
void
Instruction::setDef(int i, Value *val)
{
- int size = def.size();
+ int size = defs.size();
if (i >= size) {
- def.resize(i + 1);
+ defs.resize(i + 1);
while (size <= i)
- def[size++].setInsn(this);
+ defs[size++].setInsn(this);
}
- def[i].set(val);
+ defs[i].set(val);
}
void
Instruction::setSrc(int s, Value *val)
{
- int size = src.size();
+ int size = srcs.size();
if (s >= size) {
- src.resize(s + 1);
+ srcs.resize(s + 1);
while (size <= s)
- src[size++].setInsn(this);
+ srcs[size++].setInsn(this);
}
- src[s].set(val);
+ srcs[s].set(val);
}
void
Instruction::setSrc(int s, const ValueRef& ref)
{
setSrc(s, ref.get());
- src[s].mod = ref.mod;
+ srcs[s].mod = ref.mod;
}
void
Instruction::swapSources(int a, int b)
{
- Value *value = src[a].get();
- Modifier m = src[a].mod;
+ Value *value = srcs[a].get();
+ Modifier m = srcs[a].mod;
- setSrc(a, src[b]);
+ setSrc(a, srcs[b]);
- src[b].set(value);
- src[b].mod = m;
+ srcs[b].set(value);
+ srcs[b].mod = m;
}
void
@@ -663,7 +663,7 @@ Instruction::cloneBase(Instruction *insn, bool deep) const
}
for (int s = 0; this->srcExists(s); ++s)
- insn->setSrc(s, this->src[s]);
+ insn->setSrc(s, this->srcs[s]);
insn->predSrc = this->predSrc;
insn->flagsDef = this->flagsDef;
@@ -695,15 +695,17 @@ Instruction::setIndirect(int s, int dim, Value *value)
{
assert(this->srcExists(s));
- int p = src[s].indirect[dim];
+ int p = srcs[s].indirect[dim];
if (p < 0) {
if (!value)
return true;
- p = src.size();
+ p = srcs.size();
+ while (p > 0 && !srcExists(p - 1))
+ --p;
}
setSrc(p, value);
- src[p].usedAsPtr = (value != 0);
- src[s].indirect[dim] = value ? p : -1;
+ srcs[p].usedAsPtr = (value != 0);
+ srcs[s].indirect[dim] = value ? p : -1;
return true;
}
@@ -714,14 +716,17 @@ Instruction::setPredicate(CondCode ccode, Value *value)
if (!value) {
if (predSrc >= 0) {
- src[predSrc] = 0;
+ srcs[predSrc].set(NULL);
predSrc = -1;
}
return true;
}
- if (predSrc < 0)
- predSrc = src.size();
+ if (predSrc < 0) {
+ predSrc = srcs.size();
+ while (predSrc > 0 && !srcExists(predSrc - 1))
+ --predSrc;
+ }
setSrc(predSrc, value);
return true;
diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir.h b/src/gallium/drivers/nv50/codegen/nv50_ir.h
index ddd066df7f8..32511f64e88 100644
--- a/src/gallium/drivers/nv50/codegen/nv50_ir.h
+++ b/src/gallium/drivers/nv50/codegen/nv50_ir.h
@@ -385,8 +385,6 @@ public:
ValueRef(const ValueRef&);
~ValueRef();
- inline ValueRef& operator=(Value *val) { this->set(val); return *this; }
-
inline bool exists() const { return value != NULL; }
void set(Value *);
@@ -408,7 +406,7 @@ public:
public:
Modifier mod;
- int8_t indirect[2]; // >= 0 if relative to lvalue in insn->src[indirect[i]]
+ int8_t indirect[2]; // >= 0 if relative to lvalue in insn->src(indirect[i])
uint8_t swizzle;
bool usedAsPtr; // for printing
@@ -425,8 +423,6 @@ public:
ValueDef(const ValueDef&);
~ValueDef();
- inline ValueDef& operator=(Value *val) { this->set(val); return *this; }
-
inline bool exists() const { return value != NULL; }
inline Value *get() const { return value; }
@@ -461,6 +457,8 @@ public:
virtual bool equals(const Value *, bool strict = false) const;
virtual bool interfers(const Value *) const;
+ inline Value *rep() const { return join; }
+
inline Instruction *getUniqueInsn() const;
inline Instruction *getInsn() const; // use when uniqueness is certain
@@ -584,17 +582,22 @@ public:
void swapSources(int a, int b);
bool setIndirect(int s, int dim, Value *);
- inline Value *getDef(int d) const { return def[d].get(); }
- inline Value *getSrc(int s) const { return src[s].get(); }
+ inline ValueRef& src(int s) { return srcs[s]; }
+ inline ValueDef& def(int s) { return defs[s]; }
+ inline const ValueRef& src(int s) const { return srcs[s]; }
+ inline const ValueDef& def(int s) const { return defs[s]; }
+
+ inline Value *getDef(int d) const { return defs[d].get(); }
+ inline Value *getSrc(int s) const { return srcs[s].get(); }
inline Value *getIndirect(int s, int dim) const;
inline bool defExists(unsigned d) const
{
- return d < def.size() && def[d].exists();
+ return d < defs.size() && defs[d].exists();
}
inline bool srcExists(unsigned s) const
{
- return s < src.size() && src[s].exists();
+ return s < srcs.size() && srcs[s].exists();
}
inline bool constrainedDefs() const { return defExists(1); }
@@ -606,7 +609,9 @@ public:
inline void setFlagsSrc(int s, Value *);
inline void setFlagsDef(int d, Value *);
+ unsigned int defCount() const { return defs.size(); };
unsigned int defCount(unsigned int mask) const;
+ unsigned int srcCount() const { return srcs.size(); };
unsigned int srcCount(unsigned int mask) const;
// save & remove / set indirect[0,1] and predicate source
@@ -671,11 +676,12 @@ public:
int8_t flagsDef;
int8_t flagsSrc;
- std::deque<ValueDef> def; // no gaps !
- std::deque<ValueRef> src; // no gaps !
-
BasicBlock *bb;
+protected:
+ std::deque<ValueDef> defs; // no gaps !
+ std::deque<ValueRef> srcs; // no gaps !
+
// instruction specific methods:
// (don't want to subclass, would need more constructors and memory pools)
public:
diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_from_tgsi.cpp
index 8889b492946..5b2ee690454 100644
--- a/src/gallium/drivers/nv50/codegen/nv50_ir_from_tgsi.cpp
+++ b/src/gallium/drivers/nv50/codegen/nv50_ir_from_tgsi.cpp
@@ -1553,8 +1553,8 @@ Converter::handleTEX(Value *dst[4], int R, int S, int L, int C, int Dx, int Dy)
if (texi->op == OP_TXD) {
for (c = 0; c < tgt.getDim(); ++c) {
- texi->dPdx[c] = fetchSrc(Dx >> 4, (Dx & 3) + c);
- texi->dPdy[c] = fetchSrc(Dy >> 4, (Dy & 3) + c);
+ texi->dPdx[c].set(fetchSrc(Dx >> 4, (Dx & 3) + c));
+ texi->dPdy[c].set(fetchSrc(Dy >> 4, (Dy & 3) + c));
}
}
diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_inlines.h b/src/gallium/drivers/nv50/codegen/nv50_ir_inlines.h
index d511c93232a..713653175fd 100644
--- a/src/gallium/drivers/nv50/codegen/nv50_ir_inlines.h
+++ b/src/gallium/drivers/nv50/codegen/nv50_ir_inlines.h
@@ -115,7 +115,7 @@ static inline bool isSignedType(DataType ty)
const ValueRef *ValueRef::getIndirect(int dim) const
{
- return isIndirect(dim) ? &insn->src[indirect[dim]] : NULL;
+ return isIndirect(dim) ? &insn->src(indirect[dim]) : NULL;
}
DataFile ValueRef::getFile() const
@@ -194,7 +194,7 @@ Instruction *Value::getUniqueInsn() const
Value *Instruction::getIndirect(int s, int dim) const
{
- return src[s].isIndirect(dim) ? getSrc(src[s].indirect[dim]) : NULL;
+ return srcs[s].isIndirect(dim) ? getSrc(srcs[s].indirect[dim]) : NULL;
}
Value *Instruction::getPredicate() const
diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp
index 046f04bbf35..93ba4c5b6ae 100644
--- a/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp
@@ -40,18 +40,18 @@ Instruction::isNop() const
if (!fixed && op == OP_NOP)
return true;
- if (defExists(0) && def[0].rep()->reg.data.id < 0) {
+ if (defExists(0) && def(0).rep()->reg.data.id < 0) {
for (int d = 1; defExists(d); ++d)
- if (def[d].rep()->reg.data.id >= 0)
+ if (def(d).rep()->reg.data.id >= 0)
WARN("part of vector result is unused !\n");
return true;
}
if (op == OP_MOV || op == OP_UNION) {
- if (!def[0].rep()->equals(getSrc(0)))
+ if (!def(0).rep()->equals(getSrc(0)))
return false;
if (op == OP_UNION)
- if (!def[0].rep()->equals(getSrc(1)))
+ if (!def(0).rep()->equals(getSrc(1)))
return false;
return true;
}
@@ -100,7 +100,7 @@ CopyPropagation::visit(BasicBlock *bb)
si = mov->getSrc(0)->getInsn();
if (mov->getDef(0)->reg.data.id < 0 && si && si->op != OP_PHI) {
// propagate
- mov->def[0].replace(mov->getSrc(0), false);
+ mov->def(0).replace(mov->getSrc(0), false);
delete_Instruction(prog, mov);
}
}
@@ -123,7 +123,7 @@ private:
bool
LoadPropagation::isCSpaceLoad(Instruction *ld)
{
- return ld && ld->op == OP_LOAD && ld->src[0].getFile() == FILE_MEMORY_CONST;
+ return ld && ld->op == OP_LOAD && ld->src(0).getFile() == FILE_MEMORY_CONST;
}
bool
@@ -131,7 +131,7 @@ LoadPropagation::isImmd32Load(Instruction *ld)
{
if (!ld || (ld->op != OP_MOV) || (typeSizeof(ld->dType) != 4))
return false;
- return ld->src[0].getFile() == FILE_IMMEDIATE;
+ return ld->src(0).getFile() == FILE_IMMEDIATE;
}
void
@@ -140,7 +140,7 @@ LoadPropagation::checkSwapSrc01(Instruction *insn)
if (!prog->getTarget()->getOpInfo(insn).commutative)
if (insn->op != OP_SET && insn->op != OP_SLCT)
return;
- if (insn->src[1].getFile() != FILE_GPR)
+ if (insn->src(1).getFile() != FILE_GPR)
return;
Instruction *i0 = insn->getSrc(0)->getInsn();
@@ -190,7 +190,7 @@ LoadPropagation::visit(BasicBlock *bb)
// propagate !
i->setSrc(s, ld->getSrc(0));
- if (ld->src[0].isIndirect(0))
+ if (ld->src(0).isIndirect(0))
i->setIndirect(s, 0, ld->getIndirect(0, 0));
if (ld->getDef(0)->refCount() == 0)
@@ -249,8 +249,8 @@ ConstantFolding::visit(BasicBlock *bb)
if (i->op == OP_MOV) // continue early, MOV appears frequently
continue;
- ImmediateValue *src0 = i->srcExists(0) ? i->src[0].getImmediate() : NULL;
- ImmediateValue *src1 = i->srcExists(1) ? i->src[1].getImmediate() : NULL;
+ ImmediateValue *src0 = i->srcExists(0) ? i->src(0).getImmediate() : NULL;
+ ImmediateValue *src1 = i->srcExists(1) ? i->src(1).getImmediate() : NULL;
if (src0 && src1)
expr(i, src0, src1);
@@ -372,8 +372,8 @@ ConstantFolding::expr(Instruction *i,
struct Storage res;
struct Storage *const a = &imm0.reg, *const b = &imm1.reg;
- i->src[0].mod.applyTo(imm0);
- i->src[1].mod.applyTo(imm1);
+ i->src(0).mod.applyTo(imm0);
+ i->src(1).mod.applyTo(imm1);
switch (i->op) {
case OP_MAD:
@@ -474,8 +474,8 @@ ConstantFolding::expr(Instruction *i,
}
++foldCount;
- i->src[0].mod = Modifier(0);
- i->src[1].mod = Modifier(0);
+ i->src(0).mod = Modifier(0);
+ i->src(1).mod = Modifier(0);
i->setSrc(0, new_ImmediateValue(i->bb->getProgram(), res.data.u32));
i->setSrc(1, NULL);
@@ -486,12 +486,11 @@ ConstantFolding::expr(Instruction *i,
i->op = OP_ADD;
i->setSrc(1, i->getSrc(0));
+ i->src(1).mod = i->src(2).mod;
i->setSrc(0, i->getSrc(2));
i->setSrc(2, NULL);
- i->src[1].mod = i->src[2].mod;
-
- src0 = i->src[0].getImmediate();
+ src0 = i->src(0).getImmediate();
if (src0)
expr(i, src0, i->getSrc(1)->asImm());
} else {
@@ -526,7 +525,7 @@ ConstantFolding::unary(Instruction *i, const ImmediateValue &imm)
}
i->op = OP_MOV;
i->setSrc(0, new_ImmediateValue(i->bb->getProgram(), res.data.f32));
- i->src[0].mod = Modifier(0);
+ i->src(0).mod = Modifier(0);
}
void
@@ -547,28 +546,28 @@ ConstantFolding::tryCollapseChainedMULs(Instruction *mul2,
mul1 = insn;
if (mul1) {
int s1 = 0;
- ImmediateValue *imm = mul1->src[s1].getImmediate();
+ ImmediateValue *imm = mul1->src(s1).getImmediate();
if (!imm) {
s1 = 1;
- imm = mul1->src[s1].getImmediate();
+ imm = mul1->src(s1).getImmediate();
}
if (imm) {
bld.setPosition(mul1, false);
// a = mul r, imm1
// d = mul a, imm2 -> d = mul r, (imm1 * imm2)
- ImmediateValue imm1(mul1->src[s1].getImmediate(), TYPE_F32);
- mul1->src[s1].mod.applyTo(imm1);
- mul1->src[s1].mod = Modifier(0);
+ ImmediateValue imm1(mul1->src(s1).getImmediate(), TYPE_F32);
+ mul1->src(s1).mod.applyTo(imm1);
+ mul1->src(s1).mod = Modifier(0);
mul1->setSrc(s1, bld.loadImm(NULL, f * imm1.reg.data.f32));
- mul2->def[0].replace(mul1->getDef(0), false);
+ mul2->def(0).replace(mul1->getDef(0), false);
} else
if (prog->getTarget()->isPostMultiplySupported(OP_MUL, f, e)) {
// c = mul a, b
// d = mul c, imm -> d = mul_x_imm a, b
mul1->postFactor = e;
- mul2->def[0].replace(mul1->getDef(0), false);
+ mul2->def(0).replace(mul1->getDef(0), false);
if (f < 0)
- mul1->src[0].mod = mul1->src[0].mod ^ Modifier(NV50_IR_MOD_NEG);
+ mul1->src(0).mod = mul1->src(0).mod ^ Modifier(NV50_IR_MOD_NEG);
}
return;
}
@@ -585,13 +584,13 @@ ConstantFolding::tryCollapseChainedMULs(Instruction *mul2,
s2 = insn->getSrc(0) == mul1->getDef(0) ? 0 : 1;
t2 = s2 ? 0 : 1;
if (insn->op == OP_MUL && insn->dType == TYPE_F32)
- if (!insn->src[t2].getImmediate())
+ if (!insn->src(t2).getImmediate())
mul2 = insn;
if (mul2 && prog->getTarget()->isPostMultiplySupported(OP_MUL, f, e)) {
mul2->postFactor = e;
- mul2->setSrc(s2, mul1->src[t]);
+ mul2->setSrc(s2, mul1->src(t));
if (f < 0)
- mul2->src[s2].mod = mul2->src[s2].mod ^ Modifier(NV50_IR_MOD_NEG);
+ mul2->src(s2).mod = mul2->src(s2).mod ^ Modifier(NV50_IR_MOD_NEG);
}
}
}
@@ -604,7 +603,7 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue *src, int s)
ImmediateValue imm(src, i->sType);
- i->src[s].mod.applyTo(imm);
+ i->src(s).mod.applyTo(imm);
switch (i->op) {
case OP_MUL:
@@ -618,23 +617,23 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue *src, int s)
} else
if (imm.isInteger(1) || imm.isInteger(-1)) {
if (imm.isNegative())
- i->src[t].mod = i->src[t].mod ^ Modifier(NV50_IR_MOD_NEG);
- i->op = i->src[t].mod.getOp();
+ i->src(t).mod = i->src(t).mod ^ Modifier(NV50_IR_MOD_NEG);
+ i->op = i->src(t).mod.getOp();
if (s == 0) {
i->setSrc(0, i->getSrc(1));
- i->src[0].mod = i->src[1].mod;
- i->src[1].mod = 0;
+ i->src(0).mod = i->src(1).mod;
+ i->src(1).mod = 0;
}
if (i->op != OP_CVT)
- i->src[0].mod = 0;
+ i->src(0).mod = 0;
i->setSrc(1, NULL);
} else
if (imm.isInteger(2) || imm.isInteger(-2)) {
if (imm.isNegative())
- i->src[t].mod = i->src[t].mod ^ Modifier(NV50_IR_MOD_NEG);
+ i->src(t).mod = i->src(t).mod ^ Modifier(NV50_IR_MOD_NEG);
i->op = OP_ADD;
i->setSrc(s, i->getSrc(t));
- i->src[s].mod = i->src[t].mod;
+ i->src(s).mod = i->src(t).mod;
} else
if (!isFloatType(i->sType) && !imm.isNegative() && imm.isPow2()) {
i->op = OP_SHL;
@@ -646,12 +645,12 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue *src, int s)
if (imm.isInteger(0)) {
if (s == 0) {
i->setSrc(0, i->getSrc(1));
- i->src[0].mod = i->src[1].mod;
+ i->src(0).mod = i->src(1).mod;
}
i->setSrc(1, NULL);
- i->op = i->src[0].mod.getOp();
+ i->op = i->src(0).mod.getOp();
if (i->op != OP_CVT)
- i->src[0].mod = Modifier(0);
+ i->src(0).mod = Modifier(0);
}
break;
@@ -747,7 +746,7 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue *src, int s)
{
CmpInstruction *si = findOriginForTestWithZero(i->getSrc(t));
CondCode cc, ccZ;
- if (i->src[t].mod != Modifier(0))
+ if (i->src(t).mod != Modifier(0))
return;
if (imm.reg.data.u32 != 0 || !si || si->op != OP_SET)
return;
@@ -766,22 +765,22 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue *src, int s)
return;
}
i->asCmp()->setCond = cc;
- i->setSrc(0, si->src[0]);
- i->setSrc(1, si->src[1]);
+ i->setSrc(0, si->src(0));
+ i->setSrc(1, si->src(1));
i->sType = si->sType;
}
break;
case OP_SHL:
{
- if (s != 1 || i->src[0].mod != Modifier(0))
+ if (s != 1 || i->src(0).mod != Modifier(0))
break;
// try to concatenate shifts
Instruction *si = i->getSrc(0)->getInsn();
if (!si ||
- si->op != OP_SHL || si->src[1].mod != Modifier(0))
+ si->op != OP_SHL || si->src(1).mod != Modifier(0))
break;
- ImmediateValue *siImm = si->src[1].getImmediate();
+ ImmediateValue *siImm = si->src(1).getImmediate();
if (siImm) {
bld.setPosition(i, false);
i->setSrc(0, si->getSrc(0));
@@ -834,7 +833,7 @@ ModifierFolding::visit(BasicBlock *bb)
if (0 && i->op == OP_SUB) {
// turn "sub" into "add neg" (do we really want this ?)
i->op = OP_ADD;
- i->src[0].mod = i->src[0].mod ^ Modifier(NV50_IR_MOD_NEG);
+ i->src(0).mod = i->src(0).mod ^ Modifier(NV50_IR_MOD_NEG);
}
for (int s = 0; s < 3 && i->srcExists(s); ++s) {
@@ -854,9 +853,9 @@ ModifierFolding::visit(BasicBlock *bb)
}
if ((mod = Modifier(mi->op)) == Modifier(0))
continue;
- mod = mod * mi->src[0].mod;
+ mod = mod * mi->src(0).mod;
- if ((i->op == OP_ABS) || i->src[s].mod.abs()) {
+ if ((i->op == OP_ABS) || i->src(s).mod.abs()) {
// abs neg [abs] = abs
mod = mod & Modifier(~(NV50_IR_MOD_NEG | NV50_IR_MOD_ABS));
} else
@@ -873,7 +872,7 @@ ModifierFolding::visit(BasicBlock *bb)
if (target->isModSupported(i, s, mod)) {
i->setSrc(s, mi->getSrc(0));
- i->src[s].mod = i->src[s].mod * mod;
+ i->src(s).mod = i->src(s).mod * mod;
}
}
@@ -945,10 +944,10 @@ AlgebraicOpt::handleADD(Instruction *add)
if (src->getInsn()->postFactor)
return;
- mod[0] = add->src[0].mod;
- mod[1] = add->src[1].mod;
- mod[2] = src->getUniqueInsn()->src[0].mod;
- mod[3] = src->getUniqueInsn()->src[1].mod;
+ mod[0] = add->src(0).mod;
+ mod[1] = add->src(1).mod;
+ mod[2] = src->getUniqueInsn()->src(0).mod;
+ mod[3] = src->getUniqueInsn()->src(1).mod;
if (((mod[0] | mod[1]) | (mod[2] | mod[3])) & Modifier(~NV50_IR_MOD_NEG))
return;
@@ -956,12 +955,12 @@ AlgebraicOpt::handleADD(Instruction *add)
add->op = OP_MAD;
add->subOp = src->getInsn()->subOp; // potentially mul-high
- add->setSrc(2, add->src[s ? 0 : 1]);
+ add->setSrc(2, add->src(s ? 0 : 1));
add->setSrc(0, src->getInsn()->getSrc(0));
- add->src[0].mod = mod[2] ^ mod[s];
+ add->src(0).mod = mod[2] ^ mod[s];
add->setSrc(1, src->getInsn()->getSrc(1));
- add->src[1].mod = mod[3];
+ add->src(1).mod = mod[3];
}
void
@@ -972,12 +971,12 @@ AlgebraicOpt::handleMINMAX(Instruction *minmax)
if (src0 != src1 || src0->reg.file != FILE_GPR)
return;
- if (minmax->src[0].mod == minmax->src[1].mod) {
- if (minmax->src[0].mod) {
+ if (minmax->src(0).mod == minmax->src(1).mod) {
+ if (minmax->src(0).mod) {
minmax->op = OP_CVT;
minmax->setSrc(1, NULL);
} else {
- minmax->def[0].replace(minmax->getSrc(0), false);
+ minmax->def(0).replace(minmax->getSrc(0), false);
minmax->bb->remove(minmax);
}
} else {
@@ -997,7 +996,7 @@ AlgebraicOpt::handleRCP(Instruction *rcp)
Instruction *si = rcp->getSrc(0)->getUniqueInsn();
if (si && si->op == OP_RCP) {
- Modifier mod = rcp->src[0].mod * si->src[0].mod;
+ Modifier mod = rcp->src(0).mod * si->src(0).mod;
rcp->op = mod.getOp();
rcp->setSrc(0, si->getSrc(0));
}
@@ -1028,11 +1027,11 @@ AlgebraicOpt::handleLOGOP(Instruction *logop)
return;
if (src0 == src1) {
- if (logop->src[0].mod != Modifier(0) ||
- logop->src[1].mod != Modifier(0))
+ if (logop->src(0).mod != Modifier(0) ||
+ logop->src(1).mod != Modifier(0))
return;
if (logop->op == OP_AND || logop->op == OP_OR) {
- logop->def[0].replace(logop->getSrc(0), false);
+ logop->def(0).replace(logop->getSrc(0), false);
delete_Instruction(prog, logop);
}
} else {
@@ -1092,12 +1091,12 @@ void
AlgebraicOpt::handleCVT(Instruction *cvt)
{
if (cvt->sType != TYPE_F32 ||
- cvt->dType != TYPE_S32 || cvt->src[0].mod != Modifier(0))
+ cvt->dType != TYPE_S32 || cvt->src(0).mod != Modifier(0))
return;
Instruction *insn = cvt->getSrc(0)->getInsn();
if (!insn || insn->op != OP_NEG || insn->dType != TYPE_F32)
return;
- if (insn->src[0].mod != Modifier(0))
+ if (insn->src(0).mod != Modifier(0))
return;
insn = insn->getSrc(0)->getInsn();
if (!insn || insn->op != OP_SET || insn->dType != TYPE_F32)
@@ -1386,8 +1385,8 @@ MemoryOpt::Record **
MemoryOpt::getList(const Instruction *insn)
{
if (insn->op == OP_LOAD || insn->op == OP_VFETCH)
- return &loads[insn->src[0].getFile()];
- return &stores[insn->src[0].getFile()];
+ return &loads[insn->src(0).getFile()];
+ return &stores[insn->src(0).getFile()];
}
void
@@ -1458,7 +1457,7 @@ MemoryOpt::replaceLdFromSt(Instruction *ld, Record *rec)
return false;
if (st->getSrc(s)->reg.file != FILE_GPR)
return false;
- ld->def[d].replace(st->getSrc(s), false);
+ ld->def(d).replace(st->getSrc(s), false);
}
ld->bb->remove(ld);
return true;
@@ -1481,7 +1480,7 @@ MemoryOpt::replaceLdFromLd(Instruction *ldE, Record *rec)
for (dE = 0; ldE->defExists(dE) && ldR->defExists(dR); ++dE, ++dR) {
if (ldE->getDef(dE)->reg.size != ldR->getDef(dR)->reg.size)
return false;
- ldE->def[dE].replace(ldR->getDef(dR), false);
+ ldE->def(dE).replace(ldR->getDef(dR), false);
}
delete_Instruction(prog, ldE);
@@ -1567,7 +1566,7 @@ MemoryOpt::Record::overlaps(const Instruction *ldst) const
void
MemoryOpt::lockStores(Instruction *const ld)
{
- for (Record *r = stores[ld->src[0].getFile()]; r; r = r->next)
+ for (Record *r = stores[ld->src(0).getFile()]; r; r = r->next)
if (!r->locked && r->overlaps(ld))
r->locked = true;
}
@@ -1579,7 +1578,7 @@ void
MemoryOpt::purgeRecords(Instruction *const st, DataFile f)
{
if (st)
- f = st->src[0].getFile();
+ f = st->src(0).getFile();
for (Record *r = loads[f]; r; r = r->next)
if (!st || r->overlaps(st))
@@ -1639,7 +1638,7 @@ MemoryOpt::runOpt(BasicBlock *bb)
continue;
if (isLoad) {
- DataFile file = ldst->src[0].getFile();
+ DataFile file = ldst->src(0).getFile();
// if ld l[]/g[] look for previous store to eliminate the reload
if (file == FILE_MEMORY_GLOBAL || file == FILE_MEMORY_LOCAL) {
@@ -1712,11 +1711,11 @@ FlatteningPass::isConstantCondition(Value *pred)
if (ld) {
if (ld->op != OP_MOV && ld->op != OP_LOAD)
return false;
- if (ld->src[0].isIndirect(0))
+ if (ld->src(0).isIndirect(0))
return false;
- file = ld->src[0].getFile();
+ file = ld->src(0).getFile();
} else {
- file = insn->src[s].getFile();
+ file = insn->src(s).getFile();
// catch $r63 on NVC0
if (file == FILE_GPR && insn->getSrc(s)->reg.data.id > prog->maxGPR)
file = FILE_IMMEDIATE;
@@ -1991,7 +1990,7 @@ Instruction::isResultEqual(const Instruction *that) const
for (s = 0; this->srcExists(s); ++s) {
if (!that->srcExists(s))
return false;
- if (this->src[s].mod != that->src[s].mod)
+ if (this->src(s).mod != that->src(s).mod)
return false;
if (!this->getSrc(s)->equals(that->getSrc(s), true))
return false;
@@ -2000,7 +1999,7 @@ Instruction::isResultEqual(const Instruction *that) const
return false;
if (op == OP_LOAD || op == OP_VFETCH) {
- switch (src[0].getFile()) {
+ switch (src(0).getFile()) {
case FILE_MEMORY_CONST:
case FILE_SHADER_INPUT:
return true;
@@ -2052,7 +2051,7 @@ LocalCSE::tryReplace(Instruction **ptr, Instruction *i)
if (!old->isResultEqual(i))
return false;
for (int d = 0; old->defExists(d); ++d)
- old->def[d].replace(i->getDef(d), false);
+ old->def(d).replace(i->getDef(d), false);
delete_Instruction(prog, old);
*ptr = NULL;
return true;
diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_print.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_print.cpp
index 904b9c0ca69..acb5be58801 100644
--- a/src/gallium/drivers/nv50/codegen/nv50_ir_print.cpp
+++ b/src/gallium/drivers/nv50/codegen/nv50_ir_print.cpp
@@ -418,7 +418,7 @@ void Instruction::print() const
}
if (pos > pre + 1)
SPACE();
- pos += src[predSrc].get()->print(&buf[pos], BUFSZ - pos);
+ pos += getSrc(predSrc)->print(&buf[pos], BUFSZ - pos);
PRINT(" %s", colour[TXT_INSN]);
}
@@ -455,7 +455,7 @@ void Instruction::print() const
PRINT(" {");
for (d = 0; defExists(d); ++d) {
SPACE();
- pos += def[d].get()->print(&buf[pos], size - pos);
+ pos += getDef(d)->print(&buf[pos], size - pos);
}
if (d > 1)
PRINT(" %s}", colour[TXT_INSN]);
@@ -470,19 +470,19 @@ void Instruction::print() const
PRINT(" %s%s", colour[TXT_INSN], DataTypeStr[sType]);
for (s = 0; srcExists(s); ++s) {
- if (s == predSrc || src[s].usedAsPtr)
+ if (s == predSrc || src(s).usedAsPtr)
continue;
const size_t pre = pos;
SPACE();
- pos += src[s].mod.print(&buf[pos], BUFSZ - pos);
+ pos += src(s).mod.print(&buf[pos], BUFSZ - pos);
if (pos > pre + 1)
SPACE();
- if (src[s].isIndirect(0) || src[s].isIndirect(1))
- pos += src[s].get()->asSym()->print(&buf[pos], BUFSZ - pos,
- getIndirect(s, 0),
- getIndirect(s, 1));
+ if (src(s).isIndirect(0) || src(s).isIndirect(1))
+ pos += getSrc(s)->asSym()->print(&buf[pos], BUFSZ - pos,
+ getIndirect(s, 0),
+ getIndirect(s, 1));
else
- pos += src[s].get()->print(&buf[pos], BUFSZ - pos, sType);
+ pos += getSrc(s)->print(&buf[pos], BUFSZ - pos, sType);
}
PRINT("%s", colour[TXT_DEFAULT]);
diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_ra.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_ra.cpp
index 60ec4a3c089..43c29d5926a 100644
--- a/src/gallium/drivers/nv50/codegen/nv50_ir_ra.cpp
+++ b/src/gallium/drivers/nv50/codegen/nv50_ir_ra.cpp
@@ -322,7 +322,7 @@ RegAlloc::PhiMovesPass::visit(BasicBlock *bb)
}
}
- // insert MOVs (phi->src[j] should stem from j-th in-BB)
+ // insert MOVs (phi->src(j) should stem from j-th in-BB)
int j = 0;
for (Graph::EdgeIterator ei = bb->cfg.incident(); !ei.end(); ei.next()) {
pb = BasicBlock::get(ei.getNode());
@@ -443,7 +443,7 @@ RegAlloc::BuildIntervalsPass::visit(BasicBlock *bb)
bb->liveSet.clr(i->getDef(0)->id);
for (int s = 0; i->srcExists(s); ++s) {
- assert(i->src[s].getInsn());
+ assert(i->src(s).getInsn());
if (i->getSrc(s)->getUniqueInsn()->bb == bb) // XXX: reachableBy ?
bb->liveSet.set(i->getSrc(s)->id);
else
@@ -610,7 +610,7 @@ RegAlloc::allocateConstrainedValues()
assert(vecSize <= 4);
for (int c = 0; c < vecSize; ++c)
- defs[c] = i->def[c].rep();
+ defs[c] = i->def(c).rep();
if (defs[0]->reg.data.id >= 0) {
for (int c = 1; c < vecSize; ++c) {
@@ -960,8 +960,8 @@ RegAlloc::InsertConstraintsPass::visit(BasicBlock *bb)
addConstraint(i, 1, s - 1);
} else
if (i->op == OP_LOAD) {
- if (i->src[0].isIndirect(0) && typeSizeof(i->dType) >= 8)
- addHazard(i, i->src[0].getIndirect(0));
+ if (i->src(0).isIndirect(0) && typeSizeof(i->dType) >= 8)
+ addHazard(i, i->src(0).getIndirect(0));
}
}
return true;
@@ -979,7 +979,7 @@ RegAlloc::InsertConstraintsPass::insertConstraintMoves()
if (!detectConflict(cst, s))
continue;
Instruction *mov = new_Instruction(func, OP_MOV,
- typeOfSize(cst->src[s].getSize()));
+ typeOfSize(cst->src(s).getSize()));
mov->setSrc(0, cst->getSrc(s));
mov->setDef(0, new_LValue(func, FILE_GPR));
cst->setSrc(s, mov->getDef(0));
diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_ssa.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_ssa.cpp
index 52902591d2a..b3a14865ab4 100644
--- a/src/gallium/drivers/nv50/codegen/nv50_ir_ssa.cpp
+++ b/src/gallium/drivers/nv50/codegen/nv50_ir_ssa.cpp
@@ -433,13 +433,13 @@ void RenamePass::search(BasicBlock *bb)
}
}
for (d = 0; stmt->defExists(d); ++d) {
- lval = stmt->def[d].get()->asLValue();
+ lval = stmt->def(d).get()->asLValue();
assert(lval);
- stmt->def[d].setSSA(
+ stmt->def(d).setSSA(
new_LValue(func, targ->nativeFile(lval->reg.file)));
- stmt->def[d].get()->reg.size = lval->reg.size;
- stmt->def[d].get()->reg.data.id = lval->reg.data.id;
- stack[lval->id].push(stmt->def[d].get());
+ stmt->def(d).get()->reg.size = lval->reg.size;
+ stmt->def(d).get()->reg.data.id = lval->reg.data.id;
+ stack[lval->id].push(stmt->def(d).get());
}
}
@@ -469,7 +469,7 @@ void RenamePass::search(BasicBlock *bb)
for (Instruction *stmt = bb->getFirst(); stmt; stmt = stmt->next) {
for (d = 0; stmt->defExists(d); ++d)
- stack[stmt->def[d].preSSA()->id].pop();
+ stack[stmt->def(d).preSSA()->id].pop();
}
}