Iasm and obj lowering for advanced switch lowering.

Jump table emission is delayed until offsets are known. X86 local jumps can be
near or far. Sanboxing is applied to indirect jumps from jump table.

BUG=
R=stichnot@chromium.org, jvoung

Review URL: https://codereview.chromium.org/1257283004.
diff --git a/src/IceGlobalContext.h b/src/IceGlobalContext.h
index d19249d..acef4c5 100644
--- a/src/IceGlobalContext.h
+++ b/src/IceGlobalContext.h
@@ -20,6 +20,7 @@
 #include "IceClFlags.h"
 #include "IceIntrinsics.h"
 #include "IceRNG.h"
+#include "IceSwitchLowering.h"
 #include "IceThreading.h"
 #include "IceTimerTree.h"
 #include "IceTypes.h"
@@ -55,6 +56,7 @@
   }
   ~LockedPtr() { Lock->unlock(); }
   T *operator->() const { return Value; }
+  T &operator*() const { return *Value; }
 
 private:
   T *Value;
@@ -209,6 +211,13 @@
   /// Returns a copy of the list of external symbols.
   ConstantList getConstantExternSyms();
 
+  /// Return a locked pointer to the registered jump tables.
+  LockedPtr<JumpTableDataList> getJumpTables() {
+    return LockedPtr<JumpTableDataList>(&JumpTables, &JumpTablesLock);
+  }
+  /// Create a new jump table entry and return a reference to it.
+  JumpTableData &addJumpTable(IceString FuncName, SizeT Id, SizeT NumTargets);
+
   const ClFlags &getFlags() const { return Flags; }
 
   bool isIRGenerationDisabled() const {
@@ -335,6 +344,8 @@
 
   void lowerConstants();
 
+  void lowerJumpTables();
+
   void emitQueueBlockingPush(EmitterWorkItem *Item);
   EmitterWorkItem *emitQueueBlockingPop();
   void emitQueueNotifyEnd() { EmitQ.notifyEnd(); }
@@ -456,6 +467,11 @@
   std::unique_ptr<ConstantPool> ConstPool;
 
   ICE_CACHELINE_BOUNDARY;
+  // Managed by getJumpTables()
+  GlobalLockType JumpTablesLock;
+  JumpTableDataList JumpTables;
+
+  ICE_CACHELINE_BOUNDARY;
   // Managed by getErrorStatus()
   GlobalLockType ErrorStatusLock;
   ErrorCode ErrorStatus;