Subzero: Emit functions and global initializers in a separate thread.

(This is a continuation of https://codereview.chromium.org/876083007/ .)

Emission is done in a separate thread when -threads=N with N>0 is specified.  This includes both functions and global initializers.

Emission is deterministic.  The parser assigns sequence numbers, and the emitter thread reassembles work units into their original order, regardless of the number of threads.

Dump output, however, is not intended to be in deterministic, reassembled order.  As such, lit tests that test dump output (i.e., '-verbose inst') are explicitly run with -threads=0.

For -elf-writer and -ias=1, the translator thread invokes Cfg::emitIAS() and the assembler buffer is passed to the emitter thread.  For -ias=0, the translator thread passed the Cfg to the emitter thread which then invokes Cfg::emit() to produce the textual asm.

Minor cleanup along the way:
  * Removed Flags from the Ice::Translator object and ctor, since it was redundant with Ctx->getFlags().
  * Cfg::getAssembler<> is the same as Cfg::getAssembler<Assembler> and is useful for just passing the assembler around.
  * Removed the redundant Ctx argument from TargetDataLowering::lowerConstants() .

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4075
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/916653004
diff --git a/src/IceTranslator.h b/src/IceTranslator.h
index 6b35b25..bc9a933 100644
--- a/src/IceTranslator.h
+++ b/src/IceTranslator.h
@@ -34,14 +34,14 @@
   Translator &operator=(const Translator &) = delete;
 
 public:
-  Translator(GlobalContext *Ctx, const ClFlags &Flags);
+  Translator(GlobalContext *Ctx);
 
   ~Translator();
   const ErrorCode &getErrorStatus() const { return ErrorStatus; }
 
   GlobalContext *getContext() const { return Ctx; }
 
-  const ClFlags &getFlags() const { return Flags; }
+  const ClFlags &getFlags() const { return Ctx->getFlags(); }
 
   /// Translates the constructed ICE function Fcn to machine code.
   /// Takes ownership of Func.
@@ -56,7 +56,8 @@
 
   /// Lowers the given list of global addresses to target. Generates
   /// list of corresponding variable declarations.
-  void lowerGlobals(const VariableDeclarationList &VariableDeclarations);
+  void
+  lowerGlobals(std::unique_ptr<VariableDeclarationList> VariableDeclarations);
 
   /// Creates a name using the given prefix and corresponding index.
   std::string createUnnamedName(const IceString &Prefix, SizeT Index);
@@ -67,10 +68,11 @@
   bool checkIfUnnamedNameSafe(const IceString &Name, const char *Kind,
                               const IceString &Prefix);
 
+  uint32_t getNextSequenceNumber() { return NextSequenceNumber++; }
+
 protected:
   GlobalContext *Ctx;
-  const ClFlags &Flags;
-  std::unique_ptr<TargetDataLowering> DataLowering;
+  uint32_t NextSequenceNumber;
   // Exit status of the translation. False is successful. True otherwise.
   ErrorCode ErrorStatus;
 };