-
ARM: Add a postRA pass to legalize stack offsets. Greedy approach (reserve IP). · 28068adbJan Voung authored
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 .
28068adb
×