void PrintError(const char *Loc, const Twine &Msg);
void PrintError(const Twine &Msg);
-LLVM_ATTRIBUTE_NORETURN void PrintFatalError(const std::string &Msg);
+LLVM_ATTRIBUTE_NORETURN void PrintFatalError(const Twine &Msg);
LLVM_ATTRIBUTE_NORETURN void PrintFatalError(ArrayRef<SMLoc> ErrorLoc,
- const std::string &Msg);
+ const Twine &Msg);
extern SourceMgr SrcMgr;
extern unsigned ErrorsPrinted;
errs() << "error:" << Msg << "\n";
}
-void PrintFatalError(const std::string &Msg) {
- PrintError(Twine(Msg));
+void PrintFatalError(const Twine &Msg) {
+ PrintError(Msg);
std::exit(1);
}
-void PrintFatalError(ArrayRef<SMLoc> ErrorLoc, const std::string &Msg) {
+void PrintFatalError(ArrayRef<SMLoc> ErrorLoc, const Twine &Msg) {
PrintError(ErrorLoc, Msg);
std::exit(1);
}
const RecordVal *R = getValue(FieldName);
if (R == 0 || R->getValue() == 0)
PrintFatalError(getLoc(), "Record `" + getName() +
- "' does not have a field named `" + FieldName.str() + "'!\n");
+ "' does not have a field named `" + FieldName + "'!\n");
return R->getValue();
}
const RecordVal *R = getValue(FieldName);
if (R == 0 || R->getValue() == 0)
PrintFatalError(getLoc(), "Record `" + getName() +
- "' does not have a field named `" + FieldName.str() + "'!\n");
+ "' does not have a field named `" + FieldName + "'!\n");
if (StringInit *SI = dyn_cast<StringInit>(R->getValue()))
return SI->getValue();
PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
- FieldName.str() + "' does not have a string initializer!");
+ FieldName + "' does not have a string initializer!");
}
/// getValueAsBitsInit - This method looks up the specified field and returns
const RecordVal *R = getValue(FieldName);
if (R == 0 || R->getValue() == 0)
PrintFatalError(getLoc(), "Record `" + getName() +
- "' does not have a field named `" + FieldName.str() + "'!\n");
+ "' does not have a field named `" + FieldName + "'!\n");
if (BitsInit *BI = dyn_cast<BitsInit>(R->getValue()))
return BI;
PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
- FieldName.str() + "' does not have a BitsInit initializer!");
+ FieldName + "' does not have a BitsInit initializer!");
}
/// getValueAsListInit - This method looks up the specified field and returns
const RecordVal *R = getValue(FieldName);
if (R == 0 || R->getValue() == 0)
PrintFatalError(getLoc(), "Record `" + getName() +
- "' does not have a field named `" + FieldName.str() + "'!\n");
+ "' does not have a field named `" + FieldName + "'!\n");
if (ListInit *LI = dyn_cast<ListInit>(R->getValue()))
return LI;
PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
- FieldName.str() + "' does not have a list initializer!");
+ FieldName + "' does not have a list initializer!");
}
/// getValueAsListOfDefs - This method looks up the specified field and returns
Defs.push_back(DI->getDef());
} else {
PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
- FieldName.str() + "' list is not entirely DefInit!");
+ FieldName + "' list is not entirely DefInit!");
}
}
return Defs;
const RecordVal *R = getValue(FieldName);
if (R == 0 || R->getValue() == 0)
PrintFatalError(getLoc(), "Record `" + getName() +
- "' does not have a field named `" + FieldName.str() + "'!\n");
+ "' does not have a field named `" + FieldName + "'!\n");
if (IntInit *II = dyn_cast<IntInit>(R->getValue()))
return II->getValue();
PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
- FieldName.str() + "' does not have an int initializer!");
+ FieldName + "' does not have an int initializer!");
}
/// getValueAsListOfInts - This method looks up the specified field and returns
Ints.push_back(II->getValue());
} else {
PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
- FieldName.str() + "' does not have a list of ints initializer!");
+ FieldName + "' does not have a list of ints initializer!");
}
}
return Ints;
Strings.push_back(II->getValue());
} else {
PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
- FieldName.str() + "' does not have a list of strings initializer!");
+ FieldName + "' does not have a list of strings initializer!");
}
}
return Strings;
const RecordVal *R = getValue(FieldName);
if (R == 0 || R->getValue() == 0)
PrintFatalError(getLoc(), "Record `" + getName() +
- "' does not have a field named `" + FieldName.str() + "'!\n");
+ "' does not have a field named `" + FieldName + "'!\n");
if (DefInit *DI = dyn_cast<DefInit>(R->getValue()))
return DI->getDef();
PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
- FieldName.str() + "' does not have a def initializer!");
+ FieldName + "' does not have a def initializer!");
}
/// getValueAsBit - This method looks up the specified field and returns its
const RecordVal *R = getValue(FieldName);
if (R == 0 || R->getValue() == 0)
PrintFatalError(getLoc(), "Record `" + getName() +
- "' does not have a field named `" + FieldName.str() + "'!\n");
+ "' does not have a field named `" + FieldName + "'!\n");
if (BitInit *BI = dyn_cast<BitInit>(R->getValue()))
return BI->getValue();
PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
- FieldName.str() + "' does not have a bit initializer!");
+ FieldName + "' does not have a bit initializer!");
}
bool Record::getValueAsBitOrUnset(StringRef FieldName, bool &Unset) const {
if (BitInit *BI = dyn_cast<BitInit>(R->getValue()))
return BI->getValue();
PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
- FieldName.str() + "' does not have a bit initializer!");
+ FieldName + "' does not have a bit initializer!");
}
/// getValueAsDag - This method looks up the specified field and returns its
const RecordVal *R = getValue(FieldName);
if (R == 0 || R->getValue() == 0)
PrintFatalError(getLoc(), "Record `" + getName() +
- "' does not have a field named `" + FieldName.str() + "'!\n");
+ "' does not have a field named `" + FieldName + "'!\n");
if (DagInit *DI = dyn_cast<DagInit>(R->getValue()))
return DI;
PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
- FieldName.str() + "' does not have a dag initializer!");
+ FieldName + "' does not have a dag initializer!");
}
int DstAsmOperand = findAsmOperandNamed(Ops.second);
if (SrcAsmOperand == -1)
PrintFatalError(TheDef->getLoc(),
- "unknown source two-operand alias operand '" +
- Ops.first.str() + "'.");
+ "unknown source two-operand alias operand '" + Ops.first +
+ "'.");
if (DstAsmOperand == -1)
PrintFatalError(TheDef->getLoc(),
- "unknown destination two-operand alias operand '" +
- Ops.second.str() + "'.");
+ "unknown destination two-operand alias operand '" +
+ Ops.second + "'.");
// Find the ResOperand that refers to the operand we're aliasing away
// and update it to refer to the combined operand instead.
// FIXME : Check and raise an error if it is a register.
if (Mnemonic[0] == '$')
PrintFatalError(TheDef->getLoc(),
- "Invalid instruction mnemonic '" + Mnemonic.str() + "'!");
+ "Invalid instruction mnemonic '" + Mnemonic + "'!");
// Remove the first operand, it is tracked in the mnemonic field.
AsmOperands.erase(AsmOperands.begin());
StringRef Tok = AsmOperands[i].Token;
if (Tok[0] == '$' && Tok.find(':') != StringRef::npos)
PrintFatalError(TheDef->getLoc(),
- "matchable with operand modifier '" + Tok.str() +
- "' not supported by asm matcher. Mark isCodeGenOnly!");
+ "matchable with operand modifier '" + Tok +
+ "' not supported by asm matcher. Mark isCodeGenOnly!");
// Verify that any operand is only mentioned once.
// We reject aliases and ignore instructions for now.
if (Tok[0] == '$' && !OperandNames.insert(Tok).second) {
if (!Hack)
PrintFatalError(TheDef->getLoc(),
- "ERROR: matchable with tied operand '" + Tok.str() +
- "' can never be matched!");
+ "ERROR: matchable with tied operand '" + Tok +
+ "' can never be matched!");
// FIXME: Should reject these. The ARM backend hits this with $lane in a
// bunch of instructions. It is unclear what the right answer is.
DEBUG({
errs() << "warning: '" << TheDef->getName() << "': "
<< "ignoring instruction with tied operand '"
- << Tok.str() << "'\n";
+ << Tok << "'\n";
});
return false;
}
// Map this token to an operand.
unsigned Idx;
if (!Operands.hasOperandNamed(OperandName, Idx))
- PrintFatalError(II->TheDef->getLoc(), "error: unable to find operand: '" +
- OperandName.str() + "'");
+ PrintFatalError(II->TheDef->getLoc(),
+ "error: unable to find operand: '" + OperandName + "'");
// If the instruction operand has multiple suboperands, but the parser
// match class for the asm operand is still the default "ImmAsmOperand",
return;
}
- PrintFatalError(II->TheDef->getLoc(), "error: unable to find operand: '" +
- OperandName.str() + "'");
+ PrintFatalError(II->TheDef->getLoc(),
+ "error: unable to find operand: '" + OperandName + "'");
}
void MatchableInfo::buildInstructionResultOperands() {
Reg.TheDef->getValueAsListOfStrings("AltNames");
if (AltNames.size() <= Idx)
PrintFatalError(Reg.TheDef->getLoc(),
- (Twine("Register definition missing alt name for '") +
- AltName + "'.").str());
+ "Register definition missing alt name for '" +
+ AltName + "'.");
AsmName = AltNames[Idx];
}
}
/* Resolve all types */;
if (TPN->ContainsUnresolvedType()) {
- PrintFatalError("Value #" + utostr(i) + " of OperandWithDefaultOps '" +
- DefaultOps[i]->getName() +"' doesn't have a concrete type!");
+ PrintFatalError("Value #" + Twine(i) + " of OperandWithDefaultOps '" +
+ DefaultOps[i]->getName() +
+ "' doesn't have a concrete type!");
}
DefaultOpInfo.DefaultOps.push_back(TPN);
}
// Check that the operand has a name and that it's unique.
if (ArgName.empty())
- PrintFatalError("In instruction '" + R->getName() + "', operand #" + utostr(i) +
- " has no name!");
+ PrintFatalError("In instruction '" + R->getName() + "', operand #" +
+ Twine(i) + " has no name!");
if (!OperandNames.insert(ArgName).second)
- PrintFatalError("In instruction '" + R->getName() + "', operand #" + utostr(i) +
- " has the same name as a previous operand!");
+ PrintFatalError("In instruction '" + R->getName() + "', operand #" +
+ Twine(i) + " has the same name as a previous operand!");
OperandList.push_back(OperandInfo(Rec, ArgName, PrintMethod, EncoderMethod,
OperandType, MIOperandNo, NumOps,
unsigned CGIOperandList::getOperandNamed(StringRef Name) const {
unsigned OpIdx;
if (hasOperandNamed(Name, OpIdx)) return OpIdx;
- PrintFatalError("'" + TheDef->getName() + "' does not have an operand named '$" +
- Name.str() + "'!");
+ PrintFatalError("'" + TheDef->getName() +
+ "' does not have an operand named '$" + Name + "'!");
}
/// hasOperandNamed - Query whether the instruction has an operand of the
// If the operand is a record, it must have a name, and the record type
// must match up with the instruction's argument type.
if (Result->getArgName(AliasOpNo).empty())
- PrintFatalError(Loc, "result argument #" + utostr(AliasOpNo) +
- " must have a name!");
+ PrintFatalError(Loc, "result argument #" + Twine(AliasOpNo) +
+ " must have a name!");
ResOp = ResultOperand(Result->getArgName(AliasOpNo), ResultRecord);
return true;
}
return false;
// Integer arguments can't have names.
if (!Result->getArgName(AliasOpNo).empty())
- PrintFatalError(Loc, "result argument #" + utostr(AliasOpNo) +
+ PrintFatalError(Loc, "result argument #" + Twine(AliasOpNo) +
" must not have a name!");
ResOp = ResultOperand(II->getValue());
return true;
ResultInstOperandIndex.push_back(std::make_pair(i, SubOp));
++AliasOpNo;
} else {
- PrintFatalError(R->getLoc(), "result argument #" + utostr(AliasOpNo) +
+ PrintFatalError(R->getLoc(), "result argument #" + Twine(AliasOpNo) +
" does not match instruction operand class " +
(SubOp == 0 ? InstOpRec->getName() :SubRec->getName()));
}
}
continue;
}
- PrintFatalError(R->getLoc(), "result argument #" + utostr(AliasOpNo) +
+ PrintFatalError(R->getLoc(), "result argument #" + Twine(AliasOpNo) +
" does not match instruction operand class " +
InstOpRec->getName());
}
// Read in register class definitions.
std::vector<Record*> RCs = Records.getAllDerivedDefinitions("RegisterClass");
if (RCs.empty())
- PrintFatalError(std::string("No 'RegisterClass' subclasses defined!"));
+ PrintFatalError("No 'RegisterClass' subclasses defined!");
// Allocate user-defined register classes.
RegClasses.reserve(RCs.size());
Record *CodeGenTarget::getAsmParser() const {
std::vector<Record*> LI = TargetRec->getValueAsListOfDefs("AssemblyParsers");
if (AsmParserNum >= LI.size())
- PrintFatalError("Target does not have an AsmParser #" + utostr(AsmParserNum) + "!");
+ PrintFatalError("Target does not have an AsmParser #" +
+ Twine(AsmParserNum) + "!");
return LI[AsmParserNum];
}
std::vector<Record*> LI =
TargetRec->getValueAsListOfDefs("AssemblyParserVariants");
if (i >= LI.size())
- PrintFatalError("Target does not have an AsmParserVariant #" + utostr(i) + "!");
+ PrintFatalError("Target does not have an AsmParserVariant #" + Twine(i) +
+ "!");
return LI[i];
}
Record *CodeGenTarget::getAsmWriter() const {
std::vector<Record*> LI = TargetRec->getValueAsListOfDefs("AssemblyWriters");
if (AsmWriterNum >= LI.size())
- PrintFatalError("Target does not have an AsmWriter #" + utostr(AsmWriterNum) + "!");
+ PrintFatalError("Target does not have an AsmWriter #" +
+ Twine(AsmWriterNum) + "!");
return LI[AsmWriterNum];
}
DenseMap<const Record*, CodeGenInstruction*>::const_iterator
I = Insts.find(Rec);
if (Rec == 0 || I == Insts.end())
- PrintFatalError(std::string("Could not find '") + Name + "' instruction!");
+ PrintFatalError(Twine("Could not find '") + Name + "' instruction!");
return I->second;
}