[llvm-dev] error about adding an trinsics

沈天豪 via llvm-dev llvm-dev at lists.llvm.org
Sun Sep 16 23:05:57 PDT 2018


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180917/91fbeb09/attachment.html>


More information about the llvm-dev mailing list