Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Hi Eugene,
could you please upload a diff with the full context?
Do you know why isAddrMode3OpMinusReg and isAddrMode3OpImm are not declared as static members of ARMBaseInstrInfo?
It seems to me that those should be static. I am asking this question because there may be better ways to implement this patch without having to touch the predicate expander.
Most of the checks performed by those predicates are just checking if operands are registers or specific immediate values. We already have specialised predicates for describing constraints on register operands and immediate operands. I would personally use CheckFunctionPredicate only as a last resort, if there is no other way to express the same predicate.
@andreadb Makes sense. Let's try AArch64-like approach for this case. I've updated patch to handle just IsLdrAm3RegOffPred
llvm/lib/Target/ARM/ARMScheduleA57.td | ||
---|---|---|
31–34 | It seems to me that the original intent of isAddrMode3OpImm is to check if an operand is NOT the invalid register. isAddrMode3OpImm also seems to require that the operand must be a register (otherwise the getReg() would have trigger an assertion failure - since isReg() would have returned false). CheckIsRegOperand(idx) is simply testing if the operand at index idx is a register. However, it doesn't check the actual value of that register. You should be able to use CheckInvalidRegOperand. That being said, in the original code, the return value from isAddrMode3OpImm is also negated (example): !TII->isAddrMode3OpImm(*MI, 1) Assuming that my understanding of the code is correct, I guess that you should be able to just use a simple CheckInvalidRegOperand in your case. |
llvm/lib/Target/ARM/ARMScheduleA57.td | ||
---|---|---|
31–34 | There is not operator in the original code {!TII->isAddrMode3OpImm(*MI, 1)} which I forgot about :(. I'll update the diff shortly |
Thanks!
I cannot comment on the mca numbers (I leave that part of the review to @dmgreen).
The changes to the predicates look good to me.
As a side note (unrelated to this patch):
If in future you plan to rewrite isAddrMode3OpMinusReg, then I suggest you to have a look at TIIPredicate.
Note also that CheckImmOperand_s can be used to define predicates like this:
MyFunction(MI->getOperand(Index).getImm()) == Val
(see for example the code comments for CheckOperandBase in TargetInstrPredicate.td).
It seems to me that the original intent of isAddrMode3OpImm is to check if an operand is NOT the invalid register.
isAddrMode3OpImm also seems to require that the operand must be a register (otherwise the getReg() would have trigger an assertion failure - since isReg() would have returned false).
CheckIsRegOperand(idx) is simply testing if the operand at index idx is a register. However, it doesn't check the actual value of that register.
You should be able to use CheckInvalidRegOperand.
Basically, the original implementation is equivalent to:
CheckNot<CheckInvalidRegOperand<index>>.
That being said, in the original code, the return value from isAddrMode3OpImm is also negated (example):
Assuming that my understanding of the code is correct, I guess that you should be able to just use a simple CheckInvalidRegOperand in your case.