From 3dd5de267ae8650b168f3a856b21f639d3283480 Mon Sep 17 00:00:00 2001
From: Yoshiki Vazquez-baeza <y1vazque@ucsd.edu>
Date: Sat, 5 Dec 2015 15:49:51 -0800
Subject: [PATCH] Add constant propagation pass file

---
 llvm/src/lib/CSE231/CPAnalysis.cpp | 53 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 llvm/src/lib/CSE231/CPAnalysis.cpp

diff --git a/llvm/src/lib/CSE231/CPAnalysis.cpp b/llvm/src/lib/CSE231/CPAnalysis.cpp
new file mode 100644
index 0000000..be40036
--- /dev/null
+++ b/llvm/src/lib/CSE231/CPAnalysis.cpp
@@ -0,0 +1,53 @@
+//===- CPAnalysis.cpp
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the constant propagation analysis.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/Instruction.h"
+#include "llvm/Pass.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/InstIterator.h"
+using namespace llvm;
+
+namespace {
+
+    struct CPAnalysis : public ModulePass {
+        static char ID;
+
+        CPAnalysis() : ModulePass(ID) {}
+
+        virtual bool runOnModule(Module &M) {
+            unsigned opcode;
+            IRBuilder<> builder(M.getContext());
+
+            // Iterating over all the functions in the module
+            for (Module::iterator FB = M.begin(), FE = M.end(); FB != FE; ++FB) {
+
+                // get the list to work
+                // Worklist(LatticeDefinition, FB, LatticeDefinition.Top());
+
+            }
+
+            // we are not modifying the code so return False
+            return false;
+        }
+
+    };
+}
+
+char CPAnalysis::ID = 0;
+static RegisterPass<CPAnalysis> X("constant-propagation-analysis", "Analyze all the functions in a module with a constant propagation lattice");
+
-- 
1.9.1