xref: /llvm-project/mlir/lib/CAPI/Debug/Debug.cpp (revision 8f21909c2fa15c06107b3dd5999a918e1f5fed0d)
14acd8457SAlex Zinenko //===- Debug.cpp - C Interface for MLIR/LLVM Debugging Functions ----------===//
24acd8457SAlex Zinenko //
34acd8457SAlex Zinenko // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44acd8457SAlex Zinenko // See https://llvm.org/LICENSE.txt for license information.
54acd8457SAlex Zinenko // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
64acd8457SAlex Zinenko //
74acd8457SAlex Zinenko //===----------------------------------------------------------------------===//
84acd8457SAlex Zinenko 
94acd8457SAlex Zinenko #include "mlir-c/Debug.h"
104acd8457SAlex Zinenko #include "mlir-c/Support.h"
114acd8457SAlex Zinenko 
124acd8457SAlex Zinenko #include "mlir/CAPI/Support.h"
134acd8457SAlex Zinenko 
144acd8457SAlex Zinenko #include "llvm/Support/Debug.h"
154acd8457SAlex Zinenko 
mlirEnableGlobalDebug(bool enable)164acd8457SAlex Zinenko void mlirEnableGlobalDebug(bool enable) { llvm::DebugFlag = enable; }
174acd8457SAlex Zinenko 
mlirIsGlobalDebugEnabled()184acd8457SAlex Zinenko bool mlirIsGlobalDebugEnabled() { return llvm::DebugFlag; }
19*8f21909cSOleksandr "Alex" Zinenko 
mlirSetGlobalDebugType(const char * type)20*8f21909cSOleksandr "Alex" Zinenko void mlirSetGlobalDebugType(const char *type) {
21*8f21909cSOleksandr "Alex" Zinenko   // Depending on the NDEBUG flag, this name can be either a function or a macro
22*8f21909cSOleksandr "Alex" Zinenko   // that expands to something that isn't a funciton call, so we cannot
23*8f21909cSOleksandr "Alex" Zinenko   // explicitly prefix it with `llvm::` or declare `using` it.
24*8f21909cSOleksandr "Alex" Zinenko   using namespace llvm;
25*8f21909cSOleksandr "Alex" Zinenko   setCurrentDebugType(type);
26*8f21909cSOleksandr "Alex" Zinenko }
27*8f21909cSOleksandr "Alex" Zinenko 
mlirSetGlobalDebugTypes(const char ** types,intptr_t n)28*8f21909cSOleksandr "Alex" Zinenko void mlirSetGlobalDebugTypes(const char **types, intptr_t n) {
29*8f21909cSOleksandr "Alex" Zinenko   using namespace llvm;
30*8f21909cSOleksandr "Alex" Zinenko   setCurrentDebugTypes(types, n);
31*8f21909cSOleksandr "Alex" Zinenko }
32*8f21909cSOleksandr "Alex" Zinenko 
mlirIsCurrentDebugType(const char * type)33*8f21909cSOleksandr "Alex" Zinenko bool mlirIsCurrentDebugType(const char *type) {
34*8f21909cSOleksandr "Alex" Zinenko   using namespace llvm;
35*8f21909cSOleksandr "Alex" Zinenko   return isCurrentDebugType(type);
36*8f21909cSOleksandr "Alex" Zinenko }
37