aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
diff options
context:
space:
mode:
authorFarzon Lotfi <1802579+farzonl@users.noreply.github.com>2024-09-12 15:53:50 -0400
committerGitHub <noreply@github.com>2024-09-12 15:53:50 -0400
commitc05e29bff036060f0811b887a92715104abdceb5 (patch)
tree1c9f03b9c7e43f6d249cb685fdedd541dab888f3 /llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
parent3733528e521b7ee6af3950c65c3ff421c8fd0af6 (diff)
downloadllvm-c05e29bff036060f0811b887a92715104abdceb5.zip
llvm-c05e29bff036060f0811b887a92715104abdceb5.tar.gz
llvm-c05e29bff036060f0811b887a92715104abdceb5.tar.bz2
[LegacyPM][DirectX] Add legacy scalarizer back for use in the DirectX backend (#107427)
As discussed in this [proposal](https://github.com/llvm/wg-hlsl/pull/62/files?short_path=ac6e592#diff-ac6e59276afe8016e307eedc5c835f534c0cb353707760b44df0fa9d905a5cf8). We had to bring back the legacy pass manager interface for the scalarizer pass. Two reasons for this: 1. The DirectX backend is still using the legacy pass manager 2. The new PM isn't hooked up in clang yet via `BackendUtil.cpp`'s `AddEmitPasses` That means even if we add a `buildCodeGenPipeline` we won't be able to benefit from the new pass manager's scalarizer pass interface. The remaining changes are hooking up the scalarizer pass to the DirectX backend, updating the DirectX test cases, and allowing the `optdriver` to not block the legacy invocation of the scalarizer pass. Future work still needs to be done to allow the scalarizer pass to handle target specific intrinsics. closes #105178
Diffstat (limited to 'llvm/lib/Target/DirectX/DirectXTargetMachine.cpp')
-rw-r--r--llvm/lib/Target/DirectX/DirectXTargetMachine.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
index a29fc21..606022a9 100644
--- a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
+++ b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
@@ -28,6 +28,7 @@
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/IR/IRPrintingPasses.h"
#include "llvm/IR/LegacyPassManager.h"
+#include "llvm/InitializePasses.h"
#include "llvm/MC/MCSectionDXContainer.h"
#include "llvm/MC/SectionKind.h"
#include "llvm/MC/TargetRegistry.h"
@@ -36,6 +37,7 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
+#include "llvm/Transforms/Scalar/Scalarizer.h"
#include <optional>
using namespace llvm;
@@ -44,6 +46,7 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeDirectXTarget() {
RegisterTargetMachine<DirectXTargetMachine> X(getTheDirectXTarget());
auto *PR = PassRegistry::getPassRegistry();
initializeDXILIntrinsicExpansionLegacyPass(*PR);
+ initializeScalarizerLegacyPassPass(*PR);
initializeDXILPrepareModulePass(*PR);
initializeEmbedDXILPassPass(*PR);
initializeWriteDXILPassPass(*PR);
@@ -83,6 +86,9 @@ public:
FunctionPass *createTargetRegisterAllocator(bool) override { return nullptr; }
void addCodeGenPrepare() override {
addPass(createDXILIntrinsicExpansionLegacyPass());
+ ScalarizerPassOptions DxilScalarOptions;
+ DxilScalarOptions.ScalarizeLoadStore = true;
+ addPass(createScalarizerPass(DxilScalarOptions));
addPass(createDXILOpLoweringLegacyPass());
addPass(createDXILFinalizeLinkageLegacyPass());
addPass(createDXILTranslateMetadataLegacyPass());