blob: 161b2eeb607e7458a284fd0ea53f4043f4fc341e [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
18void TableGenBackend::EmitSourceFileHeader(const std::string &Desc,
Chris Lattner18a6a942003-08-06 04:31:26 +000019 std::ostream &OS) const {
Chris Lattner2c0f2c72003-08-06 04:23:04 +000020 OS << "//===- TableGen'erated file -------------------------------------*-"
21 " C++ -*-===//\n//\n// " << Desc << "\n//\n// Automatically generate"
22 "d file, do not edit!\n//\n//===------------------------------------"
23 "----------------------------------===//\n\n";
24}
25
Chris Lattner18a6a942003-08-06 04:31:26 +000026/// getQualifiedName - Return the name of the specified record, with a
27/// namespace qualifier if the record contains one.
28///
29std::string TableGenBackend::getQualifiedName(Record *R) const {
30 std::string Namespace = R->getValueAsString("Namespace");
31 if (Namespace.empty()) return R->getName();
32 return Namespace + "::" + R->getName();
33}
34