1*e8d8bef9SDimitry Andric //===- SkeletonEmitter.cpp - Skeleton TableGen backend -*- C++ -*-===// 2*e8d8bef9SDimitry Andric // 3*e8d8bef9SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*e8d8bef9SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*e8d8bef9SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*e8d8bef9SDimitry Andric // 7*e8d8bef9SDimitry Andric //===----------------------------------------------------------------------===// 8*e8d8bef9SDimitry Andric // 9*e8d8bef9SDimitry Andric // This Tablegen backend emits ... 10*e8d8bef9SDimitry Andric // 11*e8d8bef9SDimitry Andric //===----------------------------------------------------------------------===// 12*e8d8bef9SDimitry Andric 13*e8d8bef9SDimitry Andric #include "llvm/ADT/ArrayRef.h" 14*e8d8bef9SDimitry Andric #include "llvm/ADT/DenseMap.h" 15*e8d8bef9SDimitry Andric #include "llvm/ADT/StringExtras.h" 16*e8d8bef9SDimitry Andric #include "llvm/Support/Format.h" 17*e8d8bef9SDimitry Andric #include "llvm/Support/MemoryBuffer.h" 18*e8d8bef9SDimitry Andric #include "llvm/Support/SourceMgr.h" 19*e8d8bef9SDimitry Andric #include "llvm/TableGen/Error.h" 20*e8d8bef9SDimitry Andric #include "llvm/TableGen/Record.h" 21*e8d8bef9SDimitry Andric #include "llvm/TableGen/TableGenBackend.h" 22*e8d8bef9SDimitry Andric #include <algorithm> 23*e8d8bef9SDimitry Andric #include <set> 24*e8d8bef9SDimitry Andric #include <string> 25*e8d8bef9SDimitry Andric #include <vector> 26*e8d8bef9SDimitry Andric 27*e8d8bef9SDimitry Andric #define DEBUG_TYPE "skeleton-emitter" 28*e8d8bef9SDimitry Andric 29*e8d8bef9SDimitry Andric using namespace llvm; 30*e8d8bef9SDimitry Andric 31*e8d8bef9SDimitry Andric namespace { 32*e8d8bef9SDimitry Andric 33*e8d8bef9SDimitry Andric // Any helper data structures can be defined here. Some backends use 34*e8d8bef9SDimitry Andric // structs to collect information from the records. 35*e8d8bef9SDimitry Andric 36*e8d8bef9SDimitry Andric class SkeletonEmitter { 37*e8d8bef9SDimitry Andric private: 38*e8d8bef9SDimitry Andric RecordKeeper &Records; 39*e8d8bef9SDimitry Andric 40*e8d8bef9SDimitry Andric public: 41*e8d8bef9SDimitry Andric SkeletonEmitter(RecordKeeper &RK) : Records(RK) {} 42*e8d8bef9SDimitry Andric 43*e8d8bef9SDimitry Andric void run(raw_ostream &OS); 44*e8d8bef9SDimitry Andric }; // emitter class 45*e8d8bef9SDimitry Andric 46*e8d8bef9SDimitry Andric } // anonymous namespace 47*e8d8bef9SDimitry Andric 48*e8d8bef9SDimitry Andric void SkeletonEmitter::run(raw_ostream &OS) { 49*e8d8bef9SDimitry Andric emitSourceFileHeader("Skeleton data structures", OS); 50*e8d8bef9SDimitry Andric 51*e8d8bef9SDimitry Andric (void)Records; // To suppress unused variable warning; remove on use. 52*e8d8bef9SDimitry Andric } 53*e8d8bef9SDimitry Andric 54*e8d8bef9SDimitry Andric namespace llvm { 55*e8d8bef9SDimitry Andric 56*e8d8bef9SDimitry Andric // The only thing that should be in the llvm namespace is the 57*e8d8bef9SDimitry Andric // emitter entry point function. 58*e8d8bef9SDimitry Andric 59*e8d8bef9SDimitry Andric void EmitSkeleton(RecordKeeper &RK, raw_ostream &OS) { 60*e8d8bef9SDimitry Andric // Instantiate the emitter class and invoke run(). 61*e8d8bef9SDimitry Andric SkeletonEmitter(RK).run(OS); 62*e8d8bef9SDimitry Andric } 63*e8d8bef9SDimitry Andric 64*e8d8bef9SDimitry Andric } // namespace llvm 65