mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-02 07:32:52 +00:00
Improve the heuristic to emit the alias if the number of hard-coded registers
are also greater than the alias. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133038 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5d40ef2b1d
commit
393c4047c0
@ -232,10 +232,10 @@ cmovnzq %rbx, %rax
|
||||
|
||||
// rdar://8407928
|
||||
// CHECK: inb $127, %al
|
||||
// CHECK: inw %dx, %ax
|
||||
// CHECK: inw %dx
|
||||
// CHECK: outb %al, $127
|
||||
// CHECK: outw %ax, %dx
|
||||
// CHECK: inl %dx, %eax
|
||||
// CHECK: outw %dx
|
||||
// CHECK: inl %dx
|
||||
inb $0x7f
|
||||
inw %dx
|
||||
outb $0x7f
|
||||
@ -244,12 +244,12 @@ inl %dx
|
||||
|
||||
|
||||
// PR8114
|
||||
// CHECK: outb %al, %dx
|
||||
// CHECK: outb %al, %dx
|
||||
// CHECK: outw %ax, %dx
|
||||
// CHECK: outw %ax, %dx
|
||||
// CHECK: outl %eax, %dx
|
||||
// CHECK: outl %eax, %dx
|
||||
// CHECK: outb %dx
|
||||
// CHECK: outb %dx
|
||||
// CHECK: outw %dx
|
||||
// CHECK: outw %dx
|
||||
// CHECK: outl %dx
|
||||
// CHECK: outl %dx
|
||||
|
||||
out %al, (%dx)
|
||||
outb %al, (%dx)
|
||||
@ -258,12 +258,12 @@ outw %ax, (%dx)
|
||||
out %eax, (%dx)
|
||||
outl %eax, (%dx)
|
||||
|
||||
// CHECK: inb %dx, %al
|
||||
// CHECK: inb %dx, %al
|
||||
// CHECK: inw %dx, %ax
|
||||
// CHECK: inw %dx, %ax
|
||||
// CHECK: inl %dx, %eax
|
||||
// CHECK: inl %dx, %eax
|
||||
// CHECK: inb %dx
|
||||
// CHECK: inb %dx
|
||||
// CHECK: inw %dx
|
||||
// CHECK: inw %dx
|
||||
// CHECK: inl %dx
|
||||
// CHECK: inl %dx
|
||||
|
||||
in (%dx), %al
|
||||
inb (%dx), %al
|
||||
|
@ -842,6 +842,26 @@ static unsigned CountNumOperands(StringRef AsmString) {
|
||||
return NumOps;
|
||||
}
|
||||
|
||||
static unsigned CountResultNumOperands(StringRef AsmString) {
|
||||
unsigned NumOps = 0;
|
||||
std::pair<StringRef, StringRef> ASM = AsmString.split('\t');
|
||||
|
||||
if (!ASM.second.empty()) {
|
||||
size_t I = ASM.second.find('{');
|
||||
StringRef Str = ASM.second;
|
||||
if (I != StringRef::npos)
|
||||
Str = ASM.second.substr(I, ASM.second.find('|', I));
|
||||
|
||||
ASM = Str.split(' ');
|
||||
|
||||
do {
|
||||
++NumOps;
|
||||
ASM = ASM.second.split(' ');
|
||||
} while (!ASM.second.empty());
|
||||
}
|
||||
|
||||
return NumOps;
|
||||
}
|
||||
|
||||
void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
|
||||
CodeGenTarget Target(Records);
|
||||
@ -887,9 +907,11 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
|
||||
II = Aliases.begin(), IE = Aliases.end(); II != IE; ++II) {
|
||||
const CodeGenInstAlias *CGA = *II;
|
||||
unsigned LastOpNo = CGA->ResultInstOperandIndex.size();
|
||||
unsigned NumResultOps =
|
||||
CountResultNumOperands(CGA->ResultInst->AsmString);
|
||||
|
||||
// Don't emit the alias if it has more operands than what it's aliasing.
|
||||
if (LastOpNo < CountNumOperands(CGA->AsmString))
|
||||
if (NumResultOps < CountNumOperands(CGA->AsmString))
|
||||
continue;
|
||||
|
||||
IAPrinter *IAP = new IAPrinter(AWI, CGA->Result->getAsString(),
|
||||
|
Loading…
Reference in New Issue
Block a user