Make branching work :) Simply allow output variables as valid
authorZack Rusin <zack@tungstengraphics.com>
Wed, 24 Oct 2007 23:26:09 +0000 (19:26 -0400)
committerZack Rusin <zack@tungstengraphics.com>
Wed, 24 Oct 2007 23:26:09 +0000 (19:26 -0400)
operand inputs when they've been assigned already.

src/mesa/pipe/llvm/llvmtgsi.cpp
src/mesa/pipe/llvm/storage.cpp
src/mesa/pipe/llvm/storage.h

index ec284a624af24d90b568400edfa89987ff53d010..93dd2ea46a9d67717c83e2fd7e796a8e3cf134d6 100644 (file)
@@ -195,8 +195,8 @@ translate_instruction(llvm::Module *module,
          val = storage->inputElement(src->SrcRegister.Index, indIdx);
       } else if (src->SrcRegister.File == TGSI_FILE_TEMPORARY) {
          val = storage->tempElement(src->SrcRegister.Index);
-      } else if (src->SrcRegister.File == TGSI_FILE_TEMPORARY) {
-         fprintf(stderr, "FIXME: do somethign with immediates?\n");
+      } else if (src->SrcRegister.File == TGSI_FILE_OUTPUT) {
+         val = storage->outputElement(src->SrcRegister.Index, indIdx);
       } else {
          fprintf(stderr, "ERROR: not supported llvm source %d\n", src->SrcRegister.File);
          return;
index 6721f387c812536974ef74d386e7be1b1ba5fd99..603053c0e8fed684ab88e7a6deb09fb4cd3744a8 100644 (file)
@@ -310,3 +310,31 @@ void Storage::declareTemp(int idx)
 {
     m_temps[idx] = new AllocaInst(m_floatVecType, name("temp"), m_block);
 }
+
+llvm::Value * Storage::outputElement(int idx, llvm::Value *indIdx )
+{
+    GetElementPtrInst *getElem = 0;
+
+   if (indIdx) {
+      getElem = new GetElementPtrInst(m_IN,
+                                      BinaryOperator::create(Instruction::Add,
+                                                             indIdx,
+                                                             constantInt(idx),
+                                                             name("add"),
+                                                             m_block),
+                                      name("output_ptr"),
+                                      m_block);
+   } else {
+      getElem = new GetElementPtrInst(m_IN,
+                                      constantInt(idx),
+                                      name("output_ptr"),
+                                      m_block);
+   }
+
+   LoadInst *load = new LoadInst(getElem, name("output"),
+                                 false, m_block);
+   load->setAlignment(8);
+   m_inputs[idx] = load;
+
+   return load;
+}
index 26b2579b07067d0ca187548c835f668417098379..dd5de35073c09a8243d11e2931943af878745c5a 100644 (file)
@@ -59,6 +59,7 @@ public:
    llvm::Constant *shuffleMask(int vec);
    llvm::Value *inputElement(int idx, llvm::Value *indIdx =0);
    llvm::Value *constElement(int idx, llvm::Value *indIdx =0);
+   llvm::Value *outputElement(int idx, llvm::Value *indIdx =0);
 
    llvm::Value *tempElement(int idx);
    void setTempElement(int idx, llvm::Value *val, int mask);