[llvm-dev] Adding an trinsics in x86 (original) (raw)
沈天豪 via llvm-dev llvm-dev at lists.llvm.org
Thu Sep 6 04:19:23 PDT 2018
- Previous message: [llvm-dev] How to add Loongson ISA for Mips target?
- Next message: [llvm-dev] Adding an trinsics in x86
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Everyone! I am a newbie at llvm. So the question may be fundamental but difficult to me. I want to add an trinsics in x86 and make the following changes.I want that max_qb can find the max of two Integers and return it. In src/include/llvm/IR/Intrinsics.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 src//tools/clang/include/clang/Basic/BuiltinsX86.def TARGET_BUILTIN(__builtin_x86_max_qb, "V2iV2iV2i", "ncV:64:", "") //I don't know the meaning of these parameters, just write according to the add function. In src/tools/clang/lib/CodeGen/CGBuiltin.cpp. in function EmitX86BuiltinExpr case X86::BI__builtin_x86_max_qb:{ return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_max_qb)); } Then I do a simple test,just like this: #include <stdlib.h> #include <stdio.h> int main() { int a, b, c; a=1;b=2; c = int_x86_max_qb(a, b); }
When I use clang to compile,there is a warning:implicit declaration of function 'int_x86_max_qb' is invalid in C99 [-Wimplicit-function-declaration]. So I add the definition in src/lib/Target/X86/X86InstrInfo.td def MAX_QB : I<0xff,RawFrm, (outs GR32:$Rd), (ins GR32:$src1,GR32:$src2),"max_qb \t RdRd Rdsrc1 $src2", []>, OpSize32; But it doesn't work.What should I do to make it correct? please tell me.Thanks.
-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180906/57706ad3/attachment.html>
- Previous message: [llvm-dev] How to add Loongson ISA for Mips target?
- Next message: [llvm-dev] Adding an trinsics in x86
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]