[mach-o] refactor KindHandler into ArchHandler and simplify passes.

All architecture specific handling is now done in the appropriate
ArchHandler subclass.

The StubsPass and GOTPass have been simplified.  All architecture specific
variations in stubs are now encoded in a table which is vended by the
current ArchHandler.

llvm-svn: 213187
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
index 3befd6a..0a30680 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
@@ -21,8 +21,10 @@
 ///                    +-------+
 
 #include "MachONormalizedFile.h"
+
+#include "ArchHandler.h"
 #include "MachONormalizedFileBinaryUtils.h"
-#include "ReferenceKinds.h"
+
 #include "lld/Core/Error.h"
 #include "lld/Core/LLVM.h"
 #include "llvm/ADT/StringRef.h"
@@ -542,7 +544,7 @@
         // FIXME: Need a handler method to update content for .o file
         // output and any needed section relocations.
       } else {
-        _context.kindHandler().applyFixup(
+        _context.archHandler().applyFixup(
           ref->kindNamespace(), ref->kindArch(), ref->kindValue(),
           ref->addend(), &atomContent[offset], fixupAddress, targetAddress,
           atomAddress);
@@ -713,7 +715,7 @@
 
 const Atom *Util::targetOfLazyPointer(const DefinedAtom *lpAtom) {
   for (const Reference *ref : *lpAtom) {
-    if (_context.kindHandler().isLazyTarget(*ref)) {
+    if (_context.archHandler().isLazyPointer(*ref)) {
       return ref->target();
     }
   }
@@ -871,7 +873,7 @@
         uint64_t segmentOffset = _atomToAddress[atom] + ref->offsetInAtom()
                                 - segmentStartAddr;
         const Atom* targ = ref->target();
-        if (_context.kindHandler().isPointer(*ref)) {
+        if (_context.archHandler().isPointer(*ref)) {
           // A pointer to a DefinedAtom requires rebasing.
           if (dyn_cast<DefinedAtom>(targ)) {
             RebaseLocation rebase;
@@ -893,7 +895,7 @@
             nFile.bindingInfo.push_back(bind);
           }
         }
-        if (_context.kindHandler().isLazyTarget(*ref)) {
+        if (_context.archHandler().isLazyPointer(*ref)) {
             BindLocation bind;
             bind.segIndex = segmentIndex;
             bind.segOffset = segmentOffset;