@@ -258,14 +258,20 @@ class DAGOperand {
258258 bit hasCompleteDecoder = true;
259259}
260260
261+ /// Abstract base class common to RegisterClass and
262+ /// RegClassByHwMode. This permits using RegClassByHwMode in
263+ /// RegisterOperand contexts without creating an artificial
264+ /// RegisterClass.
265+ class RegisterClassLike : DAGOperand;
266+
261267// RegisterClass - Now that all of the registers are defined, and aliases
262268// between registers are defined, specify which registers belong to which
263269// register classes. This also defines the default allocation order of
264270// registers by register allocators.
265271//
266272class RegisterClass<string namespace, list<ValueType> regTypes, int alignment,
267273 dag regList, RegAltNameIndex idx = NoRegAltName>
268- : DAGOperand {
274+ : RegisterClassLike {
269275 string Namespace = namespace;
270276
271277 // The register size/alignment information, parameterized by a HW mode.
@@ -916,15 +922,30 @@ def decoder;
916922/// derived from this. TableGen treats the register class as having a symbolic
917923/// type that it doesn't know, and resolves the actual regclass to use by using
918924/// the TargetRegisterInfo::getPointerRegClass() hook at codegen time.
925+ ///
926+ /// This is deprecated in favor of RegClassByHwMode.
919927class PointerLikeRegClass<int Kind> {
920928 int RegClassKind = Kind;
921929}
922930
931+ /// RegClassByHwMode - Operands that change the register class based
932+ /// on the subtarget are derived from this. TableGen
933+ /// treats the register class as having a symbolic kind that it
934+ /// doesn't know, and resolves the actual regclass to use by using the
935+ /// a mapping in TargetInstrInfo at codegen time. This can be used to
936+ /// define operands which swap the register class with the pointer
937+ /// type.
938+ class RegClassByHwMode<list<HwMode> Modes,
939+ list<RegisterClass> RegClasses>
940+ : HwModeSelect<Modes, !size(RegClasses)>, RegisterClassLike {
941+ list<RegisterClass> Objects = RegClasses;
942+ }
923943
924944/// ptr_rc definition - Mark this operand as being a pointer value whose
925945/// register class is resolved dynamically via a callback to TargetInstrInfo.
926946/// FIXME: We should probably change this to a class which contain a list of
927947/// flags. But currently we have but one flag.
948+ // Deprecated, use RegClassByHwMode instead.
928949def ptr_rc : PointerLikeRegClass<0>;
929950
930951/// unknown definition - Mark this operand as being of unknown type, causing
@@ -1024,10 +1045,10 @@ class Operand<ValueType ty> : DAGOperand {
10241045 AsmOperandClass ParserMatchClass = ImmAsmOperand;
10251046}
10261047
1027- class RegisterOperand<RegisterClass regclass, string pm = "printOperand">
1048+ class RegisterOperand<RegisterClassLike regclass, string pm = "printOperand">
10281049 : DAGOperand {
10291050 // RegClass - The register class of the operand.
1030- RegisterClass RegClass = regclass;
1051+ RegisterClassLike RegClass = regclass;
10311052 // PrintMethod - The target method to call to print register operands of
10321053 // this type. The method normally will just use an alt-name index to look
10331054 // up the name to print. Default to the generic printOperand().
0 commit comments