diff options
author | Zack Rusin <[email protected]> | 2007-10-17 13:34:25 -0400 |
---|---|---|
committer | Zack Rusin <[email protected]> | 2007-10-24 11:21:04 -0400 |
commit | 7abe3364b2c463fd3e96c2bc9d07aaa91bcfbc2c (patch) | |
tree | b12db4c361215d69e3afb5094c8c3fa1c5ed3f60 | |
parent | e20294be114c2593035afaf6fe0726e0ce628ed0 (diff) |
Implement dot4 opcode
-rw-r--r-- | src/mesa/pipe/llvm/instructions.cpp | 27 | ||||
-rw-r--r-- | src/mesa/pipe/llvm/instructions.h | 1 | ||||
-rw-r--r-- | src/mesa/pipe/llvm/llvmtgsi.cpp | 12 |
3 files changed, 35 insertions, 5 deletions
diff --git a/src/mesa/pipe/llvm/instructions.cpp b/src/mesa/pipe/llvm/instructions.cpp index 31729d0f586..9e3b989600b 100644 --- a/src/mesa/pipe/llvm/instructions.cpp +++ b/src/mesa/pipe/llvm/instructions.cpp @@ -226,3 +226,30 @@ llvm::Value * Instructions::rcp(llvm::Value *in1) return vectorFromVals(res, res, res, res); } +llvm::Value * Instructions::dp4(llvm::Value *in1, llvm::Value *in2) +{ + Value *mulRes = mul(in1, in2); + ExtractElementInst *x = new ExtractElementInst(mulRes, unsigned(0), + name("extractx"), + m_block); + ExtractElementInst *y = new ExtractElementInst(mulRes, unsigned(1), + name("extracty"), + m_block); + ExtractElementInst *z = new ExtractElementInst(mulRes, unsigned(2), + name("extractz"), + m_block); + ExtractElementInst *w = new ExtractElementInst(mulRes, unsigned(3), + name("extractw"), + m_block); + BinaryOperator *xy = BinaryOperator::create(Instruction::Add, x, y, + name("xy"), + m_block); + BinaryOperator *xyz = BinaryOperator::create(Instruction::Add, xy, z, + name("xyz"), + m_block); + BinaryOperator *dot4 = BinaryOperator::create(Instruction::Add, xyz, w, + name("dot4"), + m_block); + return vectorFromVals(dot4, dot4, dot4, dot4); +} + diff --git a/src/mesa/pipe/llvm/instructions.h b/src/mesa/pipe/llvm/instructions.h index 18b5f91131e..c35cdb75f01 100644 --- a/src/mesa/pipe/llvm/instructions.h +++ b/src/mesa/pipe/llvm/instructions.h @@ -16,6 +16,7 @@ public: llvm::Value *add(llvm::Value *in1, llvm::Value *in2); llvm::Value *dp3(llvm::Value *in1, llvm::Value *in2); + llvm::Value *dp4(llvm::Value *in1, llvm::Value *in2); llvm::Value *lit(llvm::Value *in1); llvm::Value *madd(llvm::Value *in1, llvm::Value *in2, llvm::Value *in2); diff --git a/src/mesa/pipe/llvm/llvmtgsi.cpp b/src/mesa/pipe/llvm/llvmtgsi.cpp index 45114abe4e3..45bc96cb1af 100644 --- a/src/mesa/pipe/llvm/llvmtgsi.cpp +++ b/src/mesa/pipe/llvm/llvmtgsi.cpp @@ -205,7 +205,9 @@ translate_instruction(llvm::Module *module, out = instr->dp3(inputs[0], inputs[1]); } break; - case TGSI_OPCODE_DP4: + case TGSI_OPCODE_DP4: { + out = instr->dp4(inputs[0], inputs[1]); + } break; case TGSI_OPCODE_DST: break; @@ -767,6 +769,10 @@ ga_llvm_from_tgsi(struct pipe_context *pipe, const struct tgsi_token *tokens) std::cout << "Creating llvm " <<std::endl; struct ga_llvm_prog *ga_llvm = (struct ga_llvm_prog *)malloc(sizeof(struct ga_llvm_prog)); + fprintf(stderr, "DUMPX \n"); + //tgsi_dump(tokens, TGSI_DUMP_VERBOSE); + tgsi_dump(tokens, 0); + fprintf(stderr, "DUMPEND \n"); llvm::Module *mod = tgsi_to_llvm(tokens); /* Run optimization passes over it */ @@ -789,10 +795,6 @@ ga_llvm_from_tgsi(struct pipe_context *pipe, const struct tgsi_token *tokens) ee->addModuleProvider(mp); } ga_llvm->module = mod; - fprintf(stderr, "DUMPX \n"); - //tgsi_dump(tokens, TGSI_DUMP_VERBOSE); - tgsi_dump(tokens, 0); - fprintf(stderr, "DUMPEND \n"); Function *func = mod->getFunction("run_vertex_shader"); std::cout << "run_vertex_shader = "<<func<<std::endl; |