FLANG
Todo.h
1//===-- Optimizer/Builder/Todo.h --------------------------------*- 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// Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef FORTRAN_LOWER_TODO_H
14#define FORTRAN_LOWER_TODO_H
15
16#include "flang/Optimizer/Support/FatalError.h"
17#include "llvm/Support/ErrorHandling.h"
18#include "llvm/Support/raw_ostream.h"
19
20// This is throw-away code used to mark areas of the code that have not yet been
21// developed.
22
23#undef TODO
24// Use TODO_NOLOC if no mlir location is available to indicate the line in
25// Fortran source file that requires an unimplemented feature.
26#undef TODO_NOLOC
27
28#undef TODOQUOTE
29#define TODOQUOTE(X) #X
30
31// Give backtrace only in debug builds.
32#undef GEN_TRACE
33#ifdef NDEBUG
34#define GEN_TRACE false
35#else
36#define GEN_TRACE true
37#endif
38
39#undef TODO_NOLOCDEFN
40#define TODO_NOLOCDEFN(ToDoMsg, ToDoFile, ToDoLine, GenTrace) \
41 do { \
42 llvm::report_fatal_error(llvm::Twine(ToDoFile ":" TODOQUOTE( \
43 ToDoLine) ": not yet implemented: ") + \
44 llvm::Twine(ToDoMsg), \
45 GenTrace); \
46 } while (false)
47
48#define TODO_NOLOC(ToDoMsg) TODO_NOLOCDEFN(ToDoMsg, __FILE__, __LINE__, false)
49#define TODO_NOLOC_TRACE(ToDoMsg) \
50 TODO_NOLOCDEFN(ToDoMsg, __FILE__, __LINE__, GENTRACE)
51
52#undef TODO_DEFN
53#define TODO_DEFN(MlirLoc, ToDoMsg, ToDoFile, ToDoLine, GenTrace) \
54 do { \
55 fir::emitFatalError(MlirLoc, \
56 llvm::Twine(ToDoFile ":" TODOQUOTE( \
57 ToDoLine) ": not yet implemented: ") + \
58 llvm::Twine(ToDoMsg), \
59 GenTrace); \
60 } while (false)
61
62#define TODO(MlirLoc, ToDoMsg) \
63 TODO_DEFN(MlirLoc, ToDoMsg, __FILE__, __LINE__, false)
64#define TODO_TRACE(MlirLoc, ToDoMsg) \
65 TODO_DEFN(MlirLoc, ToDoMsg, __FILE__, __LINE__, GEN_TRACE)
66
67#endif // FORTRAN_LOWER_TODO_H