Provide a way to specify inliner's attribute compatibility and merging.
[oota-llvm.git] / utils / TableGen / Attributes.cpp
index 892457a90e9c473bfd2240c2a1c26847f5fb619b..7b001bf14de588a4ee6831d2da740e70b26c9cfa 100644 (file)
@@ -43,7 +43,7 @@ void Attributes::emitTargetIndependentEnums(raw_ostream &OS) {
   OS << "#ifdef GET_ATTR_ENUM\n";
   OS << "#undef GET_ATTR_ENUM\n";
 
-  const std::vector<Record*> &Attrs =
+  std::vector<Record*> Attrs =
       Records.getAllDerivedDefinitions("EnumAttr");
 
   for (auto A : Attrs)
@@ -89,7 +89,7 @@ void Attributes::emitFnAttrCompatCheck(raw_ostream &OS, bool IsStringAttr) {
      << "                                        const Function &Callee) {\n";
   OS << "  bool Ret = true;\n\n";
 
-  const std::vector<Record *> &CompatRules =
+  std::vector<Record *> CompatRules =
       Records.getAllDerivedDefinitions("CompatRule");
 
   for (auto *Rule : CompatRules) {
@@ -101,7 +101,7 @@ void Attributes::emitFnAttrCompatCheck(raw_ostream &OS, bool IsStringAttr) {
   OS << "  return Ret;\n";
   OS << "}\n\n";
 
-  const std::vector<Record *> &MergeRules =
+  std::vector<Record *> MergeRules =
       Records.getAllDerivedDefinitions("MergeRule");
   OS << "static inline void mergeFnAttrs(Function &Caller,\n"
      << "                                const Function &Callee) {\n";
@@ -121,8 +121,9 @@ void Attributes::printEnumAttrClasses(raw_ostream &OS,
   OS << "// EnumAttr classes\n";
   for (const auto *R : Records) {
     OS << "struct " << R->getName() << "Attr : EnumAttr {\n";
-    OS << "  constexpr static const enum Attribute::AttrKind Kind = ";
-    OS << "Attribute::" << R->getName() << ";\n";
+    OS << "  static enum Attribute::AttrKind getKind() {\n";
+    OS << "    return llvm::Attribute::" << R->getName() << ";\n";
+    OS << "  }\n";
     OS << "};\n";
   }
   OS << "\n";
@@ -133,8 +134,9 @@ void Attributes::printStrBoolAttrClasses(raw_ostream &OS,
   OS << "// StrBoolAttr classes\n";
   for (const auto *R : Records) {
     OS << "struct " << R->getName() << "Attr : StrBoolAttr {\n";
-    OS << "  constexpr static const char * const Kind = \"";
-    OS << R->getValueAsString("AttrString") << "\";\n";
+    OS << "  static const char *getKind() {\n";
+    OS << "    return \"" << R->getValueAsString("AttrString") << "\";\n";
+    OS << "  }\n";
     OS << "};\n";
   }
   OS << "\n";