llvm.org GIT mirror llvm / 00fb64d
[OperandBundles] Extract duplicated code into a helper function, NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254047 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjoy Das 3 years ago
4 changed file(s) with 24 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
389389 #undef CALLSITE_DELEGATE_GETTER
390390 #undef CALLSITE_DELEGATE_SETTER
391391
392 void getOperandBundlesAsDefs(SmallVectorImpl &Defs) const {
393 const Instruction *II = getInstruction();
394 // Since this is actually a getter that "looks like" a setter, don't use the
395 // above macros to avoid confusion.
396 if (isCall())
397 cast(II)->getOperandBundlesAsDefs(Defs);
398 else
399 cast(II)->getOperandBundlesAsDefs(Defs);
400 }
401
392402 /// @brief Determine whether this data operand is not captured.
393403 bool doesNotCapture(unsigned OpNo) const {
394404 return dataOperandHasImpliedAttr(OpNo + 1, Attribute::NoCapture);
13241324 return None;
13251325 }
13261326
1327 /// \brief Return the list of operand bundles attached to this instruction as
1328 /// a vector of OperandBundleDefs.
1329 ///
1330 /// This function copies the OperandBundeUse instances associated with this
1331 /// OperandBundleUser to a vector of OperandBundleDefs. Note:
1332 /// OperandBundeUses and OperandBundleDefs are non-trivially *different*
1333 /// representations of operand bundles (see documentation above).
1334 void getOperandBundlesAsDefs(SmallVectorImpl &Defs) const {
1335 for (unsigned i = 0, e = getNumOperandBundles(); i != e; ++i)
1336 Defs.emplace_back(getOperandBundleAt(i));
1337 }
1338
13271339 /// \brief Return the operand bundle for the operand at index OpIdx.
13281340 ///
13291341 /// It is an error to call this with an OpIdx that does not correspond to an
22672267 attrVec);
22682268
22692269 SmallVector OpBundles;
2270
2271 // Convert the operand bundle uses to operand bundle defs. See InstrTypes.h
2272 // for details on how these differ.
2273 for (unsigned i = 0, e = CS.getNumOperandBundles(); i != e; ++i)
2274 OpBundles.emplace_back(CS.getOperandBundleAt(i));
2270 CS.getOperandBundlesAsDefs(OpBundles);
22752271
22762272 Instruction *NC;
22772273 if (InvokeInst *II = dyn_cast(Caller)) {
209209 SmallVector InvokeArgs(CS.arg_begin(), CS.arg_end());
210210 SmallVector OpBundles;
211211
212 // Copy the OperandBundeUse instances to OperandBundleDefs. These two are
213 // *different* representations of operand bundles: see the documentation in
214 // InstrTypes.h for more details.
215 for (unsigned i = 0, e = CS.getNumOperandBundles(); i != e; ++i)
216 OpBundles.emplace_back(CS.getOperandBundleAt(i));
212 CS.getOperandBundlesAsDefs(OpBundles);
217213
218214 // Note: we're round tripping operand bundles through memory here, and that
219215 // can potentially be avoided with a cleverer API design that we do not have