summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/llvm/instructionssoa.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/pipe/llvm/instructionssoa.cpp')
-rw-r--r--src/mesa/pipe/llvm/instructionssoa.cpp64
1 files changed, 60 insertions, 4 deletions
diff --git a/src/mesa/pipe/llvm/instructionssoa.cpp b/src/mesa/pipe/llvm/instructionssoa.cpp
index 0c2032e56f..1e144393e0 100644
--- a/src/mesa/pipe/llvm/instructionssoa.cpp
+++ b/src/mesa/pipe/llvm/instructionssoa.cpp
@@ -1,12 +1,67 @@
#include "instructionssoa.h"
+#include "storagesoa.h"
+
+#include <llvm/Constants.h>
+
+using namespace llvm;
+
InstructionsSoa::InstructionsSoa(llvm::Module *mod, llvm::Function *func,
llvm::BasicBlock *block, StorageSoa *storage)
: m_builder(block),
+ m_storage(storage),
m_idx(0)
{
}
+const char * InstructionsSoa::name(const char *prefix) const
+{
+ ++m_idx;
+ snprintf(m_name, 32, "%s%d", prefix, m_idx);
+ return m_name;
+}
+
+llvm::Value * InstructionsSoa::vectorFromVals(llvm::Value *x, llvm::Value *y,
+ llvm::Value *z, llvm::Value *w)
+{
+ VectorType *vectorType = VectorType::get(Type::FloatTy, 4);
+ Constant *constVector = Constant::getNullValue(vectorType);
+ Value *res = m_builder.CreateInsertElement(constVector, x,
+ m_storage->constantInt(0),
+ name("vecx"));
+ res = m_builder.CreateInsertElement(res, y, m_storage->constantInt(1),
+ name("vecxy"));
+ res = m_builder.CreateInsertElement(res, z, m_storage->constantInt(2),
+ name("vecxyz"));
+ if (w)
+ res = m_builder.CreateInsertElement(res, w, m_storage->constantInt(3),
+ name("vecxyzw"));
+ return res;
+}
+
+std::vector<llvm::Value*> InstructionsSoa::arl(const std::vector<llvm::Value*> in)
+{
+ std::vector<llvm::Value*> res(4);
+
+ //Extract the first x (all 4 should be the same)
+ llvm::Value *x = m_builder.CreateExtractElement(in[0],
+ m_storage->constantInt(0),
+ name("extractX"));
+ //cast it to an unsigned int
+ x = m_builder.CreateFPToUI(x, IntegerType::get(32), name("xIntCast"));
+
+ res[0] = x;
+ //only x is valid. the others shouldn't be necessary
+ /*
+ res[1] = Constant::getNullValue(m_floatVecType);
+ res[2] = Constant::getNullValue(m_floatVecType);
+ res[3] = Constant::getNullValue(m_floatVecType);
+ */
+
+ return res;
+}
+
+
std::vector<llvm::Value*> InstructionsSoa::add(const std::vector<llvm::Value*> in1,
const std::vector<llvm::Value*> in2)
{
@@ -38,9 +93,10 @@ void InstructionsSoa::end()
m_builder.CreateRetVoid();
}
-const char * InstructionsSoa::name(const char *prefix) const
+std::vector<llvm::Value*> InstructionsSoa::madd(const std::vector<llvm::Value*> in1,
+ const std::vector<llvm::Value*> in2,
+ const std::vector<llvm::Value*> in3)
{
- ++m_idx;
- snprintf(m_name, 32, "%s%d", prefix, m_idx);
- return m_name;
+ std::vector<llvm::Value*> res = mul(in1, in2);
+ return add(res, in3);
}