Lines Matching +full:apt +full:- +full:get

1 //===- ProfDataUtils.cpp - Utility functions for MD_prof Metadata ---------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
55 unsigned NOps = ProfData->getNumOperands();
59 auto *ProfDataName = dyn_cast<MDString>(ProfData->getOperand(0));
63 return ProfDataName->getString() == Name;
72 unsigned NOps = ProfileData->getNumOperands();
75 Weights.resize(NOps - WeightsIdx);
79 mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(Idx));
81 assert(Weight->getValue().getActiveBits() <= (sizeof(T) * 8) &&
83 Weights[Idx - WeightsIdx] = Weight->getZExtValue();
110 // Value profiles record count-type information.
113 // Conservatively assume non CallBase instruction only get taken/not-taken
130 auto *ProfDataName = dyn_cast<MDString>(ProfileData->getOperand(1));
134 assert(ProfDataName == nullptr || ProfDataName->getString() == "expected");
143 return ProfileData.getNumOperands() - getBranchWeightOffset(&ProfileData);
209 auto *ProfDataName = dyn_cast<MDString>(ProfileData->getOperand(0));
213 if (ProfDataName->getString() == "branch_weights") {
215 for (unsigned Idx = Offset; Idx < ProfileData->getNumOperands(); ++Idx) {
216 auto *V = mdconst::extract<ConstantInt>(ProfileData->getOperand(Idx));
217 TotalVal += V->getValue().getZExtValue();
222 if (ProfDataName->getString() == "VP" && ProfileData->getNumOperands() > 3) {
223 TotalVal = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(2))
224 ->getValue()
248 auto *ProfDataName = dyn_cast<MDString>(ProfileData->getOperand(0));
249 if (!ProfDataName || (ProfDataName->getString() != "branch_weights" &&
250 ProfDataName->getString() != "VP"))
260 Vals.push_back(ProfileData->getOperand(0));
261 APInt APS(128, S), APT(128, T);
262 if (ProfDataName->getString() == "branch_weights" &&
263 ProfileData->getNumOperands() > 0) {
267 ProfileData->getOperand(getBranchWeightOffset(ProfileData)))
268 ->getValue()
271 Vals.push_back(MDB.createConstant(ConstantInt::get(
272 Type::getInt32Ty(C), Val.udiv(APT).getLimitedValue(UINT32_MAX))));
273 } else if (ProfDataName->getString() == "VP")
274 for (unsigned i = 1; i < ProfileData->getNumOperands(); i += 2) {
276 Vals.push_back(ProfileData->getOperand(i));
278 mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(i + 1))
279 ->getValue()
283 Vals.push_back(ProfileData->getOperand(i + 1));
289 Vals.push_back(MDB.createConstant(ConstantInt::get(
290 Type::getInt64Ty(C), Val.udiv(APT).getLimitedValue())));
292 I.setMetadata(LLVMContext::MD_prof, MDNode::get(C, Vals));