Provide a way to specify inliner's attribute compatibility and merging.
[oota-llvm.git] / utils / TableGen / Attributes.cpp
index df986a5fb5656f5a16dbc5710dcae1b9e25856ec..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,11 +89,11 @@ void Attributes::emitFnAttrCompatCheck(raw_ostream &OS, bool IsStringAttr) {
      << "                                        const Function &Callee) {\n";
   OS << "  bool Ret = true;\n\n";
 
-  const std::vector<Record *> &CompatRules =
-    Records.getAllDerivedDefinitions("CompatRule");
+  std::vector<Record *> CompatRules =
+      Records.getAllDerivedDefinitions("CompatRule");
 
   for (auto *Rule : CompatRules) {
-    StringRef FuncName = Rule->getValueAsString("CompatFunc");
+    std::string FuncName = Rule->getValueAsString("CompatFunc");
     OS << "  Ret &= " << FuncName << "(Caller, Callee);\n";
   }
 
@@ -101,13 +101,13 @@ 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";
 
   for (auto *Rule : MergeRules) {
-    StringRef FuncName = Rule->getValueAsString("MergeFunc");
+    std::string FuncName = Rule->getValueAsString("MergeFunc");
     OS << "  " << FuncName << "(Caller, 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";