Skip to content

Commit 27a9749

Browse files
committed
Address Mehdi's comments
1 parent b3e91bf commit 27a9749

File tree

5 files changed

+10
-21
lines changed

5 files changed

+10
-21
lines changed

mlir/include/mlir/Target/LLVMIR/Transforms/Passes.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,11 @@
99
#ifndef MLIR_TARGET_LLVMIR_TRANSFORMS_PASSES_H
1010
#define MLIR_TARGET_LLVMIR_TRANSFORMS_PASSES_H
1111

12-
#include "mlir/Dialect/LLVMIR/LLVMInterfaces.h"
1312
#include "mlir/Pass/Pass.h"
14-
#include "llvm/Support/Threading.h"
15-
#include "llvm/Target/TargetMachine.h"
1613

1714
namespace mlir {
18-
1915
namespace LLVM {
2016

21-
namespace detail {
22-
23-
void initializeBackendsOnce();
24-
25-
FailureOr<std::unique_ptr<llvm::TargetMachine>>
26-
getTargetMachine(mlir::LLVM::TargetAttrInterface attr);
27-
28-
FailureOr<llvm::DataLayout> getDataLayout(mlir::LLVM::TargetAttrInterface attr);
29-
30-
} // namespace detail
31-
3217
#define GEN_PASS_DECL
3318
#define GEN_PASS_REGISTRATION
3419
#include "mlir/Target/LLVMIR/Transforms/Passes.h.inc"

mlir/include/mlir/Target/LLVMIR/Transforms/Passes.td

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ def LLVMTargetToDataLayout : Pass<"llvm-target-to-data-layout"> {
2828
}
2929

3030
def LLVMTargetToTargetFeatures : Pass<"llvm-target-to-target-features"> {
31-
let summary = "TODO";
31+
let summary = "Update attached #llvm.target's features per the described target";
3232
let dependentDialects = ["mlir::DLTIDialect"];
3333
let description = [{
34-
TODO
34+
Obtain the TargetMachine specified by the attached #llvm.target's attributes
35+
and obtain from it the full list of features of the selected target. Updates
36+
the attached #llvm.target so that its features reflect the full list of
37+
features.
3538
}];
3639
let options = [
3740
Option<"initializeLLVMTargets", "initialize-llvm-targets", "bool",

mlir/lib/Target/LLVMIR/Transforms/TargetToDataLayout.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "mlir/Target/LLVMIR/Transforms/Passes.h"
10+
#include "mlir/Target/LLVMIR/Transforms/TargetUtils.h"
1011

1112
#include "mlir/Dialect/DLTI/DLTI.h"
1213
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"

mlir/lib/Target/LLVMIR/Transforms/TargetToTargetFeatures.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "mlir/Target/LLVMIR/Transforms/Passes.h"
10+
#include "mlir/Target/LLVMIR/Transforms/TargetUtils.h"
1011

1112
#include "mlir/Dialect/DLTI/DLTI.h"
1213
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"

mlir/lib/Target/LLVMIR/Transforms/TargetUtils.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313

1414
#include "llvm/MC/TargetRegistry.h"
1515
#include "llvm/Support/Debug.h"
16+
#include "llvm/Support/DebugLog.h"
1617
#include "llvm/Support/TargetSelect.h"
1718
#include "llvm/Target/TargetMachine.h"
1819

1920
#define DEBUG_TYPE "mlir-llvm-target-utils"
20-
#define DBGS() (llvm::dbgs() << '[' << DEBUG_TYPE << "] ")
21-
#define LDBG(X) LLVM_DEBUG(DBGS() << X << "\n")
2221

2322
llvm::once_flag initializeBackendsOnce;
2423

@@ -46,7 +45,7 @@ getTargetMachine(mlir::LLVM::TargetAttrInterface attr) {
4645
const llvm::Target *target =
4746
llvm::TargetRegistry::lookupTarget(triple, error);
4847
if (!target || !error.empty()) {
49-
LDBG("Looking up target '" << triple << "' failed: " << error << "\n");
48+
LDBG() << "Looking up target '" << triple << "' failed: " << error << "\n";
5049
return failure();
5150
}
5251

@@ -59,7 +58,7 @@ getDataLayout(mlir::LLVM::TargetAttrInterface attr) {
5958
FailureOr<std::unique_ptr<llvm::TargetMachine>> targetMachine =
6059
getTargetMachine(attr);
6160
if (failed(targetMachine)) {
62-
LDBG("Failed to retrieve the target machine for data layout.\n");
61+
LDBG() << "Failed to retrieve the target machine for data layout.\n";
6362
return failure();
6463
}
6564
return (targetMachine.value())->createDataLayout();

0 commit comments

Comments
 (0)