Skip to content

Commit cf0ff63

Browse files
committedFeb 28, 2019
[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 llvm-svn: 355083
1 parent 5306a71 commit cf0ff63

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed
 

‎llvm/lib/Target/ARM/ARMInstrInfo.td

+3-15
Original file line numberDiff line numberDiff line change
@@ -717,23 +717,11 @@ def mod_imm_neg : Operand<i32>, PatLeaf<(imm), [{
717717
}
718718

719719
/// arm_i32imm - True for +V6T2, or when isSOImmTwoParVal()
720-
def arm_i32imm : PatLeaf<(imm), [{
720+
def arm_i32imm : IntImmLeaf<i32, [{
721721
if (Subtarget->useMovt())
722722
return true;
723-
return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
724-
}]> {
725-
// Ideally this would be an IntImmLeaf, but then we wouldn't have access to
726-
// the MachineFunction.
727-
let GISelPredicateCode = [{
728-
if (STI.useMovt())
729-
return true;
730-
731-
const auto &MO = MI.getOperand(1);
732-
if (!MO.isCImm())
733-
return false;
734-
return ARM_AM::isSOImmTwoPartVal(MO.getCImm()->getZExtValue());
735-
}];
736-
}
723+
return ARM_AM::isSOImmTwoPartVal(Imm.getZExtValue());
724+
}]>;
737725

738726
/// imm0_1 predicate - Immediate in the range [0,1].
739727
def Imm0_1AsmOperand: ImmAsmOperand<0,1> { let Name = "Imm0_1"; }

‎llvm/lib/Target/ARM/ARMInstructionSelector.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ class ARMInstructionSelector : public InstructionSelector {
7575
const ARMRegisterBankInfo &RBI;
7676
const ARMSubtarget &STI;
7777

78+
// FIXME: This is necessary because DAGISel uses "Subtarget->" and GlobalISel
79+
// uses "STI." in the code generated by TableGen. If we want to reuse some of
80+
// the custom C++ predicates written for DAGISel, we need to have both around.
81+
const ARMSubtarget *Subtarget = &STI;
82+
7883
// Store the opcodes that we might need, so we don't have to check what kind
7984
// of subtarget (ARM vs Thumb) we have all the time.
8085
struct OpcodeCache {

0 commit comments

Comments
 (0)
Please sign in to comment.