src->SrcRegisterExtSwz.ExtSwizzleY != TGSI_EXTSWIZZLE_Y ||
src->SrcRegisterExtSwz.ExtSwizzleZ != TGSI_EXTSWIZZLE_Z ||
src->SrcRegisterExtSwz.ExtSwizzleW != TGSI_EXTSWIZZLE_W) {
- int swizzle = src->SrcRegisterExtSwz.ExtSwizzleX * 1000;
- swizzle += src->SrcRegisterExtSwz.ExtSwizzleY * 100;
- swizzle += src->SrcRegisterExtSwz.ExtSwizzleZ * 10;
- swizzle += src->SrcRegisterExtSwz.ExtSwizzleW * 1;
+ int swizzle = 0;
+
+ if (src->SrcRegisterExtSwz.ExtSwizzleX != TGSI_EXTSWIZZLE_X)
+ swizzle = src->SrcRegisterExtSwz.ExtSwizzleX * 1000;
+ else
+ swizzle = src->SrcRegister.SwizzleX * 1000;
+ if (src->SrcRegisterExtSwz.ExtSwizzleY != TGSI_EXTSWIZZLE_Y)
+ swizzle += src->SrcRegisterExtSwz.ExtSwizzleY * 100;
+ else
+ swizzle += src->SrcRegister.SwizzleY * 100;
+ if (src->SrcRegisterExtSwz.ExtSwizzleZ != TGSI_EXTSWIZZLE_Z)
+ swizzle += src->SrcRegisterExtSwz.ExtSwizzleZ * 10;
+ else
+ swizzle += src->SrcRegister.SwizzleZ * 10;
+ if (src->SrcRegisterExtSwz.ExtSwizzleW != TGSI_EXTSWIZZLE_W)
+ swizzle += src->SrcRegisterExtSwz.ExtSwizzleW * 1;
+ else
+ swizzle += src->SrcRegister.SwizzleW * 1;
+ /*fprintf(stderr, "EXT XXXXXXXX swizzle x = %d\n", swizzle);*/
+
val = storage->shuffleVector(val, swizzle);
}
} else if (src->SrcRegister.SwizzleX != TGSI_SWIZZLE_X ||
swizzle += src->SrcRegister.SwizzleY * 100;
swizzle += src->SrcRegister.SwizzleZ * 10;
swizzle += src->SrcRegister.SwizzleW * 1;
+ /*fprintf(stderr, "XXXXXXXX swizzle = %d\n", swizzle);*/
val = storage->shuffleVector(val, swizzle);
}
inputs[i] = val;
}
/*if (inputs[0])
- instr->printVector(inputs[0]);*/
+ instr->printVector(inputs[0]);
+ if (inputs[1])
+ instr->printVector(inputs[1]);*/
llvm::Value *out = 0;
switch (inst->Instruction.Opcode) {
case TGSI_OPCODE_ARL:
m_undefFloatVec = UndefValue::get(m_floatVecType);
m_undefIntVec = UndefValue::get(m_intVecType);
+ m_extSwizzleVec = 0;
m_numConsts = 0;
}
//can only build vectors with all members in the [0, 9] range
llvm::Constant *Storage::shuffleMask(int vec)
{
+ if (!m_extSwizzleVec) {
+ Constant *const_vec = Constant::getNullValue(m_floatVecType);
+ InsertElementInst *res = new InsertElementInst(const_vec,
+ ConstantFP::get(Type::FloatTy, APFloat(0.f)),
+ unsigned(0),
+ name("extswx"), m_block);
+ res = new InsertElementInst(res, ConstantFP::get(Type::FloatTy, APFloat(1.f)),
+ unsigned(1),
+ name("extswy"),
+ m_block);
+ res = new InsertElementInst(res, ConstantFP::get(Type::FloatTy, APFloat(0.f)),
+ unsigned(2),
+ name("extswz"),
+ m_block);
+ res = new InsertElementInst(res, ConstantFP::get(Type::FloatTy, APFloat(1.f)),
+ unsigned(3),
+ name("extsww"),
+ m_block);
+ m_extSwizzleVec = res;
+ }
+
if (m_intVecs.find(vec) != m_intVecs.end()) {
return m_intVecs[vec];
}
false, m_block);
load->setAlignment(8);
m_inputs[idx] = load;
+
return load;
}
{
Constant *mask = shuffleMask(shuffle);
ShuffleVectorInst *res =
- new ShuffleVectorInst(vec, m_undefFloatVec, mask,
+ new ShuffleVectorInst(vec, m_extSwizzleVec, mask,
name("shuffle"), m_block);
return res;
}