forked from OSchip/llvm-project
Change TargetInfo::validateInputConstraint to take begin/end name iterators instead of the number of outputs. No functionality change.
llvm-svn: 62433
This commit is contained in:
parent
18789e1c21
commit
19aa04d270
|
@ -944,6 +944,16 @@ public:
|
|||
const_outputs_iterator begin_outputs() const { return &Exprs[0]; }
|
||||
const_outputs_iterator end_outputs() const { return &Exprs[0] + NumOutputs; }
|
||||
|
||||
// Input name iterator.
|
||||
|
||||
const std::string *begin_output_names() const {
|
||||
return &Names[0];
|
||||
}
|
||||
|
||||
const std::string *end_output_names() const {
|
||||
return &Names[0] + NumOutputs;
|
||||
}
|
||||
|
||||
// Child iterators
|
||||
|
||||
virtual child_iterator child_begin();
|
||||
|
|
|
@ -198,8 +198,10 @@ public:
|
|||
// a constraint is valid and provides information about it.
|
||||
// FIXME: These should return a real error instead of just true/false.
|
||||
bool validateOutputConstraint(const char *Name, ConstraintInfo &Info) const;
|
||||
bool validateInputConstraint (const char *Name, unsigned NumOutputs,
|
||||
ConstraintInfo &info) const;
|
||||
bool validateInputConstraint(const char *Name,
|
||||
const std::string *OutputNamesBegin,
|
||||
const std::string *OutputNamesEnd,
|
||||
ConstraintInfo &info) const;
|
||||
|
||||
virtual std::string convertConstraint(const char Constraint) const {
|
||||
return std::string(1, Constraint);
|
||||
|
|
|
@ -188,7 +188,8 @@ bool TargetInfo::validateOutputConstraint(const char *Name,
|
|||
}
|
||||
|
||||
bool TargetInfo::validateInputConstraint(const char *Name,
|
||||
unsigned NumOutputs,
|
||||
const std::string *OutputNamesBegin,
|
||||
const std::string *OutputNamesEnd,
|
||||
ConstraintInfo &info) const {
|
||||
info = CI_None;
|
||||
|
||||
|
@ -197,8 +198,9 @@ bool TargetInfo::validateInputConstraint(const char *Name,
|
|||
default:
|
||||
// Check if we have a matching constraint
|
||||
if (*Name >= '0' && *Name <= '9') {
|
||||
unsigned NumOutputs = OutputNamesEnd - OutputNamesBegin;
|
||||
unsigned i = *Name - '0';
|
||||
|
||||
|
||||
// Check if matching constraint is out of bounds.
|
||||
if (i >= NumOutputs)
|
||||
return false;
|
||||
|
|
|
@ -977,7 +977,9 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
|
|||
|
||||
TargetInfo::ConstraintInfo Info;
|
||||
bool result = Target.validateInputConstraint(InputConstraint.c_str(),
|
||||
NumConstraints, Info);
|
||||
S.begin_output_names(),
|
||||
S.end_output_names(),
|
||||
Info);
|
||||
assert(result && "Failed to parse input constraint"); result=result;
|
||||
|
||||
if (i != 0 || S.getNumOutputs() > 0)
|
||||
|
|
|
@ -897,7 +897,8 @@ Sema::StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
|
|||
|
||||
TargetInfo::ConstraintInfo info;
|
||||
if (!Context.Target.validateInputConstraint(InputConstraint.c_str(),
|
||||
NumOutputs, info)) {
|
||||
&Names[0],
|
||||
&Names[0] + NumOutputs, info)) {
|
||||
// FIXME: We currently leak memory here.
|
||||
return Diag(Literal->getLocStart(),
|
||||
diag::err_asm_invalid_input_constraint) << InputConstraint;
|
||||
|
|
Loading…
Reference in New Issue