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>
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>
Thank you very much, especially for copying and testing my code.
I am very surprised that the builtin is recognized. I successfully compile
without errors.But when I use the fllowing file to test ,the error occurs.
#include <stdio.h>
int main()
{
int a;
int b;
a=1;b=2;
c = __builtin_x86_max_qb(a, b);
return 0;
}
There is a place I don't understand very well, I want to ask you.When did
the fatal error you get occur?Compile or test after compiled?May you tell me how
you test ?
As for something to connect the intrinsic to the X86ISD::max_qb opcode, do I
need to add a DAG?
Thanks again
At 2018-09-17 14:39:13, "Craig Topper" <craig.topper at
gmail.com> wrote:
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/20180917/9afae774/attachment.html>