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/IceTargetLowering.h b/src/IceTargetLowering.h
index 2dda5c5..92eed51 100644
--- a/src/IceTargetLowering.h
+++ b/src/IceTargetLowering.h
@@ -7,11 +7,14 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// This file declares the TargetLowering and LoweringContext
-// classes.  TargetLowering is an abstract class used to drive the
-// translation/lowering process.  LoweringContext maintains a
-// context for lowering each instruction, offering conveniences such
-// as iterating over non-deleted instructions.
+// This file declares the TargetLowering, LoweringContext, and
+// TargetDataLowering classes.  TargetLowering is an abstract class
+// used to drive the translation/lowering process.  LoweringContext
+// maintains a context for lowering each instruction, offering
+// conveniences such as iterating over non-deleted instructions.
+// TargetDataLowering is an abstract class used to drive the
+// lowering/emission of global initializers, external global
+// declarations, and internal constant pools.
 //
 //===----------------------------------------------------------------------===//
 
@@ -247,12 +250,12 @@
   TargetDataLowering &operator=(const TargetDataLowering &) = delete;
 
 public:
-  static TargetDataLowering *createLowering(GlobalContext *Ctx);
+  static std::unique_ptr<TargetDataLowering> createLowering(GlobalContext *Ctx);
   virtual ~TargetDataLowering();
 
-  virtual void lowerGlobal(const VariableDeclaration &Var) const = 0;
-  virtual void lowerGlobalsELF(const VariableDeclarationList &Vars) const = 0;
-  virtual void lowerConstants(GlobalContext *Ctx) const = 0;
+  virtual void
+  lowerGlobals(std::unique_ptr<VariableDeclarationList> Vars) const = 0;
+  virtual void lowerConstants() const = 0;
 
 protected:
   TargetDataLowering(GlobalContext *Ctx) : Ctx(Ctx) {}