File tree Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,19 @@ MLIR_CAPI_EXPORTED void mlirEnableGlobalDebug(bool enable);
21
21
/// Retuns `true` if the global debugging flag is set, false otherwise.
22
22
MLIR_CAPI_EXPORTED bool mlirIsGlobalDebugEnabled ();
23
23
24
+ /// Sets the current debug type, similarly to `-debug-only=type` in the
25
+ /// command-line tools. Note that global debug should be enabled for any output
26
+ /// to be produced.
27
+ MLIR_CAPI_EXPORTED void mlirSetGlobalDebugType (const char * type );
28
+
29
+ /// Sets multiple current debug types, similarly to `-debug-only=type1,type2" in
30
+ /// the command-line tools. Note that global debug should be enabled for any
31
+ /// output to be produced.
32
+ MLIR_CAPI_EXPORTED void mlirSetGlobalDebugTypes (const char * * types , intptr_t n );
33
+
34
+ /// Checks if `type` is set as the current debug type.
35
+ MLIR_CAPI_EXPORTED bool mlirIsCurrentDebugType (const char * type );
36
+
24
37
#ifdef __cplusplus
25
38
}
26
39
#endif
Original file line number Diff line number Diff line change @@ -240,7 +240,20 @@ struct PyGlobalDebugFlag {
240
240
// Debug flags.
241
241
py::class_<PyGlobalDebugFlag>(m, " _GlobalDebug" , py::module_local ())
242
242
.def_property_static (" flag" , &PyGlobalDebugFlag::get,
243
- &PyGlobalDebugFlag::set, " LLVM-wide debug flag" );
243
+ &PyGlobalDebugFlag::set, " LLVM-wide debug flag" )
244
+ .def_static (
245
+ " set_types" ,
246
+ [](const std::string &type) {
247
+ mlirSetGlobalDebugType (type.c_str ());
248
+ },
249
+ " types" _a, " Sets specific debug types to be produced by LLVM" )
250
+ .def_static (" set_types" , [](const std::vector<std::string> &types) {
251
+ std::vector<const char *> pointers;
252
+ pointers.reserve (types.size ());
253
+ for (const std::string &str : types)
254
+ pointers.push_back (str.c_str ());
255
+ mlirSetGlobalDebugTypes (pointers.data (), pointers.size ());
256
+ });
244
257
}
245
258
};
246
259
Original file line number Diff line number Diff line change 16
16
void mlirEnableGlobalDebug (bool enable) { llvm::DebugFlag = enable; }
17
17
18
18
bool mlirIsGlobalDebugEnabled () { return llvm::DebugFlag; }
19
+
20
+ void mlirSetGlobalDebugType (const char *type) {
21
+ // Depending on the NDEBUG flag, this name can be either a function or a macro
22
+ // that expands to something that isn't a funciton call, so we cannot
23
+ // explicitly prefix it with `llvm::` or declare `using` it.
24
+ using namespace llvm ;
25
+ setCurrentDebugType (type);
26
+ }
27
+
28
+ void mlirSetGlobalDebugTypes (const char **types, intptr_t n) {
29
+ using namespace llvm ;
30
+ setCurrentDebugTypes (types, n);
31
+ }
32
+
33
+ bool mlirIsCurrentDebugType (const char *type) {
34
+ using namespace llvm ;
35
+ return isCurrentDebugType (type);
36
+ }
You can’t perform that action at this time.
0 commit comments