[llvm-commits] [llvm] r62067 - /llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp

Chris Lattner sabre at nondot.org
Sun Jan 11 17:27:55 PST 2009


Author: lattner
Date: Sun Jan 11 19:27:55 2009
New Revision: 62067

URL: http://llvm.org/viewvc/llvm-project?rev=62067&view=rev
Log:
add scaffolding to emit argument attributes.  No functionality 
change.

Modified:
    llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp

Modified: llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp?rev=62067&r1=62066&r2=62067&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp Sun Jan 11 19:27:55 2009
@@ -397,7 +397,10 @@
   OS << "  Attributes Attr = Attribute::NoUnwind;\n";
   OS << "  switch (id) {\n";
   OS << "  default: break;\n";
+  unsigned MaxArgAttrs = 0;
   for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
+    MaxArgAttrs =
+      std::max(MaxArgAttrs, unsigned(Ints[i].ArgumentAttributes.size()));
     switch (Ints[i].ModRef) {
     default: break;
     case CodeGenIntrinsic::NoMem:
@@ -419,8 +422,34 @@
   OS << "    Attr |= Attribute::ReadOnly; // These do not write memory.\n";
   OS << "    break;\n";
   OS << "  }\n";
-  OS << "  AttributeWithIndex PAWI = AttributeWithIndex::get(~0, Attr);\n";
-  OS << "  return AttrListPtr::get(&PAWI, 1);\n";
+  OS << "  AttributeWithIndex AWI[" << MaxArgAttrs+1 << "];\n";
+  OS << "  AWI[0] = AttributeWithIndex::get(~0, Attr);\n";
+  OS << "  unsigned NumAttrs = 1;\n";
+  OS << "  switch (id) {\n";
+  OS << "  default: break;\n";
+  
+  // Add argument attributes for any intrinsics that have them.
+  for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
+    if (Ints[i].ArgumentAttributes.empty()) continue;
+    
+    OS << "  case Intrinsic::" << Ints[i].EnumName << ":\n";
+
+    std::vector<std::pair<unsigned, CodeGenIntrinsic::ArgAttribute> > ArgAttrs =
+      Ints[i].ArgumentAttributes;
+    // Sort by argument index.
+    std::sort(ArgAttrs.begin(), ArgAttrs.end());
+
+    unsigned NumArgsWithAttrs = 0;
+
+    // FIXME: EMIT ATTRS
+    
+    
+    OS << "    NumAttrs = " << NumArgsWithAttrs+1 << ";\n";
+    OS << "    break;\n";
+  }
+  
+  OS << "  }\n";
+  OS << "  return AttrListPtr::get(AWI, NumAttrs);\n";
   OS << "}\n";
   OS << "#endif\n\n";
 }





More information about the llvm-commits mailing list