| 1 |
//===-------- Debug.h ---- Debug 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 |
// |
| 10 |
//===----------------------------------------------------------------------===// |
| 11 |
|
| 12 |
#ifndef OMPTARGET_DEVICERTL_DEBUG_H |
| 13 |
#define OMPTARGET_DEVICERTL_DEBUG_H |
| 14 |
|
| 15 |
#include "Configuration.h" |
| 16 |
#include "LibC.h" |
| 17 |
|
| 18 |
/// Assertion |
| 19 |
/// |
| 20 |
/// { |
| 21 |
extern "C" { |
| 22 |
void __assert_assume(bool condition); |
| 23 |
void __assert_fail(const char *expr, const char *file, unsigned line, |
| 24 |
const char *function); |
| 25 |
void __assert_fail_internal(const char *expr, const char *msg, const char *file, |
| 26 |
unsigned line, const char *function); |
| 27 |
} |
| 28 |
|
| 29 |
#define ASSERT(expr, msg) \ |
| 30 |
{ \ |
| 31 |
if (config::isDebugMode(DeviceDebugKind::Assertion) && !(expr)) \ |
| 32 |
__assert_fail_internal(#expr, msg, __FILE__, __LINE__, \ |
| 33 |
__PRETTY_FUNCTION__); \ |
| 34 |
else \ |
| 35 |
__assert_assume(expr); \ |
| 36 |
} |
| 37 |
#define UNREACHABLE(msg) \ |
| 38 |
printf(msg); \ |
| 39 |
__builtin_trap(); \ |
| 40 |
__builtin_unreachable(); |
| 41 |
|
| 42 |
///} |
| 43 |
|
| 44 |
#endif |