Proteus
Programmable JIT compilation and optimization for C/C++ using LLVM
Loading...
Searching...
No Matches
Utils.h
Go to the documentation of this file.
1//===-- Utils.h -- Utilities header --===//
2//
3// Part of the Proteus Project, under the Apache License v2.0 with LLVM
4// Exceptions. 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#ifndef PROTEUS_UTILS_H
12#define PROTEUS_UTILS_H
13
14#include <string>
15
16#include <llvm/ADT/Twine.h>
17#include <llvm/Support/SourceMgr.h>
18
19#include "proteus/Error.h"
20#include "proteus/Logger.hpp"
22
23template <typename T> void saveToFile(llvm::StringRef Filepath, T &&Data) {
24 std::error_code EC;
25 llvm::raw_fd_ostream Out(Filepath, EC);
26 if (EC)
27 PROTEUS_FATAL_ERROR("Cannot open file" + Filepath);
28 Out << Data;
29 Out.close();
30}
31
32#if PROTEUS_ENABLE_HIP
33#include "proteus/UtilsHIP.h"
34#endif
35
36#if PROTEUS_ENABLE_CUDA
37#include "proteus/UtilsCUDA.h"
38#endif
39
40#endif
#define PROTEUS_FATAL_ERROR(x)
Definition Error.h:4
void saveToFile(llvm::StringRef Filepath, T &&Data)
Definition Utils.h:23