mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
Make ARM-specific version of getInlineAsmLength
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36572 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -353,7 +353,7 @@ namespace llvm {
|
|||||||
|
|
||||||
/// Measure the specified inline asm to determine an approximation of its
|
/// Measure the specified inline asm to determine an approximation of its
|
||||||
/// length.
|
/// length.
|
||||||
unsigned getInlineAsmLength(const char *Str) const;
|
virtual unsigned getInlineAsmLength(const char *Str) const;
|
||||||
|
|
||||||
/// ExpandInlineAsm - This hook allows the target to expand an inline asm
|
/// ExpandInlineAsm - This hook allows the target to expand an inline asm
|
||||||
/// call to be explicit llvm code if it wants to. This is useful for
|
/// call to be explicit llvm code if it wants to. This is useful for
|
||||||
|
@@ -86,3 +86,54 @@ ARMTargetAsmInfo::ARMTargetAsmInfo(const ARMTargetMachine &TM) {
|
|||||||
LCOMMDirective = "\t.lcomm\t";
|
LCOMMDirective = "\t.lcomm\t";
|
||||||
isThumb = Subtarget->isThumb();
|
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;
|
||||||
|
}
|
||||||
|
@@ -25,6 +25,8 @@ namespace llvm {
|
|||||||
ARMTargetAsmInfo(const ARMTargetMachine &TM);
|
ARMTargetAsmInfo(const ARMTargetMachine &TM);
|
||||||
|
|
||||||
bool isThumb;
|
bool isThumb;
|
||||||
|
|
||||||
|
virtual unsigned getInlineAsmLength(const char *Str) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user