blob: dcbcf7596266c8323b4982f93cb16d8e5e973c07 [file] [log] [blame]
Nate Begeman5ddb0872010-05-28 01:08:32 +00001//===- NeonEmitter.cpp - Generate arm_neon.h for use with clang -*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This tablegen backend is responsible for emitting arm_neon.h, which includes
11// a declaration and definition of each function specified by the ARM NEON
12// compiler interface. See ARM document DUI0348B.
13//
14//===----------------------------------------------------------------------===//
15
16#include "NeonEmitter.h"
17#include "Record.h"
18#include "llvm/ADT/StringExtras.h"
19#include "llvm/ADT/StringMap.h"
20#include <string>
21
22using namespace llvm;
23
24void NeonEmitter::run(raw_ostream &OS) {
25 EmitSourceFileHeader("ARM NEON Header", OS);
26
27 // FIXME: emit license into file?
28
29 OS << "#ifndef __ARM_NEON_H\n";
30 OS << "#define __ARM_NEON_H\n\n";
31
32 OS << "#ifndef __ARM_NEON__\n";
33 OS << "#error \"NEON support not enabled\"\n";
34 OS << "#endif\n\n";
35
36 OS << "#include <stdint.h>\n\n";
37
38 // EmitTypedefs(OS);
39
40 // Process Records
41
42 std::vector<Record*> RV = Records.getAllDerivedDefinitions("Inst");
43
44 // Unique the pattern types, and assign them
45
46 // emit #define directives for uniq'd prototypes
47
48 // emit record directives
49
50 for (unsigned i = 0, e = RV.size(); i != e; ++i) {
51 Record *R = RV[i];
52
53 OS << LowercaseString(R->getName()) << "\n";
54
55 std::string Types = R->getValueAsString("Types");
56 std::string Pattern = R->getValueAsString("Pattern");
57
58 OS << Types << "\n" << Pattern << "\n\n";
59 }
60
61 OS << "#endif /* __ARM_NEON_H */\n";
62}