forked from OSchip/llvm-project
Make namespace handling uniform across dialect backends.
Now backends spell out which namespace they want to be in, instead of relying on clients #including them inside already-opened namespaces. This also means that cppNamespaces should be fully qualified, and there's no implicit "::mlir::" prepended to them anymore. Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D86811
This commit is contained in:
parent
9d01612db4
commit
7d1ed69c8a
|
@ -41,9 +41,10 @@ mlir::ParseResult parseSelector(mlir::OpAsmParser &parser,
|
|||
mlir::OpAsmParser::OperandType &selector,
|
||||
mlir::Type &type);
|
||||
|
||||
} // namespace fir
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "flang/Optimizer/Dialect/FIROps.h.inc"
|
||||
|
||||
} // namespace fir
|
||||
|
||||
#endif // OPTIMIZER_DIALECT_FIROPS_H
|
||||
|
|
|
@ -21,6 +21,7 @@ include "mlir/Interfaces/SideEffectInterfaces.td"
|
|||
|
||||
def fir_Dialect : Dialect {
|
||||
let name = "fir";
|
||||
let cppNamespace = "::fir";
|
||||
}
|
||||
|
||||
// Types and predicates
|
||||
|
|
|
@ -1552,11 +1552,8 @@ fir::GlobalOp fir::createGlobalOp(mlir::Location loc, mlir::ModuleOp module,
|
|||
return modBuilder.create<fir::GlobalOp>(loc, name, type, attrs);
|
||||
}
|
||||
|
||||
namespace fir {
|
||||
|
||||
// Tablegen operators
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "flang/Optimizer/Dialect/FIROps.cpp.inc"
|
||||
|
||||
} // namespace fir
|
||||
|
|
|
@ -34,12 +34,12 @@ public:
|
|||
static llvm::StringRef getDialectNamespace() { return "toy"; }
|
||||
};
|
||||
|
||||
} // end namespace toy
|
||||
} // end namespace mlir
|
||||
|
||||
/// Include the auto-generated header file containing the declarations of the
|
||||
/// toy operations.
|
||||
#define GET_OP_CLASSES
|
||||
#include "toy/Ops.h.inc"
|
||||
|
||||
} // end namespace toy
|
||||
} // end namespace mlir
|
||||
|
||||
#endif // MLIR_TUTORIAL_TOY_DIALECT_H_
|
||||
|
|
|
@ -20,7 +20,7 @@ include "mlir/Interfaces/SideEffectInterfaces.td"
|
|||
// can define our operations.
|
||||
def Toy_Dialect : Dialect {
|
||||
let name = "toy";
|
||||
let cppNamespace = "toy";
|
||||
let cppNamespace = "::mlir::toy";
|
||||
}
|
||||
|
||||
// Base class for toy dialect operations. This operation inherits from the base
|
||||
|
|
|
@ -34,12 +34,12 @@ public:
|
|||
static llvm::StringRef getDialectNamespace() { return "toy"; }
|
||||
};
|
||||
|
||||
} // end namespace toy
|
||||
} // end namespace mlir
|
||||
|
||||
/// Include the auto-generated header file containing the declarations of the
|
||||
/// toy operations.
|
||||
#define GET_OP_CLASSES
|
||||
#include "toy/Ops.h.inc"
|
||||
|
||||
} // end namespace toy
|
||||
} // end namespace mlir
|
||||
|
||||
#endif // MLIR_TUTORIAL_TOY_DIALECT_H_
|
||||
|
|
|
@ -19,7 +19,7 @@ include "mlir/Interfaces/SideEffectInterfaces.td"
|
|||
// can define our operations.
|
||||
def Toy_Dialect : Dialect {
|
||||
let name = "toy";
|
||||
let cppNamespace = "toy";
|
||||
let cppNamespace = "::mlir::toy";
|
||||
}
|
||||
|
||||
// Base class for toy dialect operations. This operation inherits from the base
|
||||
|
|
|
@ -36,12 +36,12 @@ public:
|
|||
static llvm::StringRef getDialectNamespace() { return "toy"; }
|
||||
};
|
||||
|
||||
} // end namespace toy
|
||||
} // end namespace mlir
|
||||
|
||||
/// Include the auto-generated header file containing the declarations of the
|
||||
/// toy operations.
|
||||
#define GET_OP_CLASSES
|
||||
#include "toy/Ops.h.inc"
|
||||
|
||||
} // end namespace toy
|
||||
} // end namespace mlir
|
||||
|
||||
#endif // MLIR_TUTORIAL_TOY_DIALECT_H_
|
||||
|
|
|
@ -21,7 +21,7 @@ include "toy/ShapeInferenceInterface.td"
|
|||
// can define our operations.
|
||||
def Toy_Dialect : Dialect {
|
||||
let name = "toy";
|
||||
let cppNamespace = "toy";
|
||||
let cppNamespace = "::mlir::toy";
|
||||
}
|
||||
|
||||
// Base class for toy dialect operations. This operation inherits from the base
|
||||
|
|
|
@ -36,12 +36,12 @@ public:
|
|||
static llvm::StringRef getDialectNamespace() { return "toy"; }
|
||||
};
|
||||
|
||||
} // end namespace toy
|
||||
} // end namespace mlir
|
||||
|
||||
/// Include the auto-generated header file containing the declarations of the
|
||||
/// toy operations.
|
||||
#define GET_OP_CLASSES
|
||||
#include "toy/Ops.h.inc"
|
||||
|
||||
} // end namespace toy
|
||||
} // end namespace mlir
|
||||
|
||||
#endif // MLIR_TUTORIAL_TOY_DIALECT_H_
|
||||
|
|
|
@ -21,7 +21,7 @@ include "toy/ShapeInferenceInterface.td"
|
|||
// can define our operations.
|
||||
def Toy_Dialect : Dialect {
|
||||
let name = "toy";
|
||||
let cppNamespace = "toy";
|
||||
let cppNamespace = "::mlir::toy";
|
||||
}
|
||||
|
||||
// Base class for toy dialect operations. This operation inherits from the base
|
||||
|
|
|
@ -36,12 +36,12 @@ public:
|
|||
static llvm::StringRef getDialectNamespace() { return "toy"; }
|
||||
};
|
||||
|
||||
} // end namespace toy
|
||||
} // end namespace mlir
|
||||
|
||||
/// Include the auto-generated header file containing the declarations of the
|
||||
/// toy operations.
|
||||
#define GET_OP_CLASSES
|
||||
#include "toy/Ops.h.inc"
|
||||
|
||||
} // end namespace toy
|
||||
} // end namespace mlir
|
||||
|
||||
#endif // MLIR_TUTORIAL_TOY_DIALECT_H_
|
||||
|
|
|
@ -21,7 +21,7 @@ include "toy/ShapeInferenceInterface.td"
|
|||
// can define our operations.
|
||||
def Toy_Dialect : Dialect {
|
||||
let name = "toy";
|
||||
let cppNamespace = "toy";
|
||||
let cppNamespace = "::mlir::toy";
|
||||
}
|
||||
|
||||
// Base class for toy dialect operations. This operation inherits from the base
|
||||
|
|
|
@ -50,6 +50,9 @@ public:
|
|||
static llvm::StringRef getDialectNamespace() { return "toy"; }
|
||||
};
|
||||
|
||||
} // end namespace toy
|
||||
} // end namespace mlir
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Toy Operations
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -59,6 +62,9 @@ public:
|
|||
#define GET_OP_CLASSES
|
||||
#include "toy/Ops.h.inc"
|
||||
|
||||
namespace mlir {
|
||||
namespace toy {
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Toy Types
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -21,7 +21,7 @@ include "toy/ShapeInferenceInterface.td"
|
|||
// can define our operations.
|
||||
def Toy_Dialect : Dialect {
|
||||
let name = "toy";
|
||||
let cppNamespace = "toy";
|
||||
let cppNamespace = "::mlir::toy";
|
||||
}
|
||||
|
||||
// Base class for toy dialect operations. This operation inherits from the base
|
||||
|
|
|
@ -21,7 +21,7 @@ include "mlir/Interfaces/SideEffectInterfaces.td"
|
|||
|
||||
def AVX512_Dialect : Dialect {
|
||||
let name = "avx512";
|
||||
let cppNamespace = "avx512";
|
||||
let cppNamespace = "::mlir::avx512";
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -17,15 +17,9 @@
|
|||
#include "mlir/IR/OpDefinition.h"
|
||||
#include "mlir/Interfaces/SideEffectInterfaces.h"
|
||||
|
||||
namespace mlir {
|
||||
namespace avx512 {
|
||||
#include "mlir/Dialect/AVX512/AVX512Dialect.h.inc"
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/AVX512/AVX512.h.inc"
|
||||
|
||||
#include "mlir/Dialect/AVX512/AVX512Dialect.h.inc"
|
||||
|
||||
} // namespace avx512
|
||||
} // namespace mlir
|
||||
|
||||
#endif // MLIR_DIALECT_AVX512_AVX512DIALECT_H_
|
||||
|
|
|
@ -21,6 +21,7 @@ include "mlir/IR/OpBase.td"
|
|||
|
||||
def GPU_Dialect : Dialect {
|
||||
let name = "gpu";
|
||||
let cppNamespace = "::mlir::gpu";
|
||||
let hasOperationAttrVerify = 1;
|
||||
|
||||
let extraClassDeclaration = [{
|
||||
|
|
|
@ -34,12 +34,13 @@ struct KernelDim3 {
|
|||
Value z;
|
||||
};
|
||||
|
||||
} // end namespace gpu
|
||||
} // end namespace mlir
|
||||
|
||||
#include "mlir/Dialect/GPU/GPUOpsDialect.h.inc"
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/GPU/GPUOps.h.inc"
|
||||
|
||||
} // end namespace gpu
|
||||
} // end namespace mlir
|
||||
|
||||
#endif // MLIR_DIALECT_GPU_GPUDIALECT_H
|
||||
|
|
|
@ -27,8 +27,11 @@ struct LogicalResult;
|
|||
class Operation;
|
||||
class Region;
|
||||
|
||||
} // namespace mlir
|
||||
|
||||
#include "mlir/Dialect/GPU/ParallelLoopMapperAttr.h.inc"
|
||||
|
||||
namespace mlir {
|
||||
namespace scf {
|
||||
class ParallelOp;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
|
|||
|
||||
def LLVMAVX512_Dialect : Dialect {
|
||||
let name = "llvm_avx512";
|
||||
let cppNamespace = "LLVM";
|
||||
let cppNamespace = "::mlir::LLVM";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
|
|
@ -16,15 +16,9 @@
|
|||
#include "mlir/IR/Dialect.h"
|
||||
#include "mlir/IR/OpDefinition.h"
|
||||
|
||||
namespace mlir {
|
||||
namespace LLVM {
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/LLVMIR/LLVMAVX512.h.inc"
|
||||
|
||||
#include "mlir/Dialect/LLVMIR/LLVMAVX512Dialect.h.inc"
|
||||
|
||||
} // namespace LLVM
|
||||
} // namespace mlir
|
||||
|
||||
#endif // MLIR_DIALECT_LLVMIR_LLVMAVX512DIALECT_H_
|
||||
|
|
|
@ -49,18 +49,23 @@ struct LLVMTypeStorage;
|
|||
struct LLVMDialectImpl;
|
||||
} // namespace detail
|
||||
|
||||
} // namespace LLVM
|
||||
} // namespace mlir
|
||||
|
||||
///// Ops /////
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/LLVMIR/LLVMOps.h.inc"
|
||||
|
||||
#include "mlir/Dialect/LLVMIR/LLVMOpsDialect.h.inc"
|
||||
|
||||
namespace mlir {
|
||||
namespace LLVM {
|
||||
/// Create an LLVM global containing the string "value" at the module containing
|
||||
/// surrounding the insertion point of builder. Obtain the address of that
|
||||
/// global and use it to compute the address of the first character in the
|
||||
/// string (operations inserted at the builder insertion point).
|
||||
Value createGlobalString(Location loc, OpBuilder &builder, StringRef name,
|
||||
StringRef value, LLVM::Linkage linkage);
|
||||
StringRef value, Linkage linkage);
|
||||
|
||||
/// LLVM requires some operations to be inside of a Module operation. This
|
||||
/// function confirms that the Operation has the desired properties.
|
||||
|
|
|
@ -23,7 +23,7 @@ include "mlir/Interfaces/SideEffectInterfaces.td"
|
|||
|
||||
def LLVM_Dialect : Dialect {
|
||||
let name = "llvm";
|
||||
let cppNamespace = "LLVM";
|
||||
let cppNamespace = "::mlir::LLVM";
|
||||
|
||||
/// FIXME: at the moment this is a dependency of the translation to LLVM IR,
|
||||
/// not really one of this dialect per-se.
|
||||
|
|
|
@ -59,7 +59,7 @@ def LLVM_VoidResultTypeOpBuilder : OpBuilder<
|
|||
"OpBuilder &builder, OperationState &result, Type resultType, "
|
||||
"ValueRange operands, ArrayRef<NamedAttribute> attributes = {}",
|
||||
[{
|
||||
auto llvmType = resultType.dyn_cast<LLVM::LLVMType>(); (void)llvmType;
|
||||
auto llvmType = resultType.dyn_cast<LLVMType>(); (void)llvmType;
|
||||
assert(llvmType && "result must be an LLVM type");
|
||||
assert(llvmType.isVoidTy() &&
|
||||
"for zero-result operands, only 'void' is accepted as result type");
|
||||
|
@ -301,7 +301,7 @@ def LLVM_LoadOp :
|
|||
"unsigned alignment = 0, bool isVolatile = false, "
|
||||
"bool isNonTemporal = false",
|
||||
[{
|
||||
auto type = addr.getType().cast<LLVM::LLVMType>().getPointerElementTy();
|
||||
auto type = addr.getType().cast<LLVMType>().getPointerElementTy();
|
||||
build(b, result, type, addr, alignment, isVolatile, isNonTemporal);
|
||||
}]>,
|
||||
OpBuilder<
|
||||
|
@ -494,8 +494,8 @@ def LLVM_ShuffleVectorOp
|
|||
"OpBuilder &b, OperationState &result, Value v1, Value v2, "
|
||||
"ArrayAttr mask, ArrayRef<NamedAttribute> attrs = {}">];
|
||||
let verifier = [{
|
||||
auto wrappedVectorType1 = v1().getType().cast<LLVM::LLVMType>();
|
||||
auto wrappedVectorType2 = v2().getType().cast<LLVM::LLVMType>();
|
||||
auto wrappedVectorType1 = v1().getType().cast<LLVMType>();
|
||||
auto wrappedVectorType2 = v2().getType().cast<LLVMType>();
|
||||
if (!wrappedVectorType2.isVectorTy())
|
||||
return emitOpError("expected LLVM IR Dialect vector type for operand #2");
|
||||
if (wrappedVectorType1.getVectorElementType() !=
|
||||
|
@ -770,7 +770,7 @@ def LLVM_LLVMFuncOp
|
|||
|
||||
let builders = [
|
||||
OpBuilder<"OpBuilder &builder, OperationState &result, StringRef name, "
|
||||
"LLVMType type, LLVM::Linkage linkage = LLVM::Linkage::External, "
|
||||
"LLVMType type, Linkage linkage = Linkage::External, "
|
||||
"ArrayRef<NamedAttribute> attrs = {}, "
|
||||
"ArrayRef<MutableDictionaryAttr> argAttrs = {}">
|
||||
];
|
||||
|
|
|
@ -19,16 +19,10 @@
|
|||
#include "mlir/IR/OpDefinition.h"
|
||||
#include "mlir/Interfaces/SideEffectInterfaces.h"
|
||||
|
||||
namespace mlir {
|
||||
namespace NVVM {
|
||||
|
||||
///// Ops /////
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/LLVMIR/NVVMOps.h.inc"
|
||||
|
||||
#include "mlir/Dialect/LLVMIR/NVVMOpsDialect.h.inc"
|
||||
|
||||
} // namespace NVVM
|
||||
} // namespace mlir
|
||||
|
||||
#endif /* MLIR_DIALECT_LLVMIR_NVVMDIALECT_H_ */
|
||||
|
|
|
@ -22,7 +22,7 @@ include "mlir/Interfaces/SideEffectInterfaces.td"
|
|||
|
||||
def NVVM_Dialect : Dialect {
|
||||
let name = "nvvm";
|
||||
let cppNamespace = "NVVM";
|
||||
let cppNamespace = "::mlir::NVVM";
|
||||
let dependentDialects = ["LLVM::LLVMDialect"];
|
||||
}
|
||||
|
||||
|
|
|
@ -27,16 +27,10 @@
|
|||
#include "mlir/IR/OpDefinition.h"
|
||||
#include "mlir/Interfaces/SideEffectInterfaces.h"
|
||||
|
||||
namespace mlir {
|
||||
namespace ROCDL {
|
||||
|
||||
///// Ops /////
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/LLVMIR/ROCDLOps.h.inc"
|
||||
|
||||
#include "mlir/Dialect/LLVMIR/ROCDLOpsDialect.h.inc"
|
||||
|
||||
} // namespace ROCDL
|
||||
} // namespace mlir
|
||||
|
||||
#endif /* MLIR_DIALECT_LLVMIR_ROCDLDIALECT_H_ */
|
||||
|
|
|
@ -22,7 +22,7 @@ include "mlir/Interfaces/SideEffectInterfaces.td"
|
|||
|
||||
def ROCDL_Dialect : Dialect {
|
||||
let name = "rocdl";
|
||||
let cppNamespace = "ROCDL";
|
||||
let cppNamespace = "::mlir::ROCDL";
|
||||
let dependentDialects = ["LLVM::LLVMDialect"];
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ def Linalg_Dialect : Dialect {
|
|||
are also available and should be read first before going in the details of
|
||||
the op semantics.
|
||||
}];
|
||||
let cppNamespace = "::mlir::linalg";
|
||||
}
|
||||
|
||||
// Whether a type is a RangeType.
|
||||
|
|
|
@ -85,6 +85,9 @@ AffineMap extractOrIdentityMap(Optional<AffineMap> maybeMap, unsigned rank,
|
|||
SmallVector<AffineExpr, 4> concat(ArrayRef<AffineExpr> a,
|
||||
ArrayRef<AffineExpr> b);
|
||||
|
||||
} // namespace linalg
|
||||
} // namespace mlir
|
||||
|
||||
#include "mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterfaces.h.inc"
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
|
@ -93,7 +96,5 @@ SmallVector<AffineExpr, 4> concat(ArrayRef<AffineExpr> a,
|
|||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.h.inc"
|
||||
|
||||
} // namespace linalg
|
||||
} // namespace mlir
|
||||
|
||||
#endif // MLIR_DIALECT_LINALG_LINALGOPS_H_
|
||||
|
|
|
@ -18,6 +18,7 @@ include "mlir/Dialect/Linalg/IR/LinalgBase.td"
|
|||
// The linalg 'LinalgStructuredInterface' provides access to the 'LinalgOp'
|
||||
// interface.
|
||||
def LinalgStructuredInterface : OpInterface<"LinalgOp"> {
|
||||
let cppNamespace = "::mlir::linalg";
|
||||
let methods = [
|
||||
//===------------------------------------------------------------------===//
|
||||
// Loop types handling.
|
||||
|
|
|
@ -12,11 +12,12 @@
|
|||
#include "mlir/IR/Dialect.h"
|
||||
#include "mlir/IR/Types.h"
|
||||
|
||||
#include "mlir/Dialect/Linalg/IR/LinalgOpsDialect.h.inc"
|
||||
|
||||
namespace mlir {
|
||||
class MLIRContext;
|
||||
|
||||
namespace linalg {
|
||||
#include "mlir/Dialect/Linalg/IR/LinalgOpsDialect.h.inc"
|
||||
|
||||
/// A RangeType represents a minimal range abstraction (min, max, step).
|
||||
/// It is constructed by calling the linalg.range op with three values index of
|
||||
|
|
|
@ -16,15 +16,14 @@
|
|||
#include "mlir/IR/Dialect.h"
|
||||
#include "mlir/IR/OpDefinition.h"
|
||||
|
||||
#include "mlir/Dialect/OpenACC/OpenACCOpsDialect.h.inc"
|
||||
#include "mlir/Dialect/OpenACC/OpenACCOpsEnums.h.inc"
|
||||
|
||||
namespace mlir {
|
||||
namespace acc {
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/OpenACC/OpenACCOps.h.inc"
|
||||
|
||||
#include "mlir/Dialect/OpenACC/OpenACCOpsDialect.h.inc"
|
||||
namespace mlir {
|
||||
namespace acc {
|
||||
|
||||
/// Enumeration used to encode the execution mapping on a loop construct.
|
||||
/// They refer directly to the OpenACC 3.0 standard:
|
||||
|
|
|
@ -24,7 +24,7 @@ def OpenACC_Dialect : Dialect {
|
|||
This dialect models the construct from the OpenACC 3.0 directive language.
|
||||
}];
|
||||
|
||||
let cppNamespace = "acc";
|
||||
let cppNamespace = "::mlir::acc";
|
||||
}
|
||||
|
||||
// Base class for OpenACC dialect ops.
|
||||
|
|
|
@ -16,16 +16,10 @@
|
|||
#include "mlir/IR/Dialect.h"
|
||||
#include "mlir/IR/OpDefinition.h"
|
||||
|
||||
#include "mlir/Dialect/OpenMP/OpenMPOpsDialect.h.inc"
|
||||
#include "mlir/Dialect/OpenMP/OpenMPOpsEnums.h.inc"
|
||||
|
||||
namespace mlir {
|
||||
namespace omp {
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/OpenMP/OpenMPOps.h.inc"
|
||||
|
||||
#include "mlir/Dialect/OpenMP/OpenMPOpsDialect.h.inc"
|
||||
} // namespace omp
|
||||
} // namespace mlir
|
||||
|
||||
#endif // MLIR_DIALECT_OPENMP_OPENMPDIALECT_H_
|
||||
|
|
|
@ -19,7 +19,7 @@ include "mlir/Dialect/OpenMP/OmpCommon.td"
|
|||
|
||||
def OpenMP_Dialect : Dialect {
|
||||
let name = "omp";
|
||||
let cppNamespace = "omp";
|
||||
let cppNamespace = "::mlir::omp";
|
||||
}
|
||||
|
||||
class OpenMP_Op<string mnemonic, list<OpTrait> traits = []> :
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
#include "mlir/IR/SymbolTable.h"
|
||||
#include "mlir/Interfaces/SideEffectInterfaces.h"
|
||||
|
||||
namespace mlir {
|
||||
namespace pdl {
|
||||
//===----------------------------------------------------------------------===//
|
||||
// PDL Dialect
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -34,7 +32,5 @@ namespace pdl {
|
|||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/PDL/IR/PDLOps.h.inc"
|
||||
|
||||
} // end namespace pdl
|
||||
} // end namespace mlir
|
||||
|
||||
#endif // MLIR_DIALECT_PDL_IR_PDL_H_
|
||||
|
|
|
@ -63,7 +63,7 @@ def PDL_Dialect : Dialect {
|
|||
}];
|
||||
|
||||
let name = "pdl";
|
||||
let cppNamespace = "mlir::pdl";
|
||||
let cppNamespace = "::mlir::pdl";
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
#include "mlir/Interfaces/InferTypeOpInterface.h"
|
||||
#include "mlir/Interfaces/SideEffectInterfaces.h"
|
||||
|
||||
namespace mlir {
|
||||
namespace pdl_interp {
|
||||
//===----------------------------------------------------------------------===//
|
||||
// PDLInterp Dialect
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -33,7 +31,4 @@ namespace pdl_interp {
|
|||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/PDLInterp/IR/PDLInterpOps.h.inc"
|
||||
|
||||
} // end namespace pdl_interp
|
||||
} // end namespace mlir
|
||||
|
||||
#endif // MLIR_DIALECT_PDLINTERP_IR_PDLINTERP_H_
|
||||
|
|
|
@ -34,7 +34,7 @@ def PDLInterp_Dialect : Dialect {
|
|||
}];
|
||||
|
||||
let name = "pdl_interp";
|
||||
let cppNamespace = "mlir::pdl_interp";
|
||||
let cppNamespace = "::mlir::pdl_interp";
|
||||
let dependentDialects = ["pdl::PDLDialect"];
|
||||
}
|
||||
|
||||
|
|
|
@ -18,15 +18,9 @@
|
|||
#include "mlir/Interfaces/SideEffectInterfaces.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
|
||||
namespace mlir {
|
||||
namespace quant {
|
||||
|
||||
#include "mlir/Dialect/Quant/QuantOpsDialect.h.inc"
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/Quant/QuantOps.h.inc"
|
||||
|
||||
} // namespace quant
|
||||
} // namespace mlir
|
||||
|
||||
#endif // MLIR_DIALECT_QUANT_QUANTOPS_H_
|
||||
|
|
|
@ -17,6 +17,7 @@ include "mlir/IR/OpBase.td"
|
|||
|
||||
def Quantization_Dialect : Dialect {
|
||||
let name = "quant";
|
||||
let cppNamespace = "::mlir::quant";
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -23,14 +23,18 @@
|
|||
|
||||
namespace mlir {
|
||||
namespace scf {
|
||||
|
||||
void buildTerminatedBody(OpBuilder &builder, Location loc);
|
||||
} // namespace scf
|
||||
} // namespace mlir
|
||||
|
||||
#include "mlir/Dialect/SCF/SCFOpsDialect.h.inc"
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/SCF/SCFOps.h.inc"
|
||||
|
||||
namespace mlir {
|
||||
namespace scf {
|
||||
|
||||
// Insert `loop.yield` at the end of the only region's only block if it
|
||||
// does not have a terminator already. If a new `loop.yield` is inserted,
|
||||
// the location is specified by `loc`. If the region is empty, insert a new
|
||||
|
|
|
@ -19,7 +19,7 @@ include "mlir/Interfaces/SideEffectInterfaces.td"
|
|||
|
||||
def SCF_Dialect : Dialect {
|
||||
let name = "scf";
|
||||
let cppNamespace = "scf";
|
||||
let cppNamespace = "::mlir::scf";
|
||||
}
|
||||
|
||||
// Base class for SCF dialect ops.
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
#include "mlir/IR/Attributes.h"
|
||||
#include "mlir/Support/LLVM.h"
|
||||
|
||||
namespace mlir {
|
||||
// Pull in SPIR-V attribute definitions for target and ABI.
|
||||
#include "mlir/Dialect/SPIRV/TargetAndABI.h.inc"
|
||||
|
||||
namespace mlir {
|
||||
namespace spirv {
|
||||
enum class Capability : uint32_t;
|
||||
enum class Extension;
|
||||
|
|
|
@ -45,7 +45,7 @@ def SPIRV_Dialect : Dialect {
|
|||
high-level designs and implementation structures of the SPIR-V dialect.
|
||||
}];
|
||||
|
||||
let cppNamespace = "spirv";
|
||||
let cppNamespace = "::mlir::spirv";
|
||||
let hasConstantMaterializer = 1;
|
||||
let hasOperationAttrVerify = 1;
|
||||
let hasRegionArgAttrVerify = 1;
|
||||
|
@ -226,21 +226,24 @@ class Capability<list<I32EnumAttrCase> capabilities> : Availability {
|
|||
let instance = "ref";
|
||||
}
|
||||
|
||||
class SPIRVOpInterface<string name> : OpInterface<name> {
|
||||
let cppNamespace = "::mlir::spirv";
|
||||
}
|
||||
// TODO: the following interfaces definitions are duplicating with the above.
|
||||
// Remove them once we are able to support dialect-specific contents in ODS.
|
||||
def QueryMinVersionInterface : OpInterface<"QueryMinVersionInterface"> {
|
||||
def QueryMinVersionInterface : SPIRVOpInterface<"QueryMinVersionInterface"> {
|
||||
let methods = [InterfaceMethod<"", "::mlir::spirv::Version", "getMinVersion">];
|
||||
}
|
||||
def QueryMaxVersionInterface : OpInterface<"QueryMaxVersionInterface"> {
|
||||
def QueryMaxVersionInterface : SPIRVOpInterface<"QueryMaxVersionInterface"> {
|
||||
let methods = [InterfaceMethod<"", "::mlir::spirv::Version", "getMaxVersion">];
|
||||
}
|
||||
def QueryExtensionInterface : OpInterface<"QueryExtensionInterface"> {
|
||||
def QueryExtensionInterface : SPIRVOpInterface<"QueryExtensionInterface"> {
|
||||
let methods = [InterfaceMethod<
|
||||
"",
|
||||
"::llvm::SmallVector<::llvm::ArrayRef<::mlir::spirv::Extension>, 1>",
|
||||
"getExtensions">];
|
||||
}
|
||||
def QueryCapabilityInterface : OpInterface<"QueryCapabilityInterface"> {
|
||||
def QueryCapabilityInterface : SPIRVOpInterface<"QueryCapabilityInterface"> {
|
||||
let methods = [InterfaceMethod<
|
||||
"",
|
||||
"::llvm::SmallVector<::llvm::ArrayRef<::mlir::spirv::Capability>, 1>",
|
||||
|
|
|
@ -20,9 +20,9 @@ namespace spirv {
|
|||
|
||||
enum class Decoration : uint32_t;
|
||||
|
||||
#include "mlir/Dialect/SPIRV/SPIRVOpsDialect.h.inc"
|
||||
|
||||
} // end namespace spirv
|
||||
} // end namespace mlir
|
||||
|
||||
#include "mlir/Dialect/SPIRV/SPIRVOpsDialect.h.inc"
|
||||
|
||||
#endif // MLIR_DIALECT_SPIRV_SPIRVDIALECT_H_
|
||||
|
|
|
@ -28,11 +28,15 @@ class VerCapExtAttr;
|
|||
// TableGen'erated operation interfaces for querying versions, extensions, and
|
||||
// capabilities.
|
||||
#include "mlir/Dialect/SPIRV/SPIRVAvailability.h.inc"
|
||||
} // namespace spirv
|
||||
} // namespace mlir
|
||||
|
||||
// TablenGen'erated operation declarations.
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/SPIRV/SPIRVOps.h.inc"
|
||||
|
||||
namespace mlir {
|
||||
namespace spirv {
|
||||
// TableGen'erated helper functions.
|
||||
//
|
||||
// Get the name used in the Op to refer to an enum value of the given
|
||||
|
|
|
@ -77,25 +77,25 @@ public:
|
|||
/// The extension requirements for each type are following the
|
||||
/// ((Extension::A OR Extension::B) AND (Extension::C OR Extension::D))
|
||||
/// convention.
|
||||
using ExtensionArrayRefVector = SmallVectorImpl<ArrayRef<spirv::Extension>>;
|
||||
using ExtensionArrayRefVector = SmallVectorImpl<ArrayRef<Extension>>;
|
||||
|
||||
/// Appends to `extensions` the extensions needed for this type to appear in
|
||||
/// the given `storage` class. This method does not guarantee the uniqueness
|
||||
/// of extensions; the same extension may be appended multiple times.
|
||||
void getExtensions(ExtensionArrayRefVector &extensions,
|
||||
Optional<spirv::StorageClass> storage = llvm::None);
|
||||
Optional<StorageClass> storage = llvm::None);
|
||||
|
||||
/// The capability requirements for each type are following the
|
||||
/// ((Capability::A OR Extension::B) AND (Capability::C OR Capability::D))
|
||||
/// convention.
|
||||
using CapabilityArrayRefVector = SmallVectorImpl<ArrayRef<spirv::Capability>>;
|
||||
using CapabilityArrayRefVector = SmallVectorImpl<ArrayRef<Capability>>;
|
||||
|
||||
/// Appends to `capabilities` the capabilities needed for this type to appear
|
||||
/// in the given `storage` class. This method does not guarantee the
|
||||
/// uniqueness of capabilities; the same capability may be appended multiple
|
||||
/// times.
|
||||
void getCapabilities(CapabilityArrayRefVector &capabilities,
|
||||
Optional<spirv::StorageClass> storage = llvm::None);
|
||||
Optional<StorageClass> storage = llvm::None);
|
||||
|
||||
/// Returns the size in bytes for each type. If no size can be calculated,
|
||||
/// returns `llvm::None`. Note that if the type has explicit layout, it is
|
||||
|
@ -116,9 +116,9 @@ public:
|
|||
static bool isValid(IntegerType);
|
||||
|
||||
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions,
|
||||
Optional<spirv::StorageClass> storage = llvm::None);
|
||||
Optional<StorageClass> storage = llvm::None);
|
||||
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities,
|
||||
Optional<spirv::StorageClass> storage = llvm::None);
|
||||
Optional<StorageClass> storage = llvm::None);
|
||||
|
||||
Optional<int64_t> getSizeInBytes();
|
||||
};
|
||||
|
@ -144,9 +144,9 @@ public:
|
|||
bool hasCompileTimeKnownNumElements() const;
|
||||
|
||||
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions,
|
||||
Optional<spirv::StorageClass> storage = llvm::None);
|
||||
Optional<StorageClass> storage = llvm::None);
|
||||
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities,
|
||||
Optional<spirv::StorageClass> storage = llvm::None);
|
||||
Optional<StorageClass> storage = llvm::None);
|
||||
|
||||
Optional<int64_t> getSizeInBytes();
|
||||
};
|
||||
|
@ -172,9 +172,9 @@ public:
|
|||
unsigned getArrayStride() const;
|
||||
|
||||
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions,
|
||||
Optional<spirv::StorageClass> storage = llvm::None);
|
||||
Optional<StorageClass> storage = llvm::None);
|
||||
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities,
|
||||
Optional<spirv::StorageClass> storage = llvm::None);
|
||||
Optional<StorageClass> storage = llvm::None);
|
||||
|
||||
/// Returns the array size in bytes. Since array type may have an explicit
|
||||
/// stride declaration (in bytes), we also include it in the calculation.
|
||||
|
@ -215,9 +215,9 @@ public:
|
|||
// TODO: Add support for Access qualifier
|
||||
|
||||
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions,
|
||||
Optional<spirv::StorageClass> storage = llvm::None);
|
||||
Optional<StorageClass> storage = llvm::None);
|
||||
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities,
|
||||
Optional<spirv::StorageClass> storage = llvm::None);
|
||||
Optional<StorageClass> storage = llvm::None);
|
||||
};
|
||||
|
||||
// SPIR-V pointer type
|
||||
|
@ -233,9 +233,9 @@ public:
|
|||
StorageClass getStorageClass() const;
|
||||
|
||||
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions,
|
||||
Optional<spirv::StorageClass> storage = llvm::None);
|
||||
Optional<StorageClass> storage = llvm::None);
|
||||
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities,
|
||||
Optional<spirv::StorageClass> storage = llvm::None);
|
||||
Optional<StorageClass> storage = llvm::None);
|
||||
};
|
||||
|
||||
// SPIR-V run-time array type
|
||||
|
@ -257,9 +257,9 @@ public:
|
|||
unsigned getArrayStride() const;
|
||||
|
||||
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions,
|
||||
Optional<spirv::StorageClass> storage = llvm::None);
|
||||
Optional<StorageClass> storage = llvm::None);
|
||||
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities,
|
||||
Optional<spirv::StorageClass> storage = llvm::None);
|
||||
Optional<StorageClass> storage = llvm::None);
|
||||
};
|
||||
|
||||
// SPIR-V struct type
|
||||
|
@ -335,21 +335,21 @@ public:
|
|||
|
||||
uint64_t getMemberOffset(unsigned) const;
|
||||
|
||||
// Returns in `memberDecorations` the spirv::Decorations (apart from
|
||||
// Offset) associated with all members of the StructType.
|
||||
// Returns in `memberDecorations` the Decorations (apart from Offset)
|
||||
// associated with all members of the StructType.
|
||||
void getMemberDecorations(SmallVectorImpl<StructType::MemberDecorationInfo>
|
||||
&memberDecorations) const;
|
||||
|
||||
// Returns in `decorationsInfo` all the spirv::Decorations (apart from
|
||||
// Offset) associated with the `i`-th member of the StructType.
|
||||
// Returns in `decorationsInfo` all the Decorations (apart from Offset)
|
||||
// associated with the `i`-th member of the StructType.
|
||||
void getMemberDecorations(unsigned i,
|
||||
SmallVectorImpl<StructType::MemberDecorationInfo>
|
||||
&decorationsInfo) const;
|
||||
|
||||
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions,
|
||||
Optional<spirv::StorageClass> storage = llvm::None);
|
||||
Optional<StorageClass> storage = llvm::None);
|
||||
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities,
|
||||
Optional<spirv::StorageClass> storage = llvm::None);
|
||||
Optional<StorageClass> storage = llvm::None);
|
||||
};
|
||||
|
||||
llvm::hash_code
|
||||
|
@ -362,21 +362,21 @@ class CooperativeMatrixNVType
|
|||
public:
|
||||
using Base::Base;
|
||||
|
||||
static CooperativeMatrixNVType get(Type elementType, spirv::Scope scope,
|
||||
static CooperativeMatrixNVType get(Type elementType, Scope scope,
|
||||
unsigned rows, unsigned columns);
|
||||
Type getElementType() const;
|
||||
|
||||
/// Return the scope of the cooperative matrix.
|
||||
spirv::Scope getScope() const;
|
||||
Scope getScope() const;
|
||||
/// return the number of rows of the matrix.
|
||||
unsigned getRows() const;
|
||||
/// return the number of columns of the matrix.
|
||||
unsigned getColumns() const;
|
||||
|
||||
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions,
|
||||
Optional<spirv::StorageClass> storage = llvm::None);
|
||||
Optional<StorageClass> storage = llvm::None);
|
||||
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities,
|
||||
Optional<spirv::StorageClass> storage = llvm::None);
|
||||
Optional<StorageClass> storage = llvm::None);
|
||||
};
|
||||
|
||||
// SPIR-V matrix type
|
||||
|
@ -412,9 +412,9 @@ public:
|
|||
Type getElementType() const;
|
||||
|
||||
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions,
|
||||
Optional<spirv::StorageClass> storage = llvm::None);
|
||||
Optional<StorageClass> storage = llvm::None);
|
||||
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities,
|
||||
Optional<spirv::StorageClass> storage = llvm::None);
|
||||
Optional<StorageClass> storage = llvm::None);
|
||||
};
|
||||
|
||||
} // end namespace spirv
|
||||
|
|
|
@ -67,12 +67,12 @@ public:
|
|||
using Base::Base;
|
||||
};
|
||||
|
||||
} // namespace shape
|
||||
} // namespace mlir
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/Shape/IR/ShapeOps.h.inc"
|
||||
|
||||
#include "mlir/Dialect/Shape/IR/ShapeOpsDialect.h.inc"
|
||||
|
||||
} // namespace shape
|
||||
} // namespace mlir
|
||||
|
||||
#endif // MLIR_SHAPE_IR_SHAPE_H
|
||||
|
|
|
@ -36,7 +36,7 @@ def ShapeDialect : Dialect {
|
|||
concatting etc. on how to combine them).
|
||||
}];
|
||||
|
||||
let cppNamespace = "shape";
|
||||
let cppNamespace = "::mlir::shape";
|
||||
|
||||
let hasConstantMaterializer = 1;
|
||||
}
|
||||
|
|
|
@ -128,13 +128,11 @@ namespace impl {
|
|||
AffineMap getTransferMinorIdentityMap(MemRefType memRefType,
|
||||
VectorType vectorType);
|
||||
} // namespace impl
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/Vector/VectorOps.h.inc"
|
||||
|
||||
#include "mlir/Dialect/Vector/VectorOpsDialect.h.inc"
|
||||
|
||||
} // end namespace vector
|
||||
} // end namespace mlir
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/Vector/VectorOps.h.inc"
|
||||
#include "mlir/Dialect/Vector/VectorOpsDialect.h.inc"
|
||||
|
||||
#endif // MLIR_DIALECT_VECTOR_VECTOROPS_H
|
||||
|
|
|
@ -19,7 +19,7 @@ include "mlir/Interfaces/VectorInterfaces.td"
|
|||
|
||||
def Vector_Dialect : Dialect {
|
||||
let name = "vector";
|
||||
let cppNamespace = "vector";
|
||||
let cppNamespace = "::mlir::vector";
|
||||
let hasConstantMaterializer = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1672,7 +1672,7 @@ class OpTrait;
|
|||
// purpose to wrap around C++ symbol string with this class is to make
|
||||
// traits specified for ops in TableGen less alien and more integrated.
|
||||
class NativeOpTrait<string prop> : OpTrait {
|
||||
string trait = "OpTrait::" # prop;
|
||||
string trait = "::mlir::OpTrait::" # prop;
|
||||
}
|
||||
|
||||
// ParamNativeOpTrait corresponds to the template-parameterized traits in the
|
||||
|
@ -1687,7 +1687,7 @@ class ParamNativeOpTrait<string prop, string params>
|
|||
// affects op definition generator internals, like how op builders and
|
||||
// operand/attribute/result getters are generated.
|
||||
class GenInternalOpTrait<string prop> : OpTrait {
|
||||
string trait = "OpTrait::" # prop;
|
||||
string trait = "::mlir::OpTrait::" # prop;
|
||||
}
|
||||
|
||||
// PredOpTrait is an op trait implemented by way of a predicate on the op.
|
||||
|
|
|
@ -242,6 +242,17 @@ public:
|
|||
// debugging purposes.
|
||||
void print(llvm::raw_ostream &os) const;
|
||||
|
||||
// A helper RAII class to emit nested namespaces for this op.
|
||||
class NamespaceEmitter {
|
||||
public:
|
||||
NamespaceEmitter(raw_ostream &os, Operator &op);
|
||||
~NamespaceEmitter();
|
||||
|
||||
private:
|
||||
raw_ostream &os;
|
||||
SmallVector<StringRef, 2> namespaces;
|
||||
};
|
||||
|
||||
// Return whether all the result types are known.
|
||||
bool allResultTypesKnown() const { return allResultsHaveKnownTypes; };
|
||||
|
||||
|
|
|
@ -25,10 +25,5 @@ void avx512::AVX512Dialect::initialize() {
|
|||
>();
|
||||
}
|
||||
|
||||
namespace mlir {
|
||||
namespace avx512 {
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/AVX512/AVX512.cpp.inc"
|
||||
} // namespace avx512
|
||||
} // namespace mlir
|
||||
|
||||
|
|
|
@ -777,10 +777,5 @@ static void print(OpAsmPrinter &p, GPUModuleOp op) {
|
|||
/*printBlockTerminators=*/false);
|
||||
}
|
||||
|
||||
// Namespace avoids ambiguous ReturnOpAdaptor.
|
||||
namespace mlir {
|
||||
namespace gpu {
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/GPU/GPUOps.cpp.inc"
|
||||
} // namespace gpu
|
||||
} // namespace mlir
|
||||
|
|
|
@ -23,10 +23,9 @@ using namespace mlir;
|
|||
using namespace mlir::gpu;
|
||||
using namespace mlir::scf;
|
||||
|
||||
#include "mlir/Dialect/GPU/ParallelLoopMapperAttr.cpp.inc"
|
||||
#include "mlir/Dialect/GPU/ParallelLoopMapperEnums.cpp.inc"
|
||||
namespace mlir {
|
||||
|
||||
#include "mlir/Dialect/GPU/ParallelLoopMapperAttr.cpp.inc"
|
||||
namespace gpu {
|
||||
|
||||
StringRef getMappingAttrName() { return "mapping"; }
|
||||
|
|
|
@ -27,9 +27,5 @@ void LLVM::LLVMAVX512Dialect::initialize() {
|
|||
>();
|
||||
}
|
||||
|
||||
namespace mlir {
|
||||
namespace LLVM {
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/LLVMIR/LLVMAVX512.cpp.inc"
|
||||
} // namespace LLVM
|
||||
} // namespace mlir
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
#include "mlir/Dialect/LLVMIR/NVVMDialect.h"
|
||||
|
||||
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
|
||||
#include "mlir/IR/Builders.h"
|
||||
#include "mlir/IR/MLIRContext.h"
|
||||
#include "mlir/IR/Operation.h"
|
||||
|
@ -146,10 +145,5 @@ void NVVMDialect::initialize() {
|
|||
allowUnknownOperations();
|
||||
}
|
||||
|
||||
namespace mlir {
|
||||
namespace NVVM {
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/LLVMIR/NVVMOps.cpp.inc"
|
||||
} // namespace NVVM
|
||||
} // namespace mlir
|
||||
|
||||
|
|
|
@ -91,10 +91,5 @@ void ROCDLDialect::initialize() {
|
|||
allowUnknownOperations();
|
||||
}
|
||||
|
||||
namespace mlir {
|
||||
namespace ROCDL {
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/LLVMIR/ROCDLOps.cpp.inc"
|
||||
} // namespace ROCDL
|
||||
} // namespace mlir
|
||||
|
||||
|
|
|
@ -1096,9 +1096,6 @@ static LogicalResult verify(PoolingSumOp op) {
|
|||
return verifySingleInputPoolingOp(op);
|
||||
}
|
||||
|
||||
namespace mlir {
|
||||
namespace linalg {
|
||||
|
||||
#include "mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterfaces.cpp.inc"
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
|
@ -1107,9 +1104,6 @@ namespace linalg {
|
|||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc"
|
||||
|
||||
} // namespace linalg
|
||||
} // namespace mlir
|
||||
|
||||
AffineMap mlir::linalg::extractOrIdentityMap(Optional<AffineMap> maybeMap,
|
||||
unsigned rank,
|
||||
MLIRContext *context) {
|
||||
|
|
|
@ -271,9 +271,5 @@ static ParseResult parseParallelOp(OpAsmParser &parser,
|
|||
return success();
|
||||
}
|
||||
|
||||
namespace mlir {
|
||||
namespace omp {
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/OpenMP/OpenMPOps.cpp.inc"
|
||||
} // namespace omp
|
||||
} // namespace mlir
|
||||
|
|
|
@ -454,11 +454,5 @@ static LogicalResult verify(TypeOp op) {
|
|||
// TableGen'd op method definitions
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace mlir {
|
||||
namespace pdl {
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/PDL/IR/PDLOps.cpp.inc"
|
||||
|
||||
} // end namespace pdl
|
||||
} // end namespace mlir
|
||||
|
|
|
@ -899,9 +899,5 @@ static void print(OpAsmPrinter &p, scf::YieldOp op) {
|
|||
// TableGen'd op method definitions
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace mlir {
|
||||
namespace scf {
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/SCF/SCFOps.cpp.inc"
|
||||
} // namespace scf
|
||||
} // namespace mlir
|
||||
|
|
|
@ -16,9 +16,10 @@ using namespace mlir;
|
|||
// DictionaryDict derived attributes
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace mlir {
|
||||
#include "mlir/Dialect/SPIRV/TargetAndABI.cpp.inc"
|
||||
|
||||
namespace mlir {
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Attribute storage classes
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -3266,11 +3266,15 @@ namespace spirv {
|
|||
// TableGen'erated operation interfaces for querying versions, extensions, and
|
||||
// capabilities.
|
||||
#include "mlir/Dialect/SPIRV/SPIRVAvailability.cpp.inc"
|
||||
} // namespace spirv
|
||||
} // namespace mlir
|
||||
|
||||
// TablenGen'erated operation definitions.
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/SPIRV/SPIRVOps.cpp.inc"
|
||||
|
||||
namespace mlir {
|
||||
namespace spirv {
|
||||
// TableGen'erated operation availability interface implementations.
|
||||
#include "mlir/Dialect/SPIRV/SPIRVOpAvailabilityImpl.inc"
|
||||
|
||||
|
|
|
@ -938,11 +938,5 @@ static void print(OpAsmPrinter &p, ReduceOp op) {
|
|||
p.printOptionalAttrDict(op.getAttrs());
|
||||
}
|
||||
|
||||
namespace mlir {
|
||||
namespace shape {
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/Shape/IR/ShapeOps.cpp.inc"
|
||||
|
||||
} // namespace shape
|
||||
} // namespace mlir
|
||||
|
|
|
@ -2688,11 +2688,5 @@ void mlir::vector::populateVectorToVectorCanonicalizationPatterns(
|
|||
TransposeFolder>(context);
|
||||
}
|
||||
|
||||
namespace mlir {
|
||||
namespace vector {
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/Vector/VectorOps.cpp.inc"
|
||||
|
||||
} // namespace vector
|
||||
} // namespace mlir
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/Sequence.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/ADT/TypeSwitch.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/FormatVariadic.h"
|
||||
|
@ -278,7 +279,7 @@ void Operator::populateTypeInferenceInfo(
|
|||
|
||||
// Skip cases currently being custom generated.
|
||||
// TODO: Remove special cases.
|
||||
if (getTrait("OpTrait::SameOperandsAndResultType"))
|
||||
if (getTrait("::mlir::OpTrait::SameOperandsAndResultType"))
|
||||
return;
|
||||
|
||||
// We create equivalence classes of argument/result types where arguments
|
||||
|
@ -565,6 +566,21 @@ void Operator::print(llvm::raw_ostream &os) const {
|
|||
}
|
||||
}
|
||||
|
||||
Operator::NamespaceEmitter::NamespaceEmitter(raw_ostream &os, Operator &op)
|
||||
: os(os) {
|
||||
auto dialect = op.getDialect();
|
||||
if (!dialect)
|
||||
return;
|
||||
llvm::SplitString(dialect.getCppNamespace(), namespaces, "::");
|
||||
for (StringRef ns : namespaces)
|
||||
os << "namespace " << ns << " {\n";
|
||||
}
|
||||
|
||||
Operator::NamespaceEmitter::~NamespaceEmitter() {
|
||||
for (StringRef ns : llvm::reverse(namespaces))
|
||||
os << "} // namespace " << ns << "\n";
|
||||
}
|
||||
|
||||
auto Operator::VariableDecoratorIterator::unwrap(llvm::Init *init)
|
||||
-> VariableDecorator {
|
||||
return VariableDecorator(cast<llvm::DefInit>(init)->getDef());
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
|
||||
#include "TestOpEnums.h.inc"
|
||||
|
||||
namespace mlir {
|
||||
|
||||
#include "TestOpStructs.h.inc"
|
||||
#include "TestOpsDialect.h.inc"
|
||||
|
@ -37,8 +36,8 @@ namespace mlir {
|
|||
#define GET_OP_CLASSES
|
||||
#include "TestOps.h.inc"
|
||||
|
||||
namespace mlir {
|
||||
void registerTestDialect(DialectRegistry ®istry);
|
||||
|
||||
} // end namespace mlir
|
||||
|
||||
#endif // MLIR_TESTDIALECT_H
|
||||
|
|
|
@ -22,7 +22,7 @@ include "mlir/Interfaces/SideEffectInterfaces.td"
|
|||
|
||||
def Test_Dialect : Dialect {
|
||||
let name = "test";
|
||||
let cppNamespace = "";
|
||||
let cppNamespace = "::mlir";
|
||||
let hasOperationAttrVerify = 1;
|
||||
let hasRegionArgAttrVerify = 1;
|
||||
let hasRegionResultAttrVerify = 1;
|
||||
|
|
|
@ -275,3 +275,19 @@ def SomeTypedArrayAttr : TypedArrayAttrBase<SomeAttr, "SomeAttr array">;
|
|||
|
||||
// RECORD-LABEL: def SomeTypedArrayAttr
|
||||
// RECORD: Attr elementAttr = SomeAttr;
|
||||
|
||||
def Test_Dialect_2 : Dialect {
|
||||
let name = "dialect_2";
|
||||
}
|
||||
def MyStruct : StructAttr<"MyStruct", Test_Dialect_2,
|
||||
[StructFieldAttr<"potatoes", I64ElementsAttr>]> {
|
||||
let description = "A structure describing a number of potatoes.";
|
||||
}
|
||||
|
||||
def StructAttrOp : NS_Op<"struct_attr_op", []> {
|
||||
let arguments = (ins
|
||||
MyStruct:$potatoes
|
||||
);
|
||||
}
|
||||
|
||||
// DECL: dialect_2::MyStruct potatoes();
|
||||
|
|
|
@ -61,8 +61,8 @@ def NS_AOp : NS_Op<"a_op", [IsolatedFromAbove, IsolatedFromAbove]> {
|
|||
// CHECK: ::mlir::ValueRange odsOperands;
|
||||
// CHECK: };
|
||||
|
||||
// CHECK: class AOp : public ::mlir::Op<AOp, OpTrait::AtLeastNRegions<1>::Impl, OpTrait::AtLeastNResults<1>::Impl, OpTrait::ZeroSuccessor, OpTrait::AtLeastNOperands<1>::Impl, OpTrait::IsIsolatedFromAbove
|
||||
// CHECK-NOT: OpTrait::IsIsolatedFromAbove
|
||||
// CHECK: class AOp : public ::mlir::Op<AOp, ::mlir::OpTrait::AtLeastNRegions<1>::Impl, ::mlir::OpTrait::AtLeastNResults<1>::Impl, ::mlir::OpTrait::ZeroSuccessor, ::mlir::OpTrait::AtLeastNOperands<1>::Impl, ::mlir::OpTrait::IsIsolatedFromAbove
|
||||
// CHECK-NOT: ::mlir::OpTrait::IsIsolatedFromAbove
|
||||
// CHECK: public:
|
||||
// CHECK: using Op::Op;
|
||||
// CHECK: using Adaptor = AOpAdaptor;
|
||||
|
|
|
@ -153,6 +153,15 @@ static void emitDialectDecl(Dialect &dialect,
|
|||
dialectsOs << llvm::formatv(dialectRegistrationTemplate,
|
||||
dependentDialect);
|
||||
}
|
||||
|
||||
// Emit all nested namespaces.
|
||||
StringRef cppNamespace = dialect.getCppNamespace();
|
||||
llvm::SmallVector<StringRef, 2> namespaces;
|
||||
llvm::SplitString(cppNamespace, namespaces, "::");
|
||||
|
||||
for (auto ns : namespaces)
|
||||
os << "namespace " << ns << " {\n";
|
||||
|
||||
// Emit the start of the decl.
|
||||
std::string cppName = dialect.getCppClassName();
|
||||
os << llvm::formatv(dialectDeclBeginStr, cppName, dialect.getName(),
|
||||
|
@ -179,6 +188,10 @@ static void emitDialectDecl(Dialect &dialect,
|
|||
|
||||
// End the dialect decl.
|
||||
os << "};\n";
|
||||
|
||||
// Close all nested namespaces in reverse order.
|
||||
for (auto ns : llvm::reverse(namespaces))
|
||||
os << "} // namespace " << ns << "\n";
|
||||
}
|
||||
|
||||
static bool emitDialectDecls(const llvm::RecordKeeper &recordKeeper,
|
||||
|
|
|
@ -494,6 +494,7 @@ void OpEmitter::genAttrGetters() {
|
|||
FmtContext fctx;
|
||||
fctx.withBuilder("::mlir::Builder(this->getContext())");
|
||||
|
||||
Dialect opDialect = op.getDialect();
|
||||
// Emit the derived attribute body.
|
||||
auto emitDerivedAttr = [&](StringRef name, Attribute attr) {
|
||||
auto &method = opClass.newMethod(attr.getReturnType(), name);
|
||||
|
@ -503,7 +504,16 @@ void OpEmitter::genAttrGetters() {
|
|||
|
||||
// Emit with return type specified.
|
||||
auto emitAttrWithReturnType = [&](StringRef name, Attribute attr) {
|
||||
auto &method = opClass.newMethod(attr.getReturnType(), name);
|
||||
Dialect attrDialect = attr.getDialect();
|
||||
// Does the current operation have a different namespace than the attribute?
|
||||
bool differentNamespace =
|
||||
attrDialect && opDialect && attrDialect != opDialect;
|
||||
std::string returnType = differentNamespace
|
||||
? (llvm::Twine(attrDialect.getCppNamespace()) +
|
||||
"::" + attr.getReturnType())
|
||||
.str()
|
||||
: attr.getReturnType().str();
|
||||
auto &method = opClass.newMethod(returnType, name);
|
||||
auto &body = method.body();
|
||||
body << " auto attr = " << name << "Attr();\n";
|
||||
if (attr.hasDefaultValue()) {
|
||||
|
@ -684,9 +694,9 @@ static void generateNamedOperandGetters(const Operator &op, Class &opClass,
|
|||
const int numNormalOperands = numOperands - numVariadicOperands;
|
||||
|
||||
const auto *sameVariadicSize =
|
||||
op.getTrait("OpTrait::SameVariadicOperandSize");
|
||||
op.getTrait("::mlir::OpTrait::SameVariadicOperandSize");
|
||||
const auto *attrSizedOperands =
|
||||
op.getTrait("OpTrait::AttrSizedOperandSegments");
|
||||
op.getTrait("::mlir::OpTrait::AttrSizedOperandSegments");
|
||||
|
||||
if (numVariadicOperands > 1 && !sameVariadicSize && !attrSizedOperands) {
|
||||
PrintFatalError(op.getLoc(), "op has multiple variadic operands but no "
|
||||
|
@ -748,7 +758,8 @@ void OpEmitter::genNamedOperandGetters() {
|
|||
}
|
||||
|
||||
void OpEmitter::genNamedOperandSetters() {
|
||||
auto *attrSizedOperands = op.getTrait("OpTrait::AttrSizedOperandSegments");
|
||||
auto *attrSizedOperands =
|
||||
op.getTrait("::mlir::OpTrait::AttrSizedOperandSegments");
|
||||
for (int i = 0, e = op.getNumOperands(); i != e; ++i) {
|
||||
const auto &operand = op.getOperand(i);
|
||||
if (operand.name.empty())
|
||||
|
@ -775,9 +786,10 @@ void OpEmitter::genNamedResultGetters() {
|
|||
// If we have more than one variadic results, we need more complicated logic
|
||||
// to calculate the value range for each result.
|
||||
|
||||
const auto *sameVariadicSize = op.getTrait("OpTrait::SameVariadicResultSize");
|
||||
const auto *sameVariadicSize =
|
||||
op.getTrait("::mlir::OpTrait::SameVariadicResultSize");
|
||||
const auto *attrSizedResults =
|
||||
op.getTrait("OpTrait::AttrSizedResultSegments");
|
||||
op.getTrait("::mlir::OpTrait::AttrSizedResultSegments");
|
||||
|
||||
if (numVariadicResults > 1 && !sameVariadicSize && !attrSizedResults) {
|
||||
PrintFatalError(op.getLoc(), "op has multiple variadic results but no "
|
||||
|
@ -1213,7 +1225,7 @@ void OpEmitter::genBuilder() {
|
|||
// use the first operand or attribute's type as all result types
|
||||
// to facilitate different call patterns.
|
||||
if (op.getNumVariableLengthResults() == 0) {
|
||||
if (op.getTrait("OpTrait::SameOperandsAndResultType")) {
|
||||
if (op.getTrait("::mlir::OpTrait::SameOperandsAndResultType")) {
|
||||
// If the operation has a single variadic input, then the build method
|
||||
// generated by `genUseOperandAsResultTypeSeparateParamBuilder` will be
|
||||
// ambiguous with the one generated by
|
||||
|
@ -1230,7 +1242,7 @@ void OpEmitter::genBuilder() {
|
|||
if (!shouldGenerateInferredTypeCollectiveParamBuilder())
|
||||
genUseOperandAsResultTypeCollectiveParamBuilder();
|
||||
}
|
||||
if (op.getTrait("OpTrait::FirstAttrDerivedResultType"))
|
||||
if (op.getTrait("::mlir::OpTrait::FirstAttrDerivedResultType"))
|
||||
genUseAttrAsResultTypeBuilder();
|
||||
}
|
||||
}
|
||||
|
@ -1435,7 +1447,7 @@ void OpEmitter::genCodeForAddingArgAndRegionForBuilder(OpMethodBody &body,
|
|||
}
|
||||
|
||||
// If the operation has the operand segment size attribute, add it here.
|
||||
if (op.getTrait("OpTrait::AttrSizedOperandSegments")) {
|
||||
if (op.getTrait("::mlir::OpTrait::AttrSizedOperandSegments")) {
|
||||
body << " " << builderOpState
|
||||
<< ".addAttribute(\"operand_segment_sizes\", "
|
||||
"odsBuilder.getI32VectorAttr({";
|
||||
|
@ -1695,7 +1707,7 @@ void OpEmitter::genTypeInterfaceMethods() {
|
|||
continue;
|
||||
// TODO: We could verify equality here, but skipping that for verification.
|
||||
}
|
||||
os << " return success();";
|
||||
os << " return ::mlir::success();";
|
||||
}
|
||||
|
||||
void OpEmitter::genParser() {
|
||||
|
@ -1735,7 +1747,7 @@ void OpEmitter::genVerifier() {
|
|||
auto &body = method.body();
|
||||
body << " if (failed(" << op.getAdaptorName()
|
||||
<< "(*this).verify(this->getLoc()))) "
|
||||
<< "return failure();\n";
|
||||
<< "return ::mlir::failure();\n";
|
||||
|
||||
auto *valueInit = def.getValueInit("verifier");
|
||||
CodeInit *codeInit = dyn_cast<CodeInit>(valueInit);
|
||||
|
@ -1904,21 +1916,21 @@ static void addSizeCountTrait(OpClass &opClass, StringRef traitKind,
|
|||
int numTotal, int numVariadic) {
|
||||
if (numVariadic != 0) {
|
||||
if (numTotal == numVariadic)
|
||||
opClass.addTrait("OpTrait::Variadic" + traitKind + "s");
|
||||
opClass.addTrait("::mlir::OpTrait::Variadic" + traitKind + "s");
|
||||
else
|
||||
opClass.addTrait("OpTrait::AtLeastN" + traitKind + "s<" +
|
||||
opClass.addTrait("::mlir::OpTrait::AtLeastN" + traitKind + "s<" +
|
||||
Twine(numTotal - numVariadic) + ">::Impl");
|
||||
return;
|
||||
}
|
||||
switch (numTotal) {
|
||||
case 0:
|
||||
opClass.addTrait("OpTrait::Zero" + traitKind);
|
||||
opClass.addTrait("::mlir::OpTrait::Zero" + traitKind);
|
||||
break;
|
||||
case 1:
|
||||
opClass.addTrait("OpTrait::One" + traitKind);
|
||||
opClass.addTrait("::mlir::OpTrait::One" + traitKind);
|
||||
break;
|
||||
default:
|
||||
opClass.addTrait("OpTrait::N" + traitKind + "s<" + Twine(numTotal) +
|
||||
opClass.addTrait("::mlir::OpTrait::N" + traitKind + "s<" + Twine(numTotal) +
|
||||
">::Impl");
|
||||
break;
|
||||
}
|
||||
|
@ -1947,20 +1959,21 @@ void OpEmitter::genTraits() {
|
|||
// Add operand size trait.
|
||||
if (numVariadicOperands != 0) {
|
||||
if (numOperands == numVariadicOperands)
|
||||
opClass.addTrait("OpTrait::VariadicOperands");
|
||||
opClass.addTrait("::mlir::OpTrait::VariadicOperands");
|
||||
else
|
||||
opClass.addTrait("OpTrait::AtLeastNOperands<" +
|
||||
opClass.addTrait("::mlir::OpTrait::AtLeastNOperands<" +
|
||||
Twine(numOperands - numVariadicOperands) + ">::Impl");
|
||||
} else {
|
||||
switch (numOperands) {
|
||||
case 0:
|
||||
opClass.addTrait("OpTrait::ZeroOperands");
|
||||
opClass.addTrait("::mlir::OpTrait::ZeroOperands");
|
||||
break;
|
||||
case 1:
|
||||
opClass.addTrait("OpTrait::OneOperand");
|
||||
opClass.addTrait("::mlir::OpTrait::OneOperand");
|
||||
break;
|
||||
default:
|
||||
opClass.addTrait("OpTrait::NOperands<" + Twine(numOperands) + ">::Impl");
|
||||
opClass.addTrait("::mlir::OpTrait::NOperands<" + Twine(numOperands) +
|
||||
">::Impl");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2042,7 +2055,7 @@ OpOperandAdaptorEmitter::OpOperandAdaptorEmitter(const Operator &op)
|
|||
adaptor.newField("::mlir::ValueRange", "odsOperands");
|
||||
adaptor.newField("::mlir::DictionaryAttr", "odsAttrs");
|
||||
const auto *attrSizedOperands =
|
||||
op.getTrait("OpTrait::AttrSizedOperandSegments");
|
||||
op.getTrait("::mlir::OpTrait::AttrSizedOperandSegments");
|
||||
{
|
||||
auto &constructor = adaptor.newConstructor(
|
||||
attrSizedOperands
|
||||
|
@ -2125,11 +2138,11 @@ void OpOperandAdaptorEmitter::addVerification() {
|
|||
// getODSOperands()/getODSResults() in the rest of the verifier.
|
||||
for (auto &trait : op.getTraits()) {
|
||||
if (auto *t = dyn_cast<tblgen::NativeOpTrait>(&trait)) {
|
||||
if (t->getTrait() == "OpTrait::AttrSizedOperandSegments") {
|
||||
if (t->getTrait() == "::mlir::OpTrait::AttrSizedOperandSegments") {
|
||||
body << formatv(checkAttrSizedValueSegmentsCode,
|
||||
"operand_segment_sizes", op.getNumOperands(),
|
||||
"operand");
|
||||
} else if (t->getTrait() == "OpTrait::AttrSizedResultSegments") {
|
||||
} else if (t->getTrait() == "::mlir::OpTrait::AttrSizedResultSegments") {
|
||||
body << formatv(checkAttrSizedValueSegmentsCode, "result_segment_sizes",
|
||||
op.getNumResults(), "result");
|
||||
}
|
||||
|
@ -2144,7 +2157,7 @@ void OpOperandAdaptorEmitter::addVerification() {
|
|||
"' op \"",
|
||||
/*emitVerificationRequiringOp*/ false, verifyCtx, body);
|
||||
|
||||
body << " return success();";
|
||||
body << " return ::mlir::success();";
|
||||
}
|
||||
|
||||
void OpOperandAdaptorEmitter::emitDecl(const Operator &op, raw_ostream &os) {
|
||||
|
@ -2165,6 +2178,7 @@ static void emitOpClasses(const std::vector<Record *> &defs, raw_ostream &os,
|
|||
os << "#undef GET_OP_FWD_DEFINES\n";
|
||||
for (auto *def : defs) {
|
||||
Operator op(*def);
|
||||
Operator::NamespaceEmitter emitter(os, op);
|
||||
os << "class " << op.getCppClassName() << ";\n";
|
||||
}
|
||||
os << "#endif\n\n";
|
||||
|
@ -2173,6 +2187,7 @@ static void emitOpClasses(const std::vector<Record *> &defs, raw_ostream &os,
|
|||
IfDefScope scope("GET_OP_CLASSES", os);
|
||||
for (auto *def : defs) {
|
||||
Operator op(*def);
|
||||
Operator::NamespaceEmitter emitter(os, op);
|
||||
if (emitDecl) {
|
||||
os << formatv(opCommentHeader, op.getQualCppClassName(), "declarations");
|
||||
OpOperandAdaptorEmitter::emitDecl(op, os);
|
||||
|
|
|
@ -439,14 +439,14 @@ static bool shouldFormatSymbolNameAttr(const NamedAttribute *attr) {
|
|||
/// {1}: The type for the attribute.
|
||||
const char *const attrParserCode = R"(
|
||||
if (parser.parseAttribute({0}Attr{1}, "{0}", result.attributes))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
)";
|
||||
const char *const optionalAttrParserCode = R"(
|
||||
{
|
||||
::mlir::OptionalParseResult parseResult =
|
||||
parser.parseOptionalAttribute({0}Attr{1}, "{0}", result.attributes);
|
||||
if (parseResult.hasValue() && failed(*parseResult))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
}
|
||||
)";
|
||||
|
||||
|
@ -455,7 +455,7 @@ const char *const optionalAttrParserCode = R"(
|
|||
/// {0}: The name of the attribute.
|
||||
const char *const symbolNameAttrParserCode = R"(
|
||||
if (parser.parseSymbolName({0}Attr, "{0}", result.attributes))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
)";
|
||||
const char *const optionalSymbolNameAttrParserCode = R"(
|
||||
// Parsing an optional symbol name doesn't fail, so no need to check the
|
||||
|
@ -476,7 +476,7 @@ const char *const enumAttrParserCode = R"(
|
|||
auto loc = parser.getCurrentLocation();
|
||||
if (parser.parseAttribute(attrVal, parser.getBuilder().getNoneType(),
|
||||
"{0}", attrStorage))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
|
||||
auto attrOptional = {1}::{2}(attrVal.getValue());
|
||||
if (!attrOptional)
|
||||
|
@ -498,7 +498,7 @@ const char *const optionalEnumAttrParserCode = R"(
|
|||
"{0}", attrStorage);
|
||||
if (parseResult.hasValue()) {
|
||||
if (failed(*parseResult))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
|
||||
auto attrOptional = {1}::{2}(attrVal.getValue());
|
||||
if (!attrOptional)
|
||||
|
@ -517,7 +517,7 @@ const char *const optionalEnumAttrParserCode = R"(
|
|||
const char *const variadicOperandParserCode = R"(
|
||||
{0}OperandsLoc = parser.getCurrentLocation();
|
||||
if (parser.parseOperandList({0}Operands))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
)";
|
||||
const char *const optionalOperandParserCode = R"(
|
||||
{
|
||||
|
@ -527,7 +527,7 @@ const char *const optionalOperandParserCode = R"(
|
|||
parser.parseOptionalOperand(operand);
|
||||
if (parseResult.hasValue()) {
|
||||
if (failed(*parseResult))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
{0}Operands.push_back(operand);
|
||||
}
|
||||
}
|
||||
|
@ -535,7 +535,7 @@ const char *const optionalOperandParserCode = R"(
|
|||
const char *const operandParserCode = R"(
|
||||
{0}OperandsLoc = parser.getCurrentLocation();
|
||||
if (parser.parseOperand({0}RawOperands[0]))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
)";
|
||||
|
||||
/// The code snippet used to generate a parser call for a type list.
|
||||
|
@ -543,7 +543,7 @@ const char *const operandParserCode = R"(
|
|||
/// {0}: The name for the type list.
|
||||
const char *const variadicTypeParserCode = R"(
|
||||
if (parser.parseTypeList({0}Types))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
)";
|
||||
const char *const optionalTypeParserCode = R"(
|
||||
{
|
||||
|
@ -552,14 +552,14 @@ const char *const optionalTypeParserCode = R"(
|
|||
parser.parseOptionalType(optionalType);
|
||||
if (parseResult.hasValue()) {
|
||||
if (failed(*parseResult))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
{0}Types.push_back(optionalType);
|
||||
}
|
||||
}
|
||||
)";
|
||||
const char *const typeParserCode = R"(
|
||||
if (parser.parseType({0}RawTypes[0]))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
)";
|
||||
|
||||
/// The code snippet used to generate a parser call for a functional type.
|
||||
|
@ -569,7 +569,7 @@ const char *const typeParserCode = R"(
|
|||
const char *const functionalTypeParserCode = R"(
|
||||
::mlir::FunctionType {0}__{1}_functionType;
|
||||
if (parser.parseType({0}__{1}_functionType))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
{0}Types = {0}__{1}_functionType.getInputs();
|
||||
{1}Types = {0}__{1}_functionType.getResults();
|
||||
)";
|
||||
|
@ -583,14 +583,14 @@ const char *regionListParserCode = R"(
|
|||
auto firstRegionResult = parser.parseOptionalRegion(region);
|
||||
if (firstRegionResult.hasValue()) {
|
||||
if (failed(*firstRegionResult))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
{0}Regions.emplace_back(std::move(region));
|
||||
|
||||
// Parse any trailing regions.
|
||||
while (succeeded(parser.parseOptionalComma())) {
|
||||
region = std::make_unique<::mlir::Region>();
|
||||
if (parser.parseRegion(*region))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
{0}Regions.emplace_back(std::move(region));
|
||||
}
|
||||
}
|
||||
|
@ -610,7 +610,7 @@ const char *regionListEnsureTerminatorParserCode = R"(
|
|||
/// {0}: The name of the region.
|
||||
const char *optionalRegionParserCode = R"(
|
||||
if (parser.parseOptionalRegion(*{0}Region))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
)";
|
||||
|
||||
/// The code snippet used to generate a parser call for a region.
|
||||
|
@ -618,7 +618,7 @@ const char *optionalRegionParserCode = R"(
|
|||
/// {0}: The name of the region.
|
||||
const char *regionParserCode = R"(
|
||||
if (parser.parseRegion(*{0}Region))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
)";
|
||||
|
||||
/// The code snippet used to ensure a region has a terminator.
|
||||
|
@ -637,13 +637,13 @@ const char *successorListParserCode = R"(
|
|||
auto firstSucc = parser.parseOptionalSuccessor(succ);
|
||||
if (firstSucc.hasValue()) {
|
||||
if (failed(*firstSucc))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
{0}Successors.emplace_back(succ);
|
||||
|
||||
// Parse any trailing successors.
|
||||
while (succeeded(parser.parseOptionalComma())) {
|
||||
if (parser.parseSuccessor(succ))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
{0}Successors.emplace_back(succ);
|
||||
}
|
||||
}
|
||||
|
@ -655,7 +655,7 @@ const char *successorListParserCode = R"(
|
|||
/// {0}: The name of the successor.
|
||||
const char *successorParserCode = R"(
|
||||
if (parser.parseSuccessor({0}Successor))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
)";
|
||||
|
||||
namespace {
|
||||
|
@ -889,7 +889,7 @@ static void genCustomDirectiveParser(CustomDirective *dir, OpMethodBody &body) {
|
|||
genCustomParameterParser(param, body);
|
||||
|
||||
body << "))\n"
|
||||
<< " return failure();\n";
|
||||
<< " return ::mlir::failure();\n";
|
||||
|
||||
// After parsing, add handling for any of the optional constructs.
|
||||
for (Element ¶m : dir->getArguments()) {
|
||||
|
@ -949,7 +949,7 @@ void OperationFormat::genParser(Operator &op, OpClass &opClass) {
|
|||
genParserSuccessorResolution(op, body);
|
||||
genParserVariadicSegmentResolution(op, body);
|
||||
|
||||
body << " return success();\n";
|
||||
body << " return ::mlir::success();\n";
|
||||
}
|
||||
|
||||
void OperationFormat::genElementParser(Element *element, OpMethodBody &body,
|
||||
|
@ -1007,7 +1007,7 @@ void OperationFormat::genElementParser(Element *element, OpMethodBody &body,
|
|||
} else if (LiteralElement *literal = dyn_cast<LiteralElement>(element)) {
|
||||
body << " if (parser.parse";
|
||||
genLiteralParser(literal->getLiteral(), body);
|
||||
body << ")\n return failure();\n";
|
||||
body << ")\n return ::mlir::failure();\n";
|
||||
|
||||
/// Arguments.
|
||||
} else if (auto *attr = dyn_cast<AttributeVariable>(element)) {
|
||||
|
@ -1081,14 +1081,14 @@ void OperationFormat::genElementParser(Element *element, OpMethodBody &body,
|
|||
body << " if (parser.parseOptionalAttrDict"
|
||||
<< (attrDict->isWithKeyword() ? "WithKeyword" : "")
|
||||
<< "(result.attributes))\n"
|
||||
<< " return failure();\n";
|
||||
<< " return ::mlir::failure();\n";
|
||||
} else if (auto *customDir = dyn_cast<CustomDirective>(element)) {
|
||||
genCustomDirectiveParser(customDir, body);
|
||||
|
||||
} else if (isa<OperandsDirective>(element)) {
|
||||
body << " ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();\n"
|
||||
<< " if (parser.parseOperandList(allOperands))\n"
|
||||
<< " return failure();\n";
|
||||
<< " return ::mlir::failure();\n";
|
||||
|
||||
} else if (isa<RegionsDirective>(element)) {
|
||||
body << llvm::formatv(regionListParserCode, "full");
|
||||
|
@ -1197,7 +1197,7 @@ void OperationFormat::genParserTypeResolution(Operator &op,
|
|||
if (allOperands) {
|
||||
body << " if (parser.resolveOperands(allOperands, allOperandTypes, "
|
||||
"allOperandLoc, result.operands))\n"
|
||||
" return failure();\n";
|
||||
" return ::mlir::failure();\n";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1214,7 +1214,7 @@ void OperationFormat::genParserTypeResolution(Operator &op,
|
|||
body << op.operand_begin()->name << "Operands";
|
||||
}
|
||||
body << ", allOperandTypes, parser.getNameLoc(), result.operands))\n"
|
||||
<< " return failure();\n";
|
||||
<< " return ::mlir::failure();\n";
|
||||
return;
|
||||
}
|
||||
// Handle the case where all of the operands were grouped together.
|
||||
|
@ -1238,7 +1238,7 @@ void OperationFormat::genParserTypeResolution(Operator &op,
|
|||
}
|
||||
|
||||
body << ", allOperandLoc, result.operands))\n"
|
||||
<< " return failure();\n";
|
||||
<< " return ::mlir::failure();\n";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1270,7 +1270,7 @@ void OperationFormat::genParserTypeResolution(Operator &op,
|
|||
// overload.
|
||||
if (verifyOperandAndTypeSize)
|
||||
body << ", " << operand.name << "OperandsLoc";
|
||||
body << ", result.operands))\n return failure();\n";
|
||||
body << ", result.operands))\n return ::mlir::failure();\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1314,7 +1314,8 @@ void OperationFormat::genParserSuccessorResolution(Operator &op,
|
|||
|
||||
void OperationFormat::genParserVariadicSegmentResolution(Operator &op,
|
||||
OpMethodBody &body) {
|
||||
if (!allOperands && op.getTrait("OpTrait::AttrSizedOperandSegments")) {
|
||||
if (!allOperands &&
|
||||
op.getTrait("::mlir::OpTrait::AttrSizedOperandSegments")) {
|
||||
body << " result.addAttribute(\"operand_segment_sizes\", "
|
||||
<< "parser.getBuilder().getI32VectorAttr({";
|
||||
auto interleaveFn = [&](const NamedTypeConstraint &operand) {
|
||||
|
@ -1328,7 +1329,8 @@ void OperationFormat::genParserVariadicSegmentResolution(Operator &op,
|
|||
body << "}));\n";
|
||||
}
|
||||
|
||||
if (!allResultTypes && op.getTrait("OpTrait::AttrSizedResultSegments")) {
|
||||
if (!allResultTypes &&
|
||||
op.getTrait("::mlir::OpTrait::AttrSizedResultSegments")) {
|
||||
body << " result.addAttribute(\"result_segment_sizes\", "
|
||||
<< "parser.getBuilder().getI32VectorAttr({";
|
||||
auto interleaveFn = [&](const NamedTypeConstraint &result) {
|
||||
|
@ -1369,9 +1371,11 @@ static void genAttrDictPrinter(OperationFormat &fmt, Operator &op,
|
|||
body << " p.printOptionalAttrDict" << (withKeyword ? "WithKeyword" : "")
|
||||
<< "(getAttrs(), /*elidedAttrs=*/{";
|
||||
// Elide the variadic segment size attributes if necessary.
|
||||
if (!fmt.allOperands && op.getTrait("OpTrait::AttrSizedOperandSegments"))
|
||||
if (!fmt.allOperands &&
|
||||
op.getTrait("::mlir::OpTrait::AttrSizedOperandSegments"))
|
||||
body << "\"operand_segment_sizes\", ";
|
||||
if (!fmt.allResultTypes && op.getTrait("OpTrait::AttrSizedResultSegments"))
|
||||
if (!fmt.allResultTypes &&
|
||||
op.getTrait("::mlir::OpTrait::AttrSizedResultSegments"))
|
||||
body << "\"result_segment_sizes\", ";
|
||||
llvm::interleaveComma(
|
||||
fmt.usedAttributes, body,
|
||||
|
@ -1607,7 +1611,7 @@ void OperationFormat::genElementPrinter(Element *element, OpMethodBody &body,
|
|||
}
|
||||
|
||||
void OperationFormat::genPrinter(Operator &op, OpClass &opClass) {
|
||||
auto &method = opClass.newMethod("void", "print", "OpAsmPrinter &p");
|
||||
auto &method = opClass.newMethod("void", "print", "::mlir::OpAsmPrinter &p");
|
||||
auto &body = method.body();
|
||||
|
||||
// Emit the operation name, trimming the prefix if this is the standard
|
||||
|
@ -2004,16 +2008,16 @@ private:
|
|||
if (curToken.getKind() != kind)
|
||||
return emitError(curToken.getLoc(), msg);
|
||||
consumeToken();
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
LogicalResult emitError(llvm::SMLoc loc, const Twine &msg) {
|
||||
lexer.emitError(loc, msg);
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
}
|
||||
LogicalResult emitErrorAndNote(llvm::SMLoc loc, const Twine &msg,
|
||||
const Twine ¬e) {
|
||||
lexer.emitErrorAndNote(loc, msg, note);
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
@ -2045,7 +2049,7 @@ LogicalResult FormatParser::parse() {
|
|||
while (curToken.getKind() != Token::eof) {
|
||||
std::unique_ptr<Element> element;
|
||||
if (failed(parseElement(element, /*isTopLevel=*/true)))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
fmt.elements.push_back(std::move(element));
|
||||
}
|
||||
|
||||
|
@ -2075,11 +2079,11 @@ LogicalResult FormatParser::parse() {
|
|||
failed(verifyResults(loc, variableTyResolver)) ||
|
||||
failed(verifyOperands(loc, variableTyResolver)) ||
|
||||
failed(verifyRegions(loc)) || failed(verifySuccessors(loc)))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
|
||||
// Collect the set of used attributes in the format.
|
||||
fmt.usedAttributes = seenAttrs.takeVector();
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
LogicalResult FormatParser::verifyAttributes(llvm::SMLoc loc) {
|
||||
|
@ -2093,8 +2097,8 @@ LogicalResult FormatParser::verifyAttributes(llvm::SMLoc loc) {
|
|||
iteratorStack.emplace_back(fmt.elements.begin(), fmt.elements.end());
|
||||
while (!iteratorStack.empty())
|
||||
if (failed(verifyAttributes(loc, iteratorStack)))
|
||||
return failure();
|
||||
return success();
|
||||
return ::mlir::failure();
|
||||
return ::mlir::success();
|
||||
}
|
||||
/// Verify the attribute elements at the back of the given stack of iterators.
|
||||
LogicalResult FormatParser::verifyAttributes(
|
||||
|
@ -2109,7 +2113,7 @@ LogicalResult FormatParser::verifyAttributes(
|
|||
if (auto *optional = dyn_cast<OptionalElement>(element)) {
|
||||
auto elements = optional->getElements();
|
||||
iteratorStack.emplace_back(elements.begin(), elements.end());
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
// We are checking for an attribute element followed by a `:`, so there is
|
||||
|
@ -2145,7 +2149,7 @@ LogicalResult FormatParser::verifyAttributes(
|
|||
}
|
||||
}
|
||||
iteratorStack.pop_back();
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
LogicalResult FormatParser::verifyOperands(
|
||||
|
@ -2193,13 +2197,13 @@ LogicalResult FormatParser::verifyOperands(
|
|||
auto it = buildableTypes.insert({*builder, buildableTypes.size()});
|
||||
fmt.operandTypes[i].setBuilderIdx(it.first->second);
|
||||
}
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
LogicalResult FormatParser::verifyRegions(llvm::SMLoc loc) {
|
||||
// Check that all of the regions are within the format.
|
||||
if (hasAllRegions)
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
|
||||
for (unsigned i = 0, e = op.getNumRegions(); i != e; ++i) {
|
||||
const NamedRegion ®ion = op.getRegion(i);
|
||||
|
@ -2211,7 +2215,7 @@ LogicalResult FormatParser::verifyRegions(llvm::SMLoc loc) {
|
|||
"' directive to the custom assembly format");
|
||||
}
|
||||
}
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
LogicalResult FormatParser::verifyResults(
|
||||
|
@ -2219,7 +2223,7 @@ LogicalResult FormatParser::verifyResults(
|
|||
llvm::StringMap<TypeResolutionInstance> &variableTyResolver) {
|
||||
// If we format all of the types together, there is nothing to check.
|
||||
if (fmt.allResultTypes)
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
|
||||
// Check that all of the result types can be inferred.
|
||||
auto &buildableTypes = fmt.buildableTypes;
|
||||
|
@ -2252,13 +2256,13 @@ LogicalResult FormatParser::verifyResults(
|
|||
auto it = buildableTypes.insert({*builder, buildableTypes.size()});
|
||||
fmt.resultTypes[i].setBuilderIdx(it.first->second);
|
||||
}
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
LogicalResult FormatParser::verifySuccessors(llvm::SMLoc loc) {
|
||||
// Check that all of the successors are within the format.
|
||||
if (hasAllSuccessors)
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
|
||||
for (unsigned i = 0, e = op.getNumSuccessors(); i != e; ++i) {
|
||||
const NamedSuccessor &successor = op.getSuccessor(i);
|
||||
|
@ -2270,7 +2274,7 @@ LogicalResult FormatParser::verifySuccessors(llvm::SMLoc loc) {
|
|||
"' directive to the custom assembly format");
|
||||
}
|
||||
}
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
void FormatParser::handleAllTypesMatchConstraint(
|
||||
|
@ -2368,7 +2372,7 @@ LogicalResult FormatParser::parseVariable(std::unique_ptr<Element> &element,
|
|||
if (isTopLevel && !seenAttrs.insert(attr))
|
||||
return emitError(loc, "attribute '" + name + "' is already bound");
|
||||
element = std::make_unique<AttributeVariable>(attr);
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
/// Operands
|
||||
if (const NamedTypeConstraint *operand = findArg(op.getOperands(), name)) {
|
||||
|
@ -2377,7 +2381,7 @@ LogicalResult FormatParser::parseVariable(std::unique_ptr<Element> &element,
|
|||
return emitError(loc, "operand '" + name + "' is already bound");
|
||||
}
|
||||
element = std::make_unique<OperandVariable>(operand);
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
/// Regions
|
||||
if (const NamedRegion *region = findArg(op.getRegions(), name)) {
|
||||
|
@ -2386,14 +2390,14 @@ LogicalResult FormatParser::parseVariable(std::unique_ptr<Element> &element,
|
|||
if (hasAllRegions || !seenRegions.insert(region).second)
|
||||
return emitError(loc, "region '" + name + "' is already bound");
|
||||
element = std::make_unique<RegionVariable>(region);
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
/// Results.
|
||||
if (const auto *result = findArg(op.getResults(), name)) {
|
||||
if (isTopLevel)
|
||||
return emitError(loc, "results can not be used at the top level");
|
||||
element = std::make_unique<ResultVariable>(result);
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
/// Successors.
|
||||
if (const auto *successor = findArg(op.getSuccessors(), name)) {
|
||||
|
@ -2402,7 +2406,7 @@ LogicalResult FormatParser::parseVariable(std::unique_ptr<Element> &element,
|
|||
if (hasAllSuccessors || !seenSuccessors.insert(successor).second)
|
||||
return emitError(loc, "successor '" + name + "' is already bound");
|
||||
element = std::make_unique<SuccessorVariable>(successor);
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
return emitError(loc, "expected variable to refer to an argument, region, "
|
||||
"result, or successor");
|
||||
|
@ -2450,7 +2454,7 @@ LogicalResult FormatParser::parseLiteral(std::unique_ptr<Element> &element) {
|
|||
return emitError(literalTok.getLoc(), "expected valid literal");
|
||||
|
||||
element = std::make_unique<LiteralElement>(value);
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
LogicalResult FormatParser::parseOptional(std::unique_ptr<Element> &element,
|
||||
|
@ -2467,11 +2471,11 @@ LogicalResult FormatParser::parseOptional(std::unique_ptr<Element> &element,
|
|||
Optional<unsigned> anchorIdx;
|
||||
do {
|
||||
if (failed(parseOptionalChildElement(elements, seenVariables, anchorIdx)))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
} while (curToken.getKind() != Token::r_paren);
|
||||
consumeToken();
|
||||
if (failed(parseToken(Token::question, "expected '?' after optional group")))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
|
||||
// The optional group is required to have an anchor.
|
||||
if (!anchorIdx)
|
||||
|
@ -2494,22 +2498,22 @@ LogicalResult FormatParser::parseOptional(std::unique_ptr<Element> &element,
|
|||
if (!seenVariables.count(var))
|
||||
return emitError(curLoc, "type directive can only refer to variables "
|
||||
"within the optional group");
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
};
|
||||
for (auto &ele : elements) {
|
||||
if (auto *typeEle = dyn_cast<TypeDirective>(ele.get())) {
|
||||
if (failed(checkTypeOperand(typeEle->getOperand())))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
} else if (auto *typeEle = dyn_cast<FunctionalTypeDirective>(ele.get())) {
|
||||
if (failed(checkTypeOperand(typeEle->getInputs())) ||
|
||||
failed(checkTypeOperand(typeEle->getResults())))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
}
|
||||
}
|
||||
|
||||
optionalVariables.insert(seenVariables.begin(), seenVariables.end());
|
||||
element = std::make_unique<OptionalElement>(std::move(elements), *anchorIdx);
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
LogicalResult FormatParser::parseOptionalChildElement(
|
||||
|
@ -2519,7 +2523,7 @@ LogicalResult FormatParser::parseOptionalChildElement(
|
|||
llvm::SMLoc childLoc = curToken.getLoc();
|
||||
childElements.push_back({});
|
||||
if (failed(parseElement(childElements.back(), /*isTopLevel=*/true)))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
|
||||
// Check to see if this element is the anchor of the optional group.
|
||||
bool isAnchor = curToken.getKind() == Token::caret;
|
||||
|
@ -2538,7 +2542,7 @@ LogicalResult FormatParser::parseOptionalChildElement(
|
|||
if (isAnchor && !attrEle->getVar()->attr.isOptional())
|
||||
return emitError(childLoc, "only optional attributes can be used to "
|
||||
"anchor an optional group");
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
})
|
||||
// Only optional-like(i.e. variadic) operands can be within an optional
|
||||
// group.
|
||||
|
@ -2547,12 +2551,12 @@ LogicalResult FormatParser::parseOptionalChildElement(
|
|||
return emitError(childLoc, "only variable length operands can be "
|
||||
"used within an optional group");
|
||||
seenVariables.insert(ele->getVar());
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
})
|
||||
.Case<RegionVariable>([&](RegionVariable *) {
|
||||
// TODO: When ODS has proper support for marking "optional" regions, add
|
||||
// a check here.
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
})
|
||||
// Literals, custom directives, and type directives may be used,
|
||||
// but they can't anchor the group.
|
||||
|
@ -2561,7 +2565,7 @@ LogicalResult FormatParser::parseOptionalChildElement(
|
|||
if (isAnchor)
|
||||
return emitError(childLoc, "only variables can be used to anchor "
|
||||
"an optional group");
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
})
|
||||
.Default([&](Element *) {
|
||||
return emitError(childLoc, "only literals, types, and variables can be "
|
||||
|
@ -2581,7 +2585,7 @@ FormatParser::parseAttrDictDirective(std::unique_ptr<Element> &element,
|
|||
|
||||
hasAttrDict = true;
|
||||
element = std::make_unique<AttrDictDirective>(withKeyword);
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
LogicalResult
|
||||
|
@ -2592,7 +2596,7 @@ FormatParser::parseCustomDirective(std::unique_ptr<Element> &element,
|
|||
// Parse the custom directive name.
|
||||
if (failed(
|
||||
parseToken(Token::less, "expected '<' before custom directive name")))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
|
||||
Token nameTok = curToken;
|
||||
if (failed(parseToken(Token::identifier,
|
||||
|
@ -2601,13 +2605,13 @@ FormatParser::parseCustomDirective(std::unique_ptr<Element> &element,
|
|||
"expected '>' after custom directive name")) ||
|
||||
failed(parseToken(Token::l_paren,
|
||||
"expected '(' before custom directive parameters")))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
|
||||
// Parse the child elements for this optional group.=
|
||||
std::vector<std::unique_ptr<Element>> elements;
|
||||
do {
|
||||
if (failed(parseCustomDirectiveParameter(elements)))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
if (curToken.getKind() != Token::comma)
|
||||
break;
|
||||
consumeToken();
|
||||
|
@ -2615,7 +2619,7 @@ FormatParser::parseCustomDirective(std::unique_ptr<Element> &element,
|
|||
|
||||
if (failed(parseToken(Token::r_paren,
|
||||
"expected ')' after custom directive parameters")))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
|
||||
// After parsing all of the elements, ensure that all type directives refer
|
||||
// only to variables.
|
||||
|
@ -2630,7 +2634,7 @@ FormatParser::parseCustomDirective(std::unique_ptr<Element> &element,
|
|||
|
||||
element = std::make_unique<CustomDirective>(nameTok.getSpelling(),
|
||||
std::move(elements));
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
LogicalResult FormatParser::parseCustomDirectiveParameter(
|
||||
|
@ -2638,7 +2642,7 @@ LogicalResult FormatParser::parseCustomDirectiveParameter(
|
|||
llvm::SMLoc childLoc = curToken.getLoc();
|
||||
parameters.push_back({});
|
||||
if (failed(parseElement(parameters.back(), /*isTopLevel=*/true)))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
|
||||
// Verify that the element can be placed within a custom directive.
|
||||
if (!isa<TypeDirective, AttributeVariable, OperandVariable, RegionVariable,
|
||||
|
@ -2646,7 +2650,7 @@ LogicalResult FormatParser::parseCustomDirectiveParameter(
|
|||
return emitError(childLoc, "only variables and types may be used as "
|
||||
"parameters to a custom directive");
|
||||
}
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
LogicalResult
|
||||
|
@ -2664,10 +2668,10 @@ FormatParser::parseFunctionalTypeDirective(std::unique_ptr<Element> &element,
|
|||
failed(parseToken(Token::comma, "expected ',' after inputs argument")) ||
|
||||
failed(parseTypeDirectiveOperand(results)) ||
|
||||
failed(parseToken(Token::r_paren, "expected ')' after argument list")))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
element = std::make_unique<FunctionalTypeDirective>(std::move(inputs),
|
||||
std::move(results));
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
LogicalResult
|
||||
|
@ -2679,7 +2683,7 @@ FormatParser::parseOperandsDirective(std::unique_ptr<Element> &element,
|
|||
fmt.allOperands = true;
|
||||
}
|
||||
element = std::make_unique<OperandsDirective>();
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
LogicalResult
|
||||
|
@ -2691,7 +2695,7 @@ FormatParser::parseRegionsDirective(std::unique_ptr<Element> &element,
|
|||
return emitError(loc, "'regions' directive creates overlap in format");
|
||||
hasAllRegions = true;
|
||||
element = std::make_unique<RegionsDirective>();
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
LogicalResult
|
||||
|
@ -2701,7 +2705,7 @@ FormatParser::parseResultsDirective(std::unique_ptr<Element> &element,
|
|||
return emitError(loc, "'results' directive can not be used as a "
|
||||
"top-level directive");
|
||||
element = std::make_unique<ResultsDirective>();
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
LogicalResult
|
||||
|
@ -2714,7 +2718,7 @@ FormatParser::parseSuccessorsDirective(std::unique_ptr<Element> &element,
|
|||
return emitError(loc, "'successors' directive creates overlap in format");
|
||||
hasAllSuccessors = true;
|
||||
element = std::make_unique<SuccessorsDirective>();
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
LogicalResult
|
||||
|
@ -2728,16 +2732,16 @@ FormatParser::parseTypeDirective(std::unique_ptr<Element> &element, Token tok,
|
|||
if (failed(parseToken(Token::l_paren, "expected '(' before argument list")) ||
|
||||
failed(parseTypeDirectiveOperand(operand)) ||
|
||||
failed(parseToken(Token::r_paren, "expected ')' after argument list")))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
element = std::make_unique<TypeDirective>(std::move(operand));
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
LogicalResult
|
||||
FormatParser::parseTypeDirectiveOperand(std::unique_ptr<Element> &element) {
|
||||
llvm::SMLoc loc = curToken.getLoc();
|
||||
if (failed(parseElement(element, /*isTopLevel=*/false)))
|
||||
return failure();
|
||||
return ::mlir::failure();
|
||||
if (isa<LiteralElement>(element.get()))
|
||||
return emitError(
|
||||
loc, "'type' directive operand expects variable or directive operand");
|
||||
|
@ -2765,7 +2769,7 @@ FormatParser::parseTypeDirectiveOperand(std::unique_ptr<Element> &element) {
|
|||
} else {
|
||||
return emitError(loc, "invalid argument to 'type' directive");
|
||||
}
|
||||
return success();
|
||||
return ::mlir::success();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -887,8 +887,9 @@ std::string PatternEmitter::handleOpCreation(DagNode tree, int resultIndex,
|
|||
// special cases listed below, DRR needs to supply types for all results
|
||||
// when building an op.
|
||||
bool isSameOperandsAndResultType =
|
||||
resultOp.getTrait("OpTrait::SameOperandsAndResultType");
|
||||
bool useFirstAttr = resultOp.getTrait("OpTrait::FirstAttrDerivedResultType");
|
||||
resultOp.getTrait("::mlir::OpTrait::SameOperandsAndResultType");
|
||||
bool useFirstAttr =
|
||||
resultOp.getTrait("::mlir::OpTrait::FirstAttrDerivedResultType");
|
||||
|
||||
if (isSameOperandsAndResultType || useFirstAttr) {
|
||||
// We know how to deduce the result type for ops with these traits and we've
|
||||
|
|
Loading…
Reference in New Issue