Irini Stavrakantonaki via llvm-dev
2015-Oct-16 11:21 UTC
[llvm-dev] Break nested instructions?
On 16/10/15 14:09, mats petersson wrote:> I think it's important to understand that this is not ALWAYS the case. > The operands can be either a constant expression or an instruction. > > For example: > > char *a; > int x; > > if(cond) a = "%d"; > else a = "%x"; > printf(a, x); > > In this case, the compiler may still be able to convert to constant > expression for `a`, depending on if it's able to deduce `cond`. But if > `cond` is not "constant", `a` will be a GEP instruction, not a > constant expression. > (Of course, the compiler will probably also warn that passing a > variable to printf is a bad idea, but that's a different matter) > > -- > MatsDoes this mean that we can have a nested instruction into an instruction?! Wouldn't that lead having a LLVM IR language without terminals? --istavrak
On 16 October 2015 at 12:21, Irini Stavrakantonaki <istavrak at ics.forth.gr> wrote:> > > On 16/10/15 14:09, mats petersson wrote: > >> I think it's important to understand that this is not ALWAYS the case. >> The operands can be either a constant expression or an instruction. >> >> For example: >> >> char *a; >> int x; >> >> if(cond) a = "%d"; >> else a = "%x"; >> printf(a, x); >> >> In this case, the compiler may still be able to convert to constant >> expression for `a`, depending on if it's able to deduce `cond`. But if >> `cond` is not "constant", `a` will be a GEP instruction, not a constant >> expression. >> (Of course, the compiler will probably also warn that passing a variable >> to printf is a bad idea, but that's a different matter) >> >> -- >> Mats >> > Does this mean that we can have a nested instruction into an instruction?! > Wouldn't that lead having a LLVM IR language without terminals? >Interesting point, I'm not sure - but the operand on an "instruction" is a Value, so I expect it can be any type that is within the Value class hierarchy? -- Mats> > > --istavrak >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151016/45f4bca0/attachment.html>
Irini Stavrakantonaki via llvm-dev
2015-Oct-16 11:55 UTC
[llvm-dev] Break nested instructions?
On 16/10/15 14:33, mats petersson wrote:> Interesting point, I'm not sure - but the operand on an "instruction" > is a Value, so I expect it can be any type that is within the Value > class hierarchy?I expected the same. That's why I was searching a way to "break" the inlined instructions, as nested instructions are not convenient for me. In case the operands of instructions are always meant to be constant exprs, then it's simple to handle them differently by having different adaptor classes as David proposed before. --istavrak