mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-23 02:32:11 +00:00
Original patch was overly complicated.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32723 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
62d75e7695
commit
40ee69f3ca
@ -89,38 +89,15 @@ namespace {
|
|||||||
|
|
||||||
/// stripRegisterPrefix - This method strips the character prefix from a
|
/// stripRegisterPrefix - This method strips the character prefix from a
|
||||||
/// register name so that only the number is left. Used by for linux asm.
|
/// register name so that only the number is left. Used by for linux asm.
|
||||||
void stripRegisterPrefix(std::string &Name) {
|
const char *stripRegisterPrefix(const char *RegName) {
|
||||||
// Potential prefixes.
|
switch (RegName[0]) {
|
||||||
static const char *Prefixes[] = { "r", "f", "v", "cr" };
|
case 'r':
|
||||||
unsigned NPrefixes = sizeof(Prefixes) / sizeof(const char *);
|
case 'f':
|
||||||
// Fetch string length.
|
case 'v': return RegName + 1;
|
||||||
unsigned Size = Name.size();
|
case 'c': if (RegName[0] == 'r') return RegName + 2;
|
||||||
// Start position of numeric portion.
|
|
||||||
unsigned Pos = 0;
|
|
||||||
|
|
||||||
// Try each prefix.
|
|
||||||
for (unsigned i = 0; i < NPrefixes; ++i) {
|
|
||||||
const char *Prefix = Prefixes[i];
|
|
||||||
unsigned Length = strlen(Prefix);
|
|
||||||
// Does it match the beginning?
|
|
||||||
if (Name.compare(0, Length, Prefix, Length) == 0) {
|
|
||||||
// If so, start looking beyond the prefix.
|
|
||||||
Pos = strlen(Prefix);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we have a match.
|
|
||||||
if (Pos) {
|
|
||||||
// Remaining characters better be digits.
|
|
||||||
for (unsigned j = Pos; j < Size; ++j) {
|
|
||||||
unsigned Ch = Name[j];
|
|
||||||
if (Ch < '0' || '9' < Ch) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pass back just the numeric portion.
|
|
||||||
Name = Name.substr(Pos, Size - Pos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return RegName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// printRegister - Print register according to target requirements.
|
/// printRegister - Print register according to target requirements.
|
||||||
@ -135,11 +112,11 @@ namespace {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Name = TM.getRegisterInfo()->get(RegNo).Name;
|
const char *RegName = TM.getRegisterInfo()->get(RegNo).Name;
|
||||||
// Linux assembler (Others?) does not take register mnemonics.
|
// Linux assembler (Others?) does not take register mnemonics.
|
||||||
// FIXME - What about special registers used in mfspr/mtspr?
|
// FIXME - What about special registers used in mfspr/mtspr?
|
||||||
if (!Subtarget.isDarwin()) stripRegisterPrefix(Name);
|
if (!Subtarget.isDarwin()) RegName = stripRegisterPrefix(RegName);
|
||||||
O << Name;
|
O << RegName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printOperand(const MachineInstr *MI, unsigned OpNo) {
|
void printOperand(const MachineInstr *MI, unsigned OpNo) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user