aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/PCHReader.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-04-17 20:57:14 +0000
committerDouglas Gregor <dgregor@apple.com>2009-04-17 20:57:14 +0000
commitcd7d5a9dc558178ed7a66032f888781b3c592e4f (patch)
tree9f30f09488df090014d03a6147335c150bda41ec /lib/Frontend/PCHReader.cpp
parent409d4e716a01a71c4fecfaec59ca8348c8a5d275 (diff)
PCH support for inline assembly statements.
This completes support for all of C (+ extensions). We can (again) build a PCH file for Carbon.h. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69385 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PCHReader.cpp')
-rw-r--r--lib/Frontend/PCHReader.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index 8889312090..da7b4229aa 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -262,6 +262,7 @@ namespace {
unsigned VisitBreakStmt(BreakStmt *S);
unsigned VisitReturnStmt(ReturnStmt *S);
unsigned VisitDeclStmt(DeclStmt *S);
+ unsigned VisitAsmStmt(AsmStmt *S);
unsigned VisitExpr(Expr *E);
unsigned VisitPredefinedExpr(PredefinedExpr *E);
unsigned VisitDeclRefExpr(DeclRefExpr *E);
@@ -456,6 +457,42 @@ unsigned PCHStmtReader::VisitDeclStmt(DeclStmt *S) {
return 0;
}
+unsigned PCHStmtReader::VisitAsmStmt(AsmStmt *S) {
+ VisitStmt(S);
+ unsigned NumOutputs = Record[Idx++];
+ unsigned NumInputs = Record[Idx++];
+ unsigned NumClobbers = Record[Idx++];
+ S->setAsmLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
+ S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
+ S->setVolatile(Record[Idx++]);
+ S->setSimple(Record[Idx++]);
+
+ unsigned StackIdx
+ = StmtStack.size() - (NumOutputs*2 + NumInputs*2 + NumClobbers + 1);
+ S->setAsmString(cast_or_null<StringLiteral>(StmtStack[StackIdx++]));
+
+ // Outputs and inputs
+ llvm::SmallVector<std::string, 16> Names;
+ llvm::SmallVector<StringLiteral*, 16> Constraints;
+ llvm::SmallVector<Stmt*, 16> Exprs;
+ for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
+ Names.push_back(Reader.ReadString(Record, Idx));
+ Constraints.push_back(cast_or_null<StringLiteral>(StmtStack[StackIdx++]));
+ Exprs.push_back(StmtStack[StackIdx++]);
+ }
+ S->setOutputsAndInputs(NumOutputs, NumInputs,
+ &Names[0], &Constraints[0], &Exprs[0]);
+
+ // Constraints
+ llvm::SmallVector<StringLiteral*, 16> Clobbers;
+ for (unsigned I = 0; I != NumClobbers; ++I)
+ Clobbers.push_back(cast_or_null<StringLiteral>(StmtStack[StackIdx++]));
+ S->setClobbers(&Clobbers[0], NumClobbers);
+
+ assert(StackIdx == StmtStack.size() && "Error deserializing AsmStmt");
+ return NumOutputs*2 + NumInputs*2 + NumClobbers + 1;
+}
+
unsigned PCHStmtReader::VisitExpr(Expr *E) {
VisitStmt(E);
E->setType(Reader.GetType(Record[Idx++]));
@@ -2273,6 +2310,10 @@ Stmt *PCHReader::ReadStmt() {
S = new (Context) DeclStmt(Empty);
break;
+ case pch::STMT_ASM:
+ S = new (Context) AsmStmt(Empty);
+ break;
+
case pch::EXPR_PREDEFINED:
S = new (Context) PredefinedExpr(Empty);
break;