1 //===-- Float2Int.h - Demote floating point ops to work on integers -------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file provides the Float2Int pass, which aims to demote floating
10 // point operations to work on integers, where that is losslessly possible.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TRANSFORMS_SCALAR_FLOAT2INT_H
15 #define LLVM_TRANSFORMS_SCALAR_FLOAT2INT_H
17 #include "llvm/ADT/EquivalenceClasses.h"
18 #include "llvm/ADT/MapVector.h"
19 #include "llvm/IR/ConstantRange.h"
20 #include "llvm/IR/Function.h"
21 #include "llvm/IR/PassManager.h"
24 class Float2IntPass
: public PassInfoMixin
<Float2IntPass
> {
26 PreservedAnalyses
run(Function
&F
, FunctionAnalysisManager
&AM
);
29 bool runImpl(Function
&F
);
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
);
39 bool validateAndTransform();
40 Value
*convert(Instruction
*I
, Type
*ToTy
);
43 MapVector
<Instruction
*, ConstantRange
> SeenInsts
;
44 SmallPtrSet
<Instruction
*, 8> Roots
;
45 EquivalenceClasses
<Instruction
*> ECs
;
46 MapVector
<Instruction
*, Value
*> ConvertedInsts
;
50 #endif // LLVM_TRANSFORMS_SCALAR_FLOAT2INT_H