[PATCH] Add field to InstAlias used to instruct AsmMatcherEmitter to ignore alias

Akira Hatanaka ahatanak at gmail.com
Fri Jul 19 12:51:49 PDT 2013


The attached patch (instalias1.patch) adds field "Assemble", which
AsmMatcherEmitter can use to decide whether it should ignore the alias.

This is needed when there are two InstAlias patterns with the same
AsmString. For example, in MipsInstrInfo.td, there are two patterns which
have the .s format, "move $dst, $src":

def : InstAlias<"move $dst, $src",
                (ADDu CPURegsOpnd:$dst, CPURegsOpnd:$src,ZERO), 1>,
      Requires<[NotMips64]>;
def : InstAlias<"move $dst, $src",
                (OR CPURegsOpnd:$dst, CPURegsOpnd:$src,ZERO), 1>,

We need two aliases here because we want to have instPrinter print a "move"
instruction instead of an "addu" or "or" when one of the operands is $zero:

"addu $2, $3, $zero" or "or $2, $3, $zero" =>  "move $2, $3"

However, this causes tablegen to place two entries in array MatchTable
in MipsGenAsmMatcher.inc:

  { 1364 /* move */, Mips::OR,
Convert__CPURegsAsm1_0__CPURegsAsm1_1__regZERO, Feature_NotMips64, {
MCK_CPURegsAsm, MCK_CPURegsAsm }, 0},
  { 1364 /* move */, Mips::ADDu,
Convert__CPURegsAsm1_0__CPURegsAsm1_1__regZERO, Feature_NotMips64, {
MCK_CPURegsAsm, MCK_CPURegsAsm }, 0},

The order in which these entries appear in the table seems arbitrary, as I
discovered when  I made completely unrelated changes in other places. We
want to have the assembler generate an "ADDu" instruction and ignore the
pattern with "OR".

Please review.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130719/532bc943/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: instalias1.patch
Type: application/octet-stream
Size: 1498 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130719/532bc943/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: instalias-mips.patch
Type: application/octet-stream
Size: 1357 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130719/532bc943/attachment-0001.obj>


More information about the llvm-commits mailing list