aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGStmt.cpp
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2012-08-15 18:12:36 +0000
committerChad Rosier <mcrosier@apple.com>2012-08-15 18:12:36 +0000
commit5aad79f8d54bf4356b2c8b9e56ace9ac8c39adb0 (patch)
tree17c5f7e1d5ba63196ff140cf5ef221bd79c14c9d /lib/CodeGen/CGStmt.cpp
parent89c57a2198145564ab6d0b2ad10fee5a1131bd15 (diff)
[ms-inline asm] Add support for clobbers in CodeGen.
This is a reapplication of r161914 now that the scoping issue has been resolved in r161966. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161967 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGStmt.cpp')
-rw-r--r--lib/CodeGen/CGStmt.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index 467c77945e..d78908dee8 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -1691,14 +1691,36 @@ 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(), MachineClobbers, true);
+ 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);