[LLVMdev] Intrinsic cannot use illegal type

54 views
Skip to first unread message

Christian Sayer

unread,
Mar 2, 2009, 12:18:56 PM3/2/09
to LLVM Developers Mailing List
Hello everybody,

I use a target specific Intrinsic that returns an illegal type. The idea is that this returned value shall be eliminated when the Intrinsic node is lowered to a target node.
I realize that this is a rather late stage, since (at least) SelectionDAGLowering::visitTargetIntrinsic() requires legal types, and type legalization in general is also done before ISelLowering.

The background is that the intrinsic returns a boolean value which is evaluated by a branch instruction of a (special) loop. The branch targets of this kind of loop are actually controlled and generated by hardware. So in the end the intrinsic should become the branch instruction and the original branch should disappear.

Is there a way to make this intrinsic go through as it is until instruction lowering, and to avoid type legalization on it?

Thanks a lot,
Christian


--
please ignore:

CONFIDENTIAL NOTICE: The contents of this message, including any attachments, are confidential and are intended solely for the use of the person or entity to whom the message was addressed. If you are not the intended recipient of this message, please be advised that any dissemination, distribution, or use of the contents of this message is strictly prohibited. If you received this message in error, please notify the sender. Please also permanently delete all copies of the original message and any attached documentation. Thank you.

_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Duncan Sands

unread,
Mar 3, 2009, 4:39:47 AM3/3/09
to llv...@cs.uiuc.edu, Christian Sayer
Hi Christian,

> I use a target specific Intrinsic that returns an illegal type.
> The idea is that this returned value shall be eliminated when the
> Intrinsic node is lowered to a target node.
> I realize that this is a rather late stage, since (at least)
> SelectionDAGLowering::visitTargetIntrinsic() requires legal types,
> and type legalization in general is also done before ISelLowering.

no, type legalization is done after everything has been lowered to
SelectionDAG nodes. I'm not sure why visitTargetIntrinsic insists
that types must be legal. If there is an illegal type there then
the type legalizer will complain later because it doesn't know how
to legalize it, that's all. However the type legalizer (I'm talking
LLVM 2.5 here) allows targets to custom lower operations with illegal
types via hooks like ReplaceNodeResults. So if you got rid of the
assertion in visitTargetIntrinsic and added some custom lowering
logic, then hopefully everything will work.

> The background is that the intrinsic returns a boolean value which
> is evaluated by a branch instruction of a (special) loop.

Why not have it return the boolean value in a legal type (eg: i32) and
follow it up with a truncate to turn it into an i1 for the benefit of
the branch? That way you won't have to do any mucking around with the
type legalizer at all!

> The branch targets of this kind of loop are actually controlled and generated by hardware. So in the end the intrinsic should become the branch instruction and the original branch should disappear.
>
> Is there a way to make this intrinsic go through as it is until instruction lowering, and to avoid type legalization on it?

See above.

Ciao,

Duncan.

Christian Sayer

unread,
Mar 4, 2009, 8:15:16 AM3/4/09
to LLVM Developers Mailing List
Duncan,
thanks for your hints. Truncating a legal type was actually
a nice remedy for the intrinsic - and the truncate gets eliminated
by instcombine anyway.
As of the second point, I have been disturbing myself by some
setOperationAction disorder...

Best regards,
Christian

--
Christian SAYER

CONFIDENTIAL NOTICE: The contents of this message, including any attachments, are confidential and are intended solely for the use of the person or entity to whom the message was addressed. If you are not the intended recipient of this message, please be advised that any dissemination, distribution, or use of the contents of this message is strictly prohibited. If you received this message in error, please notify the sender. Please also permanently delete all copies of the original message and any attached documentation. Thank you.

_______________________________________________

Reply all
Reply to author
Forward
0 new messages