[llvm-dev] creating Intrinsic DAG Node
Matt Arsenault via llvm-dev
llvm-dev at lists.llvm.org
Tue Feb 2 13:46:51 PST 2016
> On Feb 2, 2016, at 13:40, Ryan Taylor <ryta1203 at gmail.com> wrote:
> Here's the DAG code:
> Op is the SDValue incoming (the node I want to lower).
> SDValue result = DAG.getNode(ISD::INTRINSIC_WO_CHAIN, SDLoc(Op),
> Op.getValueType(), DAG.getConstant(Intrinsic::my_intrinsic, SDLoc(Op),
> Op.getValueType()), Op.getOperand(0));
You got the wrong order. The chain is always the first operand. The intrinsic ID should be the second (and you should also be using getTargetConstant but I don’t think this really matters)
> The type of the intrinsic call is the same as the type of Op, hence I'm using Op.getValueType()
> For the C code, I'm simply calling __builtin_myIntrinsic, where __builtin_myIntrinsic has been added to the appropriate files in clang and llvm and this maps down to the table gen just fine (we have lots of other intrinsics working the same way but we've never done it directly in DAG).
If you’re using the builtin, it should be fine.
More information about the llvm-dev