diff options
author | Zack Rusin <[email protected]> | 2007-10-29 10:59:24 -0400 |
---|---|---|
committer | Zack Rusin <[email protected]> | 2007-10-30 05:15:05 -0400 |
commit | b0f3b5910ebd0737600ab7b1fdc135d74f2617f4 (patch) | |
tree | 2e4ebcc7f6d13ea151aac92cd3f19741a0bf0845 /src/mesa/pipe | |
parent | 8b2f997af572dd3aca00c4888adf2b0a60656331 (diff) |
Enable immediates in TGSI and work with them in LLVM code.
Enables immediates by default in the TGSI translation code
and adds code handling it in llvm tgsi translation.
Diffstat (limited to 'src/mesa/pipe')
-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 4611ac17664..ec38c695b93 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 ff62fcf3e49..1aaabbe8828 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 ac3e4d5af97..f9a82ef857d 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; |