[llvm-dev] Removing the register block in MIR

Justin Bogner via llvm-dev
Tue, 24 Oct 2017 18:09:05 -0000

Matthias Braun <mbraun at apple.com> writes:
>> On Oct 20, 2017, at 5:07 PM, Justin Bogner via llvm-dev <llvm-dev at
lists.llvm.org> wrote:
>>
>> The MIR format currently has a short-hand syntax for declaring vreg
>> classes and banks in the function body so you can write something like
>> this:
>>
>>  name: foo
>>  body: |
>>    %3:gpr(s64) = ...
>>
>> rather than the much more verbose and awkward:
>>
>>  name: foo
>>  registers:
>>    - { id: 3, class: gpr }
>>  body: |
>>    %3(s64) = ...
>>
>> I'd like to make this shorthand the only way to do this. There are
a few
>> things that need to be handled here:
>
> Yes not using the registers list is the way to go.

Thanks! I've gone ahead and committed this change now.

>> - We should only print the class on defs, not all uses. This is
>>  sufficient to be unambiguous, easy to be consistent, and avoids
>>  getting in the way of readability.
>
> We could in principle have no def if:
> - A vreg is completely unused. I don’t have a good reason right now we
> should serialize it then, so this is probably fine.
> - A vreg with no def but uses marked undef. This is also not
> particularily useful but legal and I could imagine this
> happening. Should be easy enough to catch this special case in the
> printer though; something like print regclass on all uses when there
> isn’t a single def.

This is a good point. I went ahead and printed the regclass on all uses
when there are no defs. If we ever make this a verifier error we could
undo that part.

>> - We'll still need to track the preferred-register elsewhere, so
we'll
>>  still need a block for those. They're used far less often than
>>  classes though, so I think its fine to just let them have their own
>>  block when any of them are set.
> Fine with me.
>
>>
>> - Basically every single MIR test will need to be updated, and its
>>  awkward to do automatically unless the test is already using the
>>  update_mir_test_checks script.
>>
>> I plan to implement this in a couple of steps:
>>
>> 1. Teach the MIRPrinter to print the regclass and update test checks
>
> That would be great. Ahmed had started working on this a while ago,
> but I think it got stuck or was interrupted by higher priority
> things...

Yep, I spoke with Ahmed. I think the sheer magnitude of the test update
kept him from finishing this.

>> 2. Modify existing tests to never provide the registers block
>> 3. Move preferred-registers to their own block and remove the registers
block
>>
>> A patch for step 1 is attached (with the other 241 test updates omitted
>> for brevity). I don't expect this direction to be contentious, but
since
>> the change will touch so many files I'll wait until Monday or
Tuesday to
>> start committing in case anyone has any concerns.
>
> I think it’s a great thing to do.
>
> - Matthias