Skip to content

Commit

Permalink
[IR] Migrate from getNumArgOperands to arg_size (NFC)
Browse files Browse the repository at this point in the history
Note that arg_operands is considered a legacy name.  See
llvm/include/llvm/IR/InstrTypes.h for details.
  • Loading branch information
kazutakahirata committed Oct 4, 2021
1 parent 933e246 commit e6e2983
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 65 deletions.
2 changes: 1 addition & 1 deletion llvm/include/llvm/IR/AbstractCallSite.h
Expand Up @@ -153,7 +153,7 @@ class AbstractCallSite {
/// Return the number of parameters of the callee.
unsigned getNumArgOperands() const {
if (isDirectCall())
return CB->getNumArgOperands();
return CB->arg_size();
// Subtract 1 for the callee encoding.
return CI.ParameterEncoding.size() - 1;
}
Expand Down
24 changes: 12 additions & 12 deletions llvm/include/llvm/IR/InstrTypes.h
Expand Up @@ -1336,22 +1336,22 @@ class CallBase : public Instruction {
unsigned getNumArgOperands() const { return arg_size(); }

Value *getArgOperand(unsigned i) const {
assert(i < getNumArgOperands() && "Out of bounds!");
assert(i < arg_size() && "Out of bounds!");
return getOperand(i);
}

void setArgOperand(unsigned i, Value *v) {
assert(i < getNumArgOperands() && "Out of bounds!");
assert(i < arg_size() && "Out of bounds!");
setOperand(i, v);
}

/// Wrappers for getting the \c Use of a call argument.
const Use &getArgOperandUse(unsigned i) const {
assert(i < getNumArgOperands() && "Out of bounds!");
assert(i < arg_size() && "Out of bounds!");
return User::getOperandUse(i);
}
Use &getArgOperandUse(unsigned i) {
assert(i < getNumArgOperands() && "Out of bounds!");
assert(i < arg_size() && "Out of bounds!");
return User::getOperandUse(i);
}

Expand Down Expand Up @@ -1518,13 +1518,13 @@ class CallBase : public Instruction {

/// Adds the attribute to the indicated argument
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) {
assert(ArgNo < getNumArgOperands() && "Out of bounds");
assert(ArgNo < arg_size() && "Out of bounds");
Attrs = Attrs.addParamAttribute(getContext(), ArgNo, Kind);
}

/// Adds the attribute to the indicated argument
void addParamAttr(unsigned ArgNo, Attribute Attr) {
assert(ArgNo < getNumArgOperands() && "Out of bounds");
assert(ArgNo < arg_size() && "Out of bounds");
Attrs = Attrs.addParamAttribute(getContext(), ArgNo, Attr);
}

Expand Down Expand Up @@ -1560,13 +1560,13 @@ class CallBase : public Instruction {

/// Removes the attribute from the given argument
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) {
assert(ArgNo < getNumArgOperands() && "Out of bounds");
assert(ArgNo < arg_size() && "Out of bounds");
Attrs = Attrs.removeParamAttribute(getContext(), ArgNo, Kind);
}

/// Removes the attribute from the given argument
void removeParamAttr(unsigned ArgNo, StringRef Kind) {
assert(ArgNo < getNumArgOperands() && "Out of bounds");
assert(ArgNo < arg_size() && "Out of bounds");
Attrs = Attrs.removeParamAttribute(getContext(), ArgNo, Kind);
}

Expand Down Expand Up @@ -1617,13 +1617,13 @@ class CallBase : public Instruction {

/// Get the attribute of a given kind from a given arg
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
assert(ArgNo < getNumArgOperands() && "Out of bounds");
assert(ArgNo < arg_size() && "Out of bounds");
return getAttributes().getParamAttr(ArgNo, Kind);
}

/// Get the attribute of a given kind from a given arg
Attribute getParamAttr(unsigned ArgNo, StringRef Kind) const {
assert(ArgNo < getNumArgOperands() && "Out of bounds");
assert(ArgNo < arg_size() && "Out of bounds");
return getAttributes().getParamAttr(ArgNo, Kind);
}

Expand All @@ -1640,14 +1640,14 @@ class CallBase : public Instruction {
/// (\p i) in the operand list.
bool dataOperandHasImpliedAttr(unsigned i, Attribute::AttrKind Kind) const {
// Note that we have to add one because `i` isn't zero-indexed.
assert(i < getNumArgOperands() + getNumTotalBundleOperands() &&
assert(i < arg_size() + getNumTotalBundleOperands() &&
"Data operand index out of bounds!");

// The attribute A can either be directly specified, if the operand in
// question is a call argument; or be indirectly implied by the kind of its
// containing operand bundle, if the operand is a bundle operand.

if (i < getNumArgOperands())
if (i < arg_size())
return paramHasAttr(i, Kind);

assert(hasOperandBundles() && i >= getBundleOperandsStartIndex() &&
Expand Down
6 changes: 2 additions & 4 deletions llvm/include/llvm/IR/Instructions.h
Expand Up @@ -4105,14 +4105,12 @@ class CallBrInst : public CallBase {
///
Value *getIndirectDestLabel(unsigned i) const {
assert(i < getNumIndirectDests() && "Out of bounds!");
return getOperand(i + getNumArgOperands() + getNumTotalBundleOperands() +
1);
return getOperand(i + arg_size() + getNumTotalBundleOperands() + 1);
}

Value *getIndirectDestLabelUse(unsigned i) const {
assert(i < getNumIndirectDests() && "Out of bounds!");
return getOperandUse(i + getNumArgOperands() + getNumTotalBundleOperands() +
1);
return getOperandUse(i + arg_size() + getNumTotalBundleOperands() + 1);
}

// Return the destination basic blocks...
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/IR/AbstractCallSite.cpp
Expand Up @@ -121,7 +121,7 @@ AbstractCallSite::AbstractCallSite(const Use *U)

assert(CallbackEncMD->getNumOperands() >= 2 && "Incomplete !callback metadata");

unsigned NumCallOperands = CB->getNumArgOperands();
unsigned NumCallOperands = CB->arg_size();
// Skip the var-arg flag at the end when reading the metadata.
for (unsigned u = 0, e = CallbackEncMD->getNumOperands() - 1; u < e; u++) {
Metadata *OpAsM = CallbackEncMD->getOperand(u).get();
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/IR/AsmWriter.cpp
Expand Up @@ -4114,7 +4114,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
Out << ' ';
writeOperand(Operand, false);
Out << '(';
for (unsigned op = 0, Eop = CI->getNumArgOperands(); op < Eop; ++op) {
for (unsigned op = 0, Eop = CI->arg_size(); op < Eop; ++op) {
if (op > 0)
Out << ", ";
writeParamOperand(CI->getArgOperand(op), PAL.getParamAttrs(op));
Expand Down Expand Up @@ -4159,7 +4159,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
Out << ' ';
writeOperand(Operand, false);
Out << '(';
for (unsigned op = 0, Eop = II->getNumArgOperands(); op < Eop; ++op) {
for (unsigned op = 0, Eop = II->arg_size(); op < Eop; ++op) {
if (op)
Out << ", ";
writeParamOperand(II->getArgOperand(op), PAL.getParamAttrs(op));
Expand Down Expand Up @@ -4199,7 +4199,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
Out << ' ';
writeOperand(Operand, false);
Out << '(';
for (unsigned op = 0, Eop = CBI->getNumArgOperands(); op < Eop; ++op) {
for (unsigned op = 0, Eop = CBI->arg_size(); op < Eop; ++op) {
if (op)
Out << ", ";
writeParamOperand(CBI->getArgOperand(op), PAL.getParamAttrs(op));
Expand Down

0 comments on commit e6e2983

Please sign in to comment.