[llvm-commits] CVS: llvm/lib/Target/ARM/ARMTargetAsmInfo.h ARMTargetAsmInfo.cpp
Dale Johannesen
dalej at apple.com
Sun Apr 29 12:18:05 PDT 2007
Changes in directory llvm/lib/Target/ARM:
ARMTargetAsmInfo.h updated: 1.2 -> 1.3
ARMTargetAsmInfo.cpp updated: 1.15 -> 1.16
---
Log message:
Make ARM-specific version of getInlineAsmLength
---
Diffs of the changes: (+53 -0)
ARMTargetAsmInfo.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
ARMTargetAsmInfo.h | 2 ++
2 files changed, 53 insertions(+)
Index: llvm/lib/Target/ARM/ARMTargetAsmInfo.h
diff -u llvm/lib/Target/ARM/ARMTargetAsmInfo.h:1.2 llvm/lib/Target/ARM/ARMTargetAsmInfo.h:1.3
--- llvm/lib/Target/ARM/ARMTargetAsmInfo.h:1.2 Mon Apr 23 15:04:35 2007
+++ llvm/lib/Target/ARM/ARMTargetAsmInfo.h Sun Apr 29 14:17:45 2007
@@ -25,6 +25,8 @@
ARMTargetAsmInfo(const ARMTargetMachine &TM);
bool isThumb;
+
+ virtual unsigned getInlineAsmLength(const char *Str) const;
};
Index: llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp
diff -u llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp:1.15 llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp:1.16
--- llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp:1.15 Fri Apr 27 08:54:47 2007
+++ llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp Sun Apr 29 14:17:45 2007
@@ -86,3 +86,54 @@
LCOMMDirective = "\t.lcomm\t";
isThumb = Subtarget->isThumb();
}
+
+/// ARM-specific version of TargetAsmInfo::getInlineAsmLength.
+unsigned ARMTargetAsmInfo::getInlineAsmLength(const char *Str) const {
+ // Count the number of bytes in the asm.
+ bool atInsnStart = true;
+ unsigned Length = 0;
+ for (; *Str; ++Str) {
+ if (atInsnStart) {
+ // Skip whitespace
+ while (*Str && isspace(*Str) && *Str != '\n')
+ Str++;
+ // Skip label
+ for (const char* p = Str; *p && !isspace(*p); p++)
+ if (*p == ':') {
+ Str = p+1;
+ break;
+ }
+ // Ignore everything from comment char(s) to EOL
+ if (strncmp(Str, CommentString, strlen(CommentString))==-0)
+ atInsnStart = false;
+ else {
+ // An instruction
+ atInsnStart = false;
+ if (isThumb) {
+ // BL and BLX <non-reg> are 4 bytes, all others 2.
+ const char*p = Str;
+ if ((*Str=='b' || *Str=='B') &&
+ (*(Str+1)=='l' || *(Str+1)=='L')) {
+ if (*(Str+2)=='x' || *(Str+2)=='X') {
+ const char* p = Str+3;
+ while (*p && isspace(*p))
+ p++;
+ if (*p == 'r' || *p=='R')
+ Length += 2; // BLX reg
+ else
+ Length += 4; // BLX non-reg
+ }
+ else
+ Length += 4; // BL
+ } else
+ Length += 2; // Thumb anything else
+ }
+ else
+ Length += 4; // ARM
+ }
+ }
+ if (*Str == '\n' || *Str == SeparatorChar)
+ atInsnStart = true;
+ }
+ return Length;
+}
More information about the llvm-commits
mailing list