Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:41

0001 //===-- Float2Int.h - Demote floating point ops to work on integers -------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file provides the Float2Int pass, which aims to demote floating
0010 // point operations to work on integers, where that is losslessly possible.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_TRANSFORMS_SCALAR_FLOAT2INT_H
0015 #define LLVM_TRANSFORMS_SCALAR_FLOAT2INT_H
0016 
0017 #include "llvm/ADT/EquivalenceClasses.h"
0018 #include "llvm/ADT/MapVector.h"
0019 #include "llvm/ADT/SetVector.h"
0020 #include "llvm/IR/ConstantRange.h"
0021 #include "llvm/IR/PassManager.h"
0022 
0023 namespace llvm {
0024 class DominatorTree;
0025 class Function;
0026 class Instruction;
0027 class LLVMContext;
0028 class Type;
0029 class Value;
0030 
0031 class Float2IntPass : public PassInfoMixin<Float2IntPass> {
0032 public:
0033   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
0034 
0035   // Glue for old PM.
0036   bool runImpl(Function &F, const DominatorTree &DT);
0037 
0038 private:
0039   void findRoots(Function &F, const DominatorTree &DT);
0040   void seen(Instruction *I, ConstantRange R);
0041   ConstantRange badRange();
0042   ConstantRange unknownRange();
0043   ConstantRange validateRange(ConstantRange R);
0044   std::optional<ConstantRange> calcRange(Instruction *I);
0045   void walkBackwards();
0046   void walkForwards();
0047   bool validateAndTransform(const DataLayout &DL);
0048   Value *convert(Instruction *I, Type *ToTy);
0049   void cleanup();
0050 
0051   MapVector<Instruction *, ConstantRange> SeenInsts;
0052   SmallSetVector<Instruction *, 8> Roots;
0053   EquivalenceClasses<Instruction *> ECs;
0054   MapVector<Instruction *, Value *> ConvertedInsts;
0055   LLVMContext *Ctx;
0056 };
0057 }
0058 #endif // LLVM_TRANSFORMS_SCALAR_FLOAT2INT_H