1 //===- TableGenBackend.cpp - Base class for TableGen Backends ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file provides useful services for TableGen backends...
12 //===----------------------------------------------------------------------===//
14 #include "TableGenBackend.h"
20 void TableGenBackend::EmitSourceFileHeader(const std::string &Desc,
21 std::ostream &OS) const {
22 OS << "//===- TableGen'erated file -------------------------------------*-"
23 " C++ -*-===//\n//\n// " << Desc << "\n//\n// Automatically generate"
24 "d file, do not edit!\n//\n//===------------------------------------"
25 "----------------------------------===//\n\nnamespace llvm {\n\n";
28 void TableGenBackend::EmitSourceFileTail( std::ostream& OS ) const {
29 OS << "} // End llvm namespace \n";
32 /// getQualifiedName - Return the name of the specified record, with a
33 /// namespace qualifier if the record contains one.
35 std::string TableGenBackend::getQualifiedName(Record *R) const {
36 std::string Namespace = R->getValueAsString("Namespace");
37 if (Namespace.empty()) return R->getName();
38 return Namespace + "::" + R->getName();
41 } // End llvm namespace