[llvm-commits] [llvm] r124870 - in /llvm/trunk: include/llvm/Target/Target.td utils/TableGen/AsmMatcherEmitter.cpp

Jim Grosbach grosbach at apple.com
Tue Feb 8 11:33:05 PST 2011


Hi Daniel,

This looks very interesting, but I'm not completely clear what it's for. Do you have an example in mind I could look at?

Tangentially, being able to do something similar on an InstAlias would be very handy. That is, by able to have match classes on input operands and then have a transform function for setting the output MCInst.

-Jim

On Feb 4, 2011, at 9:12 AM, Daniel Dunbar wrote:

> Author: ddunbar
> Date: Fri Feb  4 11:12:15 2011
> New Revision: 124870
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=124870&view=rev
> Log:
> MC/AsmMatcher: Add support for custom conversion functions.
> 
> Modified:
>    llvm/trunk/include/llvm/Target/Target.td
>    llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
> 
> Modified: llvm/trunk/include/llvm/Target/Target.td
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/Target.td?rev=124870&r1=124869&r2=124870&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Target/Target.td (original)
> +++ llvm/trunk/include/llvm/Target/Target.td Fri Feb  4 11:12:15 2011
> @@ -248,6 +248,13 @@
> 
>   /// Target-specific flags. This becomes the TSFlags field in TargetInstrDesc.
>   bits<64> TSFlags = 0;
> +
> +  ///@name Assembler Parser Support
> +  ///@{
> +
> +  string AsmMatchConverter = "";
> +
> +  ///@}
> }
> 
> /// Predicates - These are extra conditionals which are turned into instruction
> 
> Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=124870&r1=124869&r2=124870&view=diff
> ==============================================================================
> --- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original)
> +++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Fri Feb  4 11:12:15 2011
> @@ -1388,6 +1388,26 @@
>          ie = Infos.end(); it != ie; ++it) {
>     MatchableInfo &II = **it;
> 
> +    // Check if we have a custom match function.
> +    StringRef AsmMatchConverter = II.getResultInst()->TheDef->getValueAsString(
> +      "AsmMatchConverter");
> +    if (!AsmMatchConverter.empty()) {
> +      std::string Signature = "ConvertCustom_" + AsmMatchConverter.str();
> +      II.ConversionFnKind = Signature;
> +
> +      // Check if we have already generated this signature.
> +      if (!GeneratedFns.insert(Signature).second)
> +        continue;
> +
> +      // If not, emit it now.  Add to the enum list.
> +      OS << "  " << Signature << ",\n";
> +
> +      CvtOS << "  case " << Signature << ":\n";
> +      CvtOS << "    " << AsmMatchConverter << "(Inst, Opcode, Operands);\n";
> +      CvtOS << "    return;\n";
> +      continue;
> +    }
> +
>     // Build the conversion function signature.
>     std::string Signature = "Convert";
>     std::string CaseBody;
> @@ -1988,7 +2008,6 @@
>        it != ie; ++it) {
>     MatchableInfo &II = **it;
> 
> -
>     OS << "  { " << Target.getName() << "::"
>        << II.getResultInst()->TheDef->getName() << ", \"" << II.Mnemonic << "\""
>        << ", " << II.ConversionFnKind << ", { ";
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list