Skip to content

Commit

Permalink
factor header
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed May 20, 2024
1 parent 35f91b7 commit 9e507c8
Show file tree
Hide file tree
Showing 37 changed files with 315 additions and 147 deletions.
2 changes: 1 addition & 1 deletion llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ void WebAssemblyAsmPrinter::emitDecls(const Module &M) {
void WebAssemblyAsmPrinter::emitEndOfAsmFile(Module &M) {
// This is required to emit external declarations (like .functypes) when
// no functions are defined in the compilation unit and therefore,
// emitDirectiveDecls() is not called until now.
// emitDecls() is not called until now.
emitDecls(M);

// When a function's address is taken, a TABLE_INDEX relocation is emitted
Expand Down
1 change: 1 addition & 0 deletions mlir/include/mlir/TableGen/AttrOrTypeDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "mlir/Support/LLVM.h"
#include "mlir/TableGen/Builder.h"
#include "mlir/TableGen/Trait.h"

#include "llvm/TableGen/Record.h"

namespace llvm {
Expand Down
24 changes: 24 additions & 0 deletions mlir/include/mlir/TableGen/ByteCodeGen.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//===- ByteCodeGen.h - Generator info ---------------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_TABLEGEN_BYTECODEGEN_H_
#define MLIR_TABLEGEN_BYTECODEGEN_H_

#include "mlir/Support/LLVM.h"

#include "llvm/ADT/StringRef.h"
#include "llvm/TableGen/Record.h"

namespace mlir::tblgen {

bool emitBCRW(const llvm::RecordKeeper &records, raw_ostream &os,
const std::string &selectedBcDialect);

} // namespace mlir::tblgen

#endif // MLIR_TABLEGEN_BYTECODEGEN_H_
26 changes: 26 additions & 0 deletions mlir/include/mlir/TableGen/CAPIGen.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//===- CAPIGen.h - Generator info -------------------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_TABLEGEN_CAPIGEN_H_
#define MLIR_TABLEGEN_CAPIGEN_H_

#include "mlir/Support/LLVM.h"

#include "llvm/ADT/StringRef.h"
#include "llvm/TableGen/Record.h"

namespace mlir::tblgen {

bool emitCAPIHeader(const llvm::RecordKeeper &records, raw_ostream &os,
std::string groupPrefix);
bool emitCAPIImpl(const llvm::RecordKeeper &records, raw_ostream &os,
std::string groupPrefix);

} // namespace mlir::tblgen

#endif // MLIR_TABLEGEN_CAPIGEN_H_
9 changes: 9 additions & 0 deletions mlir/include/mlir/TableGen/DialectGenUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#define MLIR_TOOLS_MLIRTBLGEN_DIALECTGENUTILITIES_H_

#include "mlir/Support/LLVM.h"

#include "llvm/Support/CommandLine.h"
#include "llvm/TableGen/Record.h"

namespace mlir {
namespace tblgen {
Expand All @@ -21,6 +23,13 @@ class Dialect;
std::optional<Dialect>
findDialectToGenerate(ArrayRef<Dialect> dialects,
const std::string &selectedDialect);
bool emitDialectDecls(const llvm::RecordKeeper &recordKeeper, raw_ostream &os,
const std::string &selectedDialect);
bool emitDialectDefs(const llvm::RecordKeeper &recordKeeper, raw_ostream &os,
const std::string &selectedDialect);
bool emitDirectiveDecls(const llvm::RecordKeeper &recordKeeper,
llvm::StringRef dialect, raw_ostream &os);

} // namespace tblgen
} // namespace mlir

Expand Down
17 changes: 17 additions & 0 deletions mlir/include/mlir/TableGen/DocGenUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define MLIR_TOOLS_MLIRTBLGEN_DOCGENUTILITIES_H_

#include "llvm/ADT/StringRef.h"
#include "llvm/TableGen/Record.h"

namespace llvm {
class raw_ostream;
Expand All @@ -39,6 +40,22 @@ void emitDescription(llvm::StringRef description, llvm::raw_ostream &os);
void emitDescriptionComment(llvm::StringRef description, llvm::raw_ostream &os,
llvm::StringRef prefix = "");

void emitAttrOrTypeDefDoc(const llvm::RecordKeeper &recordKeeper,
llvm::raw_ostream &os,
llvm::StringRef recordTypeName);

void emitOpDoc(const llvm::RecordKeeper &recordKeeper, llvm::raw_ostream &os,
const std::string &emitOpDoc, bool allowHugoSpecificFeatures,
const std::string &opIncFilter, const std::string &opExcFilter);

bool emitDialectDoc(const llvm::RecordKeeper &recordKeeper,
llvm::raw_ostream &os, const std::string &selectedDialect,
const std::string &opIncFilter,
const std::string &opExcFilter,
const std::string &stripPrefix,
bool allowHugoSpecificFeatures);
void emitDocs(const llvm::RecordKeeper &recordKeeper, llvm::raw_ostream &os);

} // namespace tblgen
} // namespace mlir

Expand Down
24 changes: 24 additions & 0 deletions mlir/include/mlir/TableGen/EnumGen.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//===- EnumGen.h - Generator info -------------------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_TABLEGEN_ENUMGEN_H_
#define MLIR_TABLEGEN_ENUMGEN_H_

#include "mlir/Support/LLVM.h"

#include "llvm/ADT/StringRef.h"
#include "llvm/TableGen/Record.h"

namespace mlir::tblgen {

bool emitEnumDecls(const llvm::RecordKeeper &recordKeeper, raw_ostream &os);
bool emitEnumDefs(const llvm::RecordKeeper &recordKeeper, raw_ostream &os);

} // namespace mlir::tblgen

#endif // MLIR_TABLEGEN_ENUMGEN_H_
2 changes: 2 additions & 0 deletions mlir/include/mlir/TableGen/FormatGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@

#include "mlir/Support/LLVM.h"
#include "mlir/Support/LogicalResult.h"

#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/SMLoc.h"

#include <vector>

namespace llvm {
Expand Down
84 changes: 2 additions & 82 deletions mlir/include/mlir/TableGen/GenInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
#define MLIR_TABLEGEN_GENINFO_H_

#include "mlir/Support/LLVM.h"

#include "llvm/ADT/StringRef.h"
#include "llvm/Support/CommandLine.h"

#include <functional>
#include <utility>

Expand Down Expand Up @@ -70,87 +71,6 @@ struct GenRegistration {
const GenFunction &function);
};

namespace tblgen {
bool emitBCRW(const llvm::RecordKeeper &records, raw_ostream &os,
const std::string &selectedBcDialect);

bool emitOpDecls(const llvm::RecordKeeper &recordKeeper, raw_ostream &os,
const std::string &opIncFilter, const std::string &opExcFilter,
unsigned opShardCount, bool formatErrorIsFatal);
bool emitOpDefs(const llvm::RecordKeeper &recordKeeper, raw_ostream &os,
const std::string &opIncFilter, const std::string &opExcFilter,
unsigned opShardCount, bool formatErrorIsFatal);

bool emitDialectDecls(const llvm::RecordKeeper &recordKeeper, raw_ostream &os,
const std::string &selectedDialect);
bool emitDialectDefs(const llvm::RecordKeeper &recordKeeper, raw_ostream &os,
const std::string &selectedDialect);
bool emitDirectiveDecls(const llvm::RecordKeeper &recordKeeper,
llvm::StringRef dialect, raw_ostream &os);

bool emitPythonEnums(const llvm::RecordKeeper &recordKeeper, raw_ostream &os);
bool emitAllPythonOps(const llvm::RecordKeeper &records, raw_ostream &os,
const std::string &clDialectName,
const std::string &clDialectExtensionName);

bool emitEnumDecls(const llvm::RecordKeeper &recordKeeper, raw_ostream &os);
bool emitEnumDefs(const llvm::RecordKeeper &recordKeeper, raw_ostream &os);

bool emitLLVMBuilders(const llvm::RecordKeeper &recordKeeper, raw_ostream &os);
bool emitLLVMOpMLIRBuilders(const llvm::RecordKeeper &recordKeeper,
raw_ostream &os);
bool emitLLVMIntrMLIRBuilders(const llvm::RecordKeeper &recordKeeper,
raw_ostream &os);
template <bool ConvertTo>
bool emitLLVMEnumConversionDefs(const llvm::RecordKeeper &recordKeeper,
raw_ostream &os);
bool emitLLVMConvertibleIntrinsics(const llvm::RecordKeeper &recordKeeper,
raw_ostream &os);
bool emitLLVMIntrinsics(const llvm::RecordKeeper &records,
llvm::raw_ostream &os, const std::string &nameFilter,
const std::string &accessGroupRegexp,
const std::string &aliasAnalysisRegexp,
const std::string &opBaseClass);

void emitAttrOrTypeDefDoc(const llvm::RecordKeeper &recordKeeper,
raw_ostream &os, StringRef recordTypeName);
void emitOpDoc(const llvm::RecordKeeper &recordKeeper, raw_ostream &os,
const std::string &emitOpDoc, bool allowHugoSpecificFeatures,
const std::string &opIncFilter, const std::string &opExcFilter);
bool emitDialectDoc(const llvm::RecordKeeper &recordKeeper, raw_ostream &os,
const std::string &selectedDialect,
const std::string &opIncFilter,
const std::string &opExcFilter,
const std::string &stripPrefix,
bool allowHugoSpecificFeatures);
void emitDocs(const llvm::RecordKeeper &recordKeeper, raw_ostream &os);

bool emitCAPIHeader(const llvm::RecordKeeper &records, raw_ostream &os,
std::string groupPrefix);
bool emitCAPIImpl(const llvm::RecordKeeper &records, raw_ostream &os,
std::string groupPrefix);
void emitPasses(const llvm::RecordKeeper &recordKeeper, raw_ostream &os,
const std::string &opIncFilter, const std::string &groupName);
void emitRewriters(const llvm::RecordKeeper &recordKeeper, raw_ostream &os);

bool emitSPIRVInterfaceDefs(const llvm::RecordKeeper &recordKeeper,
raw_ostream &os);
bool emitSPIRVInterfaceDecls(const llvm::RecordKeeper &recordKeeper,
raw_ostream &os);
bool emitSPIRVEnumDecls(const llvm::RecordKeeper &recordKeeper,
raw_ostream &os);
bool emitSPIRVEnumDefs(const llvm::RecordKeeper &recordKeeper, raw_ostream &os);
bool emitSPIRVCapabilityImplication(const llvm::RecordKeeper &recordKeeper,
raw_ostream &os);
bool emitSPIRVSerializationFns(const llvm::RecordKeeper &recordKeeper,
raw_ostream &os);
bool emitSPIRVAttrUtils(const llvm::RecordKeeper &recordKeeper,
raw_ostream &os);
bool emitSPIRVAvailabilityImpl(const llvm::RecordKeeper &recordKeeper,
raw_ostream &os);

} // namespace tblgen

} // namespace mlir

#endif // MLIR_TABLEGEN_GENINFO_H_
37 changes: 37 additions & 0 deletions mlir/include/mlir/TableGen/LLVMGen.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//===- LLVMGen.h - Generator info -------------------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_TABLEGEN_LLVMGEN_H_
#define MLIR_TABLEGEN_LLVMGEN_H_

#include "mlir/Support/LLVM.h"

#include "llvm/ADT/StringRef.h"
#include "llvm/TableGen/Record.h"

namespace mlir::tblgen {

bool emitLLVMBuilders(const llvm::RecordKeeper &recordKeeper, raw_ostream &os);
bool emitLLVMOpMLIRBuilders(const llvm::RecordKeeper &recordKeeper,
raw_ostream &os);
bool emitLLVMIntrMLIRBuilders(const llvm::RecordKeeper &recordKeeper,
raw_ostream &os);
template <bool ConvertTo>
bool emitLLVMEnumConversionDefs(const llvm::RecordKeeper &recordKeeper,
raw_ostream &os);
bool emitLLVMConvertibleIntrinsics(const llvm::RecordKeeper &recordKeeper,
raw_ostream &os);
bool emitLLVMIntrinsics(const llvm::RecordKeeper &records,
llvm::raw_ostream &os, const std::string &nameFilter,
const std::string &accessGroupRegexp,
const std::string &aliasAnalysisRegexp,
const std::string &opBaseClass);

} // namespace mlir::tblgen

#endif // MLIR_TABLEGEN_LLVMGEN_H_
10 changes: 10 additions & 0 deletions mlir/include/mlir/TableGen/OpGenHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#define MLIR_TOOLS_MLIRTBLGEN_OPGENHELPERS_H_

#include "mlir/Support/LLVM.h"

#include "llvm/TableGen/Record.h"

#include <vector>

namespace mlir {
Expand All @@ -36,6 +38,14 @@ void shardOpDefinitions(ArrayRef<llvm::Record *> defs,
SmallVectorImpl<ArrayRef<llvm::Record *>> &shardedDefs,
unsigned shardOpDefinitions);

bool emitOpDecls(const llvm::RecordKeeper &recordKeeper, raw_ostream &os,
const std::string &opIncFilter, const std::string &opExcFilter,
unsigned opShardCount, bool formatErrorIsFatal);

bool emitOpDefs(const llvm::RecordKeeper &recordKeeper, raw_ostream &os,
const std::string &opIncFilter, const std::string &opExcFilter,
unsigned opShardCount, bool formatErrorIsFatal);

} // namespace tblgen
} // namespace mlir

