return insn;
}
-LValue *
-BuildUtil::mkLoad(DataType ty, Symbol *mem, Value *ptr)
+Instruction *
+BuildUtil::mkLoad(DataType ty, Value *dst, Symbol *mem, Value *ptr)
{
Instruction *insn = new_Instruction(func, OP_LOAD, ty);
- LValue *def = getScratch();
- insn->setDef(0, def);
+ insn->setDef(0, dst);
insn->setSrc(0, mem);
if (ptr)
insn->setIndirect(0, 0, ptr);
insert(insn);
- return def;
+ return insn;
}
Instruction *
if (!sym)
sym = insert(m, i, c, mkSymbol(i, c));
- return up->mkLoad(typeOfSize(eltSize), static_cast<Symbol *>(sym), ptr);
+ return up->mkLoadv(typeOfSize(eltSize), static_cast<Symbol *>(sym), ptr);
}
}
LValue *mkOp2v(operation, DataType, Value *, Value *, Value *);
LValue *mkOp3v(operation, DataType, Value *, Value *, Value *, Value *);
- LValue *mkLoad(DataType, Symbol *, Value *ptr);
+ Instruction *mkLoad(DataType, Value *dst, Symbol *, Value *ptr);
Instruction *mkStore(operation, DataType, Symbol *, Value *ptr, Value *val);
+ LValue *mkLoadv(DataType, Symbol *, Value *ptr);
+
Instruction *mkMov(Value *, Value *, DataType = TYPE_U32);
Instruction *mkMovToReg(int id, Value *);
Instruction *mkMovFromReg(Value *, int id);
return dst->asLValue();
}
+inline LValue *
+BuildUtil::mkLoadv(DataType ty, Symbol *mem, Value *ptr)
+{
+ LValue *dst = getScratch();
+ mkLoad(ty, dst, mem, ptr);
+ return dst;
+}
+
bool
BuildUtil::DataArray::exists(ValueMap &m, unsigned int i, unsigned int c)
{
assert(!ptr);
return loadImm(NULL, info->immd.data[idx * 4 + swz]);
case TGSI_FILE_CONSTANT:
- return mkLoad(TYPE_U32, srcToSym(src, c), ptr);
+ return mkLoadv(TYPE_U32, srcToSym(src, c), ptr);
case TGSI_FILE_INPUT:
if (prog->getType() == Program::TYPE_FRAGMENT) {
// don't load masked inputs, won't be assigned a slot
return mkOp1v(OP_RDSV, TYPE_F32, getSSA(), mkSysVal(SV_FACE, 0));
return interpolate(src, c, ptr);
}
- return mkLoad(TYPE_U32, srcToSym(src, c), ptr);
+ return mkLoadv(TYPE_U32, srcToSym(src, c), ptr);
case TGSI_FILE_OUTPUT:
assert(!"load from output file");
return NULL;
for (i = 0; i < info->io.genUserClip; ++i) {
Symbol *sym = mkSymbol(FILE_MEMORY_CONST, info->io.ucpBinding,
TYPE_F32, info->io.ucpBase + i * 16 + c * 4);
- Value *ucp = mkLoad(TYPE_F32, sym, NULL);
+ Value *ucp = mkLoadv(TYPE_F32, sym, NULL);
if (c == 0)
res[i] = mkOp2v(OP_MUL, TYPE_F32, getScratch(), clipVtx[c], ucp);
else
tmp[0] = bld.getScratch();
bind = bld.mkSymbol(FILE_MEMORY_CONST, 15, TYPE_U32, i->tex.r * 4);
bld.mkOp2(OP_SHL, TYPE_U32, tmp[0], rRel, shCnt);
- tmp[1] = bld.mkLoad(TYPE_U32, bind, tmp[0]);
+ tmp[1] = bld.mkLoadv(TYPE_U32, bind, tmp[0]);
bld.mkOp2(OP_AND, TYPE_U32, tmp[0], tmp[1],
bld.loadImm(tmp[0], 0x00ffffffu));
rRel = tmp[0];
tmp[0] = bld.getScratch();
bind = bld.mkSymbol(FILE_MEMORY_CONST, 15, TYPE_U32, i->tex.s * 4);
bld.mkOp2(OP_SHL, TYPE_U32, tmp[0], sRel, shCnt);
- tmp[1] = bld.mkLoad(TYPE_U32, bind, tmp[0]);
+ tmp[1] = bld.mkLoadv(TYPE_U32, bind, tmp[0]);
bld.mkOp2(OP_AND, TYPE_U32, tmp[0], tmp[1],
bld.loadImm(tmp[0], 0xff000000u));
sRel = tmp[0];