CIRCT 23.0.0git
Loading...
Searching...
No Matches
Path.h
Go to the documentation of this file.
1//===- Path.h - Path 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// Utilities for file system path handling, supplementing the ones from
10// llvm::sys::path.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef CIRCT_SUPPORT_PATH_H
15#define CIRCT_SUPPORT_PATH_H
16
17#include "circt/Support/LLVM.h"
18#include "llvm/Support/ToolOutputFile.h"
19
20namespace circt {
21
22/// Append a path to an existing path, replacing it if the other path is
23/// absolute. This mimicks the behaviour of `foo/bar` and `/foo/bar` being used
24/// in a working directory `/home`, resulting in `/home/foo/bar` and `/foo/bar`,
25/// respectively.
26void appendPossiblyAbsolutePath(llvm::SmallVectorImpl<char> &base,
27 const llvm::Twine &suffix);
28
29/// Truncate `a` in place to the longest common directory prefix of `a` and `b`,
30/// ensuring that the result ends on a directory separator (or is empty). This
31/// computes the lowest common ancestor directory of two paths and is used, for
32/// example, to pick a shared output directory for deduplicated operations.
33void makeCommonDirectoryPrefix(llvm::SmallVectorImpl<char> &a, StringRef b);
34
35/// Creates an output file with the given filename in the specified directory.
36/// The function will create any parent directories as needed. If an error
37/// occurs during file or directory creation, it will use the provided emitError
38/// callback to report the error and return an empty unique_ptr.
39std::unique_ptr<llvm::ToolOutputFile>
40createOutputFile(StringRef filename, StringRef dirname,
41 function_ref<InFlightDiagnostic()> emitError);
42
43} // namespace circt
44
45#endif // CIRCT_SUPPORT_PATH_H
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
void makeCommonDirectoryPrefix(llvm::SmallVectorImpl< char > &a, StringRef b)
Truncate a in place to the longest common directory prefix of a and b, ensuring that the result ends ...
Definition Path.cpp:36
std::unique_ptr< llvm::ToolOutputFile > createOutputFile(StringRef filename, StringRef dirname, function_ref< InFlightDiagnostic()> emitError)
Creates an output file with the given filename in the specified directory.
Definition Path.cpp:55
void appendPossiblyAbsolutePath(llvm::SmallVectorImpl< char > &base, const llvm::Twine &suffix)
Append a path to an existing path, replacing it if the other path is absolute.
Definition Path.cpp:26