In IntrinsicEmitter::EmitTypeGenerate, called from IntrinsicEmitter::EmitGenerator, here for (unsigned j = 0; j != N; ++j) { OS << " ArgTys.push_back("; EmitTypeGenerate(OS, ParamTys[j], ArgNo); OS << ");\n"; } I'm hitting this assertion: if (ArgType->isSubClassOf("LLVMMatchType")) { unsigned Number = ArgType->getValueAsInt("Number"); assert(Number < ArgNo && "Invalid matching number!"); Where both Number and ArgNo are 1. -----Original Message----- From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Bob Wilson Sent: Wednesday, April 15, 2009 9:53 AM To: LLVM Developers Mailing List Subject: Re: [LLVMdev] Tablegen question On Apr 15, 2009, at 9:29 AM, Villmow, Micah wrote:> I have this intrinsic definition for llvm. > def int_opencl_math_fdistance_fast : Intrinsic<[llvm_float_ty], > [llvm_anyfloat_ty, LLVMMatchType<0>]>; > > > Can someone explain what LLVMMatchType does and how to specify it > to match the first argument and not the return value? > > I've tried LLVMMatchType<1> but it fails in IntrinsicEmitter.cppCan you give some more info about how LLVMMatchType<1> fails? That should do what you want. _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
That's a bug. I'm working on a fix.... On Apr 15, 2009, at 10:16 AM, Villmow, Micah wrote:> In IntrinsicEmitter::EmitTypeGenerate, called from > IntrinsicEmitter::EmitGenerator, here > for (unsigned j = 0; j != N; ++j) { > OS << " ArgTys.push_back("; > EmitTypeGenerate(OS, ParamTys[j], ArgNo); > OS << ");\n"; > } > I'm hitting this assertion: > if (ArgType->isSubClassOf("LLVMMatchType")) { > unsigned Number = ArgType->getValueAsInt("Number"); > assert(Number < ArgNo && "Invalid matching number!"); > > Where both Number and ArgNo are 1. > > -----Original Message----- > From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] > On Behalf Of Bob Wilson > Sent: Wednesday, April 15, 2009 9:53 AM > To: LLVM Developers Mailing List > Subject: Re: [LLVMdev] Tablegen question > > > On Apr 15, 2009, at 9:29 AM, Villmow, Micah wrote: > >> I have this intrinsic definition for llvm. >> def int_opencl_math_fdistance_fast : Intrinsic<[llvm_float_ty], >> [llvm_anyfloat_ty, LLVMMatchType<0>]>; >> >> >> Can someone explain what LLVMMatchType does and how to specify it >> to match the first argument and not the return value? >> >> I've tried LLVMMatchType<1> but it fails in IntrinsicEmitter.cpp > > Can you give some more info about how LLVMMatchType<1> fails? That > should do what you want. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Upon further investigation, it seems that if I use llvm_float_ty, it doesn't register as an arg, so the llvm_anyfloat_ty is considered arg0 but should be arg1. Micah -----Original Message----- From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Bob Wilson Sent: Wednesday, April 15, 2009 10:31 AM To: LLVM Developers Mailing List Subject: Re: [LLVMdev] Tablegen question That's a bug. I'm working on a fix.... On Apr 15, 2009, at 10:16 AM, Villmow, Micah wrote:> In IntrinsicEmitter::EmitTypeGenerate, called from > IntrinsicEmitter::EmitGenerator, here > for (unsigned j = 0; j != N; ++j) { > OS << " ArgTys.push_back("; > EmitTypeGenerate(OS, ParamTys[j], ArgNo); > OS << ");\n"; > } > I'm hitting this assertion: > if (ArgType->isSubClassOf("LLVMMatchType")) { > unsigned Number = ArgType->getValueAsInt("Number"); > assert(Number < ArgNo && "Invalid matching number!"); > > Where both Number and ArgNo are 1. > > -----Original Message----- > From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] > On Behalf Of Bob Wilson > Sent: Wednesday, April 15, 2009 9:53 AM > To: LLVM Developers Mailing List > Subject: Re: [LLVMdev] Tablegen question > > > On Apr 15, 2009, at 9:29 AM, Villmow, Micah wrote: > >> I have this intrinsic definition for llvm. >> def int_opencl_math_fdistance_fast : Intrinsic<[llvm_float_ty], >> [llvm_anyfloat_ty, LLVMMatchType<0>]>; >> >> >> Can someone explain what LLVMMatchType does and how to specify it >> to match the first argument and not the return value? >> >> I've tried LLVMMatchType<1> but it fails in IntrinsicEmitter.cpp > > Can you give some more info about how LLVMMatchType<1> fails? That > should do what you want. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev_______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Oops. That was premature. I think your original question was on the right track. TableGen distinguishes between known and "overloaded" types (like "llvm_anyfloat_ty" in your example). The overloaded types are numbered separately, and the argument to LLVMMatchType is an index into these overloaded types, ignoring the known types. So, in your case, the first argument is the first overloaded type, so you should use LLVMMatchType<0> to refer to it. On Apr 15, 2009, at 10:31 AM, Bob Wilson wrote:> That's a bug. I'm working on a fix.... > > On Apr 15, 2009, at 10:16 AM, Villmow, Micah wrote: > >> In IntrinsicEmitter::EmitTypeGenerate, called from >> IntrinsicEmitter::EmitGenerator, here >> for (unsigned j = 0; j != N; ++j) { >> OS << " ArgTys.push_back("; >> EmitTypeGenerate(OS, ParamTys[j], ArgNo); >> OS << ");\n"; >> } >> I'm hitting this assertion: >> if (ArgType->isSubClassOf("LLVMMatchType")) { >> unsigned Number = ArgType->getValueAsInt("Number"); >> assert(Number < ArgNo && "Invalid matching number!"); >> >> Where both Number and ArgNo are 1. >> >> -----Original Message----- >> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev- >> bounces at cs.uiuc.edu] >> On Behalf Of Bob Wilson >> Sent: Wednesday, April 15, 2009 9:53 AM >> To: LLVM Developers Mailing List >> Subject: Re: [LLVMdev] Tablegen question >> >> >> On Apr 15, 2009, at 9:29 AM, Villmow, Micah wrote: >> >>> I have this intrinsic definition for llvm. >>> def int_opencl_math_fdistance_fast : Intrinsic<[llvm_float_ty], >>> [llvm_anyfloat_ty, LLVMMatchType<0>]>; >>> >>> >>> Can someone explain what LLVMMatchType does and how to specify it >>> to match the first argument and not the return value? >>> >>> I've tried LLVMMatchType<1> but it fails in IntrinsicEmitter.cpp >> >> Can you give some more info about how LLVMMatchType<1> fails? That >> should do what you want. >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >> >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev