This is an archive of the discontinued LLVM Phabricator instance.

TII: add hook getInstrOperandImmValue.
AbandonedPublic

Authored by SjoerdMeijer on Nov 29 2016, 12:34 AM.

Details

Summary

TII: add hook getInstrOperandImmValue. This is refactored from the Hexagon backend, which has been changed accordingly; this is change is intended to be NFC. This target hook is some more groundwork for recognising loop induction statement and trip counts for MachineLoops.

Diff Detail

Event Timeline

SjoerdMeijer retitled this revision from to TII: add hook getInstrOperandImmValue..
SjoerdMeijer updated this object.
SjoerdMeijer added a subscriber: llvm-commits.
qcolombet added inline comments.Nov 30 2016, 1:31 PM
include/llvm/Target/TargetInstrInfo.h
1144

MI is probably useless given it is accessible through MO.getParent(), unless it represents something else and in that case it must be documented.

1144

Val should probably be an APInt.

1144

If this is a compile time known constant, why this is not directly MO_Immediate?
What am I saying is in which cases do we need that API?

kparzysz added inline comments.Nov 30 2016, 1:36 PM
include/llvm/Target/TargetInstrInfo.h
1144

The intent was to evaluate the value of the operand at compile-time: for immediate operands that is trivial, for registers the function would look up their definitions, etc.

qcolombet added inline comments.Dec 20 2016, 2:04 PM
include/llvm/Target/TargetInstrInfo.h
1144

I see.
One thing that you didn't address is why does the API have both MI and MO?

arsenm added a subscriber: arsenm.Dec 20 2016, 2:27 PM
arsenm added inline comments.
include/llvm/Target/TargetInstrInfo.h
1144

I thought there was a vague desire to remove the parent from MachineOperands someday to save memory

SjoerdMeijer added inline comments.Dec 21 2016, 7:44 AM
include/llvm/Target/TargetInstrInfo.h
1144

I think I added the MI here (so that the API has both the MI and MO). But for no real good reason, other than perhaps consistency that most TII functions take a MI. Will remove it from since MO->getParent() will also give access to it.

SjoerdMeijer abandoned this revision.Jan 16 2017, 9:09 AM

Abandoning as the approach is not generic enough, see also https://reviews.llvm.org/D27193