+++ /dev/null
-// The implementation is mostly borrowed from LLVM
-//
-// This file is distributed under the University of Illinois Open Source
-// License.
-// TODO: add license text
-//
-// !!! If NO_NNC_DEBUG is defined the functionality of the following code in disabled !!!
-//
-// Usage:
-// 1- Make sure the project is built in debug configuration.
-// It should have macros NO_NNC_DEBUG undefinded.
-//
-// 2- Include this header and define DEBUG_AREA as a string in your code, enclosing it.
-// Example:
-// #define DEBUG_AREA "interpreter"
-// ...
-// <interpreter source code>
-// ...
-// #undef DEBUG_AREA
-//
-// 3- When running nnc, enable debugging by providing "--debug" option.
-// If the option is not provided, the debugging functionality is disabled.
-// Optionally, you may provide a filename to print debug info into.
-// Example: nnc --debug log.txt <...>
-//
-// 4- If you only want to debug some specified areas of code, use
-// "--debug-area area1,area2,area3", (areas are separated by commas)
-// where area1 etc. are DEBUG_AREAs as defined in your code
-// (in this example: #define DEBUG_AREA "area1" ... etc.)
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef NNCC_DEBUG_H
-#define NNCC_DEBUG_H
-
-#include <iostream>
-#include <vector>
-
-namespace nncc {
-namespace contrib {
-
-/// This boolean is set to true if the "--debug" command line option
-/// is specified. This should probably not be referenced directly, instead, use
-/// the DEBUG macro below.
-///
-extern bool DebugFlag;
-
-/// dbgs() - This returns a reference to an ostream for debugging
-/// messages. Return std::cerr by default.
-/// Use it like: dbgs() << "foo" << "bar";
-std::ostream &dbgs();
-
-// When building in release configuration, define NO_NNC_DEBUG to disable debugging features.
-#ifndef NO_NNC_DEBUG
-/// isCurrentDebugZone - Return true if the specified string is the debug type
-/// specified on the command line, or if none was specified on the command line
-/// with the "--debug-area X" option.
-///
-bool isCurrentDebugZone(const char *zone);
-
-/// setCurrentDebugZones - Set the current debug type, as if the
-/// "--debug-area X,Y,Z" option were specified. Note that DebugFlag
-/// also needs to be set to true for debug output to be produced.
-///
-void setCurrentDebugZones(std::vector<const char *> zones);
-
-/// setDebugFile - Set file to output debug info to.
-///
-void setDebugFile(const char* filename);
-
-/// DEBUG_SPECIFIED macro - This macro should be used by passes to emit debug
-/// information. If the '--debug' option is specified on the commandline, and if
-/// this is a debug build, then the code specified as the option to the macro
-/// will be executed. Otherwise it will not be.
-/// Example:
-///
-/// DEBUG_SPECIFIED("bitset", dbgs() << "Bitset contains: " << Bitset << "\n");
-///
-/// will emit the debug information if --debug is present, and --debug-area
-/// is not specified, or is specified as "bitset".
-#define DEBUG_SPECIFIED(ZONE, X) \
- do { if (::nncc::contrib::DebugFlag && \
- ::nncc::contrib::isCurrentDebugZone(ZONE)) { X; } \
- } while (false)
-
-#else
-#define isCurrentDebugZone(X) (false)
-#define setCurrentDebugZones(X, N)
-#define setDebugFile(X)
-#define DEBUG_SPECIFIED(ZONE, X) do { } while (false)
-#endif // NO_NNC_DEBUG
-
-// DEBUG macro - This macro should be used by passes to emit debug information.
-// If the '--debug' option is specified on the commandline, and if this is a
-// debug build, then the code specified as the option to the macro will be
-// executed. Otherwise it will not be. Example:
-//
-// NNC_DEBUG(dbgs() << "Bitset contains: " << Bitset << "\n");
-//
-#define NNC_DEBUG(X) DEBUG_SPECIFIED(DEBUG_AREA, X)
-
-} // namespace contrib
-} // namespace nncc
-
-#endif // NNCC_DEBUG_H
+++ /dev/null
-// The implementation is mostly borrowed from LLVM
-//
-// This file is distributed under the University of Illinois Open Source
-// License.
-// TODO: add license text
-//===----------------------------------------------------------------------===//
-
-#include <fstream>
-
-#include "support/Debug.h"
-
-#undef isCurrentDebugZone
-#undef setCurrentDebugZones
-#undef setDebugFile
-
-namespace nncc {
-namespace contrib {
-
-bool DebugFlag = false;
-
-#ifndef NO_NNC_DEBUG
-
-static std::vector <std::string> currentDebugZone;
-
-bool isCurrentDebugZone(const char *debugZone) {
- if (currentDebugZone.empty())
- return true;
- // Note: do not use find() as that forces us to
- // unnecessarily create an std::string instance.
- for (auto &d : currentDebugZone) {
- if (d == debugZone)
- return true;
- }
- return false;
-}
-
-void setCurrentDebugZones(std::vector<const char *> zones) {
- currentDebugZone.clear();
- for (const char * zone : zones) {
- currentDebugZone.push_back(zone);
- }
-}
-
-static std::ofstream log;
-
-void setDebugFile(const char* filename)
-{
- log.open(filename, std::ofstream::trunc);
-}
-
-std::ostream &dbgs()
-{
- if (log.is_open())
- return log;
- else
- return std::cerr;
-}
-
-#else
-
-std::ostream &dbgs() { return std::cerr; }
-
-#endif // NO_NNC_DEBUG
-
-} // namespace contrib
-} // namespace nncc