diff options
author | Zack Rusin <zack@tungstengraphics.com> | 2007-10-22 11:27:34 -0400 |
---|---|---|
committer | Zack Rusin <zack@tungstengraphics.com> | 2007-10-24 11:21:04 -0400 |
commit | 743e96eec5f89cf55873b82ee58b4a06d094c0e9 (patch) | |
tree | 44d4a590feb8cea1cfbb4ed7a9bf12daa32d072a | |
parent | b04430efd963ca541c435c6c1007feccf5474040 (diff) |
Implement SGE and SLT
-rw-r--r-- | src/mesa/pipe/llvm/instructions.cpp | 57 | ||||
-rw-r--r-- | src/mesa/pipe/llvm/instructions.h | 2 | ||||
-rw-r--r-- | src/mesa/pipe/llvm/llvmtgsi.cpp | 8 |
3 files changed, 65 insertions, 2 deletions
diff --git a/src/mesa/pipe/llvm/instructions.cpp b/src/mesa/pipe/llvm/instructions.cpp index 044b447846..1c42a37c74 100644 --- a/src/mesa/pipe/llvm/instructions.cpp +++ b/src/mesa/pipe/llvm/instructions.cpp @@ -600,6 +600,62 @@ llvm::Function * Instructions::declarePrintf() return func_printf; } +llvm::Value * Instructions::sge(llvm::Value *in1, llvm::Value *in2) +{ + Constant *const1f = ConstantFP::get(Type::FloatTy, APFloat(1.000000e+00f)); + Constant *const0f = Constant::getNullValue(Type::FloatTy); + + ExtractElementInst *x1 = new ExtractElementInst(in1, unsigned(0), name("x1"), m_block); + ExtractElementInst *x2 = new ExtractElementInst(in2, unsigned(0), name("x2"), m_block); + FCmpInst *xcmp = new FCmpInst(FCmpInst::FCMP_OGE, x1, x2, name("xcmp"), m_block); + SelectInst *x = new SelectInst(xcmp, const1f, const0f, name("xsel"), m_block); + + ExtractElementInst *y1 = new ExtractElementInst(in1, unsigned(1), name("y1"), m_block); + ExtractElementInst *y2 = new ExtractElementInst(in2, unsigned(1), name("y2"), m_block); + FCmpInst *ycmp = new FCmpInst(FCmpInst::FCMP_OGE, y1, y2, name("ycmp"), m_block); + SelectInst *y = new SelectInst(ycmp, const1f, const0f, name("ysel"), m_block); + + ExtractElementInst *z1 = new ExtractElementInst(in1, unsigned(2), name("z1"), m_block); + ExtractElementInst *z2 = new ExtractElementInst(in2, unsigned(2), name("z2"), m_block); + FCmpInst *zcmp = new FCmpInst(FCmpInst::FCMP_OGE, z1, z2, name("zcmp"), m_block); + SelectInst *z = new SelectInst(zcmp, const1f, const0f, name("zsel"), m_block); + + ExtractElementInst *w1 = new ExtractElementInst(in1, unsigned(3), name("w1"), m_block); + ExtractElementInst *w2 = new ExtractElementInst(in2, unsigned(3), name("w2"), m_block); + FCmpInst *wcmp = new FCmpInst(FCmpInst::FCMP_OGE, w1, w2, name("wcmp"), m_block); + SelectInst *w = new SelectInst(wcmp, const1f, const0f, name("wsel"), m_block); + + return vectorFromVals(x, y, z, w); +} + + +llvm::Value * Instructions::slt(llvm::Value *in1, llvm::Value *in2) +{ + Constant *const1f = ConstantFP::get(Type::FloatTy, APFloat(1.000000e+00f)); + Constant *const0f = Constant::getNullValue(Type::FloatTy); + + ExtractElementInst *x1 = new ExtractElementInst(in1, unsigned(0), name("x1"), m_block); + ExtractElementInst *x2 = new ExtractElementInst(in2, unsigned(0), name("x2"), m_block); + FCmpInst *xcmp = new FCmpInst(FCmpInst::FCMP_OLT, x1, x2, name("xcmp"), m_block); + SelectInst *x = new SelectInst(xcmp, const1f, const0f, name("xsel"), m_block); + + ExtractElementInst *y1 = new ExtractElementInst(in1, unsigned(1), name("y1"), m_block); + ExtractElementInst *y2 = new ExtractElementInst(in2, unsigned(1), name("y2"), m_block); + FCmpInst *ycmp = new FCmpInst(FCmpInst::FCMP_OLT, y1, y2, name("ycmp"), m_block); + SelectInst *y = new SelectInst(ycmp, const1f, const0f, name("ysel"), m_block); + + ExtractElementInst *z1 = new ExtractElementInst(in1, unsigned(2), name("z1"), m_block); + ExtractElementInst *z2 = new ExtractElementInst(in2, unsigned(2), name("z2"), m_block); + FCmpInst *zcmp = new FCmpInst(FCmpInst::FCMP_OLT, z1, z2, name("zcmp"), m_block); + SelectInst *z = new SelectInst(zcmp, const1f, const0f, name("zsel"), m_block); + + ExtractElementInst *w1 = new ExtractElementInst(in1, unsigned(3), name("w1"), m_block); + ExtractElementInst *w2 = new ExtractElementInst(in2, unsigned(3), name("w2"), m_block); + FCmpInst *wcmp = new FCmpInst(FCmpInst::FCMP_OLT, w1, w2, name("wcmp"), m_block); + SelectInst *w = new SelectInst(wcmp, const1f, const0f, name("wsel"), m_block); + + return vectorFromVals(x, y, z, w); +} /* typedef __attribute__(( ocu_vector_type(4) )) float float4; @@ -775,3 +831,4 @@ Constant* const_packed_14 = ConstantVector::get(VectorTy_2, const_packed_14_elem } return func_lit; } + diff --git a/src/mesa/pipe/llvm/instructions.h b/src/mesa/pipe/llvm/instructions.h index b4948ed240..557ae3730b 100644 --- a/src/mesa/pipe/llvm/instructions.h +++ b/src/mesa/pipe/llvm/instructions.h @@ -33,6 +33,8 @@ public: llvm::Value *pow(llvm::Value *in1, llvm::Value *in2); llvm::Value *rcp(llvm::Value *in); llvm::Value *rsq(llvm::Value *in); + llvm::Value *sge(llvm::Value *in1, llvm::Value *in2); + llvm::Value *slt(llvm::Value *in1, llvm::Value *in2); llvm::Value *sub(llvm::Value *in1, llvm::Value *in2); void printVector(llvm::Value *val); diff --git a/src/mesa/pipe/llvm/llvmtgsi.cpp b/src/mesa/pipe/llvm/llvmtgsi.cpp index e1bb281a94..d40a7cc380 100644 --- a/src/mesa/pipe/llvm/llvmtgsi.cpp +++ b/src/mesa/pipe/llvm/llvmtgsi.cpp @@ -235,9 +235,13 @@ translate_instruction(llvm::Module *module, out = instr->max(inputs[0], inputs[1]); } break; - case TGSI_OPCODE_SLT: + case TGSI_OPCODE_SLT: { + out = instr->slt(inputs[0], inputs[1]); + } break; - case TGSI_OPCODE_SGE: + case TGSI_OPCODE_SGE: { + out = instr->sge(inputs[0], inputs[1]); + } break; case TGSI_OPCODE_MAD: { out = instr->madd(inputs[0], inputs[1], inputs[2]); |