aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Hastings <stuart@apple.com>2011-06-07 23:45:05 +0000
committerStuart Hastings <stuart@apple.com>2011-06-07 23:45:05 +0000
commit002333f8b2cf1a8614e532f6ce366b21af85142c (patch)
tree4a0d00b35a47d56ff520a21395d7ec4a9320cc00
parentdb6393f259b8e634302e27d538ca4760f4221d91 (diff)
Clang support for ARM Uv/Uy/Uq inline-asm constraints.
rdar://problem/9037836 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132737 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/TargetInfo.h6
-rw-r--r--lib/Basic/Targets.cpp30
-rw-r--r--lib/CodeGen/CGStmt.cpp2
-rw-r--r--test/CodeGen/arm-asm.c7
4 files changed, 37 insertions, 8 deletions
diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h
index b830bf2f82..5b6d745f15 100644
--- a/include/clang/Basic/TargetInfo.h
+++ b/include/clang/Basic/TargetInfo.h
@@ -368,11 +368,11 @@ public:
ConstraintInfo *OutputConstraints,
unsigned NumOutputs, unsigned &Index) const;
- virtual std::string convertConstraint(const char Constraint) const {
+ virtual std::string convertConstraint(const char *&Constraint) const {
// 'p' defaults to 'r', but can be overridden by targets.
- if (Constraint == 'p')
+ if (*Constraint == 'p')
return std::string("r");
- return std::string(1, Constraint);
+ return std::string(1, *Constraint);
}
// Returns a string of target-specific clobbers, in LLVM format.
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
index 779c99532c..82f5df1cf1 100644
--- a/lib/Basic/Targets.cpp
+++ b/lib/Basic/Targets.cpp
@@ -1121,7 +1121,7 @@ public:
}
virtual bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const;
- virtual std::string convertConstraint(const char Constraint) const;
+ virtual std::string convertConstraint(const char *&Constraint) const;
virtual const char *getClobbers() const {
return "~{dirflag},~{fpsr},~{flags}";
}
@@ -1449,8 +1449,8 @@ X86TargetInfo::validateAsmConstraint(const char *&Name,
std::string
-X86TargetInfo::convertConstraint(const char Constraint) const {
- switch (Constraint) {
+X86TargetInfo::convertConstraint(const char *&Constraint) const {
+ switch (*Constraint) {
case 'a': return std::string("{ax}");
case 'b': return std::string("{bx}");
case 'c': return std::string("{cx}");
@@ -1464,7 +1464,7 @@ X86TargetInfo::convertConstraint(const char Constraint) const {
case 'u': // second from top of floating point stack.
return std::string("{st(1)}"); // second from top of floating point stack.
default:
- return std::string(1, Constraint);
+ return std::string(1, *Constraint);
}
}
} // end anonymous namespace
@@ -2037,9 +2037,31 @@ public:
case 'P': // VFP Floating point register double precision
Info.setAllowsRegister();
return true;
+ case 'U': // a memory reference...
+ switch (Name[1]) {
+ case 'q': // ...ARMV4 ldrsb
+ case 'v': // ...VFP load/store (reg+constant offset)
+ case 'y': // ...iWMMXt load/store
+ Info.setAllowsMemory();
+ Name++;
+ return true;
+ }
}
return false;
}
+ std::string
+ virtual convertConstraint(const char *&Constraint) const {
+ std::string R;
+ switch (*Constraint) {
+ case 'U': // Two-character constraint; add "^" hint for later parsing.
+ R = std::string("^") + Constraint;
+ Constraint++;
+ break;
+ default:
+ return std::string(1, *Constraint);
+ }
+ return R;
+ }
virtual const char *getClobbers() const {
// FIXME: Is this really right?
return "";
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index 782ff06160..a982621be7 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -1222,7 +1222,7 @@ SimplifyConstraint(const char *Constraint, const TargetInfo &Target,
while (*Constraint) {
switch (*Constraint) {
default:
- Result += Target.convertConstraint(*Constraint);
+ Result += Target.convertConstraint(Constraint);
break;
// Ignore these
case '*':
diff --git a/test/CodeGen/arm-asm.c b/test/CodeGen/arm-asm.c
new file mode 100644
index 0000000000..9b1082a198
--- /dev/null
+++ b/test/CodeGen/arm-asm.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple thumb %s -emit-llvm -o - | FileCheck %s
+int t1() {
+ static float k = 1.0f;
+ // CHECK: flds s15
+ __asm__ volatile ("flds s15, %[k] \n" :: [k] "Uv" (k) : "s15");
+ return 0;
+}