MLIR: include/mlir/Pass/PassRegistry.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14 #ifndef MLIR_PASS_PASSREGISTRY_H_

15 #define MLIR_PASS_PASSREGISTRY_H_

16

19 #include

20 #include

21 #include

22

23 namespace mlir {

24 class OpPassManager;

25 class ParserConfig;

26 class Pass;

27 class PassManager;

28

29 namespace detail {

30 class PassOptions;

31 }

32

33

34

35

36

37

40 function_ref<LogicalResult(const Twine &)> errorHandler)>;

42

43

44

45

46

47

49

50

51

53 public:

54

55

56

57 LogicalResult

59 function_ref<LogicalResult(const Twine &)> errorHandler) const {

60 assert(builder &&

61 "cannot call addToPipeline on PassRegistryEntry without builder");

62 return builder(pm, options, errorHandler);

63 }

64

65

66

68

69

71

72

73

74

75 void printHelpStr(size_t indent, size_t descIndent) const;

76

77

79

80 protected:

84 optHandler)

85 : arg(arg), description(description), builder(builder),

86 optHandler(std::move(optHandler)) {}

87

88 private:

89

90 std::string arg;

91

92

93 std::string description;

94

95

97

98

100 optHandler;

101 };

102

103

105 public:

109 optHandler)

110 : PassRegistryEntry(arg, description, builder, std::move(optHandler)) {}

111

112

113

115 };

116

117

119 public:

120

121

122 PassInfo(StringRef arg, StringRef description,

124

125

127 };

128

129

130

131

132

133

134

138 optHandler);

139

140

141

143

144

145

146

147

148

149

150

151

152

153

154 template

158 }

160 : PassRegistration([] { return std::make_unique(); }) {}

161 };

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176 template

179 StringRef arg, StringRef description,

182 arg, description,

183 [builder](OpPassManager &pm, StringRef optionsStr,

184 function_ref<LogicalResult(const Twine &)> errorHandler) {

186 if (failed(options.parseFromString(optionsStr)))

187 return failure();

189 return success();

190 },

192 optHandler(Options());

193 });

194 }

195 };

196

197

198

199 template <>

202 StringRef arg, StringRef description,

203 const std::function<void(OpPassManager &)> &builder) {

205 arg, description,

206 [builder](OpPassManager &pm, StringRef optionsStr,

207 function_ref<LogicalResult(const Twine &)> errorHandler) {

208 if (!optionsStr.empty())

209 return failure();

210 builder(pm);

211 return success();

212 },

214 }

215 };

216

217

218

219

220 LogicalResult parsePassPipeline(StringRef pipeline, OpPassManager &pm,

221 raw_ostream &errorStream = llvm::errs());

222

223

224

225

226

227

228

229 FailureOr

230 parsePassPipeline(StringRef pipeline, raw_ostream &errorStream = llvm::errs());

231

232

233

234

235

236 namespace detail {

237 struct PassPipelineCLParserImpl;

238 }

239

240

241

242

243

244

245

246

248 public:

249

250

254

255

257

258

259

261

262

263

264

265 LogicalResult

267 function_ref<LogicalResult(const Twine &)> errorHandler) const;

268

269 private:

270 std::unique_ptrdetail::PassPipelineCLParserImpl impl;

271

272 llvm:🆑:optstd::string passPipeline;

273 std::optionalllvm:🆑:alias passPipelineAlias;

274 };

275

276

277

278

280 public:

281

284

285

287

288

289

291

292 private:

293 std::unique_ptrdetail::PassPipelineCLParserImpl impl;

294 };

295

296

297

298

299

301

302

304

305

307

308 private:

309 std::optionalstd::string pipeline;

310 std::optional verifyEach;

311 std::optional disableThreading;

312 };

313

314 }

315

316 #endif

static llvm::ManagedStatic< PassManagerOptions > options

This class represents a pass manager that runs passes on either a specific operation type,...

This class represents a configuration for the MLIR assembly parser.

A structure to represent the information for a derived pass class.

static const PassInfo * lookup(StringRef passArg)

Returns the pass info for the specified pass class or null if unknown.

