diff options
Diffstat (limited to 'src/mesa/pipe/llvm')
-rw-r--r-- | src/mesa/pipe/llvm/llvmtgsi.cpp | 20 | ||||
-rw-r--r-- | src/mesa/pipe/llvm/storage.cpp | 15 | ||||
-rw-r--r-- | src/mesa/pipe/llvm/storage.h | 4 |
3 files changed, 37 insertions, 2 deletions
diff --git a/src/mesa/pipe/llvm/llvmtgsi.cpp b/src/mesa/pipe/llvm/llvmtgsi.cpp index 4611ac1766..ec38c695b9 100644 --- a/src/mesa/pipe/llvm/llvmtgsi.cpp +++ b/src/mesa/pipe/llvm/llvmtgsi.cpp @@ -164,9 +164,23 @@ translate_declaration(llvm::Module *module, static void -translate_immediate(llvm::Module *module, +translate_immediate(Storage *storage, struct tgsi_full_immediate *imm) { + float vec[4]; + int i; + for (i = 0; i < imm->Immediate.Size - 1; ++i) { + switch( imm->Immediate.DataType ) { + case TGSI_IMM_FLOAT32: + vec[i] = imm->u.ImmediateFloat32[i].Float; + break; + default: + assert( 0 ); + } + } + printf("-------------- VEC = %f %f %f %f\n", + vec[0], vec[1], vec[2], vec[3]); + storage->addImmediate(vec); } static void @@ -200,6 +214,8 @@ translate_instruction(llvm::Module *module, val = storage->tempElement(src->SrcRegister.Index); } else if (src->SrcRegister.File == TGSI_FILE_OUTPUT) { val = storage->outputElement(src->SrcRegister.Index, indIdx); + } else if (src->SrcRegister.File == TGSI_FILE_IMMEDIATE) { + val = storage->immediateElement(src->SrcRegister.Index); } else { fprintf(stderr, "ERROR: not supported llvm source %d\n", src->SrcRegister.File); return; @@ -679,7 +695,7 @@ tgsi_to_llvm(struct gallivm_prog *prog, const struct tgsi_token *tokens) break; case TGSI_TOKEN_TYPE_IMMEDIATE: - translate_immediate(mod, + translate_immediate(&storage, &parse.FullToken.FullImmediate); break; diff --git a/src/mesa/pipe/llvm/storage.cpp b/src/mesa/pipe/llvm/storage.cpp index ff62fcf3e4..1aaabbe882 100644 --- a/src/mesa/pipe/llvm/storage.cpp +++ b/src/mesa/pipe/llvm/storage.cpp @@ -393,3 +393,18 @@ void Storage::popTemps() m_tempStack.pop(); } #endif //MESA_LLVM + +llvm::Value * Storage::immediateElement(int idx) +{ + return m_immediates[idx]; +} + +void Storage::addImmediate(float *val) +{ + std::vector<Constant*> vec(4); + vec[0] = ConstantFP::get(Type::FloatTy, APFloat(val[0])); + vec[1] = ConstantFP::get(Type::FloatTy, APFloat(val[1])); + vec[2] = ConstantFP::get(Type::FloatTy, APFloat(val[2])); + vec[3] = ConstantFP::get(Type::FloatTy, APFloat(val[3])); + m_immediates.push_back(ConstantVector::get(m_floatVecType, vec)); +} diff --git a/src/mesa/pipe/llvm/storage.h b/src/mesa/pipe/llvm/storage.h index ac3e4d5af9..f9a82ef857 100644 --- a/src/mesa/pipe/llvm/storage.h +++ b/src/mesa/pipe/llvm/storage.h @@ -65,6 +65,7 @@ public: 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 *immediateElement(int idx); llvm::Value *tempElement(int idx); void setTempElement(int idx, llvm::Value *val, int mask); @@ -87,6 +88,8 @@ public: void pushTemps(); void popTemps(); + void addImmediate(float *val); + private: llvm::Value *maskWrite(llvm::Value *src, int mask, llvm::Value *templ); const char *name(const char *prefix); @@ -102,6 +105,7 @@ private: std::vector<llvm::Value*> m_temps; std::vector<llvm::Value*> m_addrs; std::vector<llvm::Value*> m_dstCache; + std::vector<llvm::Constant*> m_immediates; llvm::VectorType *m_floatVecType; llvm::VectorType *m_intVecType; |