aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe/llvm/instructions.cpp
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2007-10-29 13:42:58 -0400
committerZack Rusin <[email protected]>2007-10-30 05:15:06 -0400
commita94251d081b202e81bcd51db0dd35f1aec82b0c5 (patch)
tree083b286140b6a6dc0a8f7bec79e663ee69541534 /src/mesa/pipe/llvm/instructions.cpp
parent75a9018fb90c93033ee5cbade9dd2febdc195d11 (diff)
Cleanup constant vector handling a bit.
Diffstat (limited to 'src/mesa/pipe/llvm/instructions.cpp')
-rw-r--r--src/mesa/pipe/llvm/instructions.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/mesa/pipe/llvm/instructions.cpp b/src/mesa/pipe/llvm/instructions.cpp
index 2eac0edbc4d..3c68b764aa5 100644
--- a/src/mesa/pipe/llvm/instructions.cpp
+++ b/src/mesa/pipe/llvm/instructions.cpp
@@ -466,12 +466,8 @@ llvm::Value * Instructions::lg2(llvm::Value *in)
ExtractElementInst *w = new ExtractElementInst(in, unsigned(3),
name("extractw"),
m_block);
- llvm::Value *const_vec = vectorFromVals(
- ConstantFP::get(Type::FloatTy, APFloat(1.442695f)),
- ConstantFP::get(Type::FloatTy, APFloat(1.442695f)),
- ConstantFP::get(Type::FloatTy, APFloat(1.442695f)),
- ConstantFP::get(Type::FloatTy, APFloat(1.442695f))
- );
+ llvm::Value *const_vec = constVector(1.442695f, 1.442695f,
+ 1.442695f, 1.442695f);
return mul(vectorFromVals(callFLog(x), callFLog(y),
callFLog(z), callFLog(w)), const_vec);
}
@@ -1016,14 +1012,7 @@ llvm::Value * Instructions::lerp(llvm::Value *in1, llvm::Value *in2,
llvm::Value *in3)
{
llvm::Value *m = mul(in1, in2);
- llvm::Value *vec1 = vectorFromVals(ConstantFP::get(Type::FloatTy,
- APFloat(1.f)),
- ConstantFP::get(Type::FloatTy,
- APFloat(1.f)),
- ConstantFP::get(Type::FloatTy,
- APFloat(1.f)),
- ConstantFP::get(Type::FloatTy,
- APFloat(1.f)));
+ llvm::Value *vec1 = constVector(1.f, 1.f, 1.f, 1.f);
llvm::Value *s = sub(vec1, in1);
return add(m, mul(s, in3));
}
@@ -1170,4 +1159,15 @@ llvm::Function * Instructions::findFunction(int label)
return func;
}
+llvm::Value * Instructions::constVector(float x, float y, float z, float w)
+{
+ std::vector<Constant*> vec(4);
+ vec[0] = ConstantFP::get(Type::FloatTy, APFloat(x));
+ vec[1] = ConstantFP::get(Type::FloatTy, APFloat(y));
+ vec[2] = ConstantFP::get(Type::FloatTy, APFloat(z));
+ vec[3] = ConstantFP::get(Type::FloatTy, APFloat(w));
+ return ConstantVector::get(m_floatVecType, vec);
+}
+
#endif //MESA_LLVM
+