[LLVMdev] How to assign a constant to a register?
baldrick at free.fr
Mon Oct 18 07:18:48 CDT 2010
> Other than:
> %x = add i32 5,0 ; suppose I want to assign 5 to %x
> is there any other way? Something like x86's mov instruction
let me say that in general doing this is pointless. Due to SSA form, if %x is
set to 5 you can't set it to something else later. Thus everywhere that you
use %x you might as well just directly use 5 there instead. A common situation
is that you have a register %x, and due to performing optimizations you discover
that in fact %x will always have the value 5. You can use RAUW (aka the
replaceAllUsesWith method) to replace %x with 5 everywhere.
More information about the LLVMdev