Move lowerGlobal() from target-specific code to emitGlobal() in generic code.

Emitting the global initializers is mostly the same across
each architecture (same filling, alignment, etc.). The only difference
is in assembler-directive quirks. E.g., on ARM for ".align N" N is
the exponent for a power of 2, while on x86 N is the actual number
of bytes. To avoid target-specific directives, use .p2align which
is always a power of 2. Similarly, use % instead of @. Either one
may be a comment character for *some* architecture, but for the
architectures we care about % is not a comment character while @
is sometimes (ARM).

Usually MIPS uses ".space N" for ".zero", but the assembler seems
to accept ".zero" so don't change that for now.

May need to adjust .long in the future too.
.word for AArch64 and .4byte for MIPS?

Potentially we can refactor the lowerGlobals() dispatcher
(ELF vs ASM vs IASM). The only thing target-specific about that
is *probably* just the relocation type.

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

Review URL: https://codereview.chromium.org/1188603002.
diff --git a/src/IceTargetLowering.h b/src/IceTargetLowering.h
index 66e663b..4d9598a 100644
--- a/src/IceTargetLowering.h
+++ b/src/IceTargetLowering.h
@@ -384,6 +384,13 @@
   virtual void lowerConstants() = 0;
 
 protected:
+  void emitGlobal(const VariableDeclaration &Var);
+
+  // For now, we assume .long is the right directive for emitting 4 byte
+  // emit global relocations. However, LLVM MIPS usually uses .4byte instead.
+  // Perhaps there is some difference when the location is unaligned.
+  const char *getEmit32Directive() { return ".long"; }
+
   explicit TargetDataLowering(GlobalContext *Ctx) : Ctx(Ctx) {}
   GlobalContext *Ctx;
 };