From 6100ae120c5d8e3b61e6c17426c84e0a27b90a5c Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Mon, 27 Aug 2012 23:47:56 +0000 Subject: [PATCH] [ms-inline asm] Add virtual function, getClobber, that returns a StringRef. More work towards unifying asm stmt codegen. llvm-svn: 162712 --- clang/include/clang/AST/Stmt.h | 2 ++ clang/lib/AST/Stmt.cpp | 4 ++++ clang/lib/CodeGen/CGStmt.cpp | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h index 81eac33655c4..3c060bab999a 100644 --- a/clang/include/clang/AST/Stmt.h +++ b/clang/include/clang/AST/Stmt.h @@ -1444,6 +1444,7 @@ public: //===--- Other ---===// unsigned getNumClobbers() const { return NumClobbers; } + virtual StringRef getClobber(unsigned i) const = 0; static bool classof(const Stmt *T) { return T->getStmtClass() == GCCAsmStmtClass || @@ -1645,6 +1646,7 @@ public: /// This returns -1 if the operand name is invalid. int getNamedOperand(StringRef SymbolicName) const; + StringRef getClobber(unsigned i) const; StringLiteral *getClobberStringLiteral(unsigned i) { return Clobbers[i]; } const StringLiteral *getClobberStringLiteral(unsigned i) const { return Clobbers[i]; diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index 94aec949989f..fc66202c4aa7 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -321,6 +321,10 @@ bool Stmt::hasImplicitControlFlow() const { } } +StringRef GCCAsmStmt::getClobber(unsigned i) const { + return getClobberStringLiteral(i)->getString(); +} + Expr *GCCAsmStmt::getOutputExpr(unsigned i) { return cast(Exprs[i]); } diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index 3ebfbddba444..646d820add44 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -1581,7 +1581,7 @@ void CodeGenFunction::EmitGCCAsmStmt(const GCCAsmStmt &S) { // Clobbers for (unsigned i = 0, e = S.getNumClobbers(); i != e; i++) { - StringRef Clobber = S.getClobberStringLiteral(i)->getString(); + StringRef Clobber = S.getClobber(i); if (Clobber != "memory" && Clobber != "cc") Clobber = Target.getNormalizedGCCRegisterName(Clobber);