mirror of
https://github.com/intel/llvm.git
synced 2026-01-19 17:45:07 +08:00
[mlir][AsmPrinter] Allow explicitly disabling debug info
This adds an `enable` flag to OpPrintingFlags::enableDebugInfo that allows for overriding any command line flags for debug printing, and matches the format that we use for other `enableBlah` API.
This commit is contained in:
@@ -376,11 +376,12 @@ MLIR_CAPI_EXPORTED void
|
||||
mlirOpPrintingFlagsElideLargeElementsAttrs(MlirOpPrintingFlags flags,
|
||||
intptr_t largeElementLimit);
|
||||
|
||||
/// Enable printing of debug information. If 'prettyForm' is set to true,
|
||||
/// debug information is printed in a more readable 'pretty' form. Note: The
|
||||
/// IR generated with 'prettyForm' is not parsable.
|
||||
/// Enable or disable printing of debug information (based on `enable`). If
|
||||
/// 'prettyForm' is set to true, debug information is printed in a more readable
|
||||
/// 'pretty' form. Note: The IR generated with 'prettyForm' is not parsable.
|
||||
MLIR_CAPI_EXPORTED void
|
||||
mlirOpPrintingFlagsEnableDebugInfo(MlirOpPrintingFlags flags, bool prettyForm);
|
||||
mlirOpPrintingFlagsEnableDebugInfo(MlirOpPrintingFlags flags, bool enable,
|
||||
bool prettyForm);
|
||||
|
||||
/// Always print operations in the generic form.
|
||||
MLIR_CAPI_EXPORTED void
|
||||
|
||||
@@ -768,10 +768,11 @@ public:
|
||||
/// elements.
|
||||
OpPrintingFlags &elideLargeElementsAttrs(int64_t largeElementLimit = 16);
|
||||
|
||||
/// Enable printing of debug information. If 'prettyForm' is set to true,
|
||||
/// debug information is printed in a more readable 'pretty' form. Note: The
|
||||
/// IR generated with 'prettyForm' is not parsable.
|
||||
OpPrintingFlags &enableDebugInfo(bool prettyForm = false);
|
||||
/// Enable or disable printing of debug information (based on `enable`). If
|
||||
/// 'prettyForm' is set to true, debug information is printed in a more
|
||||
/// readable 'pretty' form. Note: The IR generated with 'prettyForm' is not
|
||||
/// parsable.
|
||||
OpPrintingFlags &enableDebugInfo(bool enable = true, bool prettyForm = false);
|
||||
|
||||
/// Always print operations in the generic form.
|
||||
OpPrintingFlags &printGenericOpForm();
|
||||
|
||||
@@ -1017,7 +1017,8 @@ void PyOperationBase::print(py::object fileObject, bool binary,
|
||||
if (largeElementsLimit)
|
||||
mlirOpPrintingFlagsElideLargeElementsAttrs(flags, *largeElementsLimit);
|
||||
if (enableDebugInfo)
|
||||
mlirOpPrintingFlagsEnableDebugInfo(flags, /*prettyForm=*/prettyDebugInfo);
|
||||
mlirOpPrintingFlagsEnableDebugInfo(flags, /*enable=*/true,
|
||||
/*prettyForm=*/prettyDebugInfo);
|
||||
if (printGenericOpForm)
|
||||
mlirOpPrintingFlagsPrintGenericOpForm(flags);
|
||||
if (useLocalScope)
|
||||
|
||||
@@ -127,9 +127,9 @@ void mlirOpPrintingFlagsElideLargeElementsAttrs(MlirOpPrintingFlags flags,
|
||||
unwrap(flags)->elideLargeElementsAttrs(largeElementLimit);
|
||||
}
|
||||
|
||||
void mlirOpPrintingFlagsEnableDebugInfo(MlirOpPrintingFlags flags,
|
||||
void mlirOpPrintingFlagsEnableDebugInfo(MlirOpPrintingFlags flags, bool enable,
|
||||
bool prettyForm) {
|
||||
unwrap(flags)->enableDebugInfo(/*prettyForm=*/prettyForm);
|
||||
unwrap(flags)->enableDebugInfo(enable, /*prettyForm=*/prettyForm);
|
||||
}
|
||||
|
||||
void mlirOpPrintingFlagsPrintGenericOpForm(MlirOpPrintingFlags flags) {
|
||||
|
||||
@@ -210,8 +210,9 @@ OpPrintingFlags::elideLargeElementsAttrs(int64_t largeElementLimit) {
|
||||
|
||||
/// Enable printing of debug information. If 'prettyForm' is set to true,
|
||||
/// debug information is printed in a more readable 'pretty' form.
|
||||
OpPrintingFlags &OpPrintingFlags::enableDebugInfo(bool prettyForm) {
|
||||
printDebugInfoFlag = true;
|
||||
OpPrintingFlags &OpPrintingFlags::enableDebugInfo(bool enable,
|
||||
bool prettyForm) {
|
||||
printDebugInfoFlag = enable;
|
||||
printDebugInfoPrettyFormFlag = prettyForm;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -467,7 +467,7 @@ static void printFirstOfEach(MlirContext ctx, MlirOperation operation) {
|
||||
MlirOpPrintingFlags flags = mlirOpPrintingFlagsCreate();
|
||||
mlirOpPrintingFlagsElideLargeElementsAttrs(flags, 2);
|
||||
mlirOpPrintingFlagsPrintGenericOpForm(flags);
|
||||
mlirOpPrintingFlagsEnableDebugInfo(flags, /*prettyForm=*/0);
|
||||
mlirOpPrintingFlagsEnableDebugInfo(flags, /*enable=*/1, /*prettyForm=*/0);
|
||||
mlirOpPrintingFlagsUseLocalScope(flags);
|
||||
fprintf(stderr, "Op print with all flags: ");
|
||||
mlirOperationPrintWithFlags(operation, flags, printToStderr, NULL);
|
||||
|
||||
Reference in New Issue
Block a user