view gen/logger.h @ 1451:297d1e2f6441

Add `syscall` to the x86-64 asm parser, and both `syscall` and `sysret` to the x86 one. Fixes #316.
author Frits van Bommel <fvbommel wxs.nl>
date Mon, 01 Jun 2009 23:42:42 +0200
parents 229e02867307
children 2292878925f4
line wrap: on
line source

#ifndef _llvmd_gen_logger_h_
#define _llvmd_gen_logger_h_

#include "llvm/Support/Streams.h"

#ifndef IS_PRINTF
# ifdef __GNUC__
#  define IS_PRINTF(FMTARG) __attribute((__format__ (__printf__, (FMTARG), (FMTARG)+1) ))
# else
#  define IS_PRINTF(FMTARG)
# endif
#endif

struct Loc;

namespace Logger
{
    void indent();
    void undent();
    llvm::OStream cout();
    void println(const char* fmt, ...) IS_PRINTF(1);
    void print(const char* fmt, ...) IS_PRINTF(1);
    void enable();
    void disable();
    bool enabled();

    void attention(Loc loc, const char* fmt, ...) IS_PRINTF(2);

    struct LoggerScope
    {
        LoggerScope()
        {
            Logger::indent();
        }
        ~LoggerScope()
        {
            Logger::undent();
        }
    };
}

#define LOG_SCOPE    Logger::LoggerScope _logscope;

#define IF_LOG       if (Logger::enabled())

#endif