Add completely untested support for mtcrf/mfcrf encoding
[oota-llvm.git] / lib / Target / SparcV9 / InternalGlobalMapper.cpp
index 0cd2faa7c31febc097d10e7b9f1d5d880beb43b6..280c836f338c47a3c85a0aa5b8e61566c7f1a778 100644 (file)
 #include "llvm/Constants.h"
 #include "llvm/Module.h"
 #include "llvm/Pass.h"
-#include "llvm/Type.h"
 #include "llvm/DerivedTypes.h"
 using namespace llvm;
 
-namespace llvm {
-
 typedef std::vector<Constant *> GVVectorTy;
 
-class InternalGlobalMapper : public Pass {
-public:
-  bool run (Module &M);
-};
+namespace {
+  struct InternalGlobalMapper : public ModulePass {
+    bool runOnModule(Module &M);
+  };
+}
 
-Pass *llvm::createInternalGlobalMapperPass () {
-  return new InternalGlobalMapper ();
+namespace llvm {
+  ModulePass *createInternalGlobalMapperPass() {
+    return new InternalGlobalMapper();
+  }
 }
 
 static void maybeAddInternalValueToVector (GVVectorTy &Vector, GlobalValue &GV){
@@ -41,18 +41,18 @@ static void maybeAddInternalValueToVector (GVVectorTy &Vector, GlobalValue &GV){
   // be mangled), then put the GV, casted to sbyte*, in the vector. Otherwise
   // add a null.
   if (GV.hasInternalLinkage () && GV.hasName ())
-    Vector.push_back (ConstantExpr::getCast
-      (&GV, PointerType::get (Type::SByteTy)));
+    Vector.push_back(ConstantExpr::getCast(&GV,
+                                           PointerType::get(Type::SByteTy)));
   else
     Vector.push_back (ConstantPointerNull::get (PointerType::get
                                                 (Type::SByteTy)));
 }
 
-bool InternalGlobalMapper::run (Module &M) {
+bool InternalGlobalMapper::runOnModule(Module &M) {
   GVVectorTy gvvector;
 
   // Populate the vector with internal global values and their names.
-  for (Module::giterator i = M.gbegin (), e = M.gend (); i != e; ++i)
+  for (Module::global_iterator i = M.global_begin (), e = M.global_end (); i != e; ++i)
     maybeAddInternalValueToVector (gvvector, *i);
   // Add an extra global for _llvm_internalGlobals itself (null,
   // because it's not internal)
@@ -80,5 +80,3 @@ bool InternalGlobalMapper::run (Module &M) {
 
   return true; // Module was modified.
 }
-
-} // end namespace llvm