27#define DEBUG_TYPE "loongarchtti"
52 case LoongArchRegisterClass::GPRRC:
55 case LoongArchRegisterClass::FPRRC:
56 return ST->hasBasicF() ? 32 : 0;
57 case LoongArchRegisterClass::VRRC:
58 return ST->hasExtLSX() ? 32 : 0;
66 return LoongArchRegisterClass::VRRC;
68 return LoongArchRegisterClass::GPRRC;
71 if ((ScalarTy->
isFloatTy() && ST->hasBasicF()) ||
73 return LoongArchRegisterClass::FPRRC;
76 return LoongArchRegisterClass::GPRRC;
81 bool HasUnorderedReductions)
const {
82 return ST->getMaxInterleaveFactor();
87 case LoongArchRegisterClass::GPRRC:
88 return "LoongArch::GPRRC";
89 case LoongArchRegisterClass::FPRRC:
90 return "LoongArch::FPRRC";
91 case LoongArchRegisterClass::VRRC:
92 return "LoongArch::VRRC";
110 switch (
II->getIntrinsicID()) {
113 case Intrinsic::vector_reduce_add:
114 case Intrinsic::vector_reduce_and:
115 case Intrinsic::vector_reduce_or:
116 case Intrinsic::vector_reduce_smax:
117 case Intrinsic::vector_reduce_smin:
118 case Intrinsic::vector_reduce_umax:
119 case Intrinsic::vector_reduce_umin:
120 case Intrinsic::vector_reduce_xor:
137 ST->hasExtLSX() && VTy &&
isPowerOf2_32(VTy->getNumElements())) {
138 unsigned Size = VTy->getPrimitiveSizeInBits().getFixedValue();
139 EVT VT = getTLI()->getValueType(
DL, Src);
141 getTLI()->getTypeAction(Src->getContext(), VT) ==
143 getTLI()->allowsMemoryAccessForAlignment(Src->getContext(),
DL, VT,
159 Options.MaxNumLoads = TLI->getMaxExpandSizeMemcmp(OptSize);
161 Options.AllowOverlappingLoads =
true;
165 Options.LoadSizes = {8, 4, 2, 1};
166 Options.AllowedTailExpansions = {3, 5, 6};
169 Options.AllowedTailExpansions = {3};
181 int ISD = TLI->InstructionOpcodeToISD(Opcode);
311 if (ST->hasExtLSX()) {
313 if (
auto KindCost = Entry->Cost[CostKind])
314 return LT.first * *KindCost;
374 {
ISD::OR, MVT::v16i16, {1, 1}},
396 if (ST->hasExtLASX()) {
397 if (
const auto *Entry =
399 if (
auto KindCost = Entry->Cost[CostKind])
400 return LT.first * *KindCost;
429 if (
auto KindCost = Entry->Cost[CostKind])
430 return LT.first * *KindCost;
458 if (
auto KindCost = Entry->Cost[CostKind])
459 return LT.first * *KindCost;
471 unsigned Bits = VTy->getPrimitiveSizeInBits().getFixedValue();
472 return (Bits == 128 && ST->hasExtLSX()) || (Bits == 256 && ST->hasExtLASX());
480 if (Opcode == Instruction::ExtractElement && Index == 0 &&
493 unsigned EltBits = SrcTy->getScalarSizeInBits();
494 bool Is128 = SrcTy->getPrimitiveSizeInBits().getFixedValue() == 128;
503 if (Is128 && EltBits >= 32)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Cost tables and simple lookup functions.
This file defines an InstructionCost class that is used when calculating the cost of an instruction,...
uint64_t IntrinsicInst * II
Represent a constant reference to an array (0 or more elements consecutively in memory),...
TTI::ShuffleKind improveShuffleKindFromMask(TTI::ShuffleKind Kind, ArrayRef< int > Mask, VectorType *SrcTy, int &Index, VectorType *&SubTy) const
InstructionCost getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Opd1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Opd2Info={TTI::OK_AnyValue, TTI::OP_None}, ArrayRef< const Value * > Args={}, const Instruction *CtxI=nullptr) const override
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy, TTI::TargetCostKind CostKind, ArrayRef< int > Mask, int Index, VectorType *SubTp, ArrayRef< const Value * > Args={}, const Instruction *CtxI=nullptr, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
std::pair< InstructionCost, MVT > getTypeLegalizationCost(Type *Ty) const
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr) const override
A wrapper class for inspecting calls to intrinsic functions.
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override
unsigned getCacheLineSize() const override
unsigned getMaxInterleaveFactor(ElementCount VF, bool HasUnorderedReductions) const override
bool shouldExpandReduction(const IntrinsicInst *II) const override
InstructionCost getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Op2Info={TTI::OK_AnyValue, TTI::OP_None}, ArrayRef< const Value * > Args={}, const Instruction *CxtI=nullptr) const override
unsigned getRegisterClassForType(bool Vector, Type *Ty=nullptr) const override
TTI::MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const override
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr) const override
const char * getRegisterClassName(unsigned ClassID) const override
unsigned getNumberOfRegisters(unsigned ClassID) const override
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy, TTI::TargetCostKind CostKind, ArrayRef< int > Mask, int Index, VectorType *SubTp, ArrayRef< const Value * > Args={}, const Instruction *CxtI=nullptr, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
unsigned getPrefetchDistance() const override
bool enableWritePrefetching() const override
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const override
static constexpr TypeSize getFixed(ScalarTy ExactSize)
The instances of the Type class are immutable: once they are created, they are never changed.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
LLVM Value Representation.
Base class of all SIMD vector types.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
ISD namespace - This namespace contains an enum which represents all of the SelectionDAG node types a...
@ ADD
Simple integer binary arithmetic operators.
@ FADD
Simple binary floating point operators.
@ SHL
Shift and rotation operations.
@ AND
Bitwise operators - logical and, logical or, logical xor.
This is an optimization pass for GlobalISel generic memory operations.
const CostTblEntryT< CostType > * CostTableLookup(ArrayRef< CostTblEntryT< CostType > > Tbl, int ISD, MVT Ty)
Find in cost table.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
This struct is a compact representation of a valid (non-zero power of two) alignment.