llvm.org GIT mirror llvm / 4a42909
[globalisel][tablegen] Add support for RegisterOperand. Summary: It functions just like RegisterClass except that the class is obtained from a field. Depends on D31761. Reviewers: ab, qcolombet, t.p.northover, rovka, kristof.beyls, aditya_nandakumar Reviewed By: ab Subscribers: dberris, llvm-commits, igorb Differential Revision: https://reviews.llvm.org/D32229 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301080 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Sanders 3 years ago
2 changed file(s) with 12 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
88
99 def R0 : Register<"r0"> { let Namespace = "MyTarget"; }
1010 def GPR32 : RegisterClass<"MyTarget", [i32], 32, (add R0)>;
11 def GPR32Op : RegisterOperand;
1112
1213 class I Pat>
1314 : Instruction {
9091 // CHECK-NEXT: }
9192
9293 def : GINodeEquiv;
93 def INSN2 : I<(outs GPR32:$dst), (ins GPR32:$src1, complex:$src2, complex:$src3), []>;
94 def INSN2 : I<(outs GPR32:$dst), (ins GPR32Op:$src1, complex:$src2, complex:$src3), []>;
9495 def : Pat<(select GPR32:$src1, complex:$src2, complex:$src3),
9596 (INSN2 GPR32:$src1, complex:$src3, complex:$src2)>;
9697
13831383 return Error::success();
13841384 }
13851385
1386 if (ChildRec->isSubClassOf("RegisterOperand")) {
1387 OM.addPredicate(
1388 Target.getRegisterClass(ChildRec->getValueAsDef("RegClass")));
1389 return Error::success();
1390 }
1391
13861392 // Check for ComplexPattern's.
13871393 if (ChildRec->isSubClassOf("ComplexPattern")) {
13881394 const auto &ComplexPattern = ComplexPatternEquivs.find(ChildRec);
14461452 return Error::success();
14471453 }
14481454
1449 if (ChildRec->isSubClassOf("RegisterClass")) {
1455 if (ChildRec->isSubClassOf("RegisterClass") ||
1456 ChildRec->isSubClassOf("RegisterOperand")) {
14501457 DstMIBuilder.addRenderer(InsnMatcher, DstChild->getName());
14511458 return Error::success();
14521459 }
16131620
16141621 const auto &DstIOperand = DstI.Operands[OpIdx];
16151622 Record *DstIOpRec = DstIOperand.Rec;
1623 if (DstIOpRec->isSubClassOf("RegisterOperand"))
1624 DstIOpRec = DstIOpRec->getValueAsDef("RegClass");
16161625 if (!DstIOpRec->isSubClassOf("RegisterClass"))
16171626 return failedImport("Dst MI def isn't a register class");
16181627