diff --git a/llvm/utils/TableGen/CMakeLists.txt b/llvm/utils/TableGen/CMakeLists.txt index 731cde92cfee7a61c2ee74e89dc93db86c6c1330..05520c147d41c73a9053eaa47bcfc39babab2dbb 100644 --- a/llvm/utils/TableGen/CMakeLists.txt +++ b/llvm/utils/TableGen/CMakeLists.txt @@ -22,6 +22,7 @@ add_executable(tblgen InstrInfoEmitter.cpp IntrinsicEmitter.cpp LLVMCConfigurationEmitter.cpp + NeonEmitter.cpp OptParserEmitter.cpp Record.cpp RegisterInfoEmitter.cpp diff --git a/llvm/utils/TableGen/NeonEmitter.cpp b/llvm/utils/TableGen/NeonEmitter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dcbcf7596266c8323b4982f93cb16d8e5e973c07 --- /dev/null +++ b/llvm/utils/TableGen/NeonEmitter.cpp @@ -0,0 +1,62 @@ +//===- NeonEmitter.cpp - Generate arm_neon.h for use with clang -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This tablegen backend is responsible for emitting arm_neon.h, which includes +// a declaration and definition of each function specified by the ARM NEON +// compiler interface. See ARM document DUI0348B. +// +//===----------------------------------------------------------------------===// + +#include "NeonEmitter.h" +#include "Record.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringMap.h" +#include + +using namespace llvm; + +void NeonEmitter::run(raw_ostream &OS) { + EmitSourceFileHeader("ARM NEON Header", OS); + + // FIXME: emit license into file? + + OS << "#ifndef __ARM_NEON_H\n"; + OS << "#define __ARM_NEON_H\n\n"; + + OS << "#ifndef __ARM_NEON__\n"; + OS << "#error \"NEON support not enabled\"\n"; + OS << "#endif\n\n"; + + OS << "#include \n\n"; + + // EmitTypedefs(OS); + + // Process Records + + std::vector RV = Records.getAllDerivedDefinitions("Inst"); + + // Unique the pattern types, and assign them + + // emit #define directives for uniq'd prototypes + + // emit record directives + + for (unsigned i = 0, e = RV.size(); i != e; ++i) { + Record *R = RV[i]; + + OS << LowercaseString(R->getName()) << "\n"; + + std::string Types = R->getValueAsString("Types"); + std::string Pattern = R->getValueAsString("Pattern"); + + OS << Types << "\n" << Pattern << "\n\n"; + } + + OS << "#endif /* __ARM_NEON_H */\n"; +} diff --git a/llvm/utils/TableGen/NeonEmitter.h b/llvm/utils/TableGen/NeonEmitter.h new file mode 100644 index 0000000000000000000000000000000000000000..dc2079419d1ce92b2fdcc46b097017ff435fe7c4 --- /dev/null +++ b/llvm/utils/TableGen/NeonEmitter.h @@ -0,0 +1,34 @@ +//===- NeonEmitter.h - Generate arm_neon.h for use with clang ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This tablegen backend is responsible for emitting arm_neon.h, which includes +// a declaration and definition of each function specified by the ARM NEON +// compiler interface. See ARM document DUI0348B. +// +//===----------------------------------------------------------------------===// + +#ifndef NEON_EMITTER_H +#define NEON_EMITTER_H + +#include "TableGenBackend.h" + +namespace llvm { + + class NeonEmitter : public TableGenBackend { + RecordKeeper &Records; + public: + NeonEmitter(RecordKeeper &R) : Records(R) {} + + // runHeader - Emit a header file that allows use of the instruction table. + void run(raw_ostream &o); + }; + +} // End llvm namespace + +#endif diff --git a/llvm/utils/TableGen/TableGen.cpp b/llvm/utils/TableGen/TableGen.cpp index 0fbfec312cbfcc633632b9bfb2d9cafafd79c975..9485864a2ec6ceae149ebcb702f184d8eaa3b78f 100644 --- a/llvm/utils/TableGen/TableGen.cpp +++ b/llvm/utils/TableGen/TableGen.cpp @@ -29,6 +29,7 @@ #include "InstrInfoEmitter.h" #include "IntrinsicEmitter.h" #include "LLVMCConfigurationEmitter.h" +#include "NeonEmitter.h" #include "OptParserEmitter.h" #include "Record.h" #include "RegisterInfoEmitter.h" @@ -63,6 +64,7 @@ enum ActionType { GenTgtIntrinsic, GenLLVMCConf, GenEDHeader, GenEDInfo, + GenNeonHeader, PrintEnums }; @@ -119,6 +121,8 @@ namespace { "Generate enhanced disassembly info header"), clEnumValN(GenEDInfo, "gen-enhanced-disassembly-info", "Generate enhanced disassembly info"), + clEnumValN(GenNeonHeader, "gen-arm-neon-header", + "Generate arm_neon.h for clang"), clEnumValN(PrintEnums, "print-enums", "Print enum values for a class"), clEnumValEnd)); @@ -280,6 +284,9 @@ int main(int argc, char **argv) { case GenEDInfo: EDEmitter(Records).run(Out); break; + case GenNeonHeader: + NeonEmitter(Records).run(*Out); + break; case PrintEnums: { std::vector Recs = Records.getAllDerivedDefinitions(Class);