[LLVMdev] Adding MachineOperands that are not part of MCInstrDesc.

Tom Stellard tom at stellard.net
Wed Apr 22 08:12:04 PDT 2015


On Wed, Apr 22, 2015 at 04:48:54PM +0200, Jonas Paulsson wrote:
> Hi,
> 
> I wonder if it is okay to add an operand that is not part of
> MCInstrDesc to an MI after isel?
> 
> There are things going on like instruction combining,
> rematerialization etc, which may call MI with TI->get(opcode). If an
> MI would get replaced with a new instance of itself in this way, any
> previously added operands would get lost, as they are not part of
> the MCInstrDesc.
> 
> RegAlloc, does this, so I assume it is safe to add operands post-ra.
> I wonder if it also safe to add phys-reg defs/uses directly after
> DAG isel? Would it be a bug if they would be removed by a
> transformation?
> 

You can add implicit uses and defs.  You may get lucky and adding explicit defs
and uses will work, but I would not recommend doing this.  If you really need
to do this, you could make the instruction variadic or create two instruction defs,
one with n operands and one with n + 1.

-Tom

> Thanks,
> 
> Jonas Paulsson
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



More information about the llvm-dev mailing list