[LLVMdev] X86: copyConstantToRegister
Vladimir Prus
ghost at cs.msu.su
Tue Jun 8 00:32:05 PDT 2004
Chris Lattner wrote:
> > I'm not sure I understand this logic. If we have "1 + 2" as constant
> > expression, then why emit the code to perform addition? It should be
> > possible to just fold the expression and copy immediate "3" into a
> > register.
> >
> > I must be missing something, but what?
>
> LLVM constant expressions are used when it is not possible to fold the
> constant. In particular expressions like "10/0" are not constant foldable
> (so it must be evaluated at runtime), and link-time constants are not
> foldable... stuff like:
>
> int X;
> int Y;
> int Z = (int)&X-(int)&Y;
>
> Yes, this is gross and disturbing, but we do support it. Constant
> expressions are the reason why there is a separation in the X86 isel
> between the "visit" methods and the "emit" methods.
Thanks for the explanation?
> > Another question is about TargetInstrInfo::CreateCodeToLoadConst. This
> > seems like a perfect fit for the task, but it's not used in X86 backend
> > at all. Further, the destination register is represented by Instruction*,
> > and not by integer number as elsewhere. What does that Instruction* mean?
>
> This is a deprecated method that is only used by the SparcV9 backend. It
> used an extremely different way of representing virtual registers based on
> Value*'s. It turns out that doing this has some serious problems, so we
> are slowly migrating away from it.
Understood. It looks like a lot of methods in TargetMachine are for Sparc
backend only, right?
- Volodya
More information about the llvm-dev
mailing list