Skip to content

Commit 3cef582

Browse files
committed
CodeGen: Port ExpandLargeFpConvert to new PM (#71027)
1 parent ae49bf5 commit 3cef582

File tree

8 files changed

+45
-0
lines changed

8 files changed

+45
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//===- ExpandLargeFpConvert.h -----------------------------------*- 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+
#ifndef LLVM_CODEGEN_EXPANDLARGEFPCONVERT_H
10+
#define LLVM_CODEGEN_EXPANDLARGEFPCONVERT_H
11+
12+
#include "llvm/IR/PassManager.h"
13+
14+
namespace llvm {
15+
16+
class TargetMachine;
17+
18+
class ExpandLargeFpConvertPass
19+
: public PassInfoMixin<ExpandLargeFpConvertPass> {
20+
private:
21+
const TargetMachine *TM;
22+
23+
public:
24+
explicit ExpandLargeFpConvertPass(const TargetMachine *TM_) : TM(TM_) {}
25+
26+
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
27+
};
28+
29+
} // end namespace llvm
30+
31+
#endif // LLVM_CODEGEN_EXPANDLARGEFPCONVERT_H

llvm/lib/CodeGen/ExpandLargeFpConvert.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//
1515
//===----------------------------------------------------------------------===//
1616

17+
#include "llvm/CodeGen/ExpandLargeFpConvert.h"
1718
#include "llvm/ADT/SmallVector.h"
1819
#include "llvm/ADT/StringExtras.h"
1920
#include "llvm/Analysis/GlobalsModRef.h"
@@ -653,6 +654,13 @@ class ExpandLargeFpConvertLegacyPass : public FunctionPass {
653654
};
654655
} // namespace
655656

657+
PreservedAnalyses ExpandLargeFpConvertPass::run(Function &F,
658+
FunctionAnalysisManager &FAM) {
659+
const TargetSubtargetInfo *STI = TM->getSubtargetImpl(F);
660+
return runImpl(F, *STI->getTargetLowering()) ? PreservedAnalyses::none()
661+
: PreservedAnalyses::all();
662+
}
663+
656664
char ExpandLargeFpConvertLegacyPass::ID = 0;
657665
INITIALIZE_PASS_BEGIN(ExpandLargeFpConvertLegacyPass, "expand-large-fp-convert",
658666
"Expand large fp convert", false, false)

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
#include "llvm/Analysis/TypeBasedAliasAnalysis.h"
7474
#include "llvm/Analysis/UniformityAnalysis.h"
7575
#include "llvm/CodeGen/ExpandLargeDivRem.h"
76+
#include "llvm/CodeGen/ExpandLargeFpConvert.h"
7677
#include "llvm/CodeGen/HardwareLoops.h"
7778
#include "llvm/CodeGen/TypePromotion.h"
7879
#include "llvm/IR/DebugInfo.h"

llvm/lib/Passes/PassRegistry.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ FUNCTION_PASS("tsan", ThreadSanitizerPass())
446446
FUNCTION_PASS("memprof", MemProfilerPass())
447447
FUNCTION_PASS("declare-to-assign", llvm::AssignmentTrackingPass())
448448
FUNCTION_PASS("expand-large-div-rem", ExpandLargeDivRemPass(TM));
449+
FUNCTION_PASS("expand-large-fp-convert", ExpandLargeFpConvertPass(TM));
449450
#undef FUNCTION_PASS
450451

451452
#ifndef FUNCTION_PASS_WITH_PARAMS

llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptosi129.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
22
; RUN: opt -S -mtriple=x86_64-- -expand-large-fp-convert < %s | FileCheck %s
3+
; RUN: opt -S -mtriple=x86_64-- -passes=expand-large-fp-convert < %s | FileCheck %s
34

45
define i129 @halftosi129(half %a) {
56
; CHECK-LABEL: @halftosi129(

llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptoui129.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
22
; RUN: opt -S -mtriple=x86_64-- -expand-large-fp-convert < %s | FileCheck %s
3+
; RUN: opt -S -mtriple=x86_64-- -passes=expand-large-fp-convert < %s | FileCheck %s
34

45
define i129 @halftoui129(half %a) {
56
; CHECK-LABEL: @halftoui129(

llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-si129tofp.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
22
; RUN: opt -S -mtriple=x86_64-- -expand-large-fp-convert < %s | FileCheck %s
3+
; RUN: opt -S -mtriple=x86_64-- -passes=expand-large-fp-convert < %s | FileCheck %s
34

45
define half @si129tohalf(i129 %a) {
56
; CHECK-LABEL: @si129tohalf(

llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-ui129tofp.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
22
; RUN: opt -S -mtriple=x86_64-- -expand-large-fp-convert < %s | FileCheck %s
3+
; RUN: opt -S -mtriple=x86_64-- -passes=expand-large-fp-convert < %s | FileCheck %s
34

45
define half @ui129tohalf(i129 %a) {
56
; CHECK-LABEL: @ui129tohalf(

0 commit comments

Comments
 (0)