summaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe/llvm/instructions.cpp
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2007-11-02 11:47:09 -0400
committerZack Rusin <[email protected]>2007-11-02 11:47:09 -0400
commit5c7bfb06e087ce4162590359ad75d1fca98f3549 (patch)
tree31156ef549c67612c0f396d813d5b916ba482dbe /src/mesa/pipe/llvm/instructions.cpp
parentcf363ba30746ee0fd46b97986ea9fd753e093039 (diff)
Implement COS and CMP opcode.
There's some weird rounding issue with COS that I can't figure out.
Diffstat (limited to 'src/mesa/pipe/llvm/instructions.cpp')
-rw-r--r--src/mesa/pipe/llvm/instructions.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/mesa/pipe/llvm/instructions.cpp b/src/mesa/pipe/llvm/instructions.cpp
index aa6e1085989..8e74ab3e94b 100644
--- a/src/mesa/pipe/llvm/instructions.cpp
+++ b/src/mesa/pipe/llvm/instructions.cpp
@@ -87,7 +87,7 @@ llvm::Value * Instructions::madd(llvm::Value *in1, llvm::Value *in2,
Value *mulRes = mul(in1, in2);
return add(mulRes, in3);
}
-
+
llvm::Value * Instructions::mul(llvm::Value *in1, llvm::Value *in2)
{
return m_builder.CreateMul(in1, in2, name("mul"));
@@ -830,7 +830,38 @@ std::vector<llvm::Value*> Instructions::extractVector(llvm::Value *vec)
return elems;
}
-#endif //MESA_LLVM
+llvm::Value * Instructions::cmp(llvm::Value *in1, llvm::Value *in2, llvm::Value *in3)
+{
+ llvm::Function *func = m_mod->getFunction("cmp");
+ assert(func);
+ std::vector<Value*> params;
+ params.push_back(in1);
+ params.push_back(in2);
+ params.push_back(in3);
+ CallInst *call = m_builder.CreateCall(func, params.begin(), params.end(), name("cmpres"));
+ call->setTailCall(false);
+ return call;
+}
+llvm::Value * Instructions::cos(llvm::Value *in)
+{
+#if 0
+ llvm::Function *func = m_mod->getFunction("vcos");
+ assert(func);
+
+ CallInst *call = m_builder.CreateCall(func, in, name("cosres"));
+ call->setTailCall(false);
+ return call;
+#else
+ std::vector<llvm::Value*> elems = extractVector(in);
+ Function *func = m_mod->getFunction("cosf");
+ assert(func);
+ CallInst *cos = m_builder.CreateCall(func, elems[0], name("cosres"));
+ cos->setCallingConv(CallingConv::C);
+ cos->setTailCall(true);
+ return vectorFromVals(cos, cos, cos, cos);
+#endif
+}
+#endif //MESA_LLVM