[cfe-commits] r70662 - /cfe/trunk/lib/Sema/SemaStmt.cpp
Chris Lattner
sabre at nondot.org
Sat May 2 22:55:43 PDT 2009
Author: lattner
Date: Sun May 3 00:55:43 2009
New Revision: 70662
URL: http://llvm.org/viewvc/llvm-project?rev=70662&view=rev
Log:
refactor matched operand type checking to happen after the AsmStmt is created,
no functionality change.
Modified:
cfe/trunk/lib/Sema/SemaStmt.cpp
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=70662&r1=70661&r2=70662&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Sun May 3 00:55:43 2009
@@ -951,6 +951,8 @@
OutputConstraintInfos.push_back(Info);
}
+ llvm::SmallVector<TargetInfo::ConstraintInfo, 4> InputConstraintInfos;
+
for (unsigned i = NumOutputs, e = NumOutputs + NumInputs; i != e; i++) {
StringLiteral *Literal = Constraints[i];
if (Literal->isWide())
@@ -989,23 +991,7 @@
DefaultFunctionArrayConversion(Exprs[i]);
- // If this is a tied constraint, verify that the output and input have
- // either exactly the same type, or that they are int/ptr operands with the
- // same size (int/long, int*/long, are ok etc).
- if (Info.hasTiedOperand()) {
- unsigned TiedTo = Info.getTiedOperand();
- QualType T1 = Exprs[TiedTo]->getType(), T2 = Exprs[i]->getType();
- if (!Context.hasSameType(T1, T2)) {
- // Int/ptr operands are ok if they are the same size.
- if (!(T1->isIntegerType() || T1->isPointerType()) ||
- !(T2->isIntegerType() || T2->isPointerType()) ||
- Context.getTypeSize(T1) != Context.getTypeSize(T2))
- return StmtError(Diag(InputExpr->getSubExpr()->getLocStart(),
- diag::err_asm_tying_incompatible_types)
- << T2 << T1 << Exprs[TiedTo]->getSourceRange()
- << Exprs[i]->getSourceRange());
- }
- }
+ InputConstraintInfos.push_back(Info);
}
// Check that the clobbers are valid.
@@ -1043,6 +1029,38 @@
return StmtError();
}
+ // Validate tied input operands for type mismatches.
+ for (unsigned i = 0, e = InputConstraintInfos.size(); i != e; ++i) {
+ TargetInfo::ConstraintInfo &Info = InputConstraintInfos[i];
+
+ // If this is a tied constraint, verify that the output and input have
+ // either exactly the same type, or that they are int/ptr operands with the
+ // same size (int/long, int*/long, are ok etc).
+ if (!Info.hasTiedOperand()) continue;
+
+ unsigned TiedTo = Info.getTiedOperand();
+ Expr *OutputExpr = Exprs[TiedTo];
+ ParenExpr *InputExpr = cast<ParenExpr>(Exprs[i+NumOutputs]);
+ QualType T1 = OutputExpr->getType();
+ QualType T2 = InputExpr->getType();
+ if (Context.hasSameType(T1, T2))
+ continue; // All types can be tied to themselves.
+
+
+ // Int/ptr operands are ok if they are the same size.
+ if ((T1->isIntegerType() || T1->isPointerType()) &&
+ (T2->isIntegerType() || T2->isPointerType())) {
+ if (Context.getTypeSize(T1) == Context.getTypeSize(T2))
+ continue;
+ }
+
+ Diag(InputExpr->getSubExpr()->getLocStart(),
+ diag::err_asm_tying_incompatible_types)
+ << T2 << T1 << OutputExpr->getSourceRange()
+ << InputExpr->getSourceRange();
+ DeleteStmt(NS);
+ return StmtError();
+ }
return Owned(NS);
}
More information about the cfe-commits
mailing list