PassInfo(StringRef arg, StringRef description, const PassAllocatorFunction &allocator)

PassInfo constructor should not be invoked directly, instead use PassRegistration or registerPass.

The main pass manager and pipeline builder.

This class implements a command-line parser specifically for MLIR pass names.

bool hasAnyOccurrences() const

Returns true if this parser contains any valid options to add.

PassNameCLParser(StringRef arg, StringRef description)

Construct a parser with the given command line description.

bool contains(const PassRegistryEntry *entry) const

Returns true if the given pass registry entry was registered at the top-level of the parser,...

This class implements a command-line parser for MLIR passes.

bool hasAnyOccurrences() const

Returns true if this parser contains any valid options to add.

PassPipelineCLParser(StringRef arg, StringRef description)

Construct a pass pipeline parser with the given command line description.

LogicalResult addToPipeline(OpPassManager &pm, function_ref< LogicalResult(const Twine &)> errorHandler) const

Adds the passes defined by this parser entry to the given pass manager.

bool contains(const PassRegistryEntry *entry) const

Returns true if the given pass registry entry was registered at the top-level of the parser,...

A structure to represent the information of a registered pass pipeline.

PassPipelineInfo(StringRef arg, StringRef description, const PassRegistryFunction &builder, std::function< void(function_ref< void(const detail::PassOptions &)>)> optHandler)

static const PassPipelineInfo * lookup(StringRef pipelineArg)

Returns the pass pipeline info for the specified pass pipeline or null if unknown.

Structure to group information about a passes and pass pipelines (argument to invoke via mlir-opt,...

void printHelpStr(size_t indent, size_t descIndent) const

Print the help information for this pass.

LogicalResult addToPipeline(OpPassManager &pm, StringRef options, function_ref< LogicalResult(const Twine &)> errorHandler) const

Adds this pass registry entry to the given pass manager.

size_t getOptionWidth() const

Return the maximum width required when printing the options of this entry.

PassRegistryEntry(StringRef arg, StringRef description, const PassRegistryFunction &builder, std::function< void(function_ref< void(const detail::PassOptions &)>)> optHandler)

StringRef getPassDescription() const

Returns a description for the pass, this never returns null.

StringRef getPassArgument() const

Returns the command line option that may be passed to 'mlir-opt' that will cause this pass to run or ...

Base container class and manager for all pass options.

Include the generated interface declarations.

const FrozenRewritePatternSet GreedyRewriteConfig config

void printRegisteredPasses()

Prints the passes that were previously registered and stored in passRegistry.

std::function< std::unique_ptr< Pass >()> PassAllocatorFunction

void registerPass(const PassAllocatorFunction &function)

Register a specific dialect pass allocator function with the system, typically used through the PassR...

void registerPassPipeline(StringRef arg, StringRef description, const PassRegistryFunction &function, std::function< void(function_ref< void(const detail::PassOptions &)>)> optHandler)

Register a specific dialect pipeline registry function with the system, typically used through the Pa...

LogicalResult parsePassPipeline(StringRef pipeline, OpPassManager &pm, raw_ostream &errorStream=llvm::errs())

Parse the textual representation of a pass pipeline, adding the result to 'pm' on success.

std::function< LogicalResult(OpPassManager &, StringRef options, function_ref< LogicalResult(const Twine &)> errorHandler)> PassRegistryFunction

A registry function that adds passes to the given pass manager.

A default empty option struct to be used for passes that do not need to take any options.

PassPipelineRegistration(StringRef arg, StringRef description, const std::function< void(OpPassManager &)> &builder)

PassPipelineRegistration provides a global initializer that registers a Pass pipeline builder routine...

PassPipelineRegistration(StringRef arg, StringRef description, std::function< void(OpPassManager &, const Options &options)> builder)

PassRegistration provides a global initializer that registers a Pass allocation routine for a concret...

PassRegistration(const PassAllocatorFunction &constructor)

void attachResourceParser(ParserConfig &config)

Attach an assembly resource parser to 'config' that collects the MLIR reproducer configuration into t...

LogicalResult apply(PassManager &pm) const

Apply the reproducer options to 'pm' and its context.