diff options
author | Chad Rosier <mcrosier@apple.com> | 2012-08-28 21:11:24 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2012-08-28 21:11:24 +0000 |
commit | 649dfc317d04648597c72d1d9678a1ac0769ae90 (patch) | |
tree | c6c41b145d98af312f08a2b0550a4649f3a95857 /clang/lib/CodeGen | |
parent | a82412da210834dd053d9168637dda7b65190257 (diff) | |
download | bcm5719-llvm-649dfc317d04648597c72d1d9678a1ac0769ae90.tar.gz bcm5719-llvm-649dfc317d04648597c72d1d9678a1ac0769ae90.zip |
[ms-inline asm] Have MSAsmStmts use the generic EmitAsmStmt codegen function.
llvm-svn: 162796
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGStmt.cpp | 46 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 1 |
2 files changed, 6 insertions, 41 deletions
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index 4e8d85733b1..465fb968b7b 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -132,8 +132,8 @@ void CodeGenFunction::EmitStmt(const Stmt *S) { case Stmt::ReturnStmtClass: EmitReturnStmt(cast<ReturnStmt>(*S)); break; case Stmt::SwitchStmtClass: EmitSwitchStmt(cast<SwitchStmt>(*S)); break; - case Stmt::GCCAsmStmtClass: EmitAsmStmt(cast<AsmStmt>(*S)); break; - case Stmt::MSAsmStmtClass: EmitMSAsmStmt(cast<MSAsmStmt>(*S)); break; + case Stmt::GCCAsmStmtClass: // Intentional fall-through. + case Stmt::MSAsmStmtClass: EmitAsmStmt(cast<AsmStmt>(*S)); break; case Stmt::ObjCAtTryStmtClass: EmitObjCAtTryStmt(cast<ObjCAtTryStmt>(*S)); @@ -1619,6 +1619,10 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) { llvm::CallInst *Result = Builder.CreateCall(IA, Args); Result->addAttribute(~0, llvm::Attribute::NoUnwind); + // Add the inline asm non-standard dialect attribute on MS-style inline asms. + if (isa<MSAsmStmt>(&S)) + Result->addAttribute(~0, llvm::Attribute::IANSDialect); + // Slap the source location of the inline asm into a !srcloc metadata on the // call. FIXME: Handle metadata for MS-style inline asms. if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(&S)) @@ -1668,41 +1672,3 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) { EmitStoreThroughLValue(RValue::get(Tmp), ResultRegDests[i]); } } - -void CodeGenFunction::EmitMSAsmStmt(const MSAsmStmt &S) { - std::vector<llvm::Value*> Args; - std::vector<llvm::Type *> ArgTypes; - std::string Constraints; - - // Clobbers - for (unsigned i = 0, e = S.getNumClobbers(); i != e; ++i) { - StringRef Clobber = S.getClobber(i); - - if (Clobber != "memory" && Clobber != "cc") - Clobber = Target.getNormalizedGCCRegisterName(Clobber); - - if (i != 0) - Constraints += ','; - - Constraints += "~{"; - Constraints += Clobber; - Constraints += '}'; - } - - // Add machine specific clobbers - std::string MachineClobbers = Target.getClobbers(); - if (!MachineClobbers.empty()) { - if (!Constraints.empty()) - Constraints += ','; - Constraints += MachineClobbers; - } - - llvm::FunctionType *FTy = - llvm::FunctionType::get(VoidTy, ArgTypes, false); - - llvm::InlineAsm *IA = - llvm::InlineAsm::get(FTy, *S.getAsmString(), Constraints, true); - llvm::CallInst *Result = Builder.CreateCall(IA, Args); - Result->addAttribute(~0, llvm::Attribute::NoUnwind); - Result->addAttribute(~0, llvm::Attribute::IANSDialect); -} diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index b96ee2e14a3..0e4e5e63c44 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -2002,7 +2002,6 @@ public: void EmitCaseStmt(const CaseStmt &S); void EmitCaseStmtRange(const CaseStmt &S); void EmitAsmStmt(const AsmStmt &S); - void EmitMSAsmStmt(const MSAsmStmt &S); void EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S); void EmitObjCAtTryStmt(const ObjCAtTryStmt &S); |