summaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2007-11-02 12:05:00 -0400
committerZack Rusin <[email protected]>2007-11-02 12:05:00 -0400
commite0e91e7ceb50f0e23311788559a8547dd24c7a80 (patch)
tree5598bb6fd54024d7ea3d302d786c1b55a27a510f /src/mesa/pipe
parent5c7bfb06e087ce4162590359ad75d1fca98f3549 (diff)
Implement scs opcode
Diffstat (limited to 'src/mesa/pipe')
-rw-r--r--src/mesa/pipe/llvm/gallivm.cpp4
-rw-r--r--src/mesa/pipe/llvm/gallivm_builtins.cpp34
-rw-r--r--src/mesa/pipe/llvm/instructions.cpp11
-rw-r--r--src/mesa/pipe/llvm/instructions.h1
-rw-r--r--src/mesa/pipe/llvm/llvm_builtins.c10
5 files changed, 59 insertions, 1 deletions
diff --git a/src/mesa/pipe/llvm/gallivm.cpp b/src/mesa/pipe/llvm/gallivm.cpp
index a737b5631f0..7e91f8c556c 100644
--- a/src/mesa/pipe/llvm/gallivm.cpp
+++ b/src/mesa/pipe/llvm/gallivm.cpp
@@ -502,7 +502,9 @@ translate_instruction(llvm::Module *module,
out = instr->cmp(inputs[0], inputs[1], inputs[2]);
}
break;
- case TGSI_OPCODE_SCS:
+ case TGSI_OPCODE_SCS: {
+ out = instr->scs(inputs[0]);
+ }
break;
case TGSI_OPCODE_TXB:
break;
diff --git a/src/mesa/pipe/llvm/gallivm_builtins.cpp b/src/mesa/pipe/llvm/gallivm_builtins.cpp
index b23af915505..b06629265a6 100644
--- a/src/mesa/pipe/llvm/gallivm_builtins.cpp
+++ b/src/mesa/pipe/llvm/gallivm_builtins.cpp
@@ -114,6 +114,18 @@ Function* func_cosf = new Function(
/*Name=*/"cosf", mod); // (external, no body)
func_cosf->setCallingConv(CallingConv::C);
+Function* func_scs = new Function(
+ /*Type=*/FuncTy_5,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"scs", mod);
+func_scs->setCallingConv(CallingConv::C);
+
+Function* func_sinf = new Function(
+ /*Type=*/FuncTy_12,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"sinf", mod); // (external, no body)
+func_sinf->setCallingConv(CallingConv::C);
+
// Global Variable Declarations
@@ -394,6 +406,28 @@ gvar_array__str1->setInitializer(const_array_14);
}
+// Function: scs (func_scs)
+{
+ Function::arg_iterator args = func_scs->arg_begin();
+ Value* packed_val_55 = args++;
+ packed_val_55->setName("val");
+
+ BasicBlock* label_entry_56 = new BasicBlock("entry",func_scs,0);
+
+ // Block entry (label_entry_56)
+ ExtractElementInst* float_tmp2 = new ExtractElementInst(packed_val_55, const_int32_18, "tmp2", label_entry_56);
+ CallInst* float_call_57 = new CallInst(func_cosf, float_tmp2, "call", label_entry_56);
+ float_call_57->setCallingConv(CallingConv::C);
+ float_call_57->setTailCall(true);
+ InsertElementInst* packed_tmp5 = new InsertElementInst(const_packed_34, float_call_57, const_int32_18, "tmp5", label_entry_56);
+ CallInst* float_call7 = new CallInst(func_sinf, float_tmp2, "call7", label_entry_56);
+ float_call7->setCallingConv(CallingConv::C);
+ float_call7->setTailCall(true);
+ InsertElementInst* packed_tmp9 = new InsertElementInst(packed_tmp5, float_call7, const_int32_22, "tmp9", label_entry_56);
+ new ReturnInst(packed_tmp9, label_entry_56);
+
+}
+
return mod;
}
diff --git a/src/mesa/pipe/llvm/instructions.cpp b/src/mesa/pipe/llvm/instructions.cpp
index 8e74ab3e94b..c4a1b2d5c1d 100644
--- a/src/mesa/pipe/llvm/instructions.cpp
+++ b/src/mesa/pipe/llvm/instructions.cpp
@@ -864,4 +864,15 @@ llvm::Value * Instructions::cos(llvm::Value *in)
#endif
}
+llvm::Value * Instructions::scs(llvm::Value *in)
+{
+ llvm::Function *func = m_mod->getFunction("scs");
+ assert(func);
+
+ CallInst *call = m_builder.CreateCall(func, in, name("scsres"));
+ call->setTailCall(false);
+ return call;
+}
+
#endif //MESA_LLVM
+
diff --git a/src/mesa/pipe/llvm/instructions.h b/src/mesa/pipe/llvm/instructions.h
index d33f61a9c13..95c845e8623 100644
--- a/src/mesa/pipe/llvm/instructions.h
+++ b/src/mesa/pipe/llvm/instructions.h
@@ -92,6 +92,7 @@ public:
llvm::Value *pow(llvm::Value *in1, llvm::Value *in2);
llvm::Value *rcp(llvm::Value *in);
llvm::Value *rsq(llvm::Value *in);
+ llvm::Value *scs(llvm::Value *in);
llvm::Value *sge(llvm::Value *in1, llvm::Value *in2);
llvm::Value *sgt(llvm::Value *in1, llvm::Value *in2);
llvm::Value *slt(llvm::Value *in1, llvm::Value *in2);
diff --git a/src/mesa/pipe/llvm/llvm_builtins.c b/src/mesa/pipe/llvm/llvm_builtins.c
index a570e0e0894..ca159955570 100644
--- a/src/mesa/pipe/llvm/llvm_builtins.c
+++ b/src/mesa/pipe/llvm/llvm_builtins.c
@@ -71,6 +71,7 @@ inline float4 cmp(float4 tmp0, float4 tmp1, float4 tmp2)
}
extern float cosf(float val);
+extern float sinf(float val);
inline float4 vcos(float4 val)
{
@@ -83,3 +84,12 @@ inline float4 vcos(float4 val)
printf("VEC OUT is %f %f %f %f\n", result.x, result.y, result.z, result.w);
return result;
}
+
+inline float4 scs(float4 val)
+{
+ float4 result;
+ float tmp = val.x;
+ result.x = cosf(tmp);
+ result.y = sinf(tmp);
+ return result;
+}