[llvm-commits] [llvm] r104910 - in /llvm/trunk/utils/TableGen: CMakeLists.txt NeonEmitter.cpp NeonEmitter.h TableGen.cpp
Nate Begeman
natebegeman at mac.com
Thu May 27 18:08:32 PDT 2010
Author: sampo
Date: Thu May 27 20:08:32 2010
New Revision: 104910
URL: http://llvm.org/viewvc/llvm-project?rev=104910&view=rev
Log:
Add support to tablegen for auto-generating arm_neon.h from a tablegen description
of the intrinsics. The goal is to auto-generate both support for GCC-style (vector)
and ARM-style (struct of vector) intrinsics.
This is work in progress, but will be completed soon.
Added:
llvm/trunk/utils/TableGen/NeonEmitter.cpp
llvm/trunk/utils/TableGen/NeonEmitter.h
Modified:
llvm/trunk/utils/TableGen/CMakeLists.txt
llvm/trunk/utils/TableGen/TableGen.cpp
Modified: llvm/trunk/utils/TableGen/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CMakeLists.txt?rev=104910&r1=104909&r2=104910&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CMakeLists.txt (original)
+++ llvm/trunk/utils/TableGen/CMakeLists.txt Thu May 27 20:08:32 2010
@@ -22,6 +22,7 @@
InstrInfoEmitter.cpp
IntrinsicEmitter.cpp
LLVMCConfigurationEmitter.cpp
+ NeonEmitter.cpp
OptParserEmitter.cpp
Record.cpp
RegisterInfoEmitter.cpp
Added: llvm/trunk/utils/TableGen/NeonEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.cpp?rev=104910&view=auto
==============================================================================
--- llvm/trunk/utils/TableGen/NeonEmitter.cpp (added)
+++ llvm/trunk/utils/TableGen/NeonEmitter.cpp Thu May 27 20:08:32 2010
@@ -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 <string>
+
+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 <stdint.h>\n\n";
+
+ // EmitTypedefs(OS);
+
+ // Process Records
+
+ std::vector<Record*> 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";
+}
Added: llvm/trunk/utils/TableGen/NeonEmitter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.h?rev=104910&view=auto
==============================================================================
--- llvm/trunk/utils/TableGen/NeonEmitter.h (added)
+++ llvm/trunk/utils/TableGen/NeonEmitter.h Thu May 27 20:08:32 2010
@@ -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
Modified: llvm/trunk/utils/TableGen/TableGen.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TableGen.cpp?rev=104910&r1=104909&r2=104910&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/TableGen.cpp (original)
+++ llvm/trunk/utils/TableGen/TableGen.cpp Thu May 27 20:08:32 2010
@@ -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 @@
GenTgtIntrinsic,
GenLLVMCConf,
GenEDHeader, GenEDInfo,
+ GenNeonHeader,
PrintEnums
};
@@ -119,6 +121,8 @@
"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 @@
case GenEDInfo:
EDEmitter(Records).run(Out);
break;
+ case GenNeonHeader:
+ NeonEmitter(Records).run(*Out);
+ break;
case PrintEnums:
{
std::vector<Record*> Recs = Records.getAllDerivedDefinitions(Class);
More information about the llvm-commits
mailing list