diff options
-rw-r--r-- | lib/CodeGen/CGStmt.cpp | 15 | ||||
-rw-r--r-- | test/CodeGen/ms-inline-asm.c | 3 |
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index 33776b6c59..2e4c557db6 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -1686,4 +1686,19 @@ void CodeGenFunction::EmitMSAsmStmt(const MSAsmStmt &S) { // MS-style inline assembly is not fully supported, so sema emits a warning. if (!CGM.getCodeGenOpts().EmitMicrosoftInlineAsm) return; + + assert (S.isSimple() && "CodeGen can only handle simple MSAsmStmts."); + + std::vector<llvm::Value*> Args; + std::vector<llvm::Type *> ArgTypes; + + std::string MachineClobbers = Target.getClobbers(); + + llvm::FunctionType *FTy = + llvm::FunctionType::get(VoidTy, ArgTypes, false); + + llvm::InlineAsm *IA = + llvm::InlineAsm::get(FTy, *S.getAsmString(), MachineClobbers, true); + llvm::CallInst *Result = Builder.CreateCall(IA, Args); + Result->addAttribute(~0, llvm::Attribute::NoUnwind); } diff --git a/test/CodeGen/ms-inline-asm.c b/test/CodeGen/ms-inline-asm.c index 2d36bbca52..3234b98bfa 100644 --- a/test/CodeGen/ms-inline-asm.c +++ b/test/CodeGen/ms-inline-asm.c @@ -1,7 +1,8 @@ -// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -O0 -fms-extensions -w -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -O0 -fms-extensions -fenable-experimental-ms-inline-asm -w -emit-llvm -o - | FileCheck %s void t1() { // CHECK: @t1 +// CHECK: call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"() nounwind // CHECK: ret void __asm {} } |