[LLVMdev] ConstantExpr Evaluation

Eli Friedman eli.friedman at gmail.com
Thu Oct 27 13:44:25 PDT 2011


On Thu, Oct 27, 2011 at 10:12 AM,  <bdavis at cs.fsu.edu> wrote:
> Hi,
>
> What I'm currently working on is a translation from LLVM IR to a
> register transfer list format used in VPO.
>
> If my understanding of ConstantExpr is correct, that they can be
> evaluated at compile-time, how can I simply have them be evaluated but
> have the code still remain in IR format?
>
> For example, in:
>
> store i32 1, i32* getelementptr [6 x i32]* @arr, i32 0, i32 0
>
> the getelementptr ConstantExpr can be evaluated at compile-time, so is
> there a way to run a pass and end up with something like:
>
> store i32 1, i32* ???
>
> where ??? is not another ConstantExpr, but rather a ConstantInt or similar.

You could write a pass that makes sure that no operand of an
Instruction is a ConstantExpr, or some subset of that.  There isn't
any such pass in the tree, but I recall there may have been some
discussion on llvmdev in the past.  I'm not sure it saves all that
much work for your translator, though.

-Eli



More information about the llvm-dev mailing list