MLIR  22.0.0git
TargetUtils.h
Go to the documentation of this file.
1 //===- TargetUtils.h - Utils to obtain LLVM's TargetMachine and DataLayout ===//
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 #ifndef MLIR_TARGET_LLVMIR_TRANSFORMS_TARGETUTILS_H
10 #define MLIR_TARGET_LLVMIR_TRANSFORMS_TARGETUTILS_H
11 
13 #include "llvm/Support/Threading.h"
14 #include "llvm/Target/TargetMachine.h"
15 
16 namespace mlir {
17 namespace LLVM {
18 namespace detail {
19 /// Idempotent helper to register/initialize all backends that LLVM has been
20 /// configured to support. Only runs the first time it is called.
22 
23 /// Helper to obtain the TargetMachine specified by the properties of the
24 /// TargetAttrInterface-implementing attribute.
25 FailureOr<std::unique_ptr<llvm::TargetMachine>>
26 getTargetMachine(mlir::LLVM::TargetAttrInterface attr);
27 
28 /// Helper to obtain the DataLayout of the target specified by the properties of
29 /// the TargetAttrInterface-implementing attribute.
30 FailureOr<llvm::DataLayout> getDataLayout(mlir::LLVM::TargetAttrInterface attr);
31 } // namespace detail
32 } // namespace LLVM
33 } // namespace mlir
34 
35 #endif // MLIR_TARGET_LLVMIR_TRANSFORMS_TARGETUTILS_H
FailureOr< std::unique_ptr< llvm::TargetMachine > > getTargetMachine(mlir::LLVM::TargetAttrInterface attr)
Helper to obtain the TargetMachine specified by the properties of the TargetAttrInterface-implementin...
Definition: TargetUtils.cpp:37
FailureOr< llvm::DataLayout > getDataLayout(mlir::LLVM::TargetAttrInterface attr)
Helper to obtain the DataLayout of the target specified by the properties of the TargetAttrInterface-...
Definition: TargetUtils.cpp:59
void initializeBackendsOnce()
Idempotent helper to register/initialize all backends that LLVM has been configured to support.
Definition: TargetUtils.cpp:25
Include the generated interface declarations.