summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorZack Rusin <zack@pixel.(none)>2008-03-01 08:32:31 -0500
committerZack Rusin <[email protected]>2008-03-01 15:28:00 -0500
commit17f543fc4529ca4ce7f73a840ed0fb50d1fec925 (patch)
tree121d1aae6cbfe0ce4ea494c394cb2983228df9f6 /src/gallium/auxiliary
parente884c7ed9a14aabaa86f6710c594d20812ed11d9 (diff)
make the first builtin work (dp3)
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/gallivm/gallivm.cpp10
-rw-r--r--src/gallium/auxiliary/gallivm/instructionssoa.cpp41
2 files changed, 33 insertions, 18 deletions
diff --git a/src/gallium/auxiliary/gallivm/gallivm.cpp b/src/gallium/auxiliary/gallivm/gallivm.cpp
index d14bb3b99a8..b6f641a3f86 100644
--- a/src/gallium/auxiliary/gallivm/gallivm.cpp
+++ b/src/gallium/auxiliary/gallivm/gallivm.cpp
@@ -306,11 +306,19 @@ struct gallivm_prog * gallivm_ir_compile(struct gallivm_ir *ir)
{
struct gallivm_prog *prog =
(struct gallivm_prog *)calloc(1, sizeof(struct gallivm_prog));
+
+ std::cout << "Before optimizations:"<<std::endl;
+ ir->module->dump();
+ std::cout<<"-------------------------------"<<std::endl;
+
+ PassManager veri;
+ veri.add(createVerifierPass());
+ veri.run(*ir->module);
llvm::Module *mod = llvm::CloneModule(ir->module);
prog->num_consts = ir->num_consts;
memcpy(prog->interpolators, ir->interpolators, sizeof(prog->interpolators));
prog->num_interp = ir->num_interp;
-
+
/* Run optimization passes over it */
PassManager passes;
passes.add(new TargetData(mod));
diff --git a/src/gallium/auxiliary/gallivm/instructionssoa.cpp b/src/gallium/auxiliary/gallivm/instructionssoa.cpp
index 5739cf0cdef..3fcfce8ce01 100644
--- a/src/gallium/auxiliary/gallivm/instructionssoa.cpp
+++ b/src/gallium/auxiliary/gallivm/instructionssoa.cpp
@@ -158,6 +158,7 @@ llvm::Function * InstructionsSoa::function(int op)
currentModule()->getFunctionList().push_back(func);
std::cout << "Func parent is "<<func->getParent()
<<", cur is "<<currentModule() <<std::endl;
+ func->dump();
//func->setParent(currentModule());
m_functions[op] = func;
return func;
@@ -184,8 +185,15 @@ std::vector<llvm::Value*> InstructionsSoa::dp3(const std::vector<llvm::Value*> i
std::vector<Value*> params;
llvm::Value *tmp = allocaTemp();
- params.push_back(tmp);
-
+ std::vector<Value*> indices;
+ indices.push_back(m_storage->constantInt(0));
+ indices.push_back(m_storage->constantInt(0));
+ GetElementPtrInst *getElem = new GetElementPtrInst(tmp,
+ indices.begin(),
+ indices.end(),
+ name("allocaPtr"),
+ m_builder.GetInsertBlock());
+ params.push_back(getElem);
params.push_back(in1[0]);
params.push_back(in1[1]);
params.push_back(in1[2]);
@@ -194,20 +202,10 @@ std::vector<llvm::Value*> InstructionsSoa::dp3(const std::vector<llvm::Value*> i
params.push_back(in2[1]);
params.push_back(in2[2]);
params.push_back(in2[3]);
- CallInst *call = m_builder.CreateCall(func, params.begin(), params.end(),
- name("dp3"));
+ CallInst *call = m_builder.CreateCall(func, params.begin(), params.end());
call->setCallingConv(CallingConv::C);
call->setTailCall(false);
- std::vector<Value*> indices;
- indices.push_back(m_storage->constantInt(0));
- indices.push_back(m_storage->constantInt(0));
-
- GetElementPtrInst *getElem = new GetElementPtrInst(tmp,
- indices.begin(),
- indices.end(),
- name("allocaPtr"),
- m_builder.GetInsertBlock());
indices = std::vector<Value*>();
indices.push_back(m_storage->constantInt(0));
GetElementPtrInst *xElemPtr = new GetElementPtrInst(getElem,
@@ -228,10 +226,19 @@ std::vector<llvm::Value*> InstructionsSoa::dp3(const std::vector<llvm::Value*> i
m_builder.GetInsertBlock());
std::vector<llvm::Value*> res(4);
- res[0] = new LoadInst(xElemPtr);
- res[1] = new LoadInst(yElemPtr);
- res[2] = new LoadInst(zElemPtr);
- res[3] = new LoadInst(wElemPtr);
+ res[0] = new LoadInst(xElemPtr, name("xRes"), false, m_builder.GetInsertBlock());
+ res[1] = new LoadInst(yElemPtr, name("yRes"), false, m_builder.GetInsertBlock());
+ res[2] = new LoadInst(zElemPtr, name("zRes"), false, m_builder.GetInsertBlock());
+ res[3] = new LoadInst(wElemPtr, name("wRes"), false, m_builder.GetInsertBlock());
return res;
}
+
+llvm::Value * InstructionsSoa::allocaTemp()
+{
+ VectorType *vector = VectorType::get(Type::FloatTy, 4);
+ ArrayType *vecArray = ArrayType::get(vector, 4);
+ AllocaInst *alloca = new AllocaInst(vecArray, name("tmpRes"),
+ m_builder.GetInsertBlock());
+ return alloca;
+}