mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-27 17:00:09 +01:00
Implement scs opcode
This commit is contained in:
parent
5c7bfb06e0
commit
e0e91e7ceb
5 changed files with 59 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue