[llvm] [MachineVerifier] Query TargetInstrInfo for PHI nodes. (PR #110507)
Vyacheslav Levytskyy via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 29 06:46:05 PDT 2024
Nathan =?utf-8?q?Gau=C3=ABr?= <brioche at google.com>,
Nathan =?utf-8?q?Gau=C3=ABr?= <brioche at google.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/110507 at github.com>
================
@@ -2278,6 +2278,32 @@ class TargetInstrInfo : public MCInstrInfo {
llvm_unreachable("unknown number of operands necessary");
}
+ // This this instruction a PHI node.
+ // This function should be favored over MI.isPHI() as it allows backends to
+ // define additional PHI instructions.
+ virtual bool isPhiInstr(const MachineInstr &MI) const {
+ return MI.getOpcode() == TargetOpcode::G_PHI ||
+ MI.getOpcode() == TargetOpcode::PHI;
+ }
+
+ // Returns the number of [Value, Src] pairs this phi instruction has.
+ // Only valid to call on a phi node.
+ virtual unsigned getNumPhiIncomingPair(const MachineInstr &MI) const {
+ assert(isPhiInstr(MI));
+ // G_PHI/PHI only have a single operand before the pairs. 2 Operands per
+ // pair.
+ return (MI.getNumOperands() - 1) / 2;
----------------
VyacheslavLevytskyy wrote:
or `>> 1` ?
https://github.com/llvm/llvm-project/pull/110507
More information about the llvm-commits
mailing list