diff options
author | Anders Carlsson <andersca@mac.com> | 2009-01-18 02:06:20 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-01-18 02:06:20 +0000 |
commit | 300fb5d0ef7edc87f3fdba17fc8b1184013b35ae (patch) | |
tree | a1f4938e7fde10bce1c3a22b37ab795700e76c31 /lib/CodeGen/CGStmt.cpp | |
parent | 190d6a25393995b42e32086949a68285ee423fb9 (diff) |
CG support for inline asm constraints with symbolic names. Fixes PR3345
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62444 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGStmt.cpp')
-rw-r--r-- | lib/CodeGen/CGStmt.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index 04fc26dd89..cd5626db5c 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -837,7 +837,10 @@ static std::string ConvertAsmString(const AsmStmt& S, bool &Failed) } static std::string SimplifyConstraint(const char* Constraint, - TargetInfo &Target) { + TargetInfo &Target, + const std::string *OutputNamesBegin = 0, + const std::string *OutputNamesEnd = 0) +{ std::string Result; while (*Constraint) { @@ -853,6 +856,17 @@ static std::string SimplifyConstraint(const char* Constraint, case 'g': Result += "imr"; break; + case '[': { + assert(OutputNamesBegin && OutputNamesEnd && + "Must pass output names to constraints with a symbolic name"); + unsigned Index; + bool result = Target.resolveSymbolicName(Constraint, + OutputNamesBegin, + OutputNamesEnd, Index); + assert(result && "Could not resolve symbolic name"); + Result += llvm::utostr(Index); + break; + } } Constraint++; @@ -986,7 +1000,9 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) { Constraints += ','; // Simplify the input constraint. - InputConstraint = SimplifyConstraint(InputConstraint.c_str(), Target); + InputConstraint = SimplifyConstraint(InputConstraint.c_str(), Target, + S.begin_output_names(), + S.end_output_names()); llvm::Value *Arg = EmitAsmInput(S, Info, InputExpr, Constraints); |