aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen/Common/CodeGenInstruction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/utils/TableGen/Common/CodeGenInstruction.cpp')
-rw-r--r--llvm/utils/TableGen/Common/CodeGenInstruction.cpp53
1 files changed, 28 insertions, 25 deletions
diff --git a/llvm/utils/TableGen/Common/CodeGenInstruction.cpp b/llvm/utils/TableGen/Common/CodeGenInstruction.cpp
index 18a4e7b0f18b..ecef9caa9c3d 100644
--- a/llvm/utils/TableGen/Common/CodeGenInstruction.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenInstruction.cpp
@@ -22,14 +22,14 @@ using namespace llvm;
// CGIOperandList Implementation
//===----------------------------------------------------------------------===//
-CGIOperandList::CGIOperandList(Record *R) : TheDef(R) {
+CGIOperandList::CGIOperandList(const Record *R) : TheDef(R) {
isPredicable = false;
hasOptionalDef = false;
isVariadic = false;
- DagInit *OutDI = R->getValueAsDag("OutOperandList");
+ const DagInit *OutDI = R->getValueAsDag("OutOperandList");
- if (DefInit *Init = dyn_cast<DefInit>(OutDI->getOperator())) {
+ if (const DefInit *Init = dyn_cast<DefInit>(OutDI->getOperator())) {
if (Init->getDef()->getName() != "outs")
PrintFatalError(R->getLoc(),
R->getName() +
@@ -40,8 +40,8 @@ CGIOperandList::CGIOperandList(Record *R) : TheDef(R) {
NumDefs = OutDI->getNumArgs();
- DagInit *InDI = R->getValueAsDag("InOperandList");
- if (DefInit *Init = dyn_cast<DefInit>(InDI->getOperator())) {
+ const DagInit *InDI = R->getValueAsDag("InOperandList");
+ if (const DefInit *Init = dyn_cast<DefInit>(InDI->getOperator())) {
if (Init->getDef()->getName() != "ins")
PrintFatalError(R->getLoc(),
R->getName() +
@@ -56,7 +56,7 @@ CGIOperandList::CGIOperandList(Record *R) : TheDef(R) {
OperandList.reserve(e);
bool VariadicOuts = false;
for (unsigned i = 0; i != e; ++i) {
- Init *ArgInit;
+ const Init *ArgInit;
StringRef ArgName;
if (i < NumDefs) {
ArgInit = OutDI->getArg(i);
@@ -66,22 +66,22 @@ CGIOperandList::CGIOperandList(Record *R) : TheDef(R) {
ArgName = InDI->getArgNameStr(i - NumDefs);
}
- DagInit *SubArgDag = dyn_cast<DagInit>(ArgInit);
+ const DagInit *SubArgDag = dyn_cast<DagInit>(ArgInit);
if (SubArgDag)
ArgInit = SubArgDag->getOperator();
- DefInit *Arg = dyn_cast<DefInit>(ArgInit);
+ const DefInit *Arg = dyn_cast<DefInit>(ArgInit);
if (!Arg)
PrintFatalError(R->getLoc(), "Illegal operand for the '" + R->getName() +
"' instruction!");
- Record *Rec = Arg->getDef();
+ const Record *Rec = Arg->getDef();
std::string PrintMethod = "printOperand";
std::string EncoderMethod;
std::string OperandType = "OPERAND_UNKNOWN";
std::string OperandNamespace = "MCOI";
unsigned NumOps = 1;
- DagInit *MIOpInfo = nullptr;
+ const DagInit *MIOpInfo = nullptr;
if (Rec->isSubClassOf("RegisterOperand")) {
PrintMethod = std::string(Rec->getValueAsString("PrintMethod"));
OperandType = std::string(Rec->getValueAsString("OperandType"));
@@ -137,7 +137,7 @@ CGIOperandList::CGIOperandList(Record *R) : TheDef(R) {
" has the same name as a previous operand!");
OperandInfo &OpInfo = OperandList.emplace_back(
- Rec, std::string(ArgName), std::string(PrintMethod),
+ Rec, std::string(ArgName), std::string(std::move(PrintMethod)),
OperandNamespace + "::" + OperandType, MIOperandNo, NumOps, MIOpInfo);
if (SubArgDag) {
@@ -175,12 +175,12 @@ CGIOperandList::CGIOperandList(Record *R) : TheDef(R) {
}
OpInfo.SubOpNames[j] = SubArgName;
- SubOpAliases[SubArgName] = std::pair(i, j);
+ SubOpAliases[SubArgName] = {i, j};
}
} else if (!EncoderMethod.empty()) {
// If we have no explicit sub-op dag, but have an top-level encoder
// method, the single encoder will multiple sub-ops, itself.
- OpInfo.EncoderMethodNames[0] = EncoderMethod;
+ OpInfo.EncoderMethodNames[0] = std::move(EncoderMethod);
for (unsigned j = 1; j < NumOps; ++j)
OpInfo.DoNotEncode[j] = true;
}
@@ -276,11 +276,11 @@ CGIOperandList::ParseOperandName(StringRef Op, bool AllowWholeOp) {
Op + "'");
// Otherwise, return the operand.
- return std::pair(OpIdx, 0U);
+ return {OpIdx, 0U};
}
// Find the suboperand number involved.
- DagInit *MIOpInfo = OperandList[OpIdx].MIOperandInfo;
+ const DagInit *MIOpInfo = OperandList[OpIdx].MIOperandInfo;
if (!MIOpInfo)
PrintFatalError(TheDef->getLoc(), TheDef->getName() +
": unknown suboperand name in '" +
@@ -289,16 +289,17 @@ CGIOperandList::ParseOperandName(StringRef Op, bool AllowWholeOp) {
// Find the operand with the right name.
for (unsigned i = 0, e = MIOpInfo->getNumArgs(); i != e; ++i)
if (MIOpInfo->getArgNameStr(i) == SubOpName)
- return std::pair(OpIdx, i);
+ return {OpIdx, i};
// Otherwise, didn't find it!
PrintFatalError(TheDef->getLoc(), TheDef->getName() +
": unknown suboperand name in '" + Op +
"'");
- return std::pair(0U, 0U);
+ return {0U, 0U};
}
-static void ParseConstraint(StringRef CStr, CGIOperandList &Ops, Record *Rec) {
+static void ParseConstraint(StringRef CStr, CGIOperandList &Ops,
+ const Record *Rec) {
// EARLY_CLOBBER: @early $reg
StringRef::size_type wpos = CStr.find_first_of(" \t");
StringRef::size_type start = CStr.find_first_not_of(" \t");
@@ -391,7 +392,8 @@ static void ParseConstraint(StringRef CStr, CGIOperandList &Ops, Record *Rec) {
Ops[SrcOp.first].Constraints[SrcOp.second] = NewConstraint;
}
-static void ParseConstraints(StringRef CStr, CGIOperandList &Ops, Record *Rec) {
+static void ParseConstraints(StringRef CStr, CGIOperandList &Ops,
+ const Record *Rec) {
if (CStr.empty())
return;
@@ -428,7 +430,7 @@ void CGIOperandList::ProcessDisableEncoding(StringRef DisableEncoding) {
// CodeGenInstruction Implementation
//===----------------------------------------------------------------------===//
-CodeGenInstruction::CodeGenInstruction(Record *R)
+CodeGenInstruction::CodeGenInstruction(const Record *R)
: TheDef(R), Operands(R), InferredFrom(nullptr) {
Namespace = R->getValueAsString("Namespace");
AsmString = std::string(R->getValueAsString("AsmString"));
@@ -501,7 +503,7 @@ CodeGenInstruction::CodeGenInstruction(Record *R)
HasComplexDeprecationPredicate = true;
DeprecatedReason =
std::string(R->getValueAsString("ComplexDeprecationPredicate"));
- } else if (RecordVal *Dep = R->getValue("DeprecatedFeatureMask")) {
+ } else if (const RecordVal *Dep = R->getValue("DeprecatedFeatureMask")) {
// Check if we have a Subtarget feature mask.
HasComplexDeprecationPredicate = false;
DeprecatedReason = Dep->getValue()->getAsString();
@@ -521,7 +523,7 @@ MVT::SimpleValueType CodeGenInstruction::HasOneImplicitDefWithKnownVT(
return MVT::Other;
// Check to see if the first implicit def has a resolvable type.
- Record *FirstImplicitDef = ImplicitDefs[0];
+ const Record *FirstImplicitDef = ImplicitDefs[0];
assert(FirstImplicitDef->isSubClassOf("Register"));
const std::vector<ValueTypeByHwMode> &RegVTs =
TargetInfo.getRegisterVTs(FirstImplicitDef);
@@ -564,7 +566,8 @@ std::string CodeGenInstruction::FlattenAsmStringVariants(StringRef Cur,
}
// Select the Nth variant (or empty).
- StringRef Selection = Cur.slice(VariantsStart, VariantsEnd);
+ StringRef Selection =
+ Cur.substr(VariantsStart, VariantsEnd - VariantsStart);
for (unsigned i = 0; i != Variant; ++i)
Selection = Selection.split('|').second;
Res += Selection.split('|').first;
@@ -579,11 +582,11 @@ std::string CodeGenInstruction::FlattenAsmStringVariants(StringRef Cur,
bool CodeGenInstruction::isOperandImpl(StringRef OpListName, unsigned i,
StringRef PropertyName) const {
- DagInit *ConstraintList = TheDef->getValueAsDag(OpListName);
+ const DagInit *ConstraintList = TheDef->getValueAsDag(OpListName);
if (!ConstraintList || i >= ConstraintList->getNumArgs())
return false;
- DefInit *Constraint = dyn_cast<DefInit>(ConstraintList->getArg(i));
+ const DefInit *Constraint = dyn_cast<DefInit>(ConstraintList->getArg(i));
if (!Constraint)
return false;