[llvm-dev] error about adding an trinsics

Craig Topper via llvm-dev llvm-dev at lists.llvm.org
Sun Sep 16 23:39:13 PDT 2018


This all looks fine to me. I even pasted into my own repo and the builtin
is recognized by my local build of clang. I got this error instead.

*fatal error: *error in backend: Cannot select: intrinsic %llvm.x86.max.qb

But the code you provide is missing anything to connect the intrinsic to
the X86ISD::max_qb opcode so that error is to be expected given what I
copied and pasted.

~Craig


On Sun, Sep 16, 2018 at 11:06 PM 沈天豪 via llvm-dev <llvm-dev at lists.llvm.org>
wrote:

> Hi,every one.
> This problem has been bothering me for several days.I really hope that
> you can help me.
> I want to add an trinsics in X86. This trinsics can compare two numbers
> and return the larger.
> There are the changes I do as fllowing.
>
> In /tools/clang/include/clang/Basic/BuiltinsX86.def :
> BUILTIN(__builtin_x86_max_qb, "iii", "")
> In include/llvm/IR/IntrinsicsX86.td :
>  let TargetPrefix = "x86" in {
>  def int_x86_max_qb: GCCBuiltin<"__builtin_x86_max_qb">,
>   Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
> }
> In /lib/Target/X86/X86SelLowering.h: add a sdnode
>     max_qb,
> In /lib/Target/X86/X86SelLowering.cpp:
> case X86ISD::max_qb:             return "X86ISD::max_qb";
> In /lib/Target/X86/X86InstrInfo.td:
> def X86max_qb_flag : SDNode<"X86ISD::max_qb", SDTBinaryArithWithFlags,
>                           [SDNPCommutative]>;
> In /lib/Target/X86/X86InstrArithmetic.td:
> def max_qb : I<0xff,MRMSrcReg, (outs  GR32:$dst), (ins
> GR32:$src1,GR32:$src2),
>              "max_qb\t {$dst, $src1,$src2|$src1,$src2, $dst}", [(set
> GR32:$dst,EFLAGS,(X86max_qb_flag GR32:$src1, GR32:$src2))]>,
>               Sched<[WriteIMul]>, TB, OpSize32 ;
> I think it can be work ,at least work as one multiplication(because I use
> the Sched<[WriteIMul]>).
> But there is an error :"error: use of unknown builtin
> '__builtin_x86_max_qb'". And I don't konw what I should do.
> Thanks a lot.
>
>
>
>
> _______________________________________________
> 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/20180916/8b15b1ae/attachment.html>


More information about the llvm-dev mailing list