OSDN Git Service

[globalisel][tablegen] Import signextload and zeroextload.
authorDaniel Sanders <daniel_l_sanders@apple.com>
Sat, 11 Nov 2017 03:23:44 +0000 (03:23 +0000)
committerDaniel Sanders <daniel_l_sanders@apple.com>
Sat, 11 Nov 2017 03:23:44 +0000 (03:23 +0000)
commit8f5a591f296730b64bb1932ab345d7180ee6314f
treef5b01e302a7ee82b22bc0ebc859ff14f7a0dd449
parent975df6ffda009b7d2d1a00456fbc4b476212b7ea
[globalisel][tablegen] Import signextload and zeroextload.

Allow a pattern rewriter to be installed in CodeGenDAGPatterns and use it to
correct situations where SelectionDAG and GlobalISel disagree on
representation. For example, it would rewrite:
  (sextload:i32 $ptr)<<unindexedload>><<sextload>><<sextloadi16>
to:
  (sext:i32 (load:i16 $ptr)<<unindexedload>>)

I'd have preferred to replace the fragments and have the expansion happen
naturally as part of PatFrag expansion but the type inferencing system can't
cope with loads of types narrower than those mentioned in register classes.
This is because the SDTCisInt's on the sext constrain both the result and
operand to the 'legal' integer types (where legal is defined as 'a register
class can contain the type') which immediately rules the narrower types out.
Several targets (those with only one legal integer type) would then go on to
crash on the SDTCisOpSmallerThanOp<> when it removes all the possible types
for the result of the extend.

Also, improve isObviouslySafeToFold() slightly to automatically return true for
neighbouring instructions. There can't be any re-ordering problems if
re-ordering isn't happenning. We'll need to improve it further to handle
sign/zero-extending loads when the extend and load aren't immediate neighbours
though.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317971 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/CodeGen/GlobalISel/InstructionSelector.h
include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h
lib/CodeGen/GlobalISel/InstructionSelector.cpp
test/CodeGen/AArch64/GlobalISel/select-load.mir
test/TableGen/GlobalISelEmitter.td
utils/TableGen/CodeGenDAGPatterns.cpp
utils/TableGen/CodeGenDAGPatterns.h
utils/TableGen/GlobalISelEmitter.cpp