summaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2007-10-17 13:38:53 -0400
committerZack Rusin <[email protected]>2007-10-24 11:21:04 -0400
commit3c558e17f03a9813d905e7dc38b59ff0ad142ee9 (patch)
tree1a461b4a242dc0065d9e428ede2f01897ae8a47c /src/mesa/pipe
parent7abe3364b2c463fd3e96c2bc9d07aaa91bcfbc2c (diff)
Implement dph opcode
Diffstat (limited to 'src/mesa/pipe')
-rw-r--r--src/mesa/pipe/llvm/instructions.cpp27
-rw-r--r--src/mesa/pipe/llvm/instructions.h1
-rw-r--r--src/mesa/pipe/llvm/llvmtgsi.cpp4
3 files changed, 31 insertions, 1 deletions
diff --git a/src/mesa/pipe/llvm/instructions.cpp b/src/mesa/pipe/llvm/instructions.cpp
index 9e3b989600b..62289ba62af 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);
+}
+
diff --git a/src/mesa/pipe/llvm/instructions.h b/src/mesa/pipe/llvm/instructions.h
index c35cdb75f01..fb8ac9b8cdc 100644
--- a/src/mesa/pipe/llvm/instructions.h
+++ b/src/mesa/pipe/llvm/instructions.h
@@ -17,6 +17,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 *dph(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 45bc96cb1af..9a5d3b8d9c7 100644
--- a/src/mesa/pipe/llvm/llvmtgsi.cpp
+++ b/src/mesa/pipe/llvm/llvmtgsi.cpp
@@ -263,7 +263,9 @@ translate_instruction(llvm::Module *module,
break;
case TGSI_OPCODE_RCC:
break;
- case TGSI_OPCODE_DPH:
+ case TGSI_OPCODE_DPH: {
+ out = instr->dph(inputs[0], inputs[1]);
+ }
break;
case TGSI_OPCODE_COS:
break;