LLVM  10.0.0svn
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 //===----------------------------------------------------------------------===//
18 #include "llvm/ADT/MapVector.h"
19 #include "llvm/IR/ConstantRange.h"
20 #include "llvm/IR/Function.h"
21 #include "llvm/IR/PassManager.h"
23 namespace llvm {
24 class Float2IntPass : public PassInfoMixin<Float2IntPass> {
25 public:
28  // Glue for old PM.
29  bool runImpl(Function &F);
31 private:
32  void findRoots(Function &F, SmallPtrSet<Instruction *, 8> &Roots);
33  void seen(Instruction *I, ConstantRange R);
34  ConstantRange badRange();
35  ConstantRange unknownRange();
36  ConstantRange validateRange(ConstantRange R);
37  void walkBackwards(const SmallPtrSetImpl<Instruction *> &Roots);
38  void walkForwards();
39  bool validateAndTransform();
40  Value *convert(Instruction *I, Type *ToTy);
41  void cleanup();
46  MapVector<Instruction *, Value *> ConvertedInsts;
47  LLVMContext *Ctx;
48 };
49 }
This class represents lattice values for constants.
Definition: AllocatorList.h:23
This class implements a map that also provides access to all stored values in a deterministic order...
Definition: MapVector.h:37
bool runImpl(Function &F)
Definition: Float2Int.cpp:506
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:372
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:153
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:64
EquivalenceClasses - This represents a collection of equivalence classes and supports three efficient...
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
Definition: SmallPtrSet.h:417
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition: Float2Int.cpp:530
This class represents a range of values.
Definition: ConstantRange.h:47
#define I(x, y, z)
Definition: MD5.cpp:58
LLVM Value Representation.
Definition: Value.h:73
A container for analyses that lazily runs them and caches their results.
This header defines various interfaces for pass management in LLVM.