-
Notifications
You must be signed in to change notification settings - Fork 274
Enable translation of ac_fixed functions #614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2375,6 +2375,19 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F, | |
| auto *IntrinsicCall = Builder.CreateIntrinsic(IID, RetTy, Args); | ||
| return mapValue(BV, IntrinsicCall); | ||
| } | ||
| case OpFixedSqrtINTEL: | ||
| case OpFixedRecipINTEL: | ||
| case OpFixedRsqrtINTEL: | ||
| case OpFixedSinINTEL: | ||
| case OpFixedCosINTEL: | ||
| case OpFixedSinCosINTEL: | ||
| case OpFixedSinPiINTEL: | ||
| case OpFixedCosPiINTEL: | ||
| case OpFixedSinCosPiINTEL: | ||
| case OpFixedLogINTEL: | ||
| case OpFixedExpINTEL: | ||
| return mapValue( | ||
| BV, transFixedPointInst(static_cast<SPIRVInstruction *>(BV), BB)); | ||
| default: { | ||
| auto OC = BV->getOpCode(); | ||
| if (isSPIRVCmpInstTransToLLVMInst(static_cast<SPIRVInstruction *>(BV))) { | ||
|
|
@@ -2399,6 +2412,55 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F, | |
| } | ||
| } | ||
|
|
||
| CallInst *SPIRVToLLVM::transFixedPointInst(SPIRVInstruction *BI, | ||
| BasicBlock *BB) { | ||
| // LLVM fixed point functions return value: | ||
| // iN | ||
| // Arguments: | ||
| // A(iN), S(i1), I(i32), rI(i32), Quantization(i32), Overflow(i32) | ||
|
|
||
| // SPIR-V fixed point instruction contains: | ||
| // <id>ResTy Res<id> <id>InTy In<id> \ | ||
| // Literal S Literal I Literal rI Literal Q Literal O | ||
|
|
||
| Type *RetTy = transType(BI->getType()); | ||
| auto Inst = static_cast<SPIRVFixedPointIntelInst *>(BI); | ||
|
|
||
| IntegerType *Int32Ty = IntegerType::get(*Context, 32); | ||
| IntegerType *Int1Ty = IntegerType::get(*Context, 1); | ||
|
|
||
| SmallVector<Type *, 7> ArgTys = {transType(Inst->getOperand(1)->getType()), | ||
| Int1Ty, | ||
| Int32Ty, | ||
| Int32Ty, | ||
| Int32Ty, | ||
| Int32Ty}; | ||
|
|
||
| FunctionType *FT = FunctionType::get(RetTy, ArgTys, false); | ||
|
|
||
| Op OpCode = Inst->getOpCode(); | ||
| Function *Func = Function::Create(FT, GlobalValue::ExternalLinkage, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have a test where the same fixed point funciton/opcode is encountered twice? I would expect that
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, that's a good point, thanks! I will fix that and add the appropriate test case.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It depends on what can be handled by the consumer of that LLVM IR which is translated from the SPIR-V. I guess that both variants are not really acceptable. Usually, such overloads are distinguished by mangling and |
||
| SPIRVFixedPointIntelMap::rmap(OpCode), M); | ||
| Func->setCallingConv(CallingConv::SPIR_FUNC); | ||
| if (isFuncNoUnwind()) | ||
| Func->addFnAttr(Attribute::NoUnwind); | ||
|
|
||
| // Words contain: | ||
| // <id>InTy In<id> Literal S Literal I Literal rI Literal Q Literal O | ||
| auto Words = Inst->getOpWords(); | ||
| std::vector<Value *> Args = { | ||
| transValue(Inst->getOperand(1), BB->getParent(), BB) /* A - input */, | ||
| ConstantInt::get(Int1Ty, Words[2]) /* S - indicator of signedness */, | ||
| ConstantInt::get(Int32Ty, | ||
| Words[3]) /* I - fixed-point location of the input */, | ||
| ConstantInt::get(Int32Ty, | ||
| Words[4]) /* rI - fixed-point location of the result*/, | ||
| ConstantInt::get(Int32Ty, Words[5]) /* Quantization mode */, | ||
| ConstantInt::get(Int32Ty, Words[6]) /* Overflow mode */}; | ||
|
|
||
| return CallInst::Create(Func, Args, "", BB); | ||
| } | ||
|
|
||
| template <class SourceTy, class FuncTy> | ||
| bool SPIRVToLLVM::foreachFuncCtlMask(SourceTy Source, FuncTy Func) { | ||
| SPIRVWord FCM = Source->getFuncCtlMask(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is
N?