forked from OSchip/llvm-project
[OperandBundles] Tighten OperandBundleDef's interface; NFC
llvm-svn: 253446
This commit is contained in:
parent
64dab75c41
commit
f79d3449c5
|
@ -1155,21 +1155,30 @@ private:
|
||||||
/// Unlike OperandBundleUse, OperandBundleDefT owns the memory it carries, and
|
/// Unlike OperandBundleUse, OperandBundleDefT owns the memory it carries, and
|
||||||
/// so it is possible to create and pass around "self-contained" instances of
|
/// so it is possible to create and pass around "self-contained" instances of
|
||||||
/// OperandBundleDef and ConstOperandBundleDef.
|
/// OperandBundleDef and ConstOperandBundleDef.
|
||||||
template <typename InputTy> struct OperandBundleDefT {
|
template <typename InputTy> class OperandBundleDefT {
|
||||||
std::string Tag;
|
std::string Tag;
|
||||||
std::vector<InputTy> Inputs;
|
std::vector<InputTy> Inputs;
|
||||||
|
|
||||||
OperandBundleDefT() {}
|
public:
|
||||||
explicit OperandBundleDefT(StringRef Tag, const std::vector<InputTy> &Inputs)
|
explicit OperandBundleDefT(StringRef Tag, std::vector<InputTy> &&Inputs)
|
||||||
: Tag(Tag), Inputs(Inputs) {}
|
: Tag(Tag), Inputs(Inputs) {}
|
||||||
|
|
||||||
explicit OperandBundleDefT(StringRef Tag, std::vector<InputTy> &&Inputs)
|
explicit OperandBundleDefT(std::string &&Tag, std::vector<InputTy> &&Inputs)
|
||||||
: Tag(Tag), Inputs(Inputs) {}
|
: Tag(Tag), Inputs(Inputs) {}
|
||||||
|
|
||||||
explicit OperandBundleDefT(const OperandBundleUse &OBU) {
|
explicit OperandBundleDefT(const OperandBundleUse &OBU) {
|
||||||
Tag = OBU.getTagName();
|
Tag = OBU.getTagName();
|
||||||
Inputs.insert(Inputs.end(), OBU.Inputs.begin(), OBU.Inputs.end());
|
Inputs.insert(Inputs.end(), OBU.Inputs.begin(), OBU.Inputs.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArrayRef<InputTy> getInputs() const { return Inputs; }
|
||||||
|
|
||||||
|
typedef typename std::vector<InputTy>::const_iterator input_iterator;
|
||||||
|
size_t input_size() const { return Inputs.size(); }
|
||||||
|
input_iterator input_begin() const { return Inputs.begin(); }
|
||||||
|
input_iterator input_end() const { return Inputs.end(); }
|
||||||
|
|
||||||
|
StringRef getTag() const { return Tag; }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef OperandBundleDefT<Value *> OperandBundleDef;
|
typedef OperandBundleDefT<Value *> OperandBundleDef;
|
||||||
|
@ -1461,7 +1470,7 @@ protected:
|
||||||
const unsigned BeginIndex) {
|
const unsigned BeginIndex) {
|
||||||
auto It = static_cast<InstrTy *>(this)->op_begin() + BeginIndex;
|
auto It = static_cast<InstrTy *>(this)->op_begin() + BeginIndex;
|
||||||
for (auto &B : Bundles)
|
for (auto &B : Bundles)
|
||||||
It = std::copy(B.Inputs.begin(), B.Inputs.end(), It);
|
It = std::copy(B.input_begin(), B.input_end(), It);
|
||||||
|
|
||||||
auto *ContextImpl = static_cast<InstrTy *>(this)->getContext().pImpl;
|
auto *ContextImpl = static_cast<InstrTy *>(this)->getContext().pImpl;
|
||||||
auto BI = Bundles.begin();
|
auto BI = Bundles.begin();
|
||||||
|
@ -1470,9 +1479,9 @@ protected:
|
||||||
for (auto &BOI : bundle_op_infos()) {
|
for (auto &BOI : bundle_op_infos()) {
|
||||||
assert(BI != Bundles.end() && "Incorrect allocation?");
|
assert(BI != Bundles.end() && "Incorrect allocation?");
|
||||||
|
|
||||||
BOI.Tag = ContextImpl->getOrInsertBundleTag(BI->Tag);
|
BOI.Tag = ContextImpl->getOrInsertBundleTag(BI->getTag());
|
||||||
BOI.Begin = CurrentIndex;
|
BOI.Begin = CurrentIndex;
|
||||||
BOI.End = CurrentIndex + BI->Inputs.size();
|
BOI.End = CurrentIndex + BI->input_size();
|
||||||
CurrentIndex = BOI.End;
|
CurrentIndex = BOI.End;
|
||||||
BI++;
|
BI++;
|
||||||
}
|
}
|
||||||
|
@ -1486,7 +1495,7 @@ protected:
|
||||||
static unsigned CountBundleInputs(ArrayRef<OperandBundleDef> Bundles) {
|
static unsigned CountBundleInputs(ArrayRef<OperandBundleDef> Bundles) {
|
||||||
unsigned Total = 0;
|
unsigned Total = 0;
|
||||||
for (auto &B : Bundles)
|
for (auto &B : Bundles)
|
||||||
Total += B.Inputs.size();
|
Total += B.input_size();
|
||||||
return Total;
|
return Total;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1972,17 +1972,13 @@ bool LLParser::ParseOptionalOperandBundles(
|
||||||
if (ParseStringConstant(Tag))
|
if (ParseStringConstant(Tag))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
BundleList.emplace_back();
|
|
||||||
auto &OBI = BundleList.back();
|
|
||||||
|
|
||||||
OBI.Tag = std::move(Tag);
|
|
||||||
|
|
||||||
if (ParseToken(lltok::lparen, "expected '(' in operand bundle"))
|
if (ParseToken(lltok::lparen, "expected '(' in operand bundle"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
std::vector<Value *> Inputs;
|
||||||
while (Lex.getKind() != lltok::rparen) {
|
while (Lex.getKind() != lltok::rparen) {
|
||||||
// If this isn't the first input, we need a comma.
|
// If this isn't the first input, we need a comma.
|
||||||
if (!OBI.Inputs.empty() &&
|
if (!Inputs.empty() &&
|
||||||
ParseToken(lltok::comma, "expected ',' in input list"))
|
ParseToken(lltok::comma, "expected ',' in input list"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -1990,9 +1986,11 @@ bool LLParser::ParseOptionalOperandBundles(
|
||||||
Value *Input = nullptr;
|
Value *Input = nullptr;
|
||||||
if (ParseType(Ty) || ParseValue(Ty, Input, PFS))
|
if (ParseType(Ty) || ParseValue(Ty, Input, PFS))
|
||||||
return true;
|
return true;
|
||||||
OBI.Inputs.push_back(Input);
|
Inputs.push_back(Input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BundleList.emplace_back(std::move(Tag), std::move(Inputs));
|
||||||
|
|
||||||
Lex.Lex(); // Lex the ')'.
|
Lex.Lex(); // Lex the ')'.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5120,10 +5120,7 @@ std::error_code BitcodeReader::parseFunctionBody(Function *F) {
|
||||||
if (Record.size() < 1 || Record[0] >= BundleTags.size())
|
if (Record.size() < 1 || Record[0] >= BundleTags.size())
|
||||||
return error("Invalid record");
|
return error("Invalid record");
|
||||||
|
|
||||||
OperandBundles.emplace_back();
|
std::vector<Value *> Inputs;
|
||||||
OperandBundles.back().Tag = BundleTags[Record[0]];
|
|
||||||
|
|
||||||
std::vector<Value *> &Inputs = OperandBundles.back().Inputs;
|
|
||||||
|
|
||||||
unsigned OpNum = 1;
|
unsigned OpNum = 1;
|
||||||
while (OpNum != Record.size()) {
|
while (OpNum != Record.size()) {
|
||||||
|
@ -5133,6 +5130,7 @@ std::error_code BitcodeReader::parseFunctionBody(Function *F) {
|
||||||
Inputs.push_back(Op);
|
Inputs.push_back(Op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OperandBundles.emplace_back(BundleTags[Record[0]], std::move(Inputs));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1195,7 +1195,7 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
|
||||||
MergedDeoptArgs.insert(MergedDeoptArgs.end(), ChildOB.Inputs.begin(),
|
MergedDeoptArgs.insert(MergedDeoptArgs.end(), ChildOB.Inputs.begin(),
|
||||||
ChildOB.Inputs.end());
|
ChildOB.Inputs.end());
|
||||||
|
|
||||||
OpDefs.emplace_back("deopt", std::move(MergedDeoptArgs));
|
OpDefs.emplace_back(StringRef("deopt"), std::move(MergedDeoptArgs));
|
||||||
}
|
}
|
||||||
|
|
||||||
Instruction *NewI = nullptr;
|
Instruction *NewI = nullptr;
|
||||||
|
|
Loading…
Reference in New Issue