blob: 716bb4886c9ada8c4c31a57489469284b7d5027a [file] [log] [blame]
Chris Lattner2c0f2c72003-08-06 04:23:04 +00001//===- TableGenBackend.cpp - Base class for TableGen Backends ---*- C++ -*-===//
Misha Brukman3da94ae2005-04-22 00:00:37 +00002//
John Criswell01d45822003-10-20 20:20:30 +00003// 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.
Misha Brukman3da94ae2005-04-22 00:00:37 +00007//
John Criswell01d45822003-10-20 20:20:30 +00008//===----------------------------------------------------------------------===//
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>
Chris Lattner2082ebe2004-08-01 03:55:39 +000017using namespace llvm;
Brian Gaeked0fde302003-11-11 22:41:34 +000018
Chris Lattner2c0f2c72003-08-06 04:23:04 +000019void TableGenBackend::EmitSourceFileHeader(const std::string &Desc,
Chris Lattner18a6a942003-08-06 04:31:26 +000020 std::ostream &OS) const {
Chris Lattner2c0f2c72003-08-06 04:23:04 +000021 OS << "//===- TableGen'erated file -------------------------------------*-"
22 " C++ -*-===//\n//\n// " << Desc << "\n//\n// Automatically generate"
23 "d file, do not edit!\n//\n//===------------------------------------"
Chris Lattner2c384132004-08-17 03:08:28 +000024 "----------------------------------===//\n\n";
Chris Lattner2c0f2c72003-08-06 04:23:04 +000025}
26
Chris Lattner18a6a942003-08-06 04:31:26 +000027/// getQualifiedName - Return the name of the specified record, with a
28/// namespace qualifier if the record contains one.
29///
30std::string TableGenBackend::getQualifiedName(Record *R) const {
31 std::string Namespace = R->getValueAsString("Namespace");
32 if (Namespace.empty()) return R->getName();
33 return Namespace + "::" + R->getName();
34}
35