OSDN Git Service

ARM: Add a postRA pass to legalize stack offsets. Greedy approach (reserve IP).
authorJan Voung <jvoung@chromium.org>
Fri, 31 Jul 2015 19:58:46 +0000 (12:58 -0700)
committerJan Voung <jvoung@chromium.org>
Fri, 31 Jul 2015 19:58:46 +0000 (12:58 -0700)
commit28068adbf34a4602090efddc18b4dd123ffdeb6a
treef17baf225e28eee23ef0319fe9f2dd8dfbc3a6d2
parent969f6a33c32f9e7197672fbc911918589f5218bd
ARM: Add a postRA pass to legalize stack offsets. Greedy approach (reserve IP).

Make a post-register allocation and post-addProlog pass to
go through variables with stack offsets and legalize them
in case the offsets are not encodeable. The naive approach
is to reserve IP, and use IP to movw/movt the offset, then
add/sub the frame/stack pointer to IP and use IP as the new
base instead of the frame/stack pointer. We do some amount
of CSE within a basic block, and share the IP base pointer
when it is (a) within range for later stack references,
and (b) IP hasn't been clobbered (e.g., by a function call).
I chose to do this greedy approach for both Om1 and O2,
since it should just be a linear pass, and it reduces the
amount of variables/instructions created compared to the
super-naive peephole approach (so might be faster?).

Introduce a test-only flag and use that to artificially
bloat the stack frame so that spill offsets are out
of range for ARM. Use that flag for cross tests to
stress this new code a bit more (than would have been
stressed by simply doing a lit test + FileCheck).

Also, the previous version of emitVariable() was using the
Var's type to determine the range (only +/- 255 for i16,
vs +/- 4095 for i32), even though mov's emit() always
uses a full 32-bit "ldr" instead of a 16-bit "ldrh".
Use a common legality check, which uses the stackSlotType
instead of the Var's type. This previously caused the
test_bitmanip to spuriously complain, even though the
offsets for Om1 were "only" in the 300 byte range. With this
fixed, we can then enable the test_bitmanip test too.

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

Review URL: https://codereview.chromium.org/1241763002 .
17 files changed:
Makefile.standalone
pydir/crosstest.py
src/IceCfg.h
src/IceClFlags.cpp
src/IceClFlags.h
src/IceInstARM32.cpp
src/IceInstARM32.def
src/IceInstARM32.h
src/IceOperand.cpp
src/IceOperand.h
src/IceTargetLowering.cpp
src/IceTargetLowering.h
src/IceTargetLoweringARM32.cpp
src/IceTargetLoweringARM32.h
src/IceTargetLoweringMIPS32.cpp
src/IceTargetLoweringX86BaseImpl.h
tests_lit/llvm2ice_tests/large_stack_offs.ll [new file with mode: 0644]