Skip to content

Commit 6962cf1

Browse files
authored
Rename ExpandLargeFpConvertPass to ExpandFpPass (#131128)
This is meant as a preparation for PR #130988 "[AMDGPU] Implement IR expansion for frem instruction" which implements the expansion of another instruction in this pass. The more general name seems more appropriate given this change and quite reasonable even without it.
1 parent 73e93ec commit 6962cf1

33 files changed

+78
-77
lines changed

llvm/docs/WritingAnLLVMPass.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ default optimization pipelines, e.g. (the output has been trimmed):
652652
Pre-ISel Intrinsic Lowering
653653
FunctionPass Manager
654654
Expand large div/rem
655-
Expand large fp convert
655+
Expand fp
656656
Expand Atomic instructions
657657
SVE intrinsics optimizations
658658
FunctionPass Manager
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
1-
//===- ExpandLargeFpConvert.h -----------------------------------*- C++ -*-===//
1+
//===- ExpandFp.h -----------------------------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLVM_CODEGEN_EXPANDLARGEFPCONVERT_H
10-
#define LLVM_CODEGEN_EXPANDLARGEFPCONVERT_H
9+
#ifndef LLVM_CODEGEN_EXPANDFP_H
10+
#define LLVM_CODEGEN_EXPANDFP_H
1111

1212
#include "llvm/IR/PassManager.h"
1313

1414
namespace llvm {
1515

1616
class TargetMachine;
1717

18-
class ExpandLargeFpConvertPass
19-
: public PassInfoMixin<ExpandLargeFpConvertPass> {
18+
class ExpandFpPass : public PassInfoMixin<ExpandFpPass> {
2019
private:
2120
const TargetMachine *TM;
2221

2322
public:
24-
explicit ExpandLargeFpConvertPass(const TargetMachine *TM_) : TM(TM_) {}
23+
explicit ExpandFpPass(const TargetMachine *TM_) : TM(TM_) {}
2524

2625
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
2726
};
2827

2928
} // end namespace llvm
3029

31-
#endif // LLVM_CODEGEN_EXPANDLARGEFPCONVERT_H
30+
#endif // LLVM_CODEGEN_EXPANDFP_H

llvm/include/llvm/CodeGen/Passes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ namespace llvm {
529529
FunctionPass *createExpandLargeDivRemPass();
530530

531531
// Expands large div/rem instructions.
532-
FunctionPass *createExpandLargeFpConvertPass();
532+
FunctionPass *createExpandFpPass();
533533

534534
// This pass expands memcmp() to load/stores.
535535
FunctionPass *createExpandMemCmpLegacyPass();

llvm/include/llvm/CodeGen/TargetLowering.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,8 +2148,8 @@ class TargetLoweringBase {
21482148
return MaxDivRemBitWidthSupported;
21492149
}
21502150

2151-
/// Returns the size in bits of the maximum larget fp convert the backend
2152-
/// supports. Larger operations will be expanded by ExpandLargeFPConvert.
2151+
/// Returns the size in bits of the maximum fp to/from int conversion the
2152+
/// backend supports. Larger operations will be expanded by ExpandFp.
21532153
unsigned getMaxLargeFPConvertBitWidthSupported() const {
21542154
return MaxLargeFPConvertBitWidthSupported;
21552155
}
@@ -2782,8 +2782,8 @@ class TargetLoweringBase {
27822782
MaxDivRemBitWidthSupported = SizeInBits;
27832783
}
27842784

2785-
/// Set the size in bits of the maximum fp convert the backend supports.
2786-
/// Larger operations will be expanded by ExpandLargeFPConvert.
2785+
/// Set the size in bits of the maximum fp to/from int conversion the backend
2786+
/// supports. Larger operations will be expanded by ExpandFp.
27872787
void setMaxLargeFPConvertBitWidthSupported(unsigned SizeInBits) {
27882788
MaxLargeFPConvertBitWidthSupported = SizeInBits;
27892789
}
@@ -3580,8 +3580,9 @@ class TargetLoweringBase {
35803580
/// Larger operations will be expanded by ExpandLargeDivRem.
35813581
unsigned MaxDivRemBitWidthSupported;
35823582

3583-
/// Size in bits of the maximum larget fp convert size the backend
3584-
/// supports. Larger operations will be expanded by ExpandLargeFPConvert.
3583+
/// Size in bits of the maximum fp to/from int conversion size the
3584+
/// backend supports. Larger operations will be expanded by
3585+
/// ExpandFp.
35853586
unsigned MaxLargeFPConvertBitWidthSupported;
35863587

35873588
/// Size in bits of the minimum cmpxchg or ll/sc operation the

llvm/include/llvm/InitializePasses.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void initializeEarlyMachineLICMPass(PassRegistry &);
105105
void initializeEarlyTailDuplicateLegacyPass(PassRegistry &);
106106
void initializeEdgeBundlesWrapperLegacyPass(PassRegistry &);
107107
void initializeEHContGuardTargetsPass(PassRegistry &);
108-
void initializeExpandLargeFpConvertLegacyPassPass(PassRegistry &);
108+
void initializeExpandFpLegacyPassPass(PassRegistry &);
109109
void initializeExpandLargeDivRemLegacyPassPass(PassRegistry &);
110110
void initializeExpandMemCmpLegacyPassPass(PassRegistry &);
111111
void initializeExpandPostRALegacyPass(PassRegistry &);

llvm/include/llvm/Passes/CodeGenPassBuilder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
#include "llvm/CodeGen/DetectDeadLanes.h"
3131
#include "llvm/CodeGen/DwarfEHPrepare.h"
3232
#include "llvm/CodeGen/EarlyIfConversion.h"
33+
#include "llvm/CodeGen/ExpandFp.h"
3334
#include "llvm/CodeGen/ExpandLargeDivRem.h"
34-
#include "llvm/CodeGen/ExpandLargeFpConvert.h"
3535
#include "llvm/CodeGen/ExpandMemCmp.h"
3636
#include "llvm/CodeGen/ExpandPostRAPseudos.h"
3737
#include "llvm/CodeGen/ExpandReductions.h"
@@ -663,7 +663,7 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addISelPasses(
663663

664664
addPass(PreISelIntrinsicLoweringPass(&TM));
665665
addPass(ExpandLargeDivRemPass(&TM));
666-
addPass(ExpandLargeFpConvertPass(&TM));
666+
addPass(ExpandFpPass(&TM));
667667

668668
derived().addIRPasses(addPass);
669669
derived().addCodeGenPrepare(addPass);

llvm/include/llvm/Passes/MachinePassRegistry.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ FUNCTION_PASS("consthoist", ConstantHoistingPass())
5252
FUNCTION_PASS("dwarf-eh-prepare", DwarfEHPreparePass(TM))
5353
FUNCTION_PASS("ee-instrument", EntryExitInstrumenterPass(false))
5454
FUNCTION_PASS("expand-large-div-rem", ExpandLargeDivRemPass(TM))
55-
FUNCTION_PASS("expand-large-fp-convert", ExpandLargeFpConvertPass(TM))
55+
FUNCTION_PASS("expand-fp", ExpandFpPass(TM))
5656
FUNCTION_PASS("expand-memcmp", ExpandMemCmpPass(TM))
5757
FUNCTION_PASS("expand-reductions", ExpandReductionsPass())
5858
FUNCTION_PASS("gc-lowering", GCLoweringPass())

llvm/lib/CodeGen/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ add_llvm_component_library(LLVMCodeGen
5757
EHContGuardTargets.cpp
5858
ExecutionDomainFix.cpp
5959
ExpandLargeDivRem.cpp
60-
ExpandLargeFpConvert.cpp
60+
ExpandFp.cpp
6161
ExpandMemCmp.cpp
6262
ExpandPostRAPseudos.cpp
6363
ExpandReductions.cpp

llvm/lib/CodeGen/CodeGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) {
4040
initializeEarlyMachineLICMPass(Registry);
4141
initializeEarlyTailDuplicateLegacyPass(Registry);
4242
initializeExpandLargeDivRemLegacyPassPass(Registry);
43-
initializeExpandLargeFpConvertLegacyPassPass(Registry);
43+
initializeExpandFpLegacyPassPass(Registry);
4444
initializeExpandMemCmpLegacyPassPass(Registry);
4545
initializeExpandPostRALegacyPass(Registry);
4646
initializeFEntryInserterPass(Registry);

llvm/lib/CodeGen/ExpandLargeFpConvert.cpp renamed to llvm/lib/CodeGen/ExpandFp.cpp

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
//===--- ExpandLargeFpConvert.cpp - Expand large fp convert----------------===//
1+
//===--- ExpandFp.cpp - Expand fp instructions ----------------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8+
// This pass expands certain floating point instructions at the IR level.
89
//
9-
10-
// This pass expands ‘fptoui .. to’, ‘fptosi .. to’, ‘uitofp .. to’,
11-
// ‘sitofp .. to’ instructions with a bitwidth above a threshold into
12-
// auto-generated functions. This is useful for targets like x86_64 that cannot
13-
// lower fp convertions with more than 128 bits.
10+
// It expands ‘fptoui .. to’, ‘fptosi .. to’, ‘uitofp .. to’, ‘sitofp
11+
// .. to’ instructions with a bitwidth above a threshold. This is
12+
// useful for targets like x86_64 that cannot lower fp convertions
13+
// with more than 128 bits.
1414
//
1515
//===----------------------------------------------------------------------===//
1616

17-
#include "llvm/CodeGen/ExpandLargeFpConvert.h"
17+
#include "llvm/CodeGen/ExpandFp.h"
1818
#include "llvm/ADT/SmallVector.h"
1919
#include "llvm/Analysis/GlobalsModRef.h"
2020
#include "llvm/CodeGen/Passes.h"
@@ -33,9 +33,11 @@ using namespace llvm;
3333

3434
static cl::opt<unsigned>
3535
ExpandFpConvertBits("expand-fp-convert-bits", cl::Hidden,
36-
cl::init(llvm::IntegerType::MAX_INT_BITS),
37-
cl::desc("fp convert instructions on integers with "
38-
"more than <N> bits are expanded."));
36+
cl::init(llvm::IntegerType::MAX_INT_BITS),
37+
cl::desc("fp convert instructions on integers with "
38+
"more than <N> bits are expanded."));
39+
40+
// clang-format off: preserve formatting of the following example
3941

4042
/// Generate code to convert a fp number to integer, replacing FPToS(U)I with
4143
/// the generated code. This currently generates code similarly to compiler-rt's
@@ -88,6 +90,7 @@ static cl::opt<unsigned>
8890
///
8991
/// Replace fp to integer with generated code.
9092
static void expandFPToI(Instruction *FPToI) {
93+
// clang-format on
9194
IRBuilder<> Builder(FPToI);
9295
auto *FloatVal = FPToI->getOperand(0);
9396
IntegerType *IntTy = cast<IntegerType>(FPToI->getType());
@@ -224,6 +227,8 @@ static void expandFPToI(Instruction *FPToI) {
224227
FPToI->eraseFromParent();
225228
}
226229

230+
// clang-format off: preserve formatting of the following example
231+
227232
/// Generate code to convert a fp number to integer, replacing S(U)IToFP with
228233
/// the generated code. This currently generates code similarly to compiler-rt's
229234
/// implementations. This implementation has an implicit assumption that integer
@@ -307,6 +312,7 @@ static void expandFPToI(Instruction *FPToI) {
307312
///
308313
/// Replace integer to fp with generated code.
309314
static void expandIToFP(Instruction *IToFP) {
315+
// clang-format on
310316
IRBuilder<> Builder(IToFP);
311317
auto *IntVal = IToFP->getOperand(0);
312318
IntegerType *IntTy = cast<IntegerType>(IntVal->getType());
@@ -666,13 +672,12 @@ static bool runImpl(Function &F, const TargetLowering &TLI) {
666672
}
667673

668674
namespace {
669-
class ExpandLargeFpConvertLegacyPass : public FunctionPass {
675+
class ExpandFpLegacyPass : public FunctionPass {
670676
public:
671677
static char ID;
672678

673-
ExpandLargeFpConvertLegacyPass() : FunctionPass(ID) {
674-
initializeExpandLargeFpConvertLegacyPassPass(
675-
*PassRegistry::getPassRegistry());
679+
ExpandFpLegacyPass() : FunctionPass(ID) {
680+
initializeExpandFpLegacyPassPass(*PassRegistry::getPassRegistry());
676681
}
677682

678683
bool runOnFunction(Function &F) override {
@@ -689,19 +694,15 @@ class ExpandLargeFpConvertLegacyPass : public FunctionPass {
689694
};
690695
} // namespace
691696

692-
PreservedAnalyses ExpandLargeFpConvertPass::run(Function &F,
693-
FunctionAnalysisManager &FAM) {
697+
PreservedAnalyses ExpandFpPass::run(Function &F, FunctionAnalysisManager &FAM) {
694698
const TargetSubtargetInfo *STI = TM->getSubtargetImpl(F);
695699
return runImpl(F, *STI->getTargetLowering()) ? PreservedAnalyses::none()
696700
: PreservedAnalyses::all();
697701
}
698702

699-
char ExpandLargeFpConvertLegacyPass::ID = 0;
700-
INITIALIZE_PASS_BEGIN(ExpandLargeFpConvertLegacyPass, "expand-large-fp-convert",
701-
"Expand large fp convert", false, false)
702-
INITIALIZE_PASS_END(ExpandLargeFpConvertLegacyPass, "expand-large-fp-convert",
703-
"Expand large fp convert", false, false)
703+
char ExpandFpLegacyPass::ID = 0;
704+
INITIALIZE_PASS_BEGIN(ExpandFpLegacyPass, "expand-fp",
705+
"Expand certain fp instructions", false, false)
706+
INITIALIZE_PASS_END(ExpandFpLegacyPass, "expand-fp", "Expand fp", false, false)
704707

705-
FunctionPass *llvm::createExpandLargeFpConvertPass() {
706-
return new ExpandLargeFpConvertLegacyPass();
707-
}
708+
FunctionPass *llvm::createExpandFpPass() { return new ExpandFpLegacyPass(); }

0 commit comments

Comments
 (0)