llvm/llvm/utils/TableGen/DirectiveEmitter.cpp

//===- DirectiveEmitter.cpp - Directive Language Emitter ------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// DirectiveEmitter uses the descriptions of directives and clauses to construct
// common code declarations to be used in Frontends.
//
//===----------------------------------------------------------------------===//

#include "llvm/TableGen/DirectiveEmitter.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"
#include "llvm/TableGen/TableGenBackend.h"

#include <numeric>
#include <vector>

usingnamespacellvm;

namespace {
// Simple RAII helper for defining ifdef-undef-endif scopes.
class IfDefScope {};
} // namespace

// Generate enum class. Entries are emitted in the order in which they appear
// in the `Records` vector.
static void GenerateEnumClass(ArrayRef<const Record *> Records, raw_ostream &OS,
                              StringRef Enum, StringRef Prefix,
                              const DirectiveLanguage &DirLang,
                              bool ExportEnums) {}

// Generate enums for values that clauses can take.
// Also generate function declarations for get<Enum>Name(StringRef Str).
static void GenerateEnumClauseVal(ArrayRef<const Record *> Records,
                                  raw_ostream &OS,
                                  const DirectiveLanguage &DirLang,
                                  std::string &EnumHelperFuncs) {}

static bool HasDuplicateClauses(ArrayRef<const Record *> Clauses,
                                const Directive &Directive,
                                StringSet<> &CrtClauses) {}

// Check for duplicate clauses in lists. Clauses cannot appear twice in the
// three allowed list. Also, since required implies allowed, clauses cannot
// appear in both the allowedClauses and requiredClauses lists.
static bool
HasDuplicateClausesInDirectives(ArrayRef<const Record *> Directives) {}

// Check consitency of records. Return true if an error has been detected.
// Return false if the records are valid.
bool DirectiveLanguage::HasValidityErrors() const {}

// Count the maximum number of leaf constituents per construct.
static size_t GetMaxLeafCount(const DirectiveLanguage &DirLang) {}

// Generate the declaration section for the enumeration in the directive
// language.
static void EmitDirectivesDecl(const RecordKeeper &Records, raw_ostream &OS) {}

// Generate function implementation for get<Enum>Name(StringRef Str)
static void GenerateGetName(ArrayRef<const Record *> Records, raw_ostream &OS,
                            StringRef Enum, const DirectiveLanguage &DirLang,
                            StringRef Prefix) {}

// Generate function implementation for get<Enum>Kind(StringRef Str)
static void GenerateGetKind(ArrayRef<const Record *> Records, raw_ostream &OS,
                            StringRef Enum, const DirectiveLanguage &DirLang,
                            StringRef Prefix, bool ImplicitAsUnknown) {}

// Generate function implementation for get<ClauseVal>Kind(StringRef Str)
static void GenerateGetKindClauseVal(const DirectiveLanguage &DirLang,
                                     raw_ostream &OS) {}

static void GenerateCaseForVersionedClauses(ArrayRef<const Record *> Clauses,
                                            raw_ostream &OS,
                                            StringRef DirectiveName,
                                            const DirectiveLanguage &DirLang,
                                            StringSet<> &Cases) {}

static std::string GetDirectiveName(const DirectiveLanguage &DirLang,
                                    const Record *Rec) {}

static std::string GetDirectiveType(const DirectiveLanguage &DirLang) {}

// Generate the isAllowedClauseForDirective function implementation.
static void GenerateIsAllowedClause(const DirectiveLanguage &DirLang,
                                    raw_ostream &OS) {}

static void EmitLeafTable(const DirectiveLanguage &DirLang, raw_ostream &OS,
                          StringRef TableName) {}

static void GenerateGetDirectiveAssociation(const DirectiveLanguage &DirLang,
                                            raw_ostream &OS) {}

static void GenerateGetDirectiveCategory(const DirectiveLanguage &DirLang,
                                         raw_ostream &OS) {}

// Generate a simple enum set with the give clauses.
static void GenerateClauseSet(ArrayRef<const Record *> Clauses, raw_ostream &OS,
                              StringRef ClauseSetPrefix, const Directive &Dir,
                              const DirectiveLanguage &DirLang) {}

// Generate an enum set for the 4 kinds of clauses linked to a directive.
static void GenerateDirectiveClauseSets(const DirectiveLanguage &DirLang,
                                        raw_ostream &OS) {}

// Generate a map of directive (key) with DirectiveClauses struct as values.
// The struct holds the 4 sets of enumeration for the 4 kinds of clauses
// allowances (allowed, allowed once, allowed exclusive and required).
static void GenerateDirectiveClauseMap(const DirectiveLanguage &DirLang,
                                       raw_ostream &OS) {}

// Generate classes entry for Flang clauses in the Flang parse-tree
// If the clause as a non-generic class, no entry is generated.
// If the clause does not hold a value, an EMPTY_CLASS is used.
// If the clause class is generic then a WRAPPER_CLASS is used. When the value
// is optional, the value class is wrapped into a std::optional.
static void GenerateFlangClauseParserClass(const DirectiveLanguage &DirLang,
                                           raw_ostream &OS) {}

// Generate a list of the different clause classes for Flang.
static void GenerateFlangClauseParserClassList(const DirectiveLanguage &DirLang,
                                               raw_ostream &OS) {}

// Generate dump node list for the clauses holding a generic class name.
static void GenerateFlangClauseDump(const DirectiveLanguage &DirLang,
                                    raw_ostream &OS) {}

// Generate Unparse functions for clauses classes in the Flang parse-tree
// If the clause is a non-generic class, no entry is generated.
static void GenerateFlangClauseUnparse(const DirectiveLanguage &DirLang,
                                       raw_ostream &OS) {}

// Generate check in the Enter functions for clauses classes.
static void GenerateFlangClauseCheckPrototypes(const DirectiveLanguage &DirLang,
                                               raw_ostream &OS) {}

// Generate the mapping for clauses between the parser class and the
// corresponding clause Kind
static void GenerateFlangClauseParserKindMap(const DirectiveLanguage &DirLang,
                                             raw_ostream &OS) {}

static bool compareClauseName(const Record *R1, const Record *R2) {}

// Generate the parser for the clauses.
static void GenerateFlangClausesParser(const DirectiveLanguage &DirLang,
                                       raw_ostream &OS) {}

// Generate the implementation section for the enumeration in the directive
// language
static void EmitDirectivesFlangImpl(const DirectiveLanguage &DirLang,
                                    raw_ostream &OS) {}

static void GenerateClauseClassMacro(const DirectiveLanguage &DirLang,
                                     raw_ostream &OS) {}

// Generate the implemenation for the enumeration in the directive
// language. This code can be included in library.
void EmitDirectivesBasicImpl(const DirectiveLanguage &DirLang,
                             raw_ostream &OS) {}

// Generate the implemenation section for the enumeration in the directive
// language.
static void EmitDirectivesImpl(const RecordKeeper &Records, raw_ostream &OS) {}

static TableGen::Emitter::Opt
    X("gen-directive-decl", EmitDirectivesDecl,
      "Generate directive related declaration code (header file)");

static TableGen::Emitter::Opt
    Y("gen-directive-impl", EmitDirectivesImpl,
      "Generate directive related implementation code");