LLVM  15.0.0git
Float2Int.h
Go to the documentation of this file.
1 //===-- Float2Int.h - Demote floating point ops to work on integers -------===//
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 // This file provides the Float2Int pass, which aims to demote floating
10 // point operations to work on integers, where that is losslessly possible.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_TRANSFORMS_SCALAR_FLOAT2INT_H
15 #define LLVM_TRANSFORMS_SCALAR_FLOAT2INT_H
16 
18 #include "llvm/ADT/MapVector.h"
19 #include "llvm/ADT/SetVector.h"
20 #include "llvm/IR/ConstantRange.h"
21 #include "llvm/IR/PassManager.h"
22 
23 namespace llvm {
24 class DominatorTree;
25 class Function;
26 class Instruction;
27 class LLVMContext;
28 template <typename T> class Optional;
29 class Type;
30 class Value;
31 
32 class Float2IntPass : public PassInfoMixin<Float2IntPass> {
33 public:
35 
36  // Glue for old PM.
37  bool runImpl(Function &F, const DominatorTree &DT);
38 
39 private:
40  void findRoots(Function &F, const DominatorTree &DT);
41  void seen(Instruction *I, ConstantRange R);
42  ConstantRange badRange();
43  ConstantRange unknownRange();
44  ConstantRange validateRange(ConstantRange R);
46  void walkBackwards();
47  void walkForwards();
48  bool validateAndTransform();
49  Value *convert(Instruction *I, Type *ToTy);
50  void cleanup();
51 
55  MapVector<Instruction *, Value *> ConvertedInsts;
56  LLVMContext *Ctx;
57 };
58 }
59 #endif // LLVM_TRANSFORMS_SCALAR_FLOAT2INT_H
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::PassInfoMixin
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:371
llvm::Function
Definition: Function.h:60
llvm::EquivalenceClasses
EquivalenceClasses - This represents a collection of equivalence classes and supports three efficient...
Definition: EquivalenceClasses.h:60
MapVector.h
llvm::DominatorTree
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:166
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::Optional
Definition: APInt.h:33
llvm::MapVector
This class implements a map that also provides access to all stored values in a deterministic order.
Definition: MapVector.h:37
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::Instruction
Definition: Instruction.h:42
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
I
#define I(x, y, z)
Definition: MD5.cpp:58
TemplateParamKind::Type
@ Type
llvm::Float2IntPass::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition: Float2Int.cpp:534
llvm::Float2IntPass
Definition: Float2Int.h:32
ConstantRange.h
llvm::cl::Optional
@ Optional
Definition: CommandLine.h:115
llvm::Float2IntPass::runImpl
bool runImpl(Function &F, const DominatorTree &DT)
Definition: Float2Int.cpp:510
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
PassManager.h
EquivalenceClasses.h
llvm::ConstantRange
This class represents a range of values.
Definition: ConstantRange.h:47
llvm::SmallSetVector
A SetVector that performs no allocations if smaller than a certain size.
Definition: SetVector.h:307
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::codeview::PublicSymFlags::Function
@ Function
SetVector.h