diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2015-11-11 20:35:42 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2015-11-11 20:35:42 +0000 |
commit | d932679c71c0a650c0afa109d4fdcbbe0e48877b (patch) | |
tree | f27f8c867abc80112b1fce550463f1437d9d1d15 /llvm/utils/TableGen | |
parent | e19fca4525919a6eb0d014a5678585e2dc96a61d (diff) | |
download | bcm5719-llvm-d932679c71c0a650c0afa109d4fdcbbe0e48877b.tar.gz bcm5719-llvm-d932679c71c0a650c0afa109d4fdcbbe0e48877b.zip |
Move the enum attributes defined in Attributes.h to a table-gen file.
This is a step towards consolidating some of the information regarding
attributes in a single place.
This patch moves the enum attributes in Attributes.h to the table-gen
file. Additionally, it adds definitions of target independent string
attributes that will be used in follow-up commits by the inliner to
check attribute compatibility.
rdar://problem/19836465
llvm-svn: 252796
Diffstat (limited to 'llvm/utils/TableGen')
-rw-r--r-- | llvm/utils/TableGen/Attributes.cpp | 59 | ||||
-rw-r--r-- | llvm/utils/TableGen/CMakeLists.txt | 1 | ||||
-rw-r--r-- | llvm/utils/TableGen/TableGen.cpp | 8 | ||||
-rw-r--r-- | llvm/utils/TableGen/TableGenBackends.h | 1 |
4 files changed, 68 insertions, 1 deletions
diff --git a/llvm/utils/TableGen/Attributes.cpp b/llvm/utils/TableGen/Attributes.cpp new file mode 100644 index 00000000000..385a244d74d --- /dev/null +++ b/llvm/utils/TableGen/Attributes.cpp @@ -0,0 +1,59 @@ +//===- Attributes.cpp - Generate attributes -------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Support/SourceMgr.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/TableGen/Error.h" +#include "llvm/TableGen/Record.h" +#include <algorithm> +#include <string> +#include <vector> +using namespace llvm; + +#define DEBUG_TYPE "attr-enum" + +namespace { + +class Attributes { +public: + Attributes(RecordKeeper &R) : Records(R) {} + void emit(raw_ostream &OS); + +private: + void emitTargetIndependentEnums(raw_ostream &OS); + + RecordKeeper &Records; +}; + +} // End anonymous namespace. + +void Attributes::emitTargetIndependentEnums(raw_ostream &OS) { + OS << "#ifdef GET_ATTR_ENUM\n"; + OS << "#undef GET_ATTR_ENUM\n"; + + const std::vector<Record*> &Attrs = + Records.getAllDerivedDefinitions("EnumAttr"); + + for (auto A : Attrs) + OS << A->getName() << ",\n"; + + OS << "#endif\n"; +} + +void Attributes::emit(raw_ostream &OS) { + emitTargetIndependentEnums(OS); +} + +namespace llvm { + +void EmitAttributes(RecordKeeper &RK, raw_ostream &OS) { + Attributes(RK).emit(OS); +} + +} // End llvm namespace. diff --git a/llvm/utils/TableGen/CMakeLists.txt b/llvm/utils/TableGen/CMakeLists.txt index feaa7c75796..eef1540424d 100644 --- a/llvm/utils/TableGen/CMakeLists.txt +++ b/llvm/utils/TableGen/CMakeLists.txt @@ -4,6 +4,7 @@ add_tablegen(llvm-tblgen LLVM AsmMatcherEmitter.cpp AsmWriterEmitter.cpp AsmWriterInst.cpp + Attributes.cpp CallingConvEmitter.cpp CodeEmitterGen.cpp CodeGenDAGPatterns.cpp diff --git a/llvm/utils/TableGen/TableGen.cpp b/llvm/utils/TableGen/TableGen.cpp index 02fe4dc98be..c16a5583eb3 100644 --- a/llvm/utils/TableGen/TableGen.cpp +++ b/llvm/utils/TableGen/TableGen.cpp @@ -41,7 +41,8 @@ enum ActionType { PrintEnums, PrintSets, GenOptParserDefs, - GenCTags + GenCTags, + GenAttributes }; namespace { @@ -85,6 +86,8 @@ namespace { "Generate option definitions"), clEnumValN(GenCTags, "gen-ctags", "Generate ctags-compatible index"), + clEnumValN(GenAttributes, "gen-attrs", + "Generate attributes"), clEnumValEnd)); cl::opt<std::string> @@ -165,6 +168,9 @@ bool LLVMTableGenMain(raw_ostream &OS, RecordKeeper &Records) { case GenCTags: EmitCTags(Records, OS); break; + case GenAttributes: + EmitAttributes(Records, OS); + break; } return false; diff --git a/llvm/utils/TableGen/TableGenBackends.h b/llvm/utils/TableGen/TableGenBackends.h index 2dc03ce1e71..d9dd3d15769 100644 --- a/llvm/utils/TableGen/TableGenBackends.h +++ b/llvm/utils/TableGen/TableGenBackends.h @@ -78,6 +78,7 @@ void EmitSubtarget(RecordKeeper &RK, raw_ostream &OS); void EmitMapTable(RecordKeeper &RK, raw_ostream &OS); void EmitOptParser(RecordKeeper &RK, raw_ostream &OS); void EmitCTags(RecordKeeper &RK, raw_ostream &OS); +void EmitAttributes(RecordKeeper &RK, raw_ostream &OS); } // End llvm namespace |