[PATCH] D18036: Enabling multiple letters and digits in constraints
Konstantin Vladimirov via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 10 05:13:56 PST 2016
Tilir created this revision.
Tilir added reviewers: echristo, dsanders.
Tilir added a subscriber: llvm-commits.
Herald added a reviewer: vkalintiris.
There was a FIXME in multiletter constraints, that required to make them really any number of letters and digits, and also problems in documentation. This patch is about to fix both.
http://reviews.llvm.org/D18036
Files:
llvm-3.7.0/docs/LangRef.rst
llvm-3.7.0/lib/IR/InlineAsm.cpp
Index: llvm-3.7.0/lib/IR/InlineAsm.cpp
===================================================================
--- llvm-3.7.0/lib/IR/InlineAsm.cpp
+++ llvm-3.7.0/lib/IR/InlineAsm.cpp
@@ -179,14 +179,24 @@
pCodes = &multipleAlternatives[multipleAlternativeIndex].Codes;
++I;
} else if (*I == '^') {
- // Multi-letter constraint
- // FIXME: For now assuming these are 2-character constraints.
- pCodes->push_back(std::string(I+1, I+3));
- I += 3;
+ // Multi-letter constraint: any number of letters and digits
+ ++I;
+ std::string code(I, I+1);
+ ++I;
+ while (isalnum(static_cast<unsigned char>(*I))) {
+ code += *I;
+ ++I;
+ }
+ pCodes->push_back(code);
} else {
- // Single letter constraint.
- pCodes->push_back(std::string(I, I+1));
+ // Single letter constraint, or single letter with trailing digits
+ std::string code(I, I+1);
++I;
+ while (isdigit(static_cast<unsigned char>(*I))) {
+ code += *I;
+ ++I;
+ }
+ pCodes->push_back(code);
}
}
Index: llvm-3.7.0/docs/LangRef.rst
===================================================================
--- llvm-3.7.0/docs/LangRef.rst
+++ llvm-3.7.0/docs/LangRef.rst
@@ -3020,9 +3020,10 @@
""""""""""""""""
After a potential prefix comes constraint code, or codes.
-A Constraint Code is either a single letter (e.g. "``r``"), a "``^``" character
-followed by two letters (e.g. "``^wc``"), or "``{``" register-name "``}``"
-(e.g. "``{eax}``").
+A Constraint Code is either a single letter (e.g. "``r``"), a single letter,
+followed by arbitrary digits (e.g. "``A32``", a "``^``" character
+followed by any number of letters and digits (e.g. "``^wc4``"),
+or "``{``" register-name "``}``" (e.g. "``{eax}``").
The one and two letter constraint codes are typically chosen to be the same as
GCC's constraint codes.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18036.50264.patch
Type: text/x-patch
Size: 1920 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160310/44e1ba9b/attachment.bin>
More information about the llvm-commits
mailing list