OSDN Git Service

Move lowerGlobal() from target-specific code to emitGlobal() in generic code.
authorJan Voung <jvoung@chromium.org>
Mon, 15 Jun 2015 22:11:56 +0000 (15:11 -0700)
committerJan Voung <jvoung@chromium.org>
Mon, 15 Jun 2015 22:11:56 +0000 (15:11 -0700)
commit58eea4d1c41d4783aadc7ff489029cffdbd38f78
treef64c2e43160dc0e4f837355306d7e06c4f2dd19a
parent0f86d03ca2e44639ba03c659413f39eedcc75541
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.
src/IceTargetLowering.cpp
src/IceTargetLowering.h
src/IceTargetLoweringARM32.cpp
src/IceTargetLoweringARM32.h
src/IceTargetLoweringMIPS32.cpp
src/IceTargetLoweringMIPS32.h
src/IceTargetLoweringX8632.cpp
src/IceTargetLoweringX8632.h
tests_lit/llvm2ice_tests/globalinit.pnacl.ll
tests_lit/llvm2ice_tests/globalrelocs.ll