[llvm-commits] [llvm] r117830 - in /llvm/trunk: docs/CodeGenerator.html include/llvm/Target/Target.td lib/Target/X86/AsmParser/X86AsmParser.cpp lib/Target/X86/X86InstrInfo.td utils/TableGen/AsmMatcherEmitter.cpp

Frits van Bommel fvbommel at gmail.com
Sat Oct 30 12:43:58 PDT 2010


On Sat, Oct 30, 2010 at 9:23 PM, Chris Lattner <sabre at nondot.org> wrote:
> Author: lattner
> Date: Sat Oct 30 14:23:13 2010
> New Revision: 117830
>
> URL: http://llvm.org/viewvc/llvm-project?rev=117830&view=rev
> Log:
> Implement (and document!) support for MnemonicAlias's to have Requires
> directives, allowing things like this:
>
> def : MnemonicAlias<"pop", "popl">, Requires<[In32BitMode]>;
> def : MnemonicAlias<"pop", "popq">, Requires<[In64BitMode]>;
>
> Move the rest of the X86 MnemonicAliases over to the .td file.

Typos etc.

>  <p>The first phase of alias processing is simple instruction mneomonic
>  remapping for classes of instructions which are allowed with two different
> -mneomonics.  This phase is a simple and unconditionally remapping from one input
> +mnemonics.  This phase is a simple and unconditionally remapping from one input

You missed the first one (on the first line quoted above, mneomonic ->
mnemonic).

> +          // We can't have two aliases from the same mnemonic with no predicate.
> +          PrintError(ToVec[AliasWithNoPredicate]->getLoc(),
> +                     "two MnemonicAliases with the same 'from' mnemonic!");
> +          PrintError(R->getLoc(), "this is the other MnemonicAliases.");

"the other MnemonicAliases" -> "the other MnemonicAlias"

> +          throw std::string("ERROR: Invalid MnemonicAliases definitions!");

This should probably be MnemonicAlias as well.

> +        }
> +
> +        AliasWithNoPredicate = i;
> +        continue;
> +      }
> +
> +      MatchCode += "if ((Features & " + FeatureMask + ") == "+FeatureMask+")\n";
> +      MatchCode += "  Mnemonic = \"" +R->getValueAsString("ToMnemonic")+"\";\n";
> +    }

Shouldn't this emit "else if" instead of "if" after the first one?
(Mostly just to future-proof it for when non-contradictory features
ever get allowed here, but should be slightly more efficient as well)

> +    if (AliasWithNoPredicate != -1) {
> +      Record *R = ToVec[AliasWithNoPredicate];
> +      MatchCode += "Mnemonic = \"" + R->getValueAsString("ToMnemonic") + "\";";
>     }

This should probably be prefixed with "else" as well if there were any
predicated aliases, otherwise it will overwrite their changes.




More information about the llvm-commits mailing list