blob: b86ae72ce9dbadea44f9841dec47d843b2e89d0b [file] [log] [blame]
Chris Lattner2c0f2c72003-08-06 04:23:04 +00001//===- TableGenBackend.cpp - Base class for TableGen Backends ---*- C++ -*-===//
2//
3// This file provides useful services for TableGen backends...
4//
5//===----------------------------------------------------------------------===//
6
7#include "TableGenBackend.h"
Chris Lattner18a6a942003-08-06 04:31:26 +00008#include "Record.h"
Chris Lattner2c0f2c72003-08-06 04:23:04 +00009#include <iostream>
10
11void TableGenBackend::EmitSourceFileHeader(const std::string &Desc,
Chris Lattner18a6a942003-08-06 04:31:26 +000012 std::ostream &OS) const {
Chris Lattner2c0f2c72003-08-06 04:23:04 +000013 OS << "//===- TableGen'erated file -------------------------------------*-"
14 " C++ -*-===//\n//\n// " << Desc << "\n//\n// Automatically generate"
15 "d file, do not edit!\n//\n//===------------------------------------"
16 "----------------------------------===//\n\n";
17}
18
Chris Lattner18a6a942003-08-06 04:31:26 +000019/// getQualifiedName - Return the name of the specified record, with a
20/// namespace qualifier if the record contains one.
21///
22std::string TableGenBackend::getQualifiedName(Record *R) const {
23 std::string Namespace = R->getValueAsString("Namespace");
24 if (Namespace.empty()) return R->getName();
25 return Namespace + "::" + R->getName();
26}
27