1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

Improve the heuristic to emit the alias if the number of hard-coded registers

are also greater than the alias.

llvm-svn: 133038
This commit is contained in:
Bill Wendling 2011-06-15 04:31:19 +00:00
parent a45cbb1743
commit 5ae6b0c972
2 changed files with 38 additions and 16 deletions

View File

@ -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

View File

@ -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(),