summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2007-04-29 19:17:45 +0000
committerDale Johannesen <dalej@apple.com>2007-04-29 19:17:45 +0000
commit1ee29dd026d80483cad5ccad5c62c390ccd38678 (patch)
tree3d8172d3a72283c27016e50eadee47b06e517eea /llvm/lib
parentb9bf8a8daa505995f5571ec96af2ded3d9903d66 (diff)
downloadbcm5719-llvm-1ee29dd026d80483cad5ccad5c62c390ccd38678.tar.gz
bcm5719-llvm-1ee29dd026d80483cad5ccad5c62c390ccd38678.zip
Make ARM-specific version of getInlineAsmLength
llvm-svn: 36572
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp51
-rw-r--r--llvm/lib/Target/ARM/ARMTargetAsmInfo.h2
2 files changed, 53 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp b/llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp
index 196348b9e9c..3d24d60c6a6 100644
--- a/llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp
@@ -86,3 +86,54 @@ ARMTargetAsmInfo::ARMTargetAsmInfo(const ARMTargetMachine &TM) {
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;
+}
diff --git a/llvm/lib/Target/ARM/ARMTargetAsmInfo.h b/llvm/lib/Target/ARM/ARMTargetAsmInfo.h
index 3fb9bb00661..441be2bd751 100644
--- a/llvm/lib/Target/ARM/ARMTargetAsmInfo.h
+++ b/llvm/lib/Target/ARM/ARMTargetAsmInfo.h
@@ -25,6 +25,8 @@ namespace llvm {
ARMTargetAsmInfo(const ARMTargetMachine &TM);
bool isThumb;
+
+ virtual unsigned getInlineAsmLength(const char *Str) const;
};
OpenPOWER on IntegriCloud