llvm_unreachable("Unsupported register kind");
}
+InstructionCost
+RISCVTTIImpl::getConstantPoolLoadCost(Type *Ty, TTI::TargetCostKind CostKind) {
+ // Add a cost of address generation + the cost of the load. The address
+ // is expected to be a PC relative offset to a constant pool entry
+ // using auipc/addi.
+ return 2 + getMemoryOpCost(Instruction::Load, Ty, DL.getABITypeAlign(Ty),
+ /*AddressSpace=*/0, CostKind);
+}
+
+
InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
VectorType *Tp, ArrayRef<int> Mask,
TTI::TargetCostKind CostKind,
LT.second.getVectorNumElements() <= 256)) {
VectorType *IdxTy = VectorType::get(IntegerType::getInt8Ty(Tp->getContext()),
Tp->getElementCount());
- InstructionCost IndexCost =
- 2 + getMemoryOpCost(Instruction::Load, IdxTy, DL.getABITypeAlign(IdxTy),
- /*AddressSpace=*/0, CostKind);
+ InstructionCost IndexCost = getConstantPoolLoadCost(IdxTy, CostKind);
return IndexCost + getLMULCost(LT.second);
}
}
// with how we treat scalar constants themselves just above.
return 1;
- // Add a cost of address generation + the cost of the vector load. The
- // address is expected to be a PC relative offset to a constant pool entry
- // using auipc/addi.
- return 2 + getMemoryOpCost(Instruction::Load, Ty, DL.getABITypeAlign(Ty),
- /*AddressSpace=*/0, CostKind);
+ return getConstantPoolLoadCost(Ty, CostKind);
}
// scalar constants in GPRs.
return 0;
- // Add a cost of address generation + the cost of the vector load. The
- // address is expected to be a PC relative offset to a constant pool entry
- // using auipc/addi.
- return 2 + getMemoryOpCost(Instruction::Load, Ty, DL.getABITypeAlign(Ty),
- /*AddressSpace=*/0, CostKind);
+ return getConstantPoolLoadCost(Ty, CostKind);
};
// Add the cost of materializing any constant vectors required.
/// Return the cost of LMUL. The larger the LMUL, the higher the cost.
InstructionCost getLMULCost(MVT VT);
+ /// Return the cost of accessing a constant pool entry of the specified
+ /// type.
+ InstructionCost getConstantPoolLoadCost(Type *Ty,
+ TTI::TargetCostKind CostKind);
public:
explicit RISCVTTIImpl(const RISCVTargetMachine *TM, const Function &F)
: BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),