[LLVMdev] Re : How to assign a constant to a register?

James Molloy James.Molloy at arm.com
Thu Oct 21 00:51:27 PDT 2010


Hi,

After the alloca, %x is of type i8* (i.e. a pointer to whatever type x
is in your HLL). It can be mutated using the 'store' instruction.

Note that if you want to read its value, you will have to perform a
'load' to a temporary - for example to increment 'x' by one:

Load i8 %x.tmp1, i8* %x
Add i8 %x.tmp2, i8 %x.tmp1, i8 1
Store i8* %x, %x.tmp2

Think of the LLVM architecture as like a load/store RISC machine, apart
from it has infinite registers and each register can only be written to
once.

Cheers,

James

> -----Original Message-----
> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu]
> On Behalf Of leledumbo
> Sent: 21 October 2010 07:20
> To: llvmdev at cs.uiuc.edu
> Subject: Re: [LLVMdev] Re : How to assign a constant to a register?
> 
> 
> > If x is a local variable, it will be stored on the stack. So you
need
> an
> > alloca for it:
> 
> Aha, I remember this in Kaleidoscope tutorial. So, after the alloca %x
> can
> be modified freely (e.g. without adding suffix)?
> --
> View this message in context: http://old.nabble.com/How-to-assign-a-
> constant-to-a-register--tp29987387p30016496.html
> Sent from the LLVM - Dev mailing list archive at Nabble.com.
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
-- 
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium.  Thank you.




More information about the llvm-dev mailing list