[llvm-dev] TableGen: Named template arguments

Paul C. Anagnostopoulos via llvm-dev llvm-dev at lists.llvm.org
Mon Nov 2 11:09:35 PST 2020


Here is a TableGen feature that I think would be useful, but I'd like some feedback.

TableGen would allow the template arguments in a class or multiclass invocation to be named (in the venerable tradition of macro arguments). For example:

class InstSubst<string Asm, dag Result, bit EmitPriority = 0>
  : InstAlias<Asm, Result, EmitPriority>, Requires<[UseNegativeImmediates]>;

This class could be invoked as follows:

  def : InstSubst<Result: (!cast<Instruction>(NAME # "Wri") GPR32sp:$Rd,
                                       GPR32:$Rn, logical_imm32_not:$imm),
                         Asm: Alias # "\t$Rd, $Rn, $imm",
                         EmitPriority: 0>;

Note that each template argument is named, so that they do not have to be in order. An argument list could start with positional arguments and then switch to named arguments, but not vice versa.



More information about the llvm-dev mailing list