From 3c558e17f03a9813d905e7dc38b59ff0ad142ee9 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 17 Oct 2007 13:38:53 -0400 Subject: Implement dph opcode --- src/mesa/pipe/llvm/instructions.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/mesa/pipe/llvm/instructions.cpp') diff --git a/src/mesa/pipe/llvm/instructions.cpp b/src/mesa/pipe/llvm/instructions.cpp index 9e3b989600..62289ba62a 100644 --- a/src/mesa/pipe/llvm/instructions.cpp +++ b/src/mesa/pipe/llvm/instructions.cpp @@ -253,3 +253,30 @@ llvm::Value * Instructions::dp4(llvm::Value *in1, llvm::Value *in2) return vectorFromVals(dot4, dot4, dot4, dot4); } +llvm::Value * Instructions::dph(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(in2, unsigned(3), + name("val2w"), + 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 *dph = BinaryOperator::create(Instruction::Add, xyz, w, + name("dph"), + m_block); + return vectorFromVals(dph, dph, dph, dph); +} + -- cgit v1.2.3