Expand Down
5 changes: 5 additions & 0 deletions mlir/include/mlir/TableGen/OpInterfacesGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
#include "mlir/TableGen/Format.h"
#include "mlir/TableGen/GenInfo.h"
#include "mlir/TableGen/Interfaces.h"

#include "llvm/TableGen/Record.h"

#include <vector>

namespace mlir {
Expand Down Expand Up @@ -105,6 +107,7 @@ struct AttrInterfaceGenerator : public InterfaceGenerator {
extraDeclsFmt.addSubst(substVar, "(*this)");
}
};

/// A specialized generator for operation interfaces.
struct OpInterfaceGenerator : public InterfaceGenerator {
OpInterfaceGenerator(const llvm::RecordKeeper &records, raw_ostream &os)
Expand All @@ -121,6 +124,7 @@ struct OpInterfaceGenerator : public InterfaceGenerator {
extraDeclsFmt.addSubst(substVar, "(*this)");
}
};

/// A specialized generator for type interfaces.
struct TypeInterfaceGenerator : public InterfaceGenerator {
TypeInterfaceGenerator(const llvm::RecordKeeper &records, raw_ostream &os)
Expand All @@ -136,6 +140,7 @@ struct TypeInterfaceGenerator : public InterfaceGenerator {
extraDeclsFmt.addSubst(substVar, "(*this)");
}
};

} // namespace tblgen
} // namespace mlir

Expand Down
25 changes: 25 additions & 0 deletions mlir/include/mlir/TableGen/PassGen.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//===- Passgen.h - Generator info -------------------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_TABLEGEN_PASSGEN_H_
#define MLIR_TABLEGEN_PASSGEN_H_

#include "mlir/Support/LLVM.h"

#include "llvm/ADT/StringRef.h"
#include "llvm/TableGen/Record.h"

namespace mlir::tblgen {

void emitPasses(const llvm::RecordKeeper &recordKeeper, raw_ostream &os,
const std::string &opIncFilter, const std::string &groupName);
void emitRewriters(const llvm::RecordKeeper &recordKeeper, raw_ostream &os);

} // namespace mlir::tblgen

#endif // MLIR_TABLEGEN_PASSGEN_H_
Loading

0 comments on commit 9e507c8

Please sign in to comment.