[LLVMdev] LowerINTRINSIC_W_CHAIN in X86

Tim Northover
2014-07-23T19:56:33Z

> def int_x86_xtest : GCCBuiltin<"__builtin_ia32_xtest">,
>               Intrinsic<[llvm_i32_ty], [], []>;
>
> which  CALL makes the “Intrinsic::x86_xtest” is caught under
> “INTRINSIC_W_CHAIN”? feel I missed something, but did not figure out.

It's this first definition that spawns the INTRINSIC_W_CHAIN. The rest
are x86-specific SDNodes, defined in X86ISelLowering.h and only ever
created from X86ISelLowering.cpp.

I assume (haven't checked) there's some special bit of
X86ISelLowering.cpp that takes an ISD::INTRINSIC_W_CHAIN node
referring to the int_x86_xtest intrinsic and turns it into an
X86ISD::XTEST node.

Specifically, for the W_CHAIN/WO_CHAIN distinction you want to be
looking at the "IntrNoMem" definition and uses in include/[1]. That
should be what determines which path an intrinsic goes down.

Cheers.

Tim.

[1] If you're interested, the code most directly responsible for
choosing between them is in visitTargetIntrinsic in
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp. It's helped by
TableGen and other components, of course.