implement mul
authorZack Rusin <zack@tungstengraphics.com>
Wed, 13 Feb 2008 08:18:37 +0000 (03:18 -0500)
committerZack Rusin <zack@tungstengraphics.com>
Wed, 13 Feb 2008 08:18:37 +0000 (03:18 -0500)
src/mesa/pipe/llvm/instructionssoa.cpp
src/mesa/pipe/llvm/instructionssoa.h

index 0e501ab08d0fc250a06adc09439b419befd8e627..f1c174a26e5e1832ad2420393086278386b5d60f 100644 (file)
@@ -2,7 +2,8 @@
 
 InstructionsSoa::InstructionsSoa(llvm::Module *mod, llvm::Function *func,
                                  llvm::BasicBlock *block, StorageSoa *storage)
-   : m_builder(block)
+   : m_builder(block),
+     m_idx(0)
 {
 }
 
@@ -19,6 +20,11 @@ std::vector<llvm::Value*> InstructionsSoa::mul(const std::vector<llvm::Value*> i
 {
    std::vector<llvm::Value*> res(4);
 
+   res[0] = m_builder.CreateMul(in1[0], in2[0], name("mul"));
+   res[1] = m_builder.CreateMul(in1[1], in2[1], name("mul"));
+   res[2] = m_builder.CreateMul(in1[2], in2[2], name("mul"));
+   res[3] = m_builder.CreateMul(in1[3], in2[3], name("mul"));
+
    return res;
 }
 
@@ -26,3 +32,10 @@ void InstructionsSoa::end()
 {
    m_builder.CreateRetVoid();
 }
+
+const char * InstructionsSoa::name(const char *prefix) const
+{
+   ++m_idx;
+   snprintf(m_name, 32, "%s%d", prefix, m_idx);
+   return m_name;
+}
index 233d363b90629329b131a8356692865af607980a..0195501584499e03bfde50936d46ef45d9ce5e11 100644 (file)
@@ -51,8 +51,15 @@ public:
    std::vector<llvm::Value*> mul(const std::vector<llvm::Value*> in1,
                                  const std::vector<llvm::Value*> in2);
    void         end();
+
+private:
+   const char * name(const char *prefix) const;
 private:
    llvm::LLVMFoldingBuilder  m_builder;
+
+private:
+   mutable int  m_idx;
+   mutable char m_name[32];
 };