[llvm] [GlobalISel] Add GIHasOneUse builtin for combiner match patterns (PR #221804)
Deepak Shirke via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 10 06:51:31 PDT 2026
================
@@ -69,6 +69,29 @@ bool PatternParser::parsePatternList(
continue;
}
+ if (const auto *DagArg = dyn_cast<DagInit>(Arg)) {
+ if (DagArg->getOperatorAsDef(DiagLoc)->getName() == "GIHasOneUse") {
+ if (DagArg->getNumArgs() != 1) {
+ PrintError(DiagLoc,
+ "GIHasOneUse expects exactly one instruction argument");
+ return false;
+ }
+ if (auto Pat = parseInstructionPattern(*DagArg->getArg(0), Name)) {
+ if (auto *CGP = dyn_cast<CodeGenInstructionPattern>(Pat.get()))
+ CGP->setHasOneUse();
+ else {
+ PrintError(
+ DiagLoc,
+ "GIHasOneUse can only wrap a CodeGenInstruction pattern");
----------------
deepakshirkem wrote:
Added error case tests. Thank You
https://github.com/llvm/llvm-project/pull/221804
More information about the llvm-commits
mailing list