Adding an trinsics in x86

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/ :
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;
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/
def MAX_QB : I<0xff,RawFrm, (outs GR32:$Rd), (ins GR32:$src1,GR32:$src2),“max_qb \t $Rd $src1 $src2”, >, OpSize32;
But it doesn’t work.What should I do to make it correct? please tell me.Thanks.

Your builtin shouldn’t use “V2iV2iV2i”, V2i means it take a vector of two 32-bit integers. You just want “iii”. You also don’t need code in CGBuiltin.cpp if you have a GCCBuiltin name in

In your C code you need to call __builtin_x86_max_qb not int_x86_max_qb. int_x86_max_qb(really llvm.x86.max.qb) is the name in LLVM IR. Clang’s C parser knows it as __builtin_x86_max_qb because that’s the name in clangs BuiltinsX86.def.

Your opinion is very important, thank you very much. I want to ask you, if there are some learning materials about how to add an trinsics in x86 or these are your accumulated experience. The documenmation(Extending LLVM: Adding instructions, intrinsics, types, etc. doesn’t tell much content,I think.
I still have a question which I hope you answer.
In, I define the max_qb as fllowing

def max_qb : I<0xff,RawFrm, (outs GR32:$Rd), (ins GR32:$src1,GR32:$src2),“max_qb\t $Rd ,$src1 $src2”, >, OpSize32;

When I make the llvm,“Unexpected number of operands for RawFrm” appears.
How can I do to convert trinsics to binary instructions?
Thanks a lot.