blob: 67a37885db1a7d21df92f79cdd410709008b7124 [file] [log] [blame]
Chris Lattner2c0f2c72003-08-06 04:23:04 +00001//===- TableGenBackend.cpp - Base class for TableGen Backends ---*- C++ -*-===//
John Criswell01d45822003-10-20 20:20:30 +00002//
3// The LLVM Compiler Infrastructure
4//
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.
7//
8//===----------------------------------------------------------------------===//
Chris Lattner2c0f2c72003-08-06 04:23:04 +00009//
10// This file provides useful services for TableGen backends...
11//
12//===----------------------------------------------------------------------===//
13
14#include "TableGenBackend.h"
Chris Lattner18a6a942003-08-06 04:31:26 +000015#include "Record.h"
Chris Lattner2c0f2c72003-08-06 04:23:04 +000016#include <iostream>
17
Brian Gaeked0fde302003-11-11 22:41:34 +000018namespace llvm {
19
Chris Lattner2c0f2c72003-08-06 04:23:04 +000020void TableGenBackend::EmitSourceFileHeader(const std::string &Desc,
Chris Lattner18a6a942003-08-06 04:31:26 +000021 std::ostream &OS) const {
Chris Lattner2c0f2c72003-08-06 04:23:04 +000022 OS << "//===- TableGen'erated file -------------------------------------*-"
23 " C++ -*-===//\n//\n// " << Desc << "\n//\n// Automatically generate"
24 "d file, do not edit!\n//\n//===------------------------------------"
Brian Gaeked0fde302003-11-11 22:41:34 +000025 "----------------------------------===//\n\nnamespace llvm {\n\n";
26}
27
28void TableGenBackend::EmitSourceFileTail( std::ostream& OS ) const {
29 OS << "} // End llvm namespace \n";
Chris Lattner2c0f2c72003-08-06 04:23:04 +000030}
31
Chris Lattner18a6a942003-08-06 04:31:26 +000032/// getQualifiedName - Return the name of the specified record, with a
33/// namespace qualifier if the record contains one.
34///
35std::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();
39}
40
Brian Gaeked0fde302003-11-11 22:41:34 +000041} // End llvm namespace