summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMichael Kuperstein <mkuper@google.com>2016-06-24 23:32:02 +0000
committerMichael Kuperstein <mkuper@google.com>2016-06-24 23:32:02 +0000
commit840a0dd1474b3df83afe81ec29fb02e41c993783 (patch)
treebda8f724c2942a3874616ccd476d8b74ac9bb1d4 /include
parent51f85a493d6507b50127c4486f7f25619e11d898 (diff)
[PM] Port float2int to the new pass manager
Differential Revision: http://reviews.llvm.org/D21704 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273747 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/InitializePasses.h2
-rw-r--r--include/llvm/Transforms/Scalar/Float2Int.h52
2 files changed, 53 insertions, 1 deletions
diff --git a/include/llvm/InitializePasses.h b/include/llvm/InitializePasses.h
index b78fdc24e0f..2dbe127809f 100644
--- a/include/llvm/InitializePasses.h
+++ b/include/llvm/InitializePasses.h
@@ -124,7 +124,7 @@ void initializeExpandPostRAPass(PassRegistry&);
void initializeExternalAAWrapperPassPass(PassRegistry&);
void initializeFinalizeMachineBundlesPass(PassRegistry&);
void initializeFlattenCFGPassPass(PassRegistry&);
-void initializeFloat2IntPass(PassRegistry&);
+void initializeFloat2IntLegacyPassPass(PassRegistry&);
void initializeForceFunctionAttrsLegacyPassPass(PassRegistry&);
void initializeForwardControlFlowIntegrityPass(PassRegistry&);
void initializeFuncletLayoutPass(PassRegistry &);
diff --git a/include/llvm/Transforms/Scalar/Float2Int.h b/include/llvm/Transforms/Scalar/Float2Int.h
new file mode 100644
index 00000000000..632f262385b
--- /dev/null
+++ b/include/llvm/Transforms/Scalar/Float2Int.h
@@ -0,0 +1,52 @@
+//===-- Float2Int.h - Demote floating point ops to work on integers -------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides the Float2Int pass, which aims to demote floating
+// point operations to work on integers, where that is losslessly possible.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_SCALAR_FLOAT2INT_H
+#define LLVM_TRANSFORMS_SCALAR_FLOAT2INT_H
+
+#include "llvm/ADT/EquivalenceClasses.h"
+#include "llvm/ADT/MapVector.h"
+#include "llvm/IR/ConstantRange.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+/// Pass to remove unused function declarations.
+class Float2IntPass : public PassInfoMixin<Float2IntPass> {
+public:
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+
+ // Glue for old PM.
+ bool runImpl(Function &F);
+
+private:
+ void findRoots(Function &F, SmallPtrSet<Instruction *, 8> &Roots);
+ ConstantRange seen(Instruction *I, ConstantRange R);
+ ConstantRange badRange();
+ ConstantRange unknownRange();
+ ConstantRange validateRange(ConstantRange R);
+ void walkBackwards(const SmallPtrSetImpl<Instruction *> &Roots);
+ void walkForwards();
+ bool validateAndTransform();
+ Value *convert(Instruction *I, Type *ToTy);
+ void cleanup();
+
+ MapVector<Instruction *, ConstantRange> SeenInsts;
+ SmallPtrSet<Instruction *, 8> Roots;
+ EquivalenceClasses<Instruction *> ECs;
+ MapVector<Instruction *, Value *> ConvertedInsts;
+ LLVMContext *Ctx;
+};
+}
+#endif // LLVM_TRANSFORMS_SCALAR_FLOAT2INT_H