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. Thanks, Brandon ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.
Hi Brandon,> 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,that's not so, because they may (for example) involve the address of a global variable or other label, which is not known 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.It can't be, since the address @arr is not known at compile time. Ciao, Duncan.
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