This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Implement instruction selection for constant offsets in addresses.
ClosedPublic

Authored by sunfish on Dec 15 2015, 12:20 PM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

sunfish updated this revision to Diff 42889.Dec 15 2015, 12:20 PM
sunfish retitled this revision from to [WebAssembly] Implement instruction selection for constant offsets in addresses..
sunfish updated this object.
sunfish set the repository for this revision to rL LLVM.
sunfish added subscribers: jfb, dschuff, llvm-commits.
dschuff accepted this revision.Dec 15 2015, 1:21 PM
dschuff added a reviewer: dschuff.
dschuff added inline comments.
test/CodeGen/WebAssembly/offset.ll
1 ↗(On Diff #42889)

I guess we don't need complete coverage of every new case in the tbglen (or do we?) but we should probably also have at least one or two of extload , zextload, sextload, truncstore too.

This revision is now accepted and ready to land.Dec 15 2015, 1:21 PM
This revision was automatically updated to reflect the committed changes.
sunfish marked an inline comment as done.Dec 15 2015, 2:06 PM
sunfish added inline comments.
test/CodeGen/WebAssembly/offset.ll
1 ↗(On Diff #42889)

I'll add more coverage when I fix the getelementptr issue and we can have more realistic testcases and not just inttoptr/ptrtoint. You're right though that it's good to have some coverage of the extending loads and truncating stores now; I added those now.