Skip to content

Commit 967e164

Browse files
committed
CodeGen: Remove PointerLikeRegClass handling from codegen
All uses have been migrated to RegClassByHwMode. This is now an implementation detail of InstrInfoEmitter for pseudoinstructions.
1 parent a8f9037 commit 967e164

File tree

8 files changed

+17
-51
lines changed

8 files changed

+17
-51
lines changed

llvm/include/llvm/MC/MCInstrDesc.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ enum OperandConstraint {
4949
/// private, all access should go through the MCOperandInfo accessors.
5050
/// See the accessors for a description of what these are.
5151
enum OperandFlags {
52-
LookupPtrRegClass = 0,
53-
LookupRegClassByHwMode,
52+
LookupRegClassByHwMode = 0,
5453
Predicate,
5554
OptionalDef,
5655
BranchTarget
@@ -90,9 +89,6 @@ class MCOperandInfo {
9089
/// operand is a register. If LookupRegClassByHwMode is set, then this is an
9190
/// index into a table in TargetInstrInfo or MCInstrInfo which contains the
9291
/// real register class ID.
93-
///
94-
/// If isLookupPtrRegClass is set, then this is an index that is passed to
95-
/// TargetRegisterInfo::getPointerRegClass(x) to get a dynamic register class.
9692
int16_t RegClass;
9793

9894
/// These are flags from the MCOI::OperandFlags enum.
@@ -104,13 +100,6 @@ class MCOperandInfo {
104100
/// Operand constraints (see OperandConstraint enum).
105101
uint16_t Constraints;
106102

107-
/// Set if this operand is a pointer value and it requires a callback
108-
/// to look up its register class.
109-
// TODO: Deprecated in favor of isLookupRegClassByHwMode
110-
bool isLookupPtrRegClass() const {
111-
return Flags & (1 << MCOI::LookupPtrRegClass);
112-
}
113-
114103
/// Set if this operand is a value that requires the current hwmode to look up
115104
/// its register class.
116105
bool isLookupRegClassByHwMode() const {

llvm/include/llvm/Target/Target.td

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -918,16 +918,23 @@ def slice;
918918
def encoder;
919919
def decoder;
920920

921-
/// PointerLikeRegClass - Values that are designed to have pointer width are
922-
/// derived from this. TableGen treats the register class as having a symbolic
923-
/// type that it doesn't know, and resolves the actual regclass to use by using
924-
/// the TargetRegisterInfo::getPointerRegClass() hook at codegen time.
925-
///
926-
/// This is deprecated in favor of RegClassByHwMode.
921+
/// PointerLikeRegClass - Pseudoinstruction operands that are designed
922+
/// to have pointer width are derived from this. This should only be
923+
/// used by StandardPseudoInstruction instructions. No target specific
924+
/// instruction should use this.
927925
class PointerLikeRegClass<int Kind> {
928926
int RegClassKind = Kind;
929927
}
930928

929+
/// ptr_rc definition - Mark this operand as being a pointer value
930+
/// whose register class needs to be defined by the target. Targets
931+
/// should provide instruction definition overrides which substitute
932+
/// the uses of this with the backend defined RegisterClass or
933+
/// RegClassByHwMode to use for pointer virtual registers for a
934+
/// particular opcode (typically by defining a subsitute instruction
935+
/// with RemapPointerOperands).
936+
def ptr_rc : PointerLikeRegClass<0>;
937+
931938
/// RegClassByHwMode - Operands that change the register class based
932939
/// on the subtarget are derived from this. TableGen
933940
/// treats the register class as having a symbolic kind that it
@@ -941,13 +948,6 @@ class RegClassByHwMode<list<HwMode> Modes,
941948
list<RegisterClass> Objects = RegClasses;
942949
}
943950

944-
/// ptr_rc definition - Mark this operand as being a pointer value whose
945-
/// register class is resolved dynamically via a callback to TargetInstrInfo.
946-
/// FIXME: We should probably change this to a class which contain a list of
947-
/// flags. But currently we have but one flag.
948-
// Deprecated, use RegClassByHwMode instead.
949-
def ptr_rc : PointerLikeRegClass<0>;
950-
951951
/// unknown definition - Mark this operand as being of unknown type, causing
952952
/// it to be resolved by inference in the context it is used.
953953
class unknown_class;

llvm/lib/CodeGen/TargetInstrInfo.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ TargetInstrInfo::getRegClass(const MCInstrDesc &MCID, unsigned OpNum,
6767
const MCOperandInfo &OpInfo = MCID.operands()[OpNum];
6868
int16_t RegClass = getOpRegClassID(OpInfo);
6969

70-
// TODO: Remove isLookupPtrRegClass in favor of isLookupRegClassByHwMode
71-
if (OpInfo.isLookupPtrRegClass())
72-
return TRI->getPointerRegClass(RegClass);
73-
7470
// Instructions like INSERT_SUBREG do not have fixed register classes.
7571
if (RegClass < 0)
7672
return nullptr;

llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Instruction::create(const MCInstrInfo &InstrInfo,
120120
Operand.IsDef = (OpIndex < Description->getNumDefs());
121121
Operand.IsEarlyClobber =
122122
(Description->getOperandConstraint(OpIndex, MCOI::EARLY_CLOBBER) != -1);
123-
// TODO(gchatelet): Handle isLookupPtrRegClass.
123+
// TODO(gchatelet): Handle LookupRegClassByHwMode.
124124
if (OpInfo.RegClass >= 0)
125125
Operand.Tracker = &RATC.getRegisterClass(OpInfo.RegClass);
126126
int TiedToIndex = Description->getOperandConstraint(OpIndex, MCOI::TIED_TO);

llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,10 +1830,6 @@ bool TreePatternNode::UpdateNodeTypeFromInst(unsigned ResNo,
18301830
return UpdateNodeType(ResNo, getValueTypeByHwMode(R, T.getHwModes()), TP);
18311831
}
18321832

1833-
// PointerLikeRegClass has a type that is determined at runtime.
1834-
if (Operand->isSubClassOf("PointerLikeRegClass"))
1835-
return UpdateNodeType(ResNo, MVT::iPTR, TP);
1836-
18371833
// Both RegisterClass and RegisterOperand operands derive their types from a
18381834
// register class def.
18391835
const Record *RC = nullptr;
@@ -2412,12 +2408,6 @@ static TypeSetByHwMode getImplicitType(const Record *R, unsigned ResNo,
24122408
const CodeGenHwModes &CGH = CDP.getTargetInfo().getHwModes();
24132409
return TypeSetByHwMode(getValueTypeByHwMode(T, CGH));
24142410
}
2415-
if (R->isSubClassOf("PointerLikeRegClass")) {
2416-
assert(ResNo == 0 && "Regclass can only have one result!");
2417-
TypeSetByHwMode VTS(MVT::iPTR);
2418-
TP.getInfer().expandOverloads(VTS);
2419-
return VTS;
2420-
}
24212411

24222412
if (R->getName() == "node" || R->getName() == "srcvalue" ||
24232413
R->getName() == "zero_reg" || R->getName() == "immAllOnesV" ||
@@ -3649,8 +3639,7 @@ void CodeGenDAGPatterns::FindPatternInputsAndOutputs(
36493639

36503640
if (Val->getDef()->isSubClassOf("RegisterClassLike") ||
36513641
Val->getDef()->isSubClassOf("ValueType") ||
3652-
Val->getDef()->isSubClassOf("RegisterOperand") ||
3653-
Val->getDef()->isSubClassOf("PointerLikeRegClass")) {
3642+
Val->getDef()->isSubClassOf("RegisterOperand")) {
36543643
if (Dest->getName().empty())
36553644
I.error("set destination must have a name!");
36563645
if (!InstResults.insert_or_assign(Dest->getName(), Dest).second)

llvm/utils/TableGen/Common/InstructionEncoding.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ InstructionEncoding::findOperandDecoderMethod(const Record *Record) {
3535
Decoder = "Decode" + Record->getName().str() + "RegisterClass";
3636
} else if (Record->isSubClassOf("RegClassByHwMode")) {
3737
Decoder = "Decode" + Record->getName().str() + "RegClassByHwMode";
38-
} else if (Record->isSubClassOf("PointerLikeRegClass")) {
39-
Decoder = "DecodePointerLikeRegClass" +
40-
utostr(Record->getValueAsInt("RegClassKind"));
4138
}
4239

4340
return {Decoder, true};

llvm/utils/TableGen/DAGISelMatcherGen.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ void MatcherGen::EmitLeafMatchCode(const TreePatternNode &N) {
240240
if ( // Handle register references. Nothing to do here, they always match.
241241
LeafRec->isSubClassOf("RegisterClassLike") ||
242242
LeafRec->isSubClassOf("RegisterOperand") ||
243-
LeafRec->isSubClassOf("PointerLikeRegClass") ||
244243
LeafRec->isSubClassOf("SubRegIndex") ||
245244
// Place holder for SRCVALUE nodes. Nothing to do here.
246245
LeafRec->getName() == "srcvalue")

llvm/utils/TableGen/InstrInfoEmitter.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,8 @@ InstrInfoEmitter::GetOperandInfo(const CodeGenInstruction &Inst) {
182182
// Fill in applicable flags.
183183
Res += "0";
184184

185-
if (OpR->isSubClassOf("RegClassByHwMode")) {
185+
if (OpR->isSubClassOf("RegClassByHwMode"))
186186
Res += "|(1<<MCOI::LookupRegClassByHwMode)";
187-
} else if (OpR->isSubClassOf("PointerLikeRegClass")) {
188-
// Ptr value whose register class is resolved via callback.
189-
Res += "|(1<<MCOI::LookupPtrRegClass)";
190-
}
191187

192188
// Predicate operands. Check to see if the original unexpanded operand
193189
// was of type PredicateOp.

0 commit comments

Comments
 (0)