summaryrefslogtreecommitdiffstats
path: root/src/gallium
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
parent8cc2eca5df0116aa7fb8233a9ab6ad1c9e4203cd (diff)
nv50/ir: make Instruction::src/def container private
Diffstat (limited to 'src/gallium')
-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
-rw-r--r--src/gallium/drivers/nvc0/codegen/nv50_ir_emit_nvc0.cpp304
-rw-r--r--src/gallium/drivers/nvc0/codegen/nv50_ir_lowering_nvc0.cpp18
-rw-r--r--src/gallium/drivers/nvc0/codegen/nv50_ir_target_nvc0.cpp14
11 files changed, 320 insertions, 304 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();
}
}
diff --git a/src/gallium/drivers/nvc0/codegen/nv50_ir_emit_nvc0.cpp b/src/gallium/drivers/nvc0/codegen/nv50_ir_emit_nvc0.cpp
index 7468733f699..692b5b84f0a 100644
--- a/src/gallium/drivers/nvc0/codegen/nv50_ir_emit_nvc0.cpp
+++ b/src/gallium/drivers/nvc0/codegen/nv50_ir_emit_nvc0.cpp
@@ -113,11 +113,11 @@ private:
inline void defId(const ValueDef&, const int pos);
inline void srcId(const ValueRef&, const int pos);
+ inline void srcId(const ValueRef *, const int pos);
+ inline void srcId(const Instruction *, int s, const int pos);
inline void srcAddr32(const ValueRef&, const int pos); // address / 4
- inline void srcId(const ValueRef *, const int pos);
-
inline bool isLIMM(const ValueRef&, DataType ty);
};
@@ -137,6 +137,12 @@ void CodeEmitterNVC0::srcId(const ValueRef *src, const int pos)
code[pos / 32] |= (src ? SDATA(*src).id : 63) << (pos % 32);
}
+void CodeEmitterNVC0::srcId(const Instruction *insn, int s, int pos)
+{
+ int r = insn->srcExists(s) ? SDATA(insn->src(s)).id : 63;
+ code[pos / 32] |= r << (pos % 32);
+}
+
void CodeEmitterNVC0::srcAddr32(const ValueRef& src, const int pos)
{
code[pos / 32] |= (SDATA(src).offset >> 2) << (pos % 32);
@@ -170,10 +176,10 @@ CodeEmitterNVC0::roundMode_A(const Instruction *insn)
void
CodeEmitterNVC0::emitNegAbs12(const Instruction *i)
{
- if (i->src[1].mod.abs()) code[0] |= 1 << 6;
- if (i->src[0].mod.abs()) code[0] |= 1 << 7;
- if (i->src[1].mod.neg()) code[0] |= 1 << 8;
- if (i->src[0].mod.neg()) code[0] |= 1 << 9;
+ if (i->src(1).mod.abs()) code[0] |= 1 << 6;
+ if (i->src(0).mod.abs()) code[0] |= 1 << 7;
+ if (i->src(1).mod.neg()) code[0] |= 1 << 8;
+ if (i->src(0).mod.neg()) code[0] |= 1 << 9;
}
void CodeEmitterNVC0::emitCondCode(CondCode cc, int pos)
@@ -218,7 +224,7 @@ CodeEmitterNVC0::emitPredicate(const Instruction *i)
{
if (i->predSrc >= 0) {
assert(i->getPredicate()->reg.file == FILE_PREDICATE);
- srcId(i->src[i->predSrc], 10);
+ srcId(i->src(i->predSrc), 10);
if (i->cc == CC_NOT_P)
code[0] |= 0x2000; // negate
} else {
@@ -240,7 +246,7 @@ CodeEmitterNVC0::setAddress16(const ValueRef& src)
void
CodeEmitterNVC0::setImmediate(const Instruction *i, const int s)
{
- const ImmediateValue *imm = i->src[s].get()->asImm();
+ const ImmediateValue *imm = i->src(s).get()->asImm();
uint32_t u32;
assert(imm);
@@ -287,7 +293,7 @@ CodeEmitterNVC0::emitForm_A(const Instruction *i, uint64_t opc)
emitPredicate(i);
- defId(i->def[0], 14);
+ defId(i->def(0), 14);
int s1 = 26;
if (i->srcExists(2) && i->getSrc(2)->reg.file == FILE_MEMORY_CONST)
@@ -299,7 +305,7 @@ CodeEmitterNVC0::emitForm_A(const Instruction *i, uint64_t opc)
assert(!(code[1] & 0xc000));
code[1] |= (s == 2) ? 0x8000 : 0x4000;
code[1] |= i->getSrc(s)->reg.fileIndex << 10;
- setAddress16(i->src[s]);
+ setAddress16(i->src(s));
break;
case FILE_IMMEDIATE:
assert(s == 1 ||
@@ -310,7 +316,7 @@ CodeEmitterNVC0::emitForm_A(const Instruction *i, uint64_t opc)
case FILE_GPR:
if ((s == 2) && ((code[0] & 0x7) == 2)) // LIMM: 3rd src == dst
break;
- srcId(i->src[s], s ? ((s == 2) ? 49 : s1) : 20);
+ srcId(i->src(s), s ? ((s == 2) ? 49 : s1) : 20);
break;
default:
// ignore here, can be predicate or flags, but must not be address
@@ -327,20 +333,20 @@ CodeEmitterNVC0::emitForm_B(const Instruction *i, uint64_t opc)
emitPredicate(i);
- defId(i->def[0], 14);
+ defId(i->def(0), 14);
- switch (i->src[0].getFile()) {
+ switch (i->src(0).getFile()) {
case FILE_MEMORY_CONST:
assert(!(code[1] & 0xc000));
- code[1] |= 0x4000 | (i->src[0].get()->reg.fileIndex << 10);
- setAddress16(i->src[0]);
+ code[1] |= 0x4000 | (i->src(0).get()->reg.fileIndex << 10);
+ setAddress16(i->src(0));
break;
case FILE_IMMEDIATE:
assert(!(code[1] & 0xc000));
setImmediate(i, 0);
break;
case FILE_GPR:
- srcId(i->src[0], 26);
+ srcId(i->src(0), 26);
break;
default:
// ignore here, can be predicate or flags, but must not be address
@@ -357,17 +363,17 @@ CodeEmitterNVC0::emitForm_S(const Instruction *i, uint32_t opc, bool pred)
if (opc == 0x0d || opc == 0x0e)
ss2a = 2;
- defId(i->def[0], 14);
- srcId(i->src[0], 20);
+ defId(i->def(0), 14);
+ srcId(i->src(0), 20);
assert(pred || (i->predSrc < 0));
if (pred)
emitPredicate(i);
for (int s = 1; s < 3 && i->srcExists(s); ++s) {
- if (i->src[s].get()->reg.file == FILE_MEMORY_CONST) {
+ if (i->src(s).get()->reg.file == FILE_MEMORY_CONST) {
assert(!(code[0] & (0x300 >> ss2a)));
- switch (i->src[s].get()->reg.fileIndex) {
+ switch (i->src(s).get()->reg.fileIndex) {
case 0: code[0] |= 0x100 >> ss2a; break;
case 1: code[0] |= 0x200 >> ss2a; break;
case 16: code[0] |= 0x300 >> ss2a; break;
@@ -380,12 +386,12 @@ CodeEmitterNVC0::emitForm_S(const Instruction *i, uint32_t opc, bool pred)
else
code[0] |= i->getSrc(s)->reg.data.offset << 6;
} else
- if (i->src[s].getFile() == FILE_IMMEDIATE) {
+ if (i->src(s).getFile() == FILE_IMMEDIATE) {
assert(s == 1);
- setImmediateS8(i->src[s]);
+ setImmediateS8(i->src(s));
} else
- if (i->src[s].getFile() == FILE_GPR) {
- srcId(i->src[s], (s == 1) ? 26 : 8);
+ if (i->src(s).getFile() == FILE_GPR) {
+ srcId(i->src(s), (s == 1) ? 26 : 8);
}
}
}
@@ -420,15 +426,15 @@ CodeEmitterNVC0::emitNOP(const Instruction *i)
void
CodeEmitterNVC0::emitFMAD(const Instruction *i)
{
- bool neg1 = (i->src[0].mod ^ i->src[1].mod).neg();
+ bool neg1 = (i->src(0).mod ^ i->src(1).mod).neg();
if (i->encSize == 8) {
- if (isLIMM(i->src[1], TYPE_F32)) {
+ if (isLIMM(i->src(1), TYPE_F32)) {
emitForm_A(i, HEX64(20000000, 00000002));
} else {
emitForm_A(i, HEX64(30000000, 00000000));
- if (i->src[2].mod.neg())
+ if (i->src(2).mod.neg())
code[0] |= 1 << 8;
}
roundMode_A(i);
@@ -441,8 +447,8 @@ CodeEmitterNVC0::emitFMAD(const Instruction *i)
if (i->ftz)
code[0] |= 1 << 6;
} else {
- assert(!i->saturate && !i->src[2].mod.neg());
- emitForm_S(i, (i->src[2].getFile() == FILE_MEMORY_CONST) ? 0x2e : 0x0e,
+ assert(!i->saturate && !i->src(2).mod.neg());
+ emitForm_S(i, (i->src(2).getFile() == FILE_MEMORY_CONST) ? 0x2e : 0x0e,
false);
if (neg1)
code[0] |= 1 << 4;
@@ -452,12 +458,12 @@ CodeEmitterNVC0::emitFMAD(const Instruction *i)
void
CodeEmitterNVC0::emitFMUL(const Instruction *i)
{
- bool neg = (i->src[0].mod ^ i->src[1].mod).neg();
+ bool neg = (i->src(0).mod ^ i->src(1).mod).neg();
assert(i->postFactor >= -3 && i->postFactor <= 3);
if (i->encSize == 8) {
- if (isLIMM(i->src[1], TYPE_F32)) {
+ if (isLIMM(i->src(1), TYPE_F32)) {
assert(i->postFactor == 0); // constant folded, hopefully
emitForm_A(i, HEX64(30000000, 00000002));
} else {
@@ -487,7 +493,7 @@ void
CodeEmitterNVC0::emitUMUL(const Instruction *i)
{
if (i->encSize == 8) {
- if (i->src[1].getFile() == FILE_IMMEDIATE) {
+ if (i->src(1).getFile() == FILE_IMMEDIATE) {
emitForm_A(i, HEX64(10000000, 00000002));
} else {
emitForm_A(i, HEX64(50000000, 00000003));
@@ -499,7 +505,7 @@ CodeEmitterNVC0::emitUMUL(const Instruction *i)
if (i->dType == TYPE_S32)
code[0] |= 1 << 7;
} else {
- emitForm_S(i, i->src[1].getFile() == FILE_IMMEDIATE ? 0xaa : 0x2a, true);
+ emitForm_S(i, i->src(1).getFile() == FILE_IMMEDIATE ? 0xaa : 0x2a, true);
if (i->sType == TYPE_S32)
code[0] |= 1 << 6;
@@ -510,16 +516,16 @@ void
CodeEmitterNVC0::emitFADD(const Instruction *i)
{
if (i->encSize == 8) {
- if (isLIMM(i->src[1], TYPE_F32)) {
+ if (isLIMM(i->src(1), TYPE_F32)) {
assert(!i->saturate);
emitForm_A(i, HEX64(28000000, 00000002));
- code[0] |= i->src[0].mod.abs() << 7;
- code[0] |= i->src[0].mod.neg() << 9;
+ code[0] |= i->src(0).mod.abs() << 7;
+ code[0] |= i->src(0).mod.neg() << 9;
- if (i->src[1].mod.abs())
+ if (i->src(1).mod.abs())
code[1] &= 0xfdffffff;
- if ((i->op == OP_SUB) != static_cast<bool>(i->src[1].mod.neg()))
+ if ((i->op == OP_SUB) != static_cast<bool>(i->src(1).mod.neg()))
code[1] ^= 0x02000000;
} else {
emitForm_A(i, HEX64(50000000, 00000000));
@@ -535,12 +541,12 @@ CodeEmitterNVC0::emitFADD(const Instruction *i)
code[0] |= 1 << 5;
} else {
assert(!i->saturate && i->op != OP_SUB &&
- !i->src[0].mod.abs() &&
- !i->src[1].mod.neg() && !i->src[1].mod.abs());
+ !i->src(0).mod.abs() &&
+ !i->src(1).mod.neg() && !i->src(1).mod.abs());
emitForm_S(i, 0x49, true);
- if (i->src[0].mod.neg())
+ if (i->src(0).mod.neg())
code[0] |= 1 << 7;
}
}
@@ -550,12 +556,12 @@ CodeEmitterNVC0::emitUADD(const Instruction *i)
{
uint32_t addOp = 0;
- assert(!i->src[0].mod.abs() && !i->src[1].mod.abs());
- assert(!i->src[0].mod.neg() || !i->src[1].mod.neg());
+ assert(!i->src(0).mod.abs() && !i->src(1).mod.abs());
+ assert(!i->src(0).mod.neg() || !i->src(1).mod.neg());
- if (i->src[0].mod.neg())
+ if (i->src(0).mod.neg())
addOp |= 0x200;
- if (i->src[1].mod.neg())
+ if (i->src(1).mod.neg())
addOp |= 0x100;
if (i->op == OP_SUB) {
addOp ^= 0x100;
@@ -563,13 +569,13 @@ CodeEmitterNVC0::emitUADD(const Instruction *i)
}
if (i->encSize == 8) {
- if (isLIMM(i->src[1], TYPE_U32)) {
+ if (isLIMM(i->src(1), TYPE_U32)) {
emitForm_A(i, HEX64(08000000, 00000002));
- if (i->def[1].exists())
+ if (i->defExists(1))
code[1] |= 1 << 26; // write carry
} else {
emitForm_A(i, HEX64(48000000, 00000003));
- if (i->def[1].exists())
+ if (i->defExists(1))
code[1] |= 1 << 16; // write carry
}
code[0] |= addOp;
@@ -581,7 +587,7 @@ CodeEmitterNVC0::emitUADD(const Instruction *i)
} else {
assert(!(addOp & 0x100));
emitForm_S(i, (addOp >> 3) |
- ((i->src[1].getFile() == FILE_IMMEDIATE) ? 0xac : 0x2c), true);
+ ((i->src(1).getFile() == FILE_IMMEDIATE) ? 0xac : 0x2c), true);
}
}
@@ -602,9 +608,9 @@ CodeEmitterNVC0::emitIMAD(const Instruction *i)
if (i->flagsDef >= 0) code[1] |= 1 << 16;
if (i->flagsSrc >= 0) code[1] |= 1 << 23;
- if (i->src[2].mod.neg()) code[0] |= 0x10;
- if (i->src[1].mod.neg() ^
- i->src[0].mod.neg()) code[0] |= 0x20;
+ if (i->src(2).mod.neg()) code[0] |= 0x10;
+ if (i->src(1).mod.neg() ^
+ i->src(0).mod.neg()) code[0] |= 0x20;
if (i->subOp == NV50_IR_SUBOP_MUL_HIGH)
code[0] |= 1 << 6;
@@ -614,7 +620,7 @@ void
CodeEmitterNVC0::emitNOT(Instruction *i)
{
assert(i->encSize == 8);
- i->src[1].set(i->src[0]);
+ i->setSrc(1, i->src(0));
emitForm_A(i, HEX64(68000000, 000001c3));
}
@@ -622,27 +628,27 @@ void
CodeEmitterNVC0::emitLogicOp(const Instruction *i, uint8_t subOp)
{
if (i->encSize == 8) {
- if (isLIMM(i->src[1], TYPE_U32)) {
+ if (isLIMM(i->src(1), TYPE_U32)) {
emitForm_A(i, HEX64(38000000, 00000002));
- if (i->src[2].exists())
+ if (i->srcExists(2))
code[1] |= 1 << 26;
} else {
emitForm_A(i, HEX64(68000000, 00000003));
- if (i->src[2].exists())
+ if (i->srcExists(2))
code[1] |= 1 << 16;
}
code[0] |= subOp << 6;
- if (i->src[2].exists()) // carry
+ if (i->srcExists(2)) // carry
code[0] |= 1 << 5;
- if (i->src[0].mod & Modifier(NV50_IR_MOD_NOT)) code[0] |= 1 << 9;
- if (i->src[1].mod & Modifier(NV50_IR_MOD_NOT)) code[0] |= 1 << 8;
+ if (i->src(0).mod & Modifier(NV50_IR_MOD_NOT)) code[0] |= 1 << 9;
+ if (i->src(1).mod & Modifier(NV50_IR_MOD_NOT)) code[0] |= 1 << 8;
} else {
emitForm_S(i, (subOp << 5) |
- ((i->src[1].getFile() == FILE_IMMEDIATE) ? 0x1d : 0x8d), true);
+ ((i->src(1).getFile() == FILE_IMMEDIATE) ? 0x1d : 0x8d), true);
}
}
@@ -651,8 +657,8 @@ CodeEmitterNVC0::emitPOPC(const Instruction *i)
{
emitForm_A(i, HEX64(54000000, 00000004));
- if (i->src[0].mod & Modifier(NV50_IR_MOD_NOT)) code[0] |= 1 << 9;
- if (i->src[1].mod & Modifier(NV50_IR_MOD_NOT)) code[0] |= 1 << 8;
+ if (i->src(0).mod & Modifier(NV50_IR_MOD_NOT)) code[0] |= 1 << 9;
+ if (i->src(1).mod & Modifier(NV50_IR_MOD_NOT)) code[0] |= 1 << 8;
}
void
@@ -684,8 +690,8 @@ CodeEmitterNVC0::emitPreOp(const Instruction *i)
if (i->op == OP_PREEX2)
code[0] |= 0x20;
- if (i->src[0].mod.abs()) code[0] |= 1 << 6;
- if (i->src[0].mod.neg()) code[0] |= 1 << 8;
+ if (i->src(0).mod.abs()) code[0] |= 1 << 6;
+ if (i->src(0).mod.neg()) code[0] |= 1 << 8;
} else {
emitForm_S(i, i->op == OP_PREEX2 ? 0x74000008 : 0x70000008, true);
}
@@ -700,20 +706,20 @@ CodeEmitterNVC0::emitSFnOp(const Instruction *i, uint8_t subOp)
emitPredicate(i);
- defId(i->def[0], 14);
- srcId(i->src[0], 20);
+ defId(i->def(0), 14);
+ srcId(i->src(0), 20);
- assert(i->src[0].getFile() == FILE_GPR);
+ assert(i->src(0).getFile() == FILE_GPR);
if (i->saturate) code[0] |= 1 << 5;
- if (i->src[0].mod.abs()) code[0] |= 1 << 7;
- if (i->src[0].mod.neg()) code[0] |= 1 << 9;
+ if (i->src(0).mod.abs()) code[0] |= 1 << 7;
+ if (i->src(0).mod.neg()) code[0] |= 1 << 9;
} else {
emitForm_S(i, 0x80000008 | (subOp << 26), true);
- assert(!i->src[0].mod.neg());
- if (i->src[0].mod.abs()) code[0] |= 1 << 30;
+ assert(!i->src(0).mod.neg());
+ if (i->src(0).mod.abs()) code[0] |= 1 << 30;
}
}
@@ -783,8 +789,8 @@ CodeEmitterNVC0::emitCVT(Instruction *i)
}
const bool sat = (i->op == OP_SAT) || i->saturate;
- const bool abs = (i->op == OP_ABS) || i->src[0].mod.abs();
- const bool neg = (i->op == OP_NEG) || i->src[0].mod.neg();
+ const bool abs = (i->op == OP_ABS) || i->src(0).mod.abs();
+ const bool neg = (i->op == OP_NEG) || i->src(0).mod.neg();
if (i->encSize == 8) {
emitForm_B(i, HEX64(10000000, 00000004));
@@ -867,16 +873,16 @@ CodeEmitterNVC0::emitSET(const CmpInstruction *i)
}
emitForm_A(i, (static_cast<uint64_t>(hi) << 32) | lo);
- if (i->def[0].getFile() == FILE_PREDICATE) {
+ if (i->def(0).getFile() == FILE_PREDICATE) {
if (i->sType == TYPE_F32)
code[1] += 0x10000000;
else
code[1] += 0x08000000;
code[0] &= ~0xfc000;
- defId(i->def[0], 17);
+ defId(i->def(0), 17);
if (i->defExists(1))
- defId(i->def[1], 14);
+ defId(i->def(1), 14);
else
code[0] |= 0x1c000;
}
@@ -912,7 +918,7 @@ CodeEmitterNVC0::emitSLCT(const CmpInstruction *i)
CondCode cc = i->setCond;
- if (i->src[2].mod.neg())
+ if (i->src(2).mod.neg())
cc = reverseCondCode(cc);
emitCondCode(cc, 32 + 23);
@@ -925,7 +931,7 @@ void CodeEmitterNVC0::emitSELP(const Instruction *i)
{
emitForm_A(i, HEX64(20000000, 00000004));
- if (i->cc == CC_NOT_P || i->src[2].mod & Modifier(NV50_IR_MOD_NOT))
+ if (i->cc == CC_NOT_P || i->src(2).mod & Modifier(NV50_IR_MOD_NOT))
code[1] |= 1 << 20;
}
@@ -940,8 +946,8 @@ void CodeEmitterNVC0::emitTEXCSAA(const TexInstruction *i)
if (i->tex.liveOnly)
code[0] |= 1 << 9;
- defId(i->def[0], 14);
- srcId(i->src[0], 20);
+ defId(i->def(0), 14);
+ srcId(i->src(0), 20);
}
void
@@ -977,8 +983,8 @@ CodeEmitterNVC0::emitTEX(const TexInstruction *i)
if (i->tex.derivAll)
code[1] |= 1 << 13;
- defId(i->def[0], 14);
- srcId(i->src[0], 20);
+ defId(i->def(0), 14);
+ srcId(i->src(0), 20);
emitPredicate(i);
@@ -1004,7 +1010,8 @@ CodeEmitterNVC0::emitTEX(const TexInstruction *i)
if (i->op == OP_TXD && i->tex.useOffsets)
++src1;
- if (i->src[src1].getFile() == FILE_IMMEDIATE) { // lzero
+ if (i->srcExists(src1) && i->src(src1).getFile() == FILE_IMMEDIATE) {
+ // lzero
if (i->op == OP_TXL)
code[1] &= ~(1 << 26);
else
@@ -1018,7 +1025,7 @@ CodeEmitterNVC0::emitTEX(const TexInstruction *i)
if (i->tex.useOffsets) // in vecSrc0.w
code[1] |= 1 << 22;
- srcId(i->src[src1], 26);
+ srcId(i, src1, 26);
}
void
@@ -1046,9 +1053,9 @@ CodeEmitterNVC0::emitTXQ(const TexInstruction *i)
if (i->tex.sIndirectSrc >= 0 || i->tex.rIndirectSrc >= 0)
code[1] |= 1 << 18;
- defId(i->def[0], 14);
- srcId(i->src[0], 20);
- srcId(i->src[1], 26);
+ defId(i->def(0), 14);
+ srcId(i->src(0), 20);
+ srcId(i->src(1), 26);
emitPredicate(i);
}
@@ -1059,9 +1066,9 @@ CodeEmitterNVC0::emitQUADOP(const Instruction *i, uint8_t qOp, uint8_t laneMask)
code[0] = 0x00000000 | (laneMask << 6);
code[1] = 0x48000000 | qOp;
- defId(i->def[0], 14);
- srcId(i->src[0], 20);
- srcId(i->srcExists(1) ? i->src[1] : i->src[0], 26);
+ defId(i->def(0), 14);
+ srcId(i->src(0), 20);
+ srcId(i->srcExists(1) ? i->src(1) : i->src(0), 26);
if (i->op == OP_QUADOP && progType != Program::TYPE_FRAGMENT)
code[0] |= 1 << 9; // dall
@@ -1081,15 +1088,14 @@ CodeEmitterNVC0::emitFlow(const Instruction *i)
switch (i->op) {
case OP_BRA:
code[1] = f->absolute ? 0x00000000 : 0x40000000;
- if (i->src[0].getFile() == FILE_MEMORY_CONST ||
- i->src[1].getFile() == FILE_MEMORY_CONST)
- code[1] |= 0x4000;
+ if (i->srcExists(0) && i->src(0).getFile() == FILE_MEMORY_CONST)
+ code[0] |= 0x4000;
mask = 3;
break;
case OP_CALL:
code[1] = f->absolute ? 0x10000000 : 0x50000000;
- if (i->src[0].getFile() == FILE_MEMORY_CONST)
- code[1] |= 0x4000;
+ if (i->srcExists(0) && i->src(0).getFile() == FILE_MEMORY_CONST)
+ code[0] |= 0x4000;
mask = 2;
break;
@@ -1151,22 +1157,22 @@ CodeEmitterNVC0::emitFlow(const Instruction *i)
void
CodeEmitterNVC0::emitPFETCH(const Instruction *i)
{
- uint32_t prim = i->src[0].get()->reg.data.u32;
+ uint32_t prim = i->src(0).get()->reg.data.u32;
code[0] = 0x00000006 | ((prim & 0x3f) << 26);
code[1] = 0x00000000 | (prim >> 6);
emitPredicate(i);
- defId(i->def[0], 14);
- srcId(i->src[1], 20);
+ defId(i->def(0), 14);
+ srcId(i->src(1), 20);
}
void
CodeEmitterNVC0::emitVFETCH(const Instruction *i)
{
code[0] = 0x00000006;
- code[1] = 0x06000000 | i->src[0].get()->reg.data.offset;
+ code[1] = 0x06000000 | i->src(0).get()->reg.data.offset;
if (i->perPatch)
code[0] |= 0x100;
@@ -1177,9 +1183,9 @@ CodeEmitterNVC0::emitVFETCH(const Instruction *i)
code[0] |= (i->defCount(0xf) - 1) << 5;
- defId(i->def[0], 14);
- srcId(i->src[0].getIndirect(0), 20);
- srcId(i->src[0].getIndirect(1), 26); // vertex address
+ defId(i->def(0), 14);
+ srcId(i->src(0).getIndirect(0), 20);
+ srcId(i->src(0).getIndirect(1), 26); // vertex address
}
void
@@ -1188,7 +1194,7 @@ CodeEmitterNVC0::emitEXPORT(const Instruction *i)
unsigned int size = typeSizeof(i->dType);
code[0] = 0x00000006 | ((size / 4 - 1) << 5);
- code[1] = 0x0a000000 | i->src[0].get()->reg.data.offset;
+ code[1] = 0x0a000000 | i->src(0).get()->reg.data.offset;
assert(!(code[1] & ((size == 12) ? 15 : (size - 1))));
@@ -1197,11 +1203,11 @@ CodeEmitterNVC0::emitEXPORT(const Instruction *i)
emitPredicate(i);
- assert(i->src[1].getFile() == FILE_GPR);
+ assert(i->src(1).getFile() == FILE_GPR);
- srcId(i->src[0].getIndirect(0), 20);
- srcId(i->src[0].getIndirect(1), 32 + 17); // vertex base address
- srcId(i->src[1], 26);
+ srcId(i->src(0).getIndirect(0), 20);
+ srcId(i->src(0).getIndirect(1), 32 + 17); // vertex base address
+ srcId(i->src(1), 26);
}
void
@@ -1212,10 +1218,10 @@ CodeEmitterNVC0::emitOUT(const Instruction *i)
emitPredicate(i);
- defId(i->def[0], 14); // new secret address
- srcId(i->src[0], 20); // old secret address, should be 0 initially
+ defId(i->def(0), 14); // new secret address
+ srcId(i->src(0), 20); // old secret address, should be 0 initially
- assert(i->src[0].getFile() == FILE_GPR);
+ assert(i->src(0).getFile() == FILE_GPR);
if (i->op == OP_EMIT)
code[0] |= 1 << 5;
@@ -1223,11 +1229,11 @@ CodeEmitterNVC0::emitOUT(const Instruction *i)
code[0] |= 1 << 6;
// vertex stream
- if (i->src[1].getFile() == FILE_IMMEDIATE) {
+ if (i->src(1).getFile() == FILE_IMMEDIATE) {
code[1] |= 0xc000;
- code[0] |= SDATA(i->src[1]).u32 << 26;
+ code[0] |= SDATA(i->src(1)).u32 << 26;
} else {
- srcId(i->src[1], 26);
+ srcId(i->src(1), 26);
}
}
@@ -1256,23 +1262,23 @@ CodeEmitterNVC0::emitINTERP(const Instruction *i)
code[0] |= 1 << 5;
if (i->op == OP_PINTERP)
- srcId(i->src[1], 26);
+ srcId(i->src(1), 26);
else
code[0] |= 0x3f << 26;
- srcId(i->src[0].getIndirect(0), 20);
+ srcId(i->src(0).getIndirect(0), 20);
} else {
assert(i->op == OP_PINTERP);
code[0] = 0x00000009 | ((base & 0xc) << 6) | ((base >> 4) << 26);
- srcId(i->src[1], 20);
+ srcId(i->src(1), 20);
}
emitInterpMode(i);
emitPredicate(i);
- defId(i->def[0], 14);
+ defId(i->def(0), 14);
if (i->getSampleMode() == NV50_IR_INTERP_OFFSET)
- srcId(i->src[i->op == OP_PINTERP ? 2 : 1], 17);
+ srcId(i->src(i->op == OP_PINTERP ? 2 : 1), 17);
else
code[1] |= 0x3f << 17;
}
@@ -1350,7 +1356,7 @@ CodeEmitterNVC0::emitSTORE(const Instruction *i)
{
uint32_t opc;
- switch (i->src[0].getFile()) {
+ switch (i->src(0).getFile()) {
case FILE_MEMORY_GLOBAL: opc = 0x90000000; break;
case FILE_MEMORY_LOCAL: opc = 0xc8000000; break;
case FILE_MEMORY_SHARED: opc = 0xc9000000; break;
@@ -1362,9 +1368,9 @@ CodeEmitterNVC0::emitSTORE(const Instruction *i)
code[0] = 0x00000005;
code[1] = opc;
- setAddress16(i->src[0]);
- srcId(i->src[1], 14);
- srcId(i->src[0].getIndirect(0), 20);
+ setAddress16(i->src(0));
+ srcId(i->src(1), 14);
+ srcId(i->src(0).getIndirect(0), 20);
emitPredicate(i);
@@ -1379,16 +1385,16 @@ CodeEmitterNVC0::emitLOAD(const Instruction *i)
code[0] = 0x00000005;
- switch (i->src[0].getFile()) {
+ switch (i->src(0).getFile()) {
case FILE_MEMORY_GLOBAL: opc = 0x80000000; break;
case FILE_MEMORY_LOCAL: opc = 0xc0000000; break;
case FILE_MEMORY_SHARED: opc = 0xc1000000; break;
case FILE_MEMORY_CONST:
- if (!i->src[0].isIndirect(0) && typeSizeof(i->dType) == 4) {
+ if (!i->src(0).isIndirect(0) && typeSizeof(i->dType) == 4) {
emitMOV(i); // not sure if this is any better
return;
}
- opc = 0x14000000 | (i->src[0].get()->reg.fileIndex << 10);
+ opc = 0x14000000 | (i->src(0).get()->reg.fileIndex << 10);
code[0] = 0x00000006 | (i->subOp << 8);
break;
default:
@@ -1398,10 +1404,10 @@ CodeEmitterNVC0::emitLOAD(const Instruction *i)
}
code[1] = opc;
- defId(i->def[0], 14);
+ defId(i->def(0), 14);
- setAddress16(i->src[0]);
- srcId(i->src[0].getIndirect(0), 20);
+ setAddress16(i->src(0));
+ srcId(i->src(0).getIndirect(0), 20);
emitPredicate(i);
@@ -1435,8 +1441,8 @@ CodeEmitterNVC0::getSRegEncoding(const ValueRef& ref)
void
CodeEmitterNVC0::emitMOV(const Instruction *i)
{
- if (i->src[0].getFile() == FILE_SYSTEM_VALUE) {
- uint8_t sr = getSRegEncoding(i->src[0]);
+ if (i->src(0).getFile() == FILE_SYSTEM_VALUE) {
+ uint8_t sr = getSRegEncoding(i->src(0));
if (i->encSize == 8) {
code[0] = 0x00000004 | (sr << 26);
@@ -1444,17 +1450,17 @@ CodeEmitterNVC0::emitMOV(const Instruction *i)
} else {
code[0] = 0x40000008 | (sr << 20);
}
- defId(i->def[0], 14);
+ defId(i->def(0), 14);
emitPredicate(i);
} else
if (i->encSize == 8) {
uint64_t opc;
- if (i->src[0].getFile() == FILE_IMMEDIATE)
+ if (i->src(0).getFile() == FILE_IMMEDIATE)
opc = HEX64(18000000, 000001e2);
else
- if (i->src[0].getFile() == FILE_PREDICATE)
+ if (i->src(0).getFile() == FILE_PREDICATE)
opc = HEX64(080e0000, 1c000004);
else
opc = HEX64(28000000, 00000004);
@@ -1465,8 +1471,8 @@ CodeEmitterNVC0::emitMOV(const Instruction *i)
} else {
uint32_t imm;
- if (i->src[0].getFile() == FILE_IMMEDIATE) {
- imm = SDATA(i->src[0]).u32;
+ if (i->src(0).getFile() == FILE_IMMEDIATE) {
+ imm = SDATA(i->src(0)).u32;
if (imm & 0xfff00000) {
assert(!(imm & 0x000fffff));
code[0] = 0x00000318 | imm;
@@ -1476,9 +1482,9 @@ CodeEmitterNVC0::emitMOV(const Instruction *i)
}
} else {
code[0] = 0x0028;
- emitShortSrc2(i->src[0]);
+ emitShortSrc2(i->src(0));
}
- defId(i->def[0], 14);
+ defId(i->def(0), 14);
emitPredicate(i);
}
@@ -1498,7 +1504,7 @@ CodeEmitterNVC0::emitInstruction(Instruction *insn)
// assert that instructions with multiple defs don't corrupt registers
for (int d = 0; insn->defExists(d); ++d)
- assert(insn->asTex() || insn->def[d].rep()->reg.data.id >= 0);
+ assert(insn->asTex() || insn->def(d).rep()->reg.data.id >= 0);
switch (insn->op) {
case OP_MOV:
@@ -1643,10 +1649,10 @@ CodeEmitterNVC0::emitInstruction(Instruction *insn)
emitQUADOP(insn, insn->subOp, insn->lanes);
break;
case OP_DFDX:
- emitQUADOP(insn, insn->src[0].mod.neg() ? 0x66 : 0x99, 0x4);
+ emitQUADOP(insn, insn->src(0).mod.neg() ? 0x66 : 0x99, 0x4);
break;
case OP_DFDY:
- emitQUADOP(insn, insn->src[0].mod.neg() ? 0x5a : 0xa5, 0x5);
+ emitQUADOP(insn, insn->src(0).mod.neg() ? 0x5a : 0xa5, 0x5);
break;
case OP_POPCNT:
emitPOPC(insn);
@@ -1705,33 +1711,33 @@ CodeEmitterNVC0::getMinEncodingSize(const Instruction *i) const
}
for (int s = 0; i->srcExists(s); ++s) {
- if (i->src[s].isIndirect(0))
+ if (i->src(s).isIndirect(0))
return 8;
- if (i->src[s].getFile() == FILE_MEMORY_CONST) {
- if (SDATA(i->src[s]).offset >= 0x100)
+ if (i->src(s).getFile() == FILE_MEMORY_CONST) {
+ if (SDATA(i->src(s)).offset >= 0x100)
return 8;
if (i->getSrc(s)->reg.fileIndex > 1 &&
i->getSrc(s)->reg.fileIndex != 16)
return 8;
} else
- if (i->src[s].getFile() == FILE_IMMEDIATE) {
+ if (i->src(s).getFile() == FILE_IMMEDIATE) {
if (i->dType == TYPE_F32) {
- if (SDATA(i->src[s]).u32 >= 0x100)
+ if (SDATA(i->src(s)).u32 >= 0x100)
return 8;
} else {
- if (SDATA(i->src[s]).u32 > 0xff)
+ if (SDATA(i->src(s)).u32 > 0xff)
return 8;
}
}
if (i->op == OP_CVT)
continue;
- if (i->src[s].mod != Modifier(0)) {
- if (i->src[s].mod == Modifier(NV50_IR_MOD_ABS))
+ if (i->src(s).mod != Modifier(0)) {
+ if (i->src(s).mod == Modifier(NV50_IR_MOD_ABS))
if (i->op != OP_RSQ)
return 8;
- if (i->src[s].mod == Modifier(NV50_IR_MOD_NEG))
+ if (i->src(s).mod == Modifier(NV50_IR_MOD_NEG))
if (i->op != OP_ADD || s != 0)
return 8;
}
diff --git a/src/gallium/drivers/nvc0/codegen/nv50_ir_lowering_nvc0.cpp b/src/gallium/drivers/nvc0/codegen/nv50_ir_lowering_nvc0.cpp
index 1c19651f1cf..6eb0bf48928 100644
--- a/src/gallium/drivers/nvc0/codegen/nv50_ir_lowering_nvc0.cpp
+++ b/src/gallium/drivers/nvc0/codegen/nv50_ir_lowering_nvc0.cpp
@@ -220,7 +220,7 @@ NVC0LegalizePostRA::visit(BasicBlock *bb)
if (i->op == OP_EMIT || i->op == OP_RESTART) {
if (!i->getDef(0)->refCount())
i->setDef(0, NULL);
- if (i->src[0].getFile() == FILE_IMMEDIATE)
+ if (i->src(0).getFile() == FILE_IMMEDIATE)
i->setSrc(0, r63); // initial value must be 0
} else
if (i->isNop()) {
@@ -421,7 +421,7 @@ NVC0LoweringPass::handleTXD(TexInstruction *txd)
int arg = txd->tex.target.getDim() + txd->tex.target.isArray();
handleTEX(txd);
- while (txd->src[arg].exists())
+ while (txd->src(arg).exists())
++arg;
txd->tex.derivAll = true;
@@ -431,10 +431,10 @@ NVC0LoweringPass::handleTXD(TexInstruction *txd)
assert(arg <= 4); // at most s/t/array, x, y, offset
for (int c = 0; c < dim; ++c) {
- txd->src[arg + c * 2 + 0].set(txd->dPdx[c]);
- txd->src[arg + c * 2 + 1].set(txd->dPdy[c]);
- txd->dPdx[c] = NULL;
- txd->dPdy[c] = NULL;
+ txd->src(arg + c * 2 + 0).set(txd->dPdx[c]);
+ txd->src(arg + c * 2 + 1).set(txd->dPdy[c]);
+ txd->dPdx[c].set(NULL);
+ txd->dPdy[c].set(NULL);
}
return true;
}
@@ -600,10 +600,10 @@ NVC0LoweringPass::handleEXPORT(Instruction *i)
if (prog->getType() == Program::TYPE_FRAGMENT) {
int id = i->getSrc(0)->reg.data.offset / 4;
- if (i->src[0].isIndirect(0)) // TODO, ugly
+ if (i->src(0).isIndirect(0)) // TODO, ugly
return false;
i->op = OP_MOV;
- i->src[0].set(i->src[1]);
+ i->src(0).set(i->src(1));
i->setSrc(1, NULL);
i->setDef(0, new_LValue(func, FILE_GPR));
i->getDef(0)->reg.data.id = id;
@@ -698,7 +698,7 @@ NVC0LoweringPass::visit(Instruction *i)
case OP_WRSV:
return handleWRSV(i);
case OP_LOAD:
- if (i->src[0].getFile() == FILE_SHADER_INPUT) {
+ if (i->src(0).getFile() == FILE_SHADER_INPUT) {
i->op = OP_VFETCH;
assert(prog->getType() != Program::TYPE_FRAGMENT);
}
diff --git a/src/gallium/drivers/nvc0/codegen/nv50_ir_target_nvc0.cpp b/src/gallium/drivers/nvc0/codegen/nv50_ir_target_nvc0.cpp
index 6fe95c6693f..8f34cacd81b 100644
--- a/src/gallium/drivers/nvc0/codegen/nv50_ir_target_nvc0.cpp
+++ b/src/gallium/drivers/nvc0/codegen/nv50_ir_target_nvc0.cpp
@@ -388,7 +388,7 @@ bool
TargetNVC0::insnCanLoad(const Instruction *i, int s,
const Instruction *ld) const
{
- DataFile sf = ld->src[0].getFile();
+ DataFile sf = ld->src(0).getFile();
// immediate 0 can be represented by GPR $r63
if (sf == FILE_IMMEDIATE && ld->getSrc(0)->reg.data.u64 == 0)
@@ -400,16 +400,16 @@ TargetNVC0::insnCanLoad(const Instruction *i, int s,
return false;
// indirect loads can only be done by OP_LOAD/VFETCH/INTERP on nvc0
- if (ld->src[0].isIndirect(0))
+ if (ld->src(0).isIndirect(0))
return false;
for (int k = 0; i->srcExists(k); ++k) {
- if (i->src[k].getFile() == FILE_IMMEDIATE) {
+ if (i->src(k).getFile() == FILE_IMMEDIATE) {
if (i->getSrc(k)->reg.data.u64 != 0)
return false;
} else
- if (i->src[k].getFile() != FILE_GPR &&
- i->src[k].getFile() != FILE_PREDICATE) {
+ if (i->src(k).getFile() != FILE_GPR &&
+ i->src(k).getFile() != FILE_PREDICATE) {
return false;
}
}
@@ -478,12 +478,12 @@ TargetNVC0::isModSupported(const Instruction *insn, int s, Modifier mod) const
case OP_XOR:
break;
case OP_ADD:
- if (insn->src[s ? 0 : 1].mod.neg())
+ if (insn->src(s ? 0 : 1).mod.neg())
return false;
break;
case OP_SUB:
if (s == 0)
- return insn->src[1].mod.neg() ? false : true;
+ return insn->src(1).mod.neg() ? false : true;
break;
default:
return false;