summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-01-18 02:06:20 +0000
committerAnders Carlsson <andersca@mac.com>2009-01-18 02:06:20 +0000
commita92271d0679263800e36bac13710f78116463451 (patch)
treec2d3b0ea8e0758d3981d6d7f1111920777b7d60d /clang/lib/CodeGen
parent7e5185b2649f1f5c95e01be3570c0edb529480fe (diff)
downloadbcm5719-llvm-a92271d0679263800e36bac13710f78116463451.tar.gz
bcm5719-llvm-a92271d0679263800e36bac13710f78116463451.zip
CG support for inline asm constraints with symbolic names. Fixes PR3345
llvm-svn: 62444
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 04fc26dd895..cd5626db5c7 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/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);
OpenPOWER on IntegriCloud