@@ -21996,24 +21996,32 @@ SDValue RISCVTargetLowering::expandIndirectJTBranch(const SDLoc &dl,
2199621996 return TargetLowering::expandIndirectJTBranch(dl, Value, Addr, JTI, DAG);
2199721997}
2199821998
21999- // Some types are listed in the GPR register class to support isel patterns for
22000- // GISel, but are not legal in SelectionDAG. This prevents the default
22001- // implementation from finding a register clss for them.
21999+ // If an output pattern produces multiple instructions tablegen may pick an
22000+ // arbitrary type from an instructions destination register class to use for the
22001+ // VT of that MachineSDNode. This VT may be used to look up the representative
22002+ // register class. If the type isn't legal, the default implementation will
22003+ // not find a register class.
22004+ //
22005+ // Some integer types smaller than XLen are listed in the GPR register class to
22006+ // support isel patterns for GISel, but are not legal in SelectionDAG. The
22007+ // arbitrary type tablegen picks may be one of these smaller types.
22008+ //
22009+ // f16 and bf16 are both valid for the FPR16 or GPRF16 register class. It's
22010+ // possible for tablegen to pick bf16 as the arbitrary type for an f16 pattern.
2200222011std::pair<const TargetRegisterClass *, uint8_t>
2200322012RISCVTargetLowering::findRepresentativeClass(const TargetRegisterInfo *TRI,
2200422013 MVT VT) const {
22005- const TargetRegisterClass *RRC = nullptr;
22006- uint8_t Cost = 1;
2200722014 switch (VT.SimpleTy) {
22008- default:
22009- return TargetLowering::findRepresentativeClass(TRI, VT);
2201022015 case MVT::i8:
2201122016 case MVT::i16:
2201222017 case MVT::i32:
22013- RRC = &RISCV::GPRRegClass;
22014- break;
22018+ return TargetLowering::findRepresentativeClass(TRI, Subtarget.getXLenVT());
22019+ case MVT::bf16:
22020+ case MVT::f16:
22021+ return TargetLowering::findRepresentativeClass(TRI, MVT::f32);
2201522022 }
22016- return std::make_pair(RRC, Cost);
22023+
22024+ return TargetLowering::findRepresentativeClass(TRI, VT);
2201722025}
2201822026
2201922027namespace llvm::RISCVVIntrinsicsTable {
0 commit comments