[cfe-commits] r132737 - in /cfe/trunk: include/clang/Basic/TargetInfo.h lib/Basic/Targets.cpp lib/CodeGen/CGStmt.cpp test/CodeGen/arm-asm.c
Stuart Hastings
stuart at apple.com
Tue Jun 7 16:45:05 PDT 2011
Author: stuart
Date: Tue Jun 7 18:45:05 2011
New Revision: 132737
URL: http://llvm.org/viewvc/llvm-project?rev=132737&view=rev
Log:
Clang support for ARM Uv/Uy/Uq inline-asm constraints.
rdar://problem/9037836
Added:
cfe/trunk/test/CodeGen/arm-asm.c
Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=132737&r1=132736&r2=132737&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Tue Jun 7 18:45:05 2011
@@ -368,11 +368,11 @@
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.
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=132737&r1=132736&r2=132737&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Jun 7 18:45:05 2011
@@ -1121,7 +1121,7 @@
}
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 @@
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 @@
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 @@
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 "";
Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=132737&r1=132736&r2=132737&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Tue Jun 7 18:45:05 2011
@@ -1222,7 +1222,7 @@
while (*Constraint) {
switch (*Constraint) {
default:
- Result += Target.convertConstraint(*Constraint);
+ Result += Target.convertConstraint(Constraint);
break;
// Ignore these
case '*':
Added: cfe/trunk/test/CodeGen/arm-asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-asm.c?rev=132737&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/arm-asm.c (added)
+++ cfe/trunk/test/CodeGen/arm-asm.c Tue Jun 7 18:45:05 2011
@@ -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;
+}
More information about the cfe-commits
mailing list