llvm.org GIT mirror llvm / 6ca659a
[ARM GlobalISel] Make arm_i32imm an IntImmLeaf This gets rid of some duplication in the TableGen definition, but it forces us to keep both a pointer and a reference to the subtarget in the ARMInstructionSelector. That is pretty ugly but it might be a reasonable trade-off, since the TableGen descriptions should outlive the code in the selector (or in the worst case we can update to use just the reference when we get rid of DAGISel). Differential Revision: https://reviews.llvm.org/D58031 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355083 91177308-0d34-0410-b5e6-96231b3b80d8 Diana Picus 1 year, 7 months ago
2 changed file(s) with 8 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
716716 }
717717
718718 /// arm_i32imm - True for +V6T2, or when isSOImmTwoParVal()
719 def arm_i32imm : PatLeaf<(imm), [{
719 def arm_i32imm : IntImmLeaf, [{
720720 if (Subtarget->useMovt())
721721 return true;
722 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
723 }]> {
724 // Ideally this would be an IntImmLeaf, but then we wouldn't have access to
725 // the MachineFunction.
726 let GISelPredicateCode = [{
727 if (STI.useMovt())
728 return true;
729
730 const auto &MO = MI.getOperand(1);
731 if (!MO.isCImm())
732 return false;
733 return ARM_AM::isSOImmTwoPartVal(MO.getCImm()->getZExtValue());
734 }];
735 }
722 return ARM_AM::isSOImmTwoPartVal(Imm.getZExtValue());
723 }]>;
736724
737725 /// imm0_1 predicate - Immediate in the range [0,1].
738726 def Imm0_1AsmOperand: ImmAsmOperand<0,1> { let Name = "Imm0_1"; }
7373 const ARMBaseTargetMachine &TM;
7474 const ARMRegisterBankInfo &RBI;
7575 const ARMSubtarget &STI;
76
77 // FIXME: This is necessary because DAGISel uses "Subtarget->" and GlobalISel
78 // uses "STI." in the code generated by TableGen. If we want to reuse some of
79 // the custom C++ predicates written for DAGISel, we need to have both around.
80 const ARMSubtarget *Subtarget = &STI;
7681
7782 // Store the opcodes that we might need, so we don't have to check what kind
7883 // of subtarget (ARM vs Thumb) we have all the time.