[LLVMdev] RFC: Code Gen Change!

Jakob Stoklund Olesen stoklund at 2pi.dk
Tue May 12 22:10:08 PDT 2009


On 13/05/2009, at 02.46, Bill Wendling wrote:
> Instead of all of the booleans, you pass in a flag that has bits set
> to indicate what state the register is in:
>
> namespace RegState {
>  enum {
>    Define         = 0x1,
>    Implicit       = 0x2,
>    Kill           = 0x4,
>    Dead           = 0x8,
>    EarlyClobber   = 0x10,
>    ImplicitDefine = Implicit | Define,
>    ImplicitKill   = Implicit | Kill
>  };
> }
[...]
>  MachineInstrBuilder &addReg(unsigned RegNo, unsigned flags = 0,
>                              unsigned SubReg = 0) const {

Hi Bill,

I definitely like this change. The staccato bool arguments are  
impossible to read. One comment:

If I forget to update an addReg(Reg, true) call, it will still compile  
and work by accident. If you leave bit 0 unused by the enum and  
assert(flags&1 == 0), you make sure I have updated all my addReg calls.

Humans being human, we are going to fix addReg calls until everything  
compiles and passes 'make check'. I don't think addReg(Reg, true)  
should be allowed to survive the API change.

/jakob




More information about the llvm-dev mailing list