From 051d088161d474279614296f44d2a84eeed48416 Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Sat, 4 Jul 2020 16:40:02 -0700 Subject: [PATCH] NFC: Move CPA typing analysis down a directory. --- include/npcomp/Dialect/Basicpy/IR/BasicpyDialect.h | 2 +- include/npcomp/Dialect/Numpy/IR/NumpyDialect.h | 2 +- include/npcomp/Dialect/Numpy/IR/NumpyOps.h | 2 +- include/npcomp/Dialect/Numpy/IR/NumpyOps.td | 2 +- include/npcomp/Typing/Analysis/CMakeLists.txt | 1 + .../npcomp/Typing/{ => Analysis}/CPA/Algorithm.h | 8 ++++---- .../Typing/{ => Analysis}/CPA/CMakeLists.txt | 0 .../npcomp/Typing/{ => Analysis}/CPA/Interfaces.h | 12 ++++++------ .../npcomp/Typing/{ => Analysis}/CPA/Interfaces.td | 6 +++--- include/npcomp/Typing/{ => Analysis}/CPA/Support.h | 4 ++-- include/npcomp/Typing/CMakeLists.txt | 2 +- .../Basicpy/Transforms/CPATypeInference.cpp | 14 +++++++++++--- lib/Typing/Analysis/CMakeLists.txt | 1 + lib/Typing/{ => Analysis}/CPA/Algorithm.cpp | 2 +- lib/Typing/{ => Analysis}/CPA/CMakeLists.txt | 0 lib/Typing/{ => Analysis}/CPA/Interfaces.cpp | 6 +++--- lib/Typing/{ => Analysis}/CPA/Support.cpp | 8 ++++---- lib/Typing/CMakeLists.txt | 2 +- 18 files changed, 42 insertions(+), 32 deletions(-) create mode 100644 include/npcomp/Typing/Analysis/CMakeLists.txt rename include/npcomp/Typing/{ => Analysis}/CPA/Algorithm.h (88%) rename include/npcomp/Typing/{ => Analysis}/CPA/CMakeLists.txt (100%) rename include/npcomp/Typing/{ => Analysis}/CPA/Interfaces.h (60%) rename include/npcomp/Typing/{ => Analysis}/CPA/Interfaces.td (88%) rename include/npcomp/Typing/{ => Analysis}/CPA/Support.h (99%) create mode 100644 lib/Typing/Analysis/CMakeLists.txt rename lib/Typing/{ => Analysis}/CPA/Algorithm.cpp (97%) rename lib/Typing/{ => Analysis}/CPA/CMakeLists.txt (100%) rename lib/Typing/{ => Analysis}/CPA/Interfaces.cpp (69%) rename lib/Typing/{ => Analysis}/CPA/Support.cpp (97%) diff --git a/include/npcomp/Dialect/Basicpy/IR/BasicpyDialect.h b/include/npcomp/Dialect/Basicpy/IR/BasicpyDialect.h index af0ea3d10..ccf0d4944 100644 --- a/include/npcomp/Dialect/Basicpy/IR/BasicpyDialect.h +++ b/include/npcomp/Dialect/Basicpy/IR/BasicpyDialect.h @@ -13,7 +13,7 @@ #include "mlir/IR/Dialect.h" #include "mlir/IR/Types.h" #include "npcomp/Dialect/Common.h" -#include "npcomp/Typing/CPA/Interfaces.h" +#include "npcomp/Typing/Analysis/CPA/Interfaces.h" namespace mlir { namespace NPCOMP { diff --git a/include/npcomp/Dialect/Numpy/IR/NumpyDialect.h b/include/npcomp/Dialect/Numpy/IR/NumpyDialect.h index febfa20f7..b34bc4b52 100644 --- a/include/npcomp/Dialect/Numpy/IR/NumpyDialect.h +++ b/include/npcomp/Dialect/Numpy/IR/NumpyDialect.h @@ -11,7 +11,7 @@ #include "mlir/IR/Dialect.h" #include "npcomp/Dialect/Common.h" -#include "npcomp/Typing/CPA/Interfaces.h" +#include "npcomp/Typing/Analysis/CPA/Interfaces.h" namespace mlir { namespace NPCOMP { diff --git a/include/npcomp/Dialect/Numpy/IR/NumpyOps.h b/include/npcomp/Dialect/Numpy/IR/NumpyOps.h index e0687ed4d..6623e9135 100644 --- a/include/npcomp/Dialect/Numpy/IR/NumpyOps.h +++ b/include/npcomp/Dialect/Numpy/IR/NumpyOps.h @@ -16,7 +16,7 @@ #include "mlir/IR/StandardTypes.h" #include "mlir/IR/SymbolTable.h" #include "mlir/Interfaces/SideEffectInterfaces.h" -#include "npcomp/Typing/CPA/Interfaces.h" +#include "npcomp/Typing/Analysis/CPA/Interfaces.h" namespace mlir { namespace NPCOMP { diff --git a/include/npcomp/Dialect/Numpy/IR/NumpyOps.td b/include/npcomp/Dialect/Numpy/IR/NumpyOps.td index 4ff763634..4b9b5a477 100644 --- a/include/npcomp/Dialect/Numpy/IR/NumpyOps.td +++ b/include/npcomp/Dialect/Numpy/IR/NumpyOps.td @@ -10,7 +10,7 @@ #define NPCOMP_DIALECT_NUMPY_IR_NUMPY_OPS include "NumpyDialect.td" -include "npcomp/Typing/CPA/Interfaces.td" +include "npcomp/Typing/Analysis/CPA/Interfaces.td" include "mlir/Interfaces/SideEffectInterfaces.td" include "mlir/IR/SymbolInterfaces.td" diff --git a/include/npcomp/Typing/Analysis/CMakeLists.txt b/include/npcomp/Typing/Analysis/CMakeLists.txt new file mode 100644 index 000000000..fd2a3eae4 --- /dev/null +++ b/include/npcomp/Typing/Analysis/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(CPA) diff --git a/include/npcomp/Typing/CPA/Algorithm.h b/include/npcomp/Typing/Analysis/CPA/Algorithm.h similarity index 88% rename from include/npcomp/Typing/CPA/Algorithm.h rename to include/npcomp/Typing/Analysis/CPA/Algorithm.h index 1eea843dc..bab83c06a 100644 --- a/include/npcomp/Typing/CPA/Algorithm.h +++ b/include/npcomp/Typing/Analysis/CPA/Algorithm.h @@ -13,10 +13,10 @@ // http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.129.2756 //===----------------------------------------------------------------------===// -#ifndef NPCOMP_TYPING_CPA_ALGORITHM_H -#define NPCOMP_TYPING_CPA_ALGORITHM_H +#ifndef NPCOMP_TYPING_ANALYSIS_CPA_ALGORITHM_H +#define NPCOMP_TYPING_ANALYSIS_CPA_ALGORITHM_H -#include "npcomp/Typing/CPA/Support.h" +#include "npcomp/Typing/Analysis/CPA/Support.h" #include "llvm/ADT/DenseSet.h" namespace mlir { @@ -51,4 +51,4 @@ private: } // namespace NPCOMP } // namespace mlir -#endif // NPCOMP_TYPING_CPA_ALGORITHM_H +#endif // NPCOMP_TYPING_ANALYSIS_CPA_ALGORITHM_H diff --git a/include/npcomp/Typing/CPA/CMakeLists.txt b/include/npcomp/Typing/Analysis/CPA/CMakeLists.txt similarity index 100% rename from include/npcomp/Typing/CPA/CMakeLists.txt rename to include/npcomp/Typing/Analysis/CPA/CMakeLists.txt diff --git a/include/npcomp/Typing/CPA/Interfaces.h b/include/npcomp/Typing/Analysis/CPA/Interfaces.h similarity index 60% rename from include/npcomp/Typing/CPA/Interfaces.h rename to include/npcomp/Typing/Analysis/CPA/Interfaces.h index 6c8caf2ac..8a1d22b7d 100644 --- a/include/npcomp/Typing/CPA/Interfaces.h +++ b/include/npcomp/Typing/Analysis/CPA/Interfaces.h @@ -6,19 +6,19 @@ // //===----------------------------------------------------------------------===// -#ifndef NPCOMP_TYPING_CPA_INTERFACES_H -#define NPCOMP_TYPING_CPA_INTERFACES_H +#ifndef NPCOMP_TYPING_ANALYSIS_CPA_INTERFACES_H +#define NPCOMP_TYPING_ANALYSIS_CPA_INTERFACES_H #include "mlir/IR/OpDefinition.h" #include "mlir/IR/Types.h" -#include "npcomp/Typing/CPA/Support.h" +#include "npcomp/Typing/Analysis/CPA/Support.h" namespace mlir { -#include "npcomp/Typing/CPA/OpInterfaces.h.inc" -#include "npcomp/Typing/CPA/TypeInterfaces.h.inc" +#include "npcomp/Typing/Analysis/CPA/OpInterfaces.h.inc" +#include "npcomp/Typing/Analysis/CPA/TypeInterfaces.h.inc" } // namespace mlir -#endif // NPCOMP_TYPING_CPA_INTERFACES_H +#endif // NPCOMP_TYPING_ANALYSIS_CPA_INTERFACES_H diff --git a/include/npcomp/Typing/CPA/Interfaces.td b/include/npcomp/Typing/Analysis/CPA/Interfaces.td similarity index 88% rename from include/npcomp/Typing/CPA/Interfaces.td rename to include/npcomp/Typing/Analysis/CPA/Interfaces.td index 1d65fe231..dd2608f0c 100644 --- a/include/npcomp/Typing/CPA/Interfaces.td +++ b/include/npcomp/Typing/Analysis/CPA/Interfaces.td @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef NPCOMP_TYPING_CPA_CPA_INTERFACES -#define NPCOMP_TYPING_CPA_CPA_INTERFACES +#ifndef NPCOMP_TYPING_ANALYSIS_CPA_CPA_INTERFACES +#define NPCOMP_TYPING_ANALYSIS_CPA_CPA_INTERFACES include "mlir/IR/OpBase.td" @@ -35,4 +35,4 @@ def NPCOMP_CPATypeInferenceOpInterface : OpInterface< ]; } -#endif // NPCOMP_TYPING_CPA_CPA_INTERFACES +#endif // NPCOMP_TYPING_ANALYSIS_CPA_CPA_INTERFACES diff --git a/include/npcomp/Typing/CPA/Support.h b/include/npcomp/Typing/Analysis/CPA/Support.h similarity index 99% rename from include/npcomp/Typing/CPA/Support.h rename to include/npcomp/Typing/Analysis/CPA/Support.h index cbada9bf8..5374f618a 100644 --- a/include/npcomp/Typing/CPA/Support.h +++ b/include/npcomp/Typing/Analysis/CPA/Support.h @@ -22,8 +22,8 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/raw_ostream.h" -#ifndef NPCOMP_TYPING_CPA_SUPPORT_H -#define NPCOMP_TYPING_CPA_SUPPORT_H +#ifndef NPCOMP_TYPING_ANALYSIS_CPA_SUPPORT_H +#define NPCOMP_TYPING_ANALYSIS_CPA_SUPPORT_H namespace mlir { namespace NPCOMP { diff --git a/include/npcomp/Typing/CMakeLists.txt b/include/npcomp/Typing/CMakeLists.txt index fd2a3eae4..fc6ef10fa 100644 --- a/include/npcomp/Typing/CMakeLists.txt +++ b/include/npcomp/Typing/CMakeLists.txt @@ -1 +1 @@ -add_subdirectory(CPA) +add_subdirectory(Analysis) diff --git a/lib/Dialect/Basicpy/Transforms/CPATypeInference.cpp b/lib/Dialect/Basicpy/Transforms/CPATypeInference.cpp index 7675f9598..4da96c07c 100644 --- a/lib/Dialect/Basicpy/Transforms/CPATypeInference.cpp +++ b/lib/Dialect/Basicpy/Transforms/CPATypeInference.cpp @@ -14,9 +14,9 @@ #include "npcomp/Dialect/Basicpy/IR/BasicpyDialect.h" #include "npcomp/Dialect/Basicpy/IR/BasicpyOps.h" #include "npcomp/Dialect/Basicpy/Transforms/Passes.h" -#include "npcomp/Typing/CPA/Algorithm.h" -#include "npcomp/Typing/CPA/Interfaces.h" -#include "npcomp/Typing/CPA/Support.h" +#include "npcomp/Typing/Analysis/CPA/Algorithm.h" +#include "npcomp/Typing/Analysis/CPA/Interfaces.h" +#include "npcomp/Typing/Analysis/CPA/Support.h" #include "llvm/Support/Debug.h" #define DEBUG_TYPE "basicpy-type-inference" @@ -220,6 +220,14 @@ public: llvm::errs() << "------------------\n"; prop.propagateTransitivity(); } while (prop.commit()); + + llvm::errs() << "CONSTRAINTS:\n"; + llvm::errs() << "------------\n"; + env.getConstraints().print(cpaContext, llvm::errs()); + + llvm::errs() << "\nTYPEVARS:\n"; + llvm::errs() << "---------\n"; + env.getTypeVars().print(cpaContext, llvm::errs()); } }; diff --git a/lib/Typing/Analysis/CMakeLists.txt b/lib/Typing/Analysis/CMakeLists.txt new file mode 100644 index 000000000..fd2a3eae4 --- /dev/null +++ b/lib/Typing/Analysis/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(CPA) diff --git a/lib/Typing/CPA/Algorithm.cpp b/lib/Typing/Analysis/CPA/Algorithm.cpp similarity index 97% rename from lib/Typing/CPA/Algorithm.cpp rename to lib/Typing/Analysis/CPA/Algorithm.cpp index ca1aa8fb9..f05c39e77 100644 --- a/lib/Typing/CPA/Algorithm.cpp +++ b/lib/Typing/Analysis/CPA/Algorithm.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "npcomp/Typing/CPA/Algorithm.h" +#include "npcomp/Typing/Analysis/CPA/Algorithm.h" using namespace mlir::NPCOMP::Typing::CPA; diff --git a/lib/Typing/CPA/CMakeLists.txt b/lib/Typing/Analysis/CPA/CMakeLists.txt similarity index 100% rename from lib/Typing/CPA/CMakeLists.txt rename to lib/Typing/Analysis/CPA/CMakeLists.txt diff --git a/lib/Typing/CPA/Interfaces.cpp b/lib/Typing/Analysis/CPA/Interfaces.cpp similarity index 69% rename from lib/Typing/CPA/Interfaces.cpp rename to lib/Typing/Analysis/CPA/Interfaces.cpp index e1795491c..04d486a07 100644 --- a/lib/Typing/CPA/Interfaces.cpp +++ b/lib/Typing/Analysis/CPA/Interfaces.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// -#include "npcomp/Typing/CPA/Interfaces.h" +#include "npcomp/Typing/Analysis/CPA/Interfaces.h" using namespace mlir; -#include "npcomp/Typing/CPA/OpInterfaces.cpp.inc" -#include "npcomp/Typing/CPA/TypeInterfaces.cpp.inc" +#include "npcomp/Typing/Analysis/CPA/OpInterfaces.cpp.inc" +#include "npcomp/Typing/Analysis/CPA/TypeInterfaces.cpp.inc" diff --git a/lib/Typing/CPA/Support.cpp b/lib/Typing/Analysis/CPA/Support.cpp similarity index 97% rename from lib/Typing/CPA/Support.cpp rename to lib/Typing/Analysis/CPA/Support.cpp index 60597489f..cd47501fc 100644 --- a/lib/Typing/CPA/Support.cpp +++ b/lib/Typing/Analysis/CPA/Support.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#include "npcomp/Typing/CPA/Support.h" -#include "npcomp/Typing/CPA/Interfaces.h" +#include "npcomp/Typing/Analysis/CPA/Support.h" +#include "npcomp/Typing/Analysis/CPA/Interfaces.h" #include "mlir/IR/Operation.h" @@ -233,9 +233,9 @@ void ObjectValueType::print(Context &context, raw_ostream &os, bool brief) { } void Constraint::print(Context &context, raw_ostream &os, bool brief) { - from->print(context, os, brief); + from->print(context, os, true); os << " <: "; - to->print(context, os, brief); + to->print(context, os, true); if (!brief && contextOp) { os << "\n " << *contextOp; } diff --git a/lib/Typing/CMakeLists.txt b/lib/Typing/CMakeLists.txt index fd2a3eae4..fc6ef10fa 100644 --- a/lib/Typing/CMakeLists.txt +++ b/lib/Typing/CMakeLists.txt @@ -1 +1 @@ -add_subdirectory(CPA) +add_subdirectory(Analysis)