[llvm-commits] [PATCH] Allow converting ConstantExprs to Instructions

Renato Golin rengolin at systemcall.org
Fri Nov 16 12:23:22 PST 2012


On 16 November 2012 18:17, James Molloy <James.Molloy at arm.com> wrote:
> The attached patch implements a simple extra API function to retrieve an
> Instruction* equivalent for a ConstantExpr. With this addition, dealing
> with the constraints imposed by SPIR is actually possible without
> horrible hackery...

A ConstantExpr *is* a Value, so the wrapper you did bypasses the
hierarchy (possibly broken), but is also disconnected from the API,
which means when either side change, you might forget to change this
bridge and get away with it.

Having said that, I don't think the consequences of forgetting to
update this code is drastic (I can't see why it'd do anything other
than assert at compile time), but since there is already a connection
between ConstantExpr and Value, I think it's a cheap trick.

Have you thought about adding constructors for the Instructions
passing ConstantExpr references? That might be used automatically by
the compiler as a casting match, which will be even neater.

--
cheers,
--renato

http://systemcall.org/



More information about the llvm-commits mailing list