[cfe-commits] r161524 - in /cfe/trunk: lib/CodeGen/CGStmt.cpp test/CodeGen/ms-inline-asm.c

Chad Rosier mcrosier at apple.com
Wed Aug 8 14:15:52 PDT 2012


Author: mcrosier
Date: Wed Aug  8 16:15:52 2012
New Revision: 161524

URL: http://llvm.org/viewvc/llvm-project?rev=161524&view=rev
Log:
[ms-inline asm] Add basic codegen support for simple asm stmts.  Currently,
only machine specific clobbers are modeled.

Modified:
    cfe/trunk/lib/CodeGen/CGStmt.cpp
    cfe/trunk/test/CodeGen/ms-inline-asm.c

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=161524&r1=161523&r2=161524&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Wed Aug  8 16:15:52 2012
@@ -1686,4 +1686,19 @@
   // 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);
 }

Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=161524&r1=161523&r2=161524&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c Wed Aug  8 16:15:52 2012
@@ -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 {}
 }





More information about the cfe-commits mailing list