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/Attributes.cpp | |
parent | e19fca4525919a6eb0d014a5678585e2dc96a61d (diff) | |
download | llvm-d932679c71c0a650c0afa109d4fdcbbe0e48877b.zip llvm-d932679c71c0a650c0afa109d4fdcbbe0e48877b.tar.gz llvm-d932679c71c0a650c0afa109d4fdcbbe0e48877b.tar.bz2 |
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/Attributes.cpp')
-rw-r--r-- | llvm/utils/TableGen/Attributes.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/llvm/utils/TableGen/Attributes.cpp b/llvm/utils/TableGen/Attributes.cpp new file mode 100644 index 0000000..385a244 --- /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. |