diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2023-11-03 08:34:15 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-03 08:34:15 +0900 |
commit | 94202e7b175dc602b7e998d05bed8ded964c6ec1 (patch) | |
tree | abfe2f8cad88ce8416cb4b55504ed7f15491de50 | |
parent | 2b67942139f0226b47b969631a114c7afd9207a7 (diff) | |
download | llvm-94202e7b175dc602b7e998d05bed8ded964c6ec1.zip llvm-94202e7b175dc602b7e998d05bed8ded964c6ec1.tar.gz llvm-94202e7b175dc602b7e998d05bed8ded964c6ec1.tar.bz2 |
CodeGen: Port ExpandLargeDivRem to new pass manager (#71022)
-rw-r--r-- | llvm/include/llvm/CodeGen/ExpandLargeDivRem.h | 30 | ||||
-rw-r--r-- | llvm/lib/CodeGen/ExpandLargeDivRem.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/Passes/PassBuilder.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/Passes/PassRegistry.def | 1 | ||||
-rw-r--r-- | llvm/test/Transforms/ExpandLargeDivRem/X86/sdiv129.ll | 1 | ||||
-rw-r--r-- | llvm/test/Transforms/ExpandLargeDivRem/X86/srem129.ll | 1 | ||||
-rw-r--r-- | llvm/test/Transforms/ExpandLargeDivRem/X86/udiv129.ll | 1 | ||||
-rw-r--r-- | llvm/test/Transforms/ExpandLargeDivRem/X86/urem129.ll | 1 |
8 files changed, 45 insertions, 1 deletions
diff --git a/llvm/include/llvm/CodeGen/ExpandLargeDivRem.h b/llvm/include/llvm/CodeGen/ExpandLargeDivRem.h new file mode 100644 index 0000000..6fc4409 --- /dev/null +++ b/llvm/include/llvm/CodeGen/ExpandLargeDivRem.h @@ -0,0 +1,30 @@ +//===- ExpandLargeDivRem.h --------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CODEGEN_EXPANDLARGEDIVREM_H +#define LLVM_CODEGEN_EXPANDLARGEDIVREM_H + +#include "llvm/IR/PassManager.h" + +namespace llvm { + +class TargetMachine; + +class ExpandLargeDivRemPass : public PassInfoMixin<ExpandLargeDivRemPass> { +private: + const TargetMachine *TM; + +public: + explicit ExpandLargeDivRemPass(const TargetMachine *TM_) : TM(TM_) {} + + PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); +}; + +} // end namespace llvm + +#endif // LLVM_CODEGEN_EXPANDLARGEDIVREM_H diff --git a/llvm/lib/CodeGen/ExpandLargeDivRem.cpp b/llvm/lib/CodeGen/ExpandLargeDivRem.cpp index 057b531..973c814 100644 --- a/llvm/lib/CodeGen/ExpandLargeDivRem.cpp +++ b/llvm/lib/CodeGen/ExpandLargeDivRem.cpp @@ -14,6 +14,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/CodeGen/ExpandLargeDivRem.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Analysis/GlobalsModRef.h" @@ -128,6 +129,13 @@ public: }; } // namespace +PreservedAnalyses ExpandLargeDivRemPass::run(Function &F, + FunctionAnalysisManager &FAM) { + const TargetSubtargetInfo *STI = TM->getSubtargetImpl(F); + return runImpl(F, *STI->getTargetLowering()) ? PreservedAnalyses::none() + : PreservedAnalyses::all(); +} + char ExpandLargeDivRemLegacyPass::ID = 0; INITIALIZE_PASS_BEGIN(ExpandLargeDivRemLegacyPass, "expand-large-div-rem", "Expand large div/rem", false, false) diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index fde7590..baf7f55 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -72,6 +72,7 @@ #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/Analysis/TypeBasedAliasAnalysis.h" #include "llvm/Analysis/UniformityAnalysis.h" +#include "llvm/CodeGen/ExpandLargeDivRem.h" #include "llvm/CodeGen/HardwareLoops.h" #include "llvm/CodeGen/TypePromotion.h" #include "llvm/IR/DebugInfo.h" @@ -234,8 +235,8 @@ #include "llvm/Transforms/Utils/CanonicalizeAliases.h" #include "llvm/Transforms/Utils/CanonicalizeFreezeInLoops.h" #include "llvm/Transforms/Utils/CountVisits.h" -#include "llvm/Transforms/Utils/Debugify.h" #include "llvm/Transforms/Utils/DXILUpgrade.h" +#include "llvm/Transforms/Utils/Debugify.h" #include "llvm/Transforms/Utils/EntryExitInstrumenter.h" #include "llvm/Transforms/Utils/FixIrreducible.h" #include "llvm/Transforms/Utils/HelloWorld.h" diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def index 91782d6..5c58e4c 100644 --- a/llvm/lib/Passes/PassRegistry.def +++ b/llvm/lib/Passes/PassRegistry.def @@ -445,6 +445,7 @@ FUNCTION_PASS("transform-warning", WarnMissedTransformationsPass()) FUNCTION_PASS("tsan", ThreadSanitizerPass()) FUNCTION_PASS("memprof", MemProfilerPass()) FUNCTION_PASS("declare-to-assign", llvm::AssignmentTrackingPass()) +FUNCTION_PASS("expand-large-div-rem", ExpandLargeDivRemPass(TM)); #undef FUNCTION_PASS #ifndef FUNCTION_PASS_WITH_PARAMS diff --git a/llvm/test/Transforms/ExpandLargeDivRem/X86/sdiv129.ll b/llvm/test/Transforms/ExpandLargeDivRem/X86/sdiv129.ll index 61c8f88..184a420 100644 --- a/llvm/test/Transforms/ExpandLargeDivRem/X86/sdiv129.ll +++ b/llvm/test/Transforms/ExpandLargeDivRem/X86/sdiv129.ll @@ -1,5 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt -S -mtriple=x86_64-- -expand-large-div-rem -expand-div-rem-bits 128 < %s | FileCheck %s +; RUN: opt -S -mtriple=x86_64-- -passes=expand-large-div-rem -expand-div-rem-bits 128 < %s | FileCheck %s define void @sdiv129(ptr %ptr, ptr %out) nounwind { ; CHECK-LABEL: @sdiv129( diff --git a/llvm/test/Transforms/ExpandLargeDivRem/X86/srem129.ll b/llvm/test/Transforms/ExpandLargeDivRem/X86/srem129.ll index eddb209..ce428dd 100644 --- a/llvm/test/Transforms/ExpandLargeDivRem/X86/srem129.ll +++ b/llvm/test/Transforms/ExpandLargeDivRem/X86/srem129.ll @@ -1,5 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt -S -mtriple=x86_64-- -expand-large-div-rem -expand-div-rem-bits 128 < %s | FileCheck %s +; RUN: opt -S -mtriple=x86_64-- -passes=expand-large-div-rem -expand-div-rem-bits 128 < %s | FileCheck %s define void @test(ptr %ptr, ptr %out) nounwind { ; CHECK-LABEL: @test( diff --git a/llvm/test/Transforms/ExpandLargeDivRem/X86/udiv129.ll b/llvm/test/Transforms/ExpandLargeDivRem/X86/udiv129.ll index 78bce5c..bc2d39d 100644 --- a/llvm/test/Transforms/ExpandLargeDivRem/X86/udiv129.ll +++ b/llvm/test/Transforms/ExpandLargeDivRem/X86/udiv129.ll @@ -1,5 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt -S -mtriple=x86_64-- -expand-large-div-rem -expand-div-rem-bits 128 < %s | FileCheck %s +; RUN: opt -S -mtriple=x86_64-- -passes=expand-large-div-rem -expand-div-rem-bits 128 < %s | FileCheck %s define void @test(ptr %ptr, ptr %out) nounwind { ; CHECK-LABEL: @test( diff --git a/llvm/test/Transforms/ExpandLargeDivRem/X86/urem129.ll b/llvm/test/Transforms/ExpandLargeDivRem/X86/urem129.ll index ebe75fc..6e2f5b8 100644 --- a/llvm/test/Transforms/ExpandLargeDivRem/X86/urem129.ll +++ b/llvm/test/Transforms/ExpandLargeDivRem/X86/urem129.ll @@ -1,5 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt -S -mtriple=x86_64-- -expand-large-div-rem -expand-div-rem-bits 128 < %s | FileCheck %s +; RUN: opt -S -mtriple=x86_64-- -passes=expand-large-div-rem -expand-div-rem-bits 128 < %s | FileCheck %s define void @test(ptr %ptr, ptr %out) nounwind { ; CHECK-LABEL: @test( |