From 7abe3364b2c463fd3e96c2bc9d07aaa91bcfbc2c Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 17 Oct 2007 13:34:25 -0400 Subject: Implement dot4 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 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); +} + -- cgit v1.2.3