Chris Lattner | 2c0f2c7 | 2003-08-06 04:23:04 +0000 | [diff] [blame] | 1 | //===- TableGenBackend.cpp - Base class for TableGen Backends ---*- C++ -*-===// |
Misha Brukman | 3da94ae | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 2 | // |
John Criswell | 01d4582 | 2003-10-20 20:20:30 +0000 | [diff] [blame] | 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. |
Misha Brukman | 3da94ae | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 7 | // |
John Criswell | 01d4582 | 2003-10-20 20:20:30 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | 2c0f2c7 | 2003-08-06 04:23:04 +0000 | [diff] [blame] | 9 | // |
| 10 | // This file provides useful services for TableGen backends... |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "TableGenBackend.h" |
Chris Lattner | 18a6a94 | 2003-08-06 04:31:26 +0000 | [diff] [blame] | 15 | #include "Record.h" |
Chris Lattner | 2c0f2c7 | 2003-08-06 04:23:04 +0000 | [diff] [blame] | 16 | #include <iostream> |
Chris Lattner | 2082ebe | 2004-08-01 03:55:39 +0000 | [diff] [blame] | 17 | using namespace llvm; |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 18 | |
Chris Lattner | 2c0f2c7 | 2003-08-06 04:23:04 +0000 | [diff] [blame] | 19 | void TableGenBackend::EmitSourceFileHeader(const std::string &Desc, |
Chris Lattner | 18a6a94 | 2003-08-06 04:31:26 +0000 | [diff] [blame] | 20 | std::ostream &OS) const { |
Chris Lattner | 2c0f2c7 | 2003-08-06 04:23:04 +0000 | [diff] [blame] | 21 | OS << "//===- TableGen'erated file -------------------------------------*-" |
| 22 | " C++ -*-===//\n//\n// " << Desc << "\n//\n// Automatically generate" |
| 23 | "d file, do not edit!\n//\n//===------------------------------------" |
Chris Lattner | 2c38413 | 2004-08-17 03:08:28 +0000 | [diff] [blame] | 24 | "----------------------------------===//\n\n"; |
Chris Lattner | 2c0f2c7 | 2003-08-06 04:23:04 +0000 | [diff] [blame] | 25 | } |
| 26 | |
Chris Lattner | 18a6a94 | 2003-08-06 04:31:26 +0000 | [diff] [blame] | 27 | /// getQualifiedName - Return the name of the specified record, with a |
| 28 | /// namespace qualifier if the record contains one. |
| 29 | /// |
| 30 | std::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 | |