summaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe/llvm/storagesoa.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/pipe/llvm/storagesoa.cpp')
-rw-r--r--src/mesa/pipe/llvm/storagesoa.cpp156
1 files changed, 51 insertions, 105 deletions
diff --git a/src/mesa/pipe/llvm/storagesoa.cpp b/src/mesa/pipe/llvm/storagesoa.cpp
index 314ffe62dc3..ed0674a96f0 100644
--- a/src/mesa/pipe/llvm/storagesoa.cpp
+++ b/src/mesa/pipe/llvm/storagesoa.cpp
@@ -132,40 +132,27 @@ llvm::Value *StorageSoa::addrElement(int idx) const
return res;
}
-std::vector<llvm::Value*> StorageSoa::inputElement(int idx, llvm::Value *indIdx)
+std::vector<llvm::Value*> StorageSoa::inputElement(llvm::Value *idx)
{
std::vector<llvm::Value*> res(4);
- if (!indIdx) {
- res[0] = element(m_input, idx, 0);
- res[1] = element(m_input, idx, 1);
- res[2] = element(m_input, idx, 2);
- res[3] = element(m_input, idx, 3);
- } else {
- res[0] = indirectElement(m_input, indIdx, 0);
- res[1] = indirectElement(m_input, indIdx, 1);
- res[2] = indirectElement(m_input, indIdx, 2);
- res[3] = indirectElement(m_input, indIdx, 3);
- }
+ res[0] = element(m_input, idx, 0);
+ res[1] = element(m_input, idx, 1);
+ res[2] = element(m_input, idx, 2);
+ res[3] = element(m_input, idx, 3);
return res;
}
-std::vector<llvm::Value*> StorageSoa::constElement(int idx, llvm::Value *indIdx)
+std::vector<llvm::Value*> StorageSoa::constElement(llvm::Value *idx)
{
std::vector<llvm::Value*> res(4);
llvm::Value *xChannel, *yChannel, *zChannel, *wChannel;
- if (!indIdx) {
- xChannel = elementPointer(m_consts, idx, 0);
- yChannel = elementPointer(m_consts, idx, 1);
- zChannel = elementPointer(m_consts, idx, 2);
- wChannel = elementPointer(m_consts, idx, 3);
- } else {
- xChannel = indirectElementPointer(m_consts, indIdx, 0);
- yChannel = indirectElementPointer(m_consts, indIdx, 1);
- zChannel = indirectElementPointer(m_consts, indIdx, 2);
- wChannel = indirectElementPointer(m_consts, indIdx, 3);
- }
+
+ xChannel = elementPointer(m_consts, idx, 0);
+ yChannel = elementPointer(m_consts, idx, 1);
+ zChannel = elementPointer(m_consts, idx, 2);
+ wChannel = elementPointer(m_consts, idx, 3);
res[0] = alignedArrayLoad(xChannel);
res[1] = alignedArrayLoad(yChannel);
@@ -175,70 +162,49 @@ std::vector<llvm::Value*> StorageSoa::constElement(int idx, llvm::Value *indIdx)
return res;
}
-std::vector<llvm::Value*> StorageSoa::outputElement(int idx, llvm::Value *indIdx)
+std::vector<llvm::Value*> StorageSoa::outputElement(llvm::Value *idx)
{
std::vector<llvm::Value*> res(4);
- if (!indIdx) {
- res[0] = element(m_output, idx, 0);
- res[1] = element(m_output, idx, 1);
- res[2] = element(m_output, idx, 2);
- res[3] = element(m_output, idx, 3);
- } else {
- res[0] = indirectElement(m_output, indIdx, 0);
- res[1] = indirectElement(m_output, indIdx, 1);
- res[2] = indirectElement(m_output, indIdx, 2);
- res[3] = indirectElement(m_output, indIdx, 3);
- }
+ res[0] = element(m_output, idx, 0);
+ res[1] = element(m_output, idx, 1);
+ res[2] = element(m_output, idx, 2);
+ res[3] = element(m_output, idx, 3);
return res;
}
-std::vector<llvm::Value*> StorageSoa::tempElement(int idx, llvm::Value *indIdx)
+std::vector<llvm::Value*> StorageSoa::tempElement(llvm::Value *idx)
{
std::vector<llvm::Value*> res(4);
- if (!indIdx) {
- res[0] = element(m_temps, idx, 0);
- res[1] = element(m_temps, idx, 1);
- res[2] = element(m_temps, idx, 2);
- res[3] = element(m_temps, idx, 3);
- } else {
- res[0] = indirectElement(m_temps, indIdx, 0);
- res[1] = indirectElement(m_temps, indIdx, 1);
- res[2] = indirectElement(m_temps, indIdx, 2);
- res[3] = indirectElement(m_temps, indIdx, 3);
- }
+ res[0] = element(m_temps, idx, 0);
+ res[1] = element(m_temps, idx, 1);
+ res[2] = element(m_temps, idx, 2);
+ res[3] = element(m_temps, idx, 3);
return res;
}
-std::vector<llvm::Value*> StorageSoa::immediateElement(int idx, llvm::Value *indIdx)
+std::vector<llvm::Value*> StorageSoa::immediateElement(llvm::Value *idx)
{
std::vector<llvm::Value*> res(4);
- if (!indIdx) {
- res[0] = element(m_immediates, idx, 0);
- res[1] = element(m_immediates, idx, 1);
- res[2] = element(m_immediates, idx, 2);
- res[3] = element(m_immediates, idx, 3);
- } else {
- res[0] = indirectElement(m_immediates, indIdx, 0);
- res[1] = indirectElement(m_immediates, indIdx, 1);
- res[2] = indirectElement(m_immediates, indIdx, 2);
- res[3] = indirectElement(m_immediates, indIdx, 3);
- }
+ res[0] = element(m_immediates, idx, 0);
+ res[1] = element(m_immediates, idx, 1);
+ res[2] = element(m_immediates, idx, 2);
+ res[3] = element(m_immediates, idx, 3);
return res;
}
-llvm::Value * StorageSoa::elementPointer(llvm::Value *ptr, int index,
+llvm::Value * StorageSoa::elementPointer(llvm::Value *ptr, llvm::Value *index,
int channel) const
{
std::vector<Value*> indices;
if (m_immediates == ptr)
indices.push_back(constantInt(0));
- indices.push_back(constantInt(index));
+ indices.push_back(index);
indices.push_back(constantInt(channel));
GetElementPtrInst *getElem = new GetElementPtrInst(ptr,
@@ -249,7 +215,7 @@ llvm::Value * StorageSoa::elementPointer(llvm::Value *ptr, int index,
return getElem;
}
-llvm::Value * StorageSoa::element(llvm::Value *ptr, int index,
+llvm::Value * StorageSoa::element(llvm::Value *ptr, llvm::Value *index,
int channel) const
{
llvm::Value *res = elementPointer(ptr, index, channel);
@@ -315,23 +281,31 @@ std::vector<llvm::Value*> StorageSoa::load(Argument type, int idx, int swizzle,
llvm::Value *indIdx)
{
std::vector<llvm::Value*> val(4);
- debug_printf("XXXXXXXXX indIdx = %p\n", indIdx);
- assert(!indIdx);
+
+ //if we have an indirect index, always use that
+ // if not use the integer offset to create one
+ llvm::Value *realIndex = 0;
+ if (indIdx)
+ realIndex = indIdx;
+ else
+ realIndex = constantInt(idx);
+ debug_printf("XXXXXXXXX realIdx = %p, indIdx = %p\n", realIndex, indIdx);
+
switch(type) {
case Input:
- val = inputElement(idx, indIdx);
+ val = inputElement(realIndex);
break;
case Output:
- val = outputElement(idx, indIdx);
+ val = outputElement(realIndex);
break;
case Temp:
- val = tempElement(idx, indIdx);
+ val = tempElement(realIndex);
break;
case Const:
- val = constElement(idx, indIdx);
+ val = constElement(realIndex);
break;
case Immediate:
- val = immediateElement(idx, indIdx);
+ val = immediateElement(realIndex);
break;
case Address:
debug_printf("Address not handled in the load phase!\n");
@@ -380,64 +354,36 @@ void StorageSoa::store(Argument type, int idx, const std::vector<llvm::Value*> &
assert(0);
break;
}
-
+ llvm::Value *realIndex = constantInt(idx);
if ((mask & TGSI_WRITEMASK_X)) {
- llvm::Value *xChannel = elementPointer(out, idx, 0);
+ llvm::Value *xChannel = elementPointer(out, realIndex, 0);
new StoreInst(val[0], xChannel, false, m_block);
}
if ((mask & TGSI_WRITEMASK_Y)) {
- llvm::Value *yChannel = elementPointer(out, idx, 1);
+ llvm::Value *yChannel = elementPointer(out, realIndex, 1);
new StoreInst(val[1], yChannel, false, m_block);
}
if ((mask & TGSI_WRITEMASK_Z)) {
- llvm::Value *zChannel = elementPointer(out, idx, 2);
+ llvm::Value *zChannel = elementPointer(out, realIndex, 2);
new StoreInst(val[2], zChannel, false, m_block);
}
if ((mask & TGSI_WRITEMASK_W)) {
- llvm::Value *wChannel = elementPointer(out, idx, 3);
+ llvm::Value *wChannel = elementPointer(out, realIndex, 3);
new StoreInst(val[3], wChannel, false, m_block);
}
}
void StorageSoa::addAddress(int idx)
{
- VectorType *vectorType = VectorType::get(Type::FloatTy, 4);
GlobalVariable *val = new GlobalVariable(
- /*Type=*/vectorType,
+ /*Type=*/IntegerType::get(32),
/*isConstant=*/false,
/*Linkage=*/GlobalValue::ExternalLinkage,
/*Initializer=*/0, // has initializer, specified below
/*Name=*/name("address"),
currentModule());
- //val->setInitializer(Constant::getNullValue(IntegerType::get(32)));
- //val->setInitializer(constantInt(1));
+ val->setInitializer(Constant::getNullValue(IntegerType::get(32)));
debug_printf("adding to %d\n", idx);
m_addresses[idx] = val;
}
-
-llvm::Value * StorageSoa::indirectElementPointer(llvm::Value *ptr, llvm::Value *indIdx,
- int channel) const
-{
- std::vector<Value*> indices;
- if (m_immediates == ptr)
- indices.push_back(constantInt(0));
- indices.push_back(indIdx);
- indices.push_back(constantInt(channel));
-
- GetElementPtrInst *getElem = new GetElementPtrInst(ptr,
- indices.begin(),
- indices.end(),
- name("ptr"),
- m_block);
- return getElem;
-}
-
-llvm::Value * StorageSoa::indirectElement(llvm::Value *ptr, llvm::Value *indIdx,
- int channel) const
-{
- llvm::Value *res = indirectElementPointer(ptr, indIdx, channel);
- LoadInst *load = new LoadInst(res, name("element"), false, m_block);
- //load->setAlignment(8);
- return load;
-}