[PATCH] #pragma vectorize

Tyler Nowicki tnowicki at apple.com
Thu May 8 14:00:11 PDT 2014


Hi,

> It doesn't really require a spelling because it's not something that
> the user can type out directly. If you went with two attributes
> instead of one, then you don't require a spelling for it. You could
> get away with something like:
> 
> def LoopHint : Attr {
>  let Args = [IntArgument<"type">,
>                  ExprArgument<"value", 1>];
> let AdditionalMembers = [{
>    // Your static methods
>  }];
> }
> 
> def VectorizeLoopHint : LoopHint;
> def InterleaveLoopHint : LoopHint;
> 
> Pretty sure that would work for you. You definitely do not need a
> spelling to get the class generated by tablegen (there are several
> other attributes which are implicit-only and have no spelling).


Something may be missing here. It fails to compile the td file:

Basic/Attr.td:1763:25: error: Couldn't find class 'LoopHint'
def VectorizeLoopHint : LoopHint;

Changing def LoopHint for class LoopHint also fails

Basic/Attr.td:1763:1: error: Record `InterleaveLoopHint', field `Spellings' does not have a list initializer!
def InterleaveLoopHint : LoopHint;

Adding an empty spelling `let Spellings = []’ allows it to get through the td file but it does not generate a LoopHint class causing the compilation of the generated code to fail.

AST/Attrs.inc:2500:39: error: expected class
      name
class InterleaveLoopHintAttr : public LoopHint {

Perhaps I’m doing something wrong? But…

The pretty printing function is generated to blank anyway without a Spelling because the spelling is required by tablegen to generate the body of the function.

static void
writePrettyPrintFunction(Record &R,
                         const std::vector<std::unique_ptr<Argument>> &Args,
                         raw_ostream &OS) {
  std::vector<FlattenedSpelling> Spellings = GetFlattenedSpellings(R);

  OS << "void " << R.getName() << "Attr::printPretty("
    << "raw_ostream &OS, const PrintingPolicy &Policy) const {\n";

  if (Spellings.empty()) {
    OS << "}\n\n";
    return;
  }
…

I’m pretty sure a spelling is required unless you are providing the base class outside the td file. I’m looking at modifying the way pretty printing works now to generate a printer that prints the pragma. But it seems bad to specialize the code that generates the pretty printer for printing loop pragmas and so it will still be necessary to make some kind of a call into the LoopHintAttr to print the pragma.

Tyler
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140508/5fcbc13d/attachment.html>


More information about the cfe-commits mailing list