[WebAssembly] Implement instruction selection for constant offsets in addresses.
authorDan Gohman <dan433584@gmail.com>
Tue, 15 Dec 2015 22:01:29 +0000 (22:01 +0000)
committerDan Gohman <dan433584@gmail.com>
Tue, 15 Dec 2015 22:01:29 +0000 (22:01 +0000)
commit3768c07818ad882f8bcc97e0fb35e358fd799b27
treef72b2e0cb5797f0dd04c15301800c7fff30c2456
parent7284c4e48db8c0fd6d5a7f8ca3db448c2f813a54
[WebAssembly] Implement instruction selection for constant offsets in addresses.

Add instruction patterns for matching load and store instructions with constant
offsets in addresses. The code is fairly redundant due to the need to replicate
everything between imm, tglobaldadr, and texternalsym, but this appears to be
common tablegen practice. The main alternative appears to be to introduce
matching functions with C++ code, but sticking with purely generated matchers
seems better for now.

Also note that this doesn't yet support offsets from getelementptr, which will
be the most common case; that will depend on a change in target-independent code
in order to set the NoUnsignedWrap flag, which I'll submit separately. Until
then, the testcase uses ptrtoint+add+inttoptr with a nuw on the add.

Also implement isLegalAddressingMode with an approximation of this.

Differential Revision: http://reviews.llvm.org/D15538

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255681 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/WebAssembly/README.txt
lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
lib/Target/WebAssembly/WebAssemblyISelLowering.h
lib/Target/WebAssembly/WebAssemblyInstrMemory.td
test/CodeGen/WebAssembly/global.ll
test/CodeGen/WebAssembly/offset.ll [new file with mode: 0644]
test/CodeGen/WebAssembly/store-results.ll