diff --git a/mlir/include/mlir/Conversion/Passes.td b/mlir/include/mlir/Conversion/Passes.td --- a/mlir/include/mlir/Conversion/Passes.td +++ b/mlir/include/mlir/Conversion/Passes.td @@ -119,11 +119,25 @@ def ConvertSimpleLoopsToGPU : Pass<"convert-loops-to-gpu"> { let summary = "Convert top-level loops to GPU kernels"; let constructor = "mlir::createSimpleLoopsToGPUPass()"; + let options = [ + Option<"numBlockDims", "gpu-block-dims", "unsigned", /*default=*/"1u", + "Number of GPU block dimensions for mapping">, + Option<"numThreadDims", "gpu-thread-dims", "unsigned", /*default=*/"1u", + "Number of GPU thread dimensions for mapping"> + ]; } def ConvertLoopsToGPU : Pass<"convert-loop-op-to-gpu"> { let summary = "Convert top-level loop::ForOp to GPU kernels"; let constructor = "mlir::createLoopToGPUPass()"; + let options = [ + ListOption<"numWorkGroups", "gpu-num-workgroups", "int64_t", + "Num workgroups in the GPU launch", + "llvm::cl::ZeroOrMore, llvm::cl::MiscFlags::CommaSeparated">, + ListOption<"workGroupSize", "gpu-workgroup-size", "int64_t", + "Workgroup Size in the GPU launch", + "llvm::cl::ZeroOrMore, llvm::cl::MiscFlags::CommaSeparated"> + ]; } def ConvertParallelLoopToGpu : Pass<"convert-parallel-loops-to-gpu"> { @@ -139,6 +153,20 @@ let summary = "Convert scalar and vector operations from the Standard to the " "LLVM dialect"; let constructor = "mlir::createLowerToLLVMPass()"; + let options = [ + Option<"useAlloca", "use-alloca", "bool", /*default=*/"false", + "Use `alloca` instead of `call @malloc` for converting std.alloc">, + Option<"useBarePtrCallConv", "use-bare-ptr-memref-call-conv", "bool", + /*default=*/"false", + "Replace FuncOp's MemRef arguments with bare pointers to the MemRef " + "element types">, + Option<"emitCWrappers", "emit-c-wrappers", "bool", /*default=*/"false", + "Emit wrappers for C-compatible pointer-to-struct memref " + "descriptors">, + Option<"indexBitwidth", "index-bitwidth", "unsigned", + /*default=*/"kDeriveIndexBitwidthFromDataLayout", + "Bitwidth of the index type, 0 to use size of machine word">, + ]; } //===----------------------------------------------------------------------===// diff --git a/mlir/include/mlir/Dialect/Affine/Passes.td b/mlir/include/mlir/Dialect/Affine/Passes.td --- a/mlir/include/mlir/Dialect/Affine/Passes.td +++ b/mlir/include/mlir/Dialect/Affine/Passes.td @@ -43,6 +43,22 @@ def AffineVectorize : Pass<"affine-super-vectorize"> { let summary = "Vectorize to a target independent n-D vector abstraction"; let constructor = "mlir::createSuperVectorizePass()"; + let options = [ + ListOption<"vectorSizes", "virtual-vector-size", "int64_t", + "Specify an n-D virtual vector size for vectorization", + "llvm::cl::ZeroOrMore, llvm::cl::MiscFlags::CommaSeparated">, + // Optionally, the fixed mapping from loop to fastest varying MemRef + // dimension for all the MemRefs within a loop pattern: + // the index represents the loop depth, the value represents the k^th + // fastest varying memory dimension. + // This is voluntarily restrictive and is meant to precisely target a + // particular loop/op pair, for testing purposes. + ListOption<"fastestVaryingPattern", "test-fastest-varying", "int64_t", + "Specify a 1-D, 2-D or 3-D pattern of fastest varying memory " + "dimensions to match. See defaultPatterns in Vectorize.cpp for " + "a description and examples. This is used for testing purposes", + "llvm::cl::ZeroOrMore, llvm::cl::MiscFlags::CommaSeparated"> + ]; } def SimplifyAffineStructures : Pass<"simplify-affine-structures"> { diff --git a/mlir/include/mlir/Dialect/Linalg/Passes.td b/mlir/include/mlir/Dialect/Linalg/Passes.td --- a/mlir/include/mlir/Dialect/Linalg/Passes.td +++ b/mlir/include/mlir/Dialect/Linalg/Passes.td @@ -41,16 +41,30 @@ def LinalgPromotion : Pass<"linalg-promote-subviews"> { let summary = "Promote subview ops to local buffers"; let constructor = "mlir::createLinalgPromotionPass()"; + let options = [ + Option<"dynamicBuffers", "test-promote-dynamic", "bool", + /*default=*/"false", "Test generation of dynamic promoted buffers"> + ]; } def LinalgTiling : Pass<"linalg-tile"> { let summary = "Tile operations in the linalg dialect"; let constructor = "mlir::createLinalgTilingPass()"; + let options = [ + ListOption<"tileSizes", "linalg-tile-sizes", "int64_t", + "Test generation of dynamic promoted buffers", + "llvm::cl::ZeroOrMore, llvm::cl::MiscFlags::CommaSeparated"> + ]; } def LinalgTilingToParallelLoops : Pass<"linalg-tile-to-parallel-loops"> { let summary = "Tile operations in the linalg dialect to parallel loops"; let constructor = "mlir::createLinalgTilingToParallelLoopsPass()"; + let options = [ + ListOption<"tileSizes", "linalg-tile-sizes", "int64_t", + "Test generation of dynamic promoted buffers", + "llvm::cl::ZeroOrMore, llvm::cl::MiscFlags::CommaSeparated"> + ]; } #endif // MLIR_DIALECT_LINALG_PASSES diff --git a/mlir/include/mlir/Dialect/LoopOps/Passes.td b/mlir/include/mlir/Dialect/LoopOps/Passes.td --- a/mlir/include/mlir/Dialect/LoopOps/Passes.td +++ b/mlir/include/mlir/Dialect/LoopOps/Passes.td @@ -24,6 +24,11 @@ def LoopParallelLoopTiling : Pass<"parallel-loop-tiling"> { let summary = "Tile parallel loops"; let constructor = "mlir::createParallelLoopTilingPass()"; + let options = [ + ListOption<"tileSizes", "parallel-loop-tile-sizes", "int64_t", + "Factors to tile parallel loops by", + "llvm::cl::ZeroOrMore, llvm::cl::MiscFlags::CommaSeparated"> + ]; } #endif // MLIR_DIALECT_LOOP_PASSES diff --git a/mlir/include/mlir/Pass/PassBase.td b/mlir/include/mlir/Pass/PassBase.td --- a/mlir/include/mlir/Pass/PassBase.td +++ b/mlir/include/mlir/Pass/PassBase.td @@ -15,6 +15,50 @@ #define MLIR_PASS_PASSBASE //===----------------------------------------------------------------------===// +// Options +//===----------------------------------------------------------------------===// + +class Option { + // The name for the C++ option variable. + string cppName = varName; + + // The command line argument to use for this option. + string argument = arg; + + // The C++ type of the option. + string type = valueType; + + // The default value of the option. "" corresponds to no default. + string defaultValue = default; + + // A description for this option. + string description = desc; + + // A set of additional flags to pass along to the option constructor. + string additionalOptFlags = additionalFlags; +} + +class ListOption + : Option {} + +//===----------------------------------------------------------------------===// +// Statistics +//===----------------------------------------------------------------------===// + +class Statistic { + // The C++ variable name for the statistic. + string cppName = varName; + + // The displayed name of the statistic, similar to the argument of an option. + string name = statName; + + // The description of the statistic. + string description = desc; +} + +//===----------------------------------------------------------------------===// // Pass //===----------------------------------------------------------------------===// @@ -30,6 +74,12 @@ // A C++ constructor call to create an instance of this pass. code constructor = [{}]; + + // A set of options provided by this pass. + list