forked from OSchip/llvm-project
Rename the 'namePrefix' field in the Dialect class to 'name' and tidy some comments to make it clear that 'name' refers to the dialect namespace.
-- PiperOrigin-RevId: 241103116
This commit is contained in:
parent
0fb905c070
commit
dfc58742a2
|
@ -47,7 +47,7 @@ class Dialect {
|
|||
public:
|
||||
MLIRContext *getContext() const { return context; }
|
||||
|
||||
StringRef getNamespace() const { return namePrefix; }
|
||||
StringRef getNamespace() const { return name; }
|
||||
|
||||
/// Registered fallback constant fold hook for the dialect. Like the constant
|
||||
/// fold hook of each operation, it attempts to constant fold the operation
|
||||
|
@ -127,12 +127,14 @@ public:
|
|||
static bool isValidNamespace(StringRef str);
|
||||
|
||||
protected:
|
||||
/// Note: The namePrefix must not contain '.' characters.
|
||||
/// Note: All operations belonging to this dialect will need to have names
|
||||
/// starting with the namePrefix followed by '.'.
|
||||
/// The constructor takes a unique namespace for this dialect as well as the
|
||||
/// context to bind to.
|
||||
/// Note: The namespace must not contain '.' characters.
|
||||
/// Note: All operations belonging to this dialect must have names starting
|
||||
/// with the namespace followed by '.'.
|
||||
/// Example:
|
||||
/// - "tf" for the TensorFlow ops like "tf.add".
|
||||
Dialect(StringRef namePrefix, MLIRContext *context);
|
||||
Dialect(StringRef name, MLIRContext *context);
|
||||
|
||||
/// This method is used by derived classes to add their operations to the set.
|
||||
///
|
||||
|
@ -194,8 +196,8 @@ private:
|
|||
/// takes ownership of the heap allocated dialect.
|
||||
void registerDialect(MLIRContext *context);
|
||||
|
||||
/// This is the namespace used as a prefix for IR defined by this dialect.
|
||||
StringRef namePrefix;
|
||||
/// The namespace of this dialect.
|
||||
StringRef name;
|
||||
|
||||
/// This is the context that owns this Dialect object.
|
||||
MLIRContext *context;
|
||||
|
|
|
@ -36,7 +36,7 @@ using llvm::dbgs;
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
AffineOpsDialect::AffineOpsDialect(MLIRContext *context)
|
||||
: Dialect(/*namePrefix=*/"affine", context) {
|
||||
: Dialect(/*name=*/"affine", context) {
|
||||
addOperations<AffineApplyOp, AffineForOp, AffineIfOp, AffineTerminatorOp>();
|
||||
}
|
||||
|
||||
|
|
|
@ -59,9 +59,9 @@ void mlir::registerAllDialects(MLIRContext *context) {
|
|||
}
|
||||
}
|
||||
|
||||
Dialect::Dialect(StringRef namePrefix, MLIRContext *context)
|
||||
: namePrefix(namePrefix), context(context) {
|
||||
assert(isValidNamespace(namePrefix) && "invalid dialect namespace");
|
||||
Dialect::Dialect(StringRef name, MLIRContext *context)
|
||||
: name(name), context(context) {
|
||||
assert(isValidNamespace(name) && "invalid dialect namespace");
|
||||
registerDialect(context);
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace {
|
|||
/// A builtin dialect to define types/etc that are necessary for the
|
||||
/// validity of the IR.
|
||||
struct BuiltinDialect : public Dialect {
|
||||
BuiltinDialect(MLIRContext *context) : Dialect(/*namePrefix=*/"", context) {
|
||||
BuiltinDialect(MLIRContext *context) : Dialect(/*name=*/"", context) {
|
||||
addTypes<FunctionType, UnknownType, FloatType, IndexType, IntegerType,
|
||||
VectorType, RankedTensorType, UnrankedTensorType, MemRefType,
|
||||
ComplexType, TupleType>();
|
||||
|
@ -742,15 +742,15 @@ std::vector<AbstractOperation *> MLIRContext::getRegisteredOperations() {
|
|||
}
|
||||
|
||||
void Dialect::addOperation(AbstractOperation opInfo) {
|
||||
assert(opInfo.name.split('.').first == namePrefix &&
|
||||
"op name doesn't start with dialect prefix");
|
||||
assert(opInfo.name.split('.').first == getNamespace() &&
|
||||
"op name doesn't start with dialect namespace");
|
||||
assert(&opInfo.dialect == this && "Dialect object mismatch");
|
||||
auto &impl = context->getImpl();
|
||||
|
||||
// Lock access to the context registry.
|
||||
llvm::sys::SmartScopedWriter<true> registryLock(impl.contextMutex);
|
||||
if (!impl.registeredOperations.insert({opInfo.name, opInfo}).second) {
|
||||
llvm::errs() << "error: ops named '" << opInfo.name
|
||||
llvm::errs() << "error: operation named '" << opInfo.name
|
||||
<< "' is already registered.\n";
|
||||
abort();
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ void detail::printStandardBinaryOp(Operation *op, OpAsmPrinter *p) {
|
|||
}
|
||||
|
||||
StandardOpsDialect::StandardOpsDialect(MLIRContext *context)
|
||||
: Dialect(/*namePrefix=*/"std", context) {
|
||||
: Dialect(/*name=*/"std", context) {
|
||||
addOperations<AllocOp, BranchOp, CallOp, CallIndirectOp, CmpIOp, CondBranchOp,
|
||||
ConstantOp, DeallocOp, DimOp, DmaStartOp, DmaWaitOp,
|
||||
ExtractElementOp, LoadOp, MemRefCastOp, ReturnOp, SelectOp,
|
||||
|
|
|
@ -23,7 +23,7 @@ using namespace mlir::detail;
|
|||
|
||||
namespace {
|
||||
struct TestDialect : public Dialect {
|
||||
TestDialect(MLIRContext *context) : Dialect(/*namePrefix=*/"test", context) {}
|
||||
TestDialect(MLIRContext *context) : Dialect(/*name=*/"test", context) {}
|
||||
};
|
||||
|
||||
TEST(DialectDeathTest, MultipleDialectsWithSameNamespace) {
|
||||
|
|
Loading…
Reference in New Issue