[Reland][Runtimes] Merge 'compile_commands.json' files from runtimes build (#116303)
[llvm-project.git] / compiler-rt / lib / orc / debug.h
blob587994e484af6ea369f67f9aadccfb417b3dcd18
1 //===- debug.h - Debugging output utilities ---------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file is a part of the ORC runtime support library.
11 //===----------------------------------------------------------------------===//
13 #ifndef ORC_RT_DEBUG_H
14 #define ORC_RT_DEBUG_H
16 #include <atomic>
18 #ifndef NDEBUG
20 namespace orc_rt {
22 extern std::atomic<const char *> DebugTypes;
23 extern char DebugTypesAll;
24 extern char DebugTypesNone;
26 const char *initializeDebug();
27 bool debugTypeEnabled(const char *Type, const char *Types);
28 void printdbg(const char *format, ...);
30 } // namespace orc_rt
32 #define ORC_RT_DEBUG_WITH_TYPE(TYPE, X) \
33 do { \
34 const char *Types = ::orc_rt::DebugTypes.load(std::memory_order_relaxed); \
35 if (!Types) \
36 Types = initializeDebug(); \
37 if (Types == &DebugTypesNone) \
38 break; \
39 if (Types == &DebugTypesAll || ::orc_rt::debugTypeEnabled(TYPE, Types)) { \
40 X; \
41 } \
42 } while (false)
44 #else
46 #define ORC_RT_DEBUG_WITH_TYPE(TYPE, X) \
47 do { \
48 } while (false)
50 #endif // !NDEBUG
52 #define ORC_RT_DEBUG(X) ORC_RT_DEBUG_WITH_TYPE(DEBUG_TYPE, X)
54 #endif // ORC_RT_DEBUG_H