Jakob Stoklund Olesen | 764dc75 | 2012-06-13 05:15:49 +0000 | [diff] [blame] | 1 | //===- TableGenBackend.cpp - Utilities 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 | // |
Chris Lattner | 3060910 | 2007-12-29 20:37:13 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // 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 | |
Benjamin Kramer | 90540ad | 2012-06-19 17:04:16 +0000 | [diff] [blame] | 14 | #include "llvm/ADT/Twine.h" |
Jakob Stoklund Olesen | 764dc75 | 2012-06-13 05:15:49 +0000 | [diff] [blame] | 15 | #include "llvm/Support/raw_ostream.h" |
Peter Collingbourne | 7c78888 | 2011-10-01 16:41:13 +0000 | [diff] [blame] | 16 | #include "llvm/TableGen/TableGenBackend.h" |
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 | |
Benjamin Kramer | 90540ad | 2012-06-19 17:04:16 +0000 | [diff] [blame] | 19 | static void printLine(raw_ostream &OS, const Twine &Prefix, char Fill, |
| 20 | StringRef Suffix) { |
| 21 | uint64_t Pos = OS.tell(); |
| 22 | OS << Prefix; |
| 23 | for (unsigned i = OS.tell() - Pos, e = 80 - Suffix.size(); i != e; ++i) |
| 24 | OS << Fill; |
| 25 | OS << Suffix << '\n'; |
| 26 | } |
| 27 | |
Jakob Stoklund Olesen | 6f36fa9 | 2012-06-11 15:37:55 +0000 | [diff] [blame] | 28 | void llvm::emitSourceFileHeader(StringRef Desc, raw_ostream &OS) { |
Benjamin Kramer | 90540ad | 2012-06-19 17:04:16 +0000 | [diff] [blame] | 29 | printLine(OS, "/*===- TableGen'erated file ", '-', "*- C++ -*-===*\\"); |
| 30 | printLine(OS, "|*", ' ', "*|"); |
| 31 | printLine(OS, "|* " + Desc, ' ', "*|"); |
| 32 | printLine(OS, "|*", ' ', "*|"); |
| 33 | printLine(OS, "|* Automatically generated file, do not edit!", ' ', "*|"); |
| 34 | printLine(OS, "|*", ' ', "*|"); |
| 35 | printLine(OS, "\\*===", '-', "===*/"); |
| 36 | OS << '\n'; |
Chris Lattner | 2c0f2c7 | 2003-08-06 04:23:04 +0000 | [diff] [blame] | 37 | } |