[cfe-commits] r70136 - in /cfe/trunk: include/clang/Basic/TargetInfo.h lib/Basic/TargetInfo.cpp lib/CodeGen/CGStmt.cpp lib/Sema/SemaStmt.cpp
Chris Lattner
sabre at nondot.org
Sun Apr 26 10:57:13 PDT 2009
Author: lattner
Date: Sun Apr 26 12:57:12 2009
New Revision: 70136
URL: http://llvm.org/viewvc/llvm-project?rev=70136&view=rev
Log:
pull operands names "[foo]" into ConstraintInfo.
Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=70136&r1=70135&r2=70136&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Sun Apr 26 12:57:12 2009
@@ -209,14 +209,16 @@
unsigned Flags;
int TiedOperand;
- std::string ConstraintStr;
+ std::string ConstraintStr; // constraint: "=rm"
+ std::string Name; // Operand name: [foo] with no []'s.
public:
- ConstraintInfo(const char *str, unsigned strlen)
- : Flags(0), TiedOperand(-1), ConstraintStr(str, str+strlen) {}
- explicit ConstraintInfo(const std::string &Str)
- : Flags(0), TiedOperand(-1), ConstraintStr(Str) {}
+ ConstraintInfo(const char *str, unsigned strlen, const std::string &name)
+ : Flags(0), TiedOperand(-1), ConstraintStr(str, str+strlen), Name(name) {}
+ explicit ConstraintInfo(const std::string &Str, const std::string &name)
+ : Flags(0), TiedOperand(-1), ConstraintStr(Str), Name(name) {}
const std::string &getConstraintStr() const { return ConstraintStr; }
+ const std::string &getName() const { return Name; }
bool isReadWrite() const { return (Flags & CI_ReadWrite) != 0; }
bool allowsRegister() const { return (Flags & CI_AllowsRegister) != 0; }
bool allowsMemory() const { return (Flags & CI_AllowsMemory) != 0; }
@@ -236,14 +238,12 @@
// a constraint is valid and provides information about it.
// FIXME: These should return a real error instead of just true/false.
bool validateOutputConstraint(ConstraintInfo &Info) const;
- bool validateInputConstraint(const std::string *OutputNamesBegin,
- const std::string *OutputNamesEnd,
- ConstraintInfo* OutputConstraints,
+ bool validateInputConstraint(ConstraintInfo *OutputConstraints,
+ unsigned NumOutputs,
ConstraintInfo &info) const;
bool resolveSymbolicName(const char *&Name,
- const std::string *OutputNamesBegin,
- const std::string *OutputNamesEnd,
- unsigned &Index) const;
+ ConstraintInfo *OutputConstraints,
+ unsigned NumOutputs, unsigned &Index) const;
virtual std::string convertConstraint(const char Constraint) const {
return std::string(1, Constraint);
Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=70136&r1=70135&r2=70136&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Sun Apr 26 12:57:12 2009
@@ -204,8 +204,8 @@
}
bool TargetInfo::resolveSymbolicName(const char *&Name,
- const std::string *OutputNamesBegin,
- const std::string *OutputNamesEnd,
+ ConstraintInfo *OutputConstraints,
+ unsigned NumOutputs,
unsigned &Index) const {
assert(*Name == '[' && "Symbolic name did not start with '['");
Name++;
@@ -220,20 +220,15 @@
std::string SymbolicName(Start, Name - Start);
- Index = 0;
- for (const std::string *it = OutputNamesBegin;
- it != OutputNamesEnd;
- ++it, Index++) {
- if (SymbolicName == *it)
+ for (Index = 0; Index != NumOutputs; ++Index)
+ if (SymbolicName == OutputConstraints[Index].getName())
return true;
- }
return false;
}
-bool TargetInfo::validateInputConstraint(const std::string *OutputNamesBegin,
- const std::string *OutputNamesEnd,
- ConstraintInfo *OutputConstraints,
+bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints,
+ unsigned NumOutputs,
ConstraintInfo &Info) const {
const char *Name = Info.ConstraintStr.c_str();
@@ -242,7 +237,6 @@
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.
@@ -262,7 +256,7 @@
break;
case '[': {
unsigned Index = 0;
- if (!resolveSymbolicName(Name, OutputNamesBegin, OutputNamesEnd, Index))
+ if (!resolveSymbolicName(Name, OutputConstraints, NumOutputs, Index))
return false;
break;
Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=70136&r1=70135&r2=70136&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Sun Apr 26 12:57:12 2009
@@ -688,10 +688,9 @@
CaseRangeBlock = SavedCRBlock;
}
-static std::string SimplifyConstraint(const char* Constraint,
- TargetInfo &Target,
- const std::string *OutputNamesBegin = 0,
- const std::string *OutputNamesEnd = 0) {
+static std::string
+SimplifyConstraint(const char *Constraint, TargetInfo &Target,
+ llvm::SmallVectorImpl<TargetInfo::ConstraintInfo> *OutCons=0) {
std::string Result;
while (*Constraint) {
@@ -708,12 +707,12 @@
Result += "imr";
break;
case '[': {
- assert(OutputNamesBegin && OutputNamesEnd &&
+ assert(OutCons &&
"Must pass output names to constraints with a symbolic name");
unsigned Index;
bool result = Target.resolveSymbolicName(Constraint,
- OutputNamesBegin,
- OutputNamesEnd, Index);
+ &(*OutCons)[0],
+ OutCons->size(), Index);
assert(result && "Could not resolve symbolic name"); result=result;
Result += llvm::utostr(Index);
break;
@@ -798,7 +797,7 @@
for (unsigned i = 0, e = S.getNumOutputs(); i != e; i++) {
std::string OutputConstraint(S.getOutputConstraint(i));
- TargetInfo::ConstraintInfo Info(OutputConstraint);
+ TargetInfo::ConstraintInfo Info(OutputConstraint, S.getOutputName(i));
bool result = Target.validateOutputConstraint(Info);
assert(result && "Failed to parse output constraint"); result=result;
@@ -852,10 +851,9 @@
std::string InputConstraint(S.getInputConstraint(i));
- TargetInfo::ConstraintInfo Info(InputConstraint);
- bool result = Target.validateInputConstraint(S.begin_output_names(),
- S.end_output_names(),
- &OutputConstraintInfos[0],
+ TargetInfo::ConstraintInfo Info(InputConstraint, S.getInputName(i));
+ bool result = Target.validateInputConstraint(&OutputConstraintInfos[0],
+ S.getNumOutputs(),
Info); result=result;
assert(result && "Failed to parse input constraint");
@@ -864,8 +862,7 @@
// Simplify the input constraint.
InputConstraint = SimplifyConstraint(InputConstraint.c_str(), Target,
- S.begin_output_names(),
- S.end_output_names());
+ &OutputConstraintInfos);
llvm::Value *Arg = EmitAsmInput(S, Info, InputExpr, Constraints);
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=70136&r1=70135&r2=70136&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Sun Apr 26 12:57:12 2009
@@ -923,7 +923,8 @@
<< Literal->getSourceRange());
TargetInfo::ConstraintInfo Info(Literal->getStrData(),
- Literal->getByteLength());
+ Literal->getByteLength(),
+ Names[i]);
if (!Context.Target.validateOutputConstraint(Info))
return StmtError(Diag(Literal->getLocStart(),
diag::err_asm_invalid_output_constraint)
@@ -948,11 +949,10 @@
<< Literal->getSourceRange());
TargetInfo::ConstraintInfo Info(Literal->getStrData(),
- Literal->getByteLength());
- if (!Context.Target.validateInputConstraint(&Names[0],
- &Names[0] + NumOutputs,
- &OutputConstraintInfos[0],
- Info)) {
+ Literal->getByteLength(),
+ Names[i]);
+ if (!Context.Target.validateInputConstraint(&OutputConstraintInfos[0],
+ NumOutputs, Info)) {
return StmtError(Diag(Literal->getLocStart(),
diag::err_asm_invalid_input_constraint)
<< Info.getConstraintStr());
More information about the cfe-commits
mailing list