David Noursi via llvm-dev
2016-Jul-26 22:21 UTC
[llvm-dev] Help wanted: Overloading an Intinsic
Hello All, I have been modifying LLVM a project of mine, and have encountered issues with overloading an intrinsic function. I have defined two types, abit (which is mapped, in Intrinsics.td, to i128) and qbit (accordingly mapped to i16). I would like my intrinsic function, CNOT(x,y), to accept either an abit or a qbit for each argument, so I overload with iAny and llvm_anyint_ty, as seemed to be the method for other intrinsics: def int_CNOT: Intrinsic<[], [llvm_anyint_ty, llvm_anyint_ty],[],["llvm.CNOT"]>; My llvm/clang directory builds successfully, but I get an error on getType from clang, which I believe is rooted in my llvm code. My question is simply, are there any additional steps to overloading an intrinsic? I stand to believe there is more to be done than what I did in the one line above, but I cannot find where to do this. For what its worth, I get this error in generating the initial IR through clang: clang: ../ArrayRef.h:129: const T &llvm::ArrayRef<llvm::Type *>::operator[](size_t) const [T = llvm::Type *]: Assertion `Index < Length && "Invalid index!"' failed. Many Thanks, David Noursi -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160726/a13f9f35/attachment.html>
Anna Thomas via llvm-dev
2016-Jul-28 23:18 UTC
[llvm-dev] Help wanted: Overloading an Intinsic
Hi David, The error shows that the clang source code uses this intrinsic as well, but in the old form. You need to modify the clang source code (where this intrinsic is used) to consider the overloaded operands. The assert would show the trace where clang uses this intrinsic. Hope this helps, Anna> On Jul 26, 2016, at 3:21 PM, David Noursi via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hello All, > > I have been modifying LLVM a project of mine, and have encountered issues with overloading an intrinsic function. > > I have defined two types, abit (which is mapped, in Intrinsics.td, to i128) and qbit (accordingly mapped to i16). I would like my intrinsic function, CNOT(x,y), to accept either an abit or a qbit for each argument, so I overload with iAny and llvm_anyint_ty, as seemed to be the method for other intrinsics: > > def int_CNOT: Intrinsic<[], [llvm_anyint_ty, llvm_anyint_ty],[],["llvm.CNOT"]>; > > My llvm/clang directory builds successfully, but I get an error on getType from clang, which I believe is rooted in my llvm code. My question is simply, are there any additional steps to overloading an intrinsic? I stand to believe there is more to be done than what I did in the one line above, but I cannot find where to do this. > > For what its worth, I get this error in generating the initial IR through clang: > > clang: ../ArrayRef.h:129: const T &llvm::ArrayRef<llvm::Type *>::operator[](size_t) const [T = llvm::Type *]: Assertion `Index < Length && "Invalid index!"' failed. > > Many Thanks, > David Noursi > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
David Noursi via llvm-dev
2016-Jul-28 23:28 UTC
[llvm-dev] Help wanted: Overloading an Intinsic
Thank you Anna! Since sending this email I have reached this conclusion from the stack dump, and have been modifying calls to getIntrinsic in clang. Many Thanks, David On Jul 28, 2016 6:18 PM, "Anna Thomas" <anna at azul.com> wrote:> Hi David, > > The error shows that the clang source code uses this intrinsic as well, > but in the old form. You need to modify the clang source code (where this > intrinsic is used) to consider the overloaded operands. > > The assert would show the trace where clang uses this intrinsic. > > Hope this helps, > Anna > > > On Jul 26, 2016, at 3:21 PM, David Noursi via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > > > > Hello All, > > > > I have been modifying LLVM a project of mine, and have encountered > issues with overloading an intrinsic function. > > > > I have defined two types, abit (which is mapped, in Intrinsics.td, to > i128) and qbit (accordingly mapped to i16). I would like my intrinsic > function, CNOT(x,y), to accept either an abit or a qbit for each argument, > so I overload with iAny and llvm_anyint_ty, as seemed to be the method for > other intrinsics: > > > > def int_CNOT: Intrinsic<[], [llvm_anyint_ty, > llvm_anyint_ty],[],["llvm.CNOT"]>; > > > > My llvm/clang directory builds successfully, but I get an error on > getType from clang, which I believe is rooted in my llvm code. My question > is simply, are there any additional steps to overloading an intrinsic? I > stand to believe there is more to be done than what I did in the one line > above, but I cannot find where to do this. > > > > For what its worth, I get this error in generating the initial IR > through clang: > > > > clang: ../ArrayRef.h:129: const T &llvm::ArrayRef<llvm::Type > *>::operator[](size_t) const [T = llvm::Type *]: Assertion `Index < Length > && "Invalid index!"' failed. > > > > Many Thanks, > > David Noursi > > > > > > _______________________________________________ > > LLVM Developers mailing list > > llvm-dev at lists.llvm.org > > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160728/a83b73bb/attachment.html>
Maybe Matching Threads
- Help wanted: Overloading an Intinsic
- [LLVMdev] Fwd: Re: [PATCH] [TABLEGEN] Do not crash on intrinsics with names longer than 40 characters
- [LLVMdev] Fwd: Re: [PATCH] [TABLEGEN] Do not crash on intrinsics with names longer than 40 characters
- [LLVMdev] Creation of Intrinsics with Pointer Return Types
- [LLVMdev] Creation of Intrinsics with Pointer Return Types