forked from OSchip/llvm-project
Handle passing constant integers to functions much more efficiently. Instead
of generating this code: mov %EAX, 4 mov DWORD PTR [%ESP], %EAX mov %AX, 123 movsx %EAX, %AX mov DWORD PTR [%ESP + 4], %EAX call Y we now generate: mov DWORD PTR [%ESP], 4 mov DWORD PTR [%ESP + 4], 123 call Y Which hurts the eyes less. :) Considering that register pressure around call sites is already high (with all of the callee clobber registers n stuff), this may help a lot. llvm-svn: 12028
This commit is contained in:
parent
b19dcc6651
commit
1f4642c47c
|
@ -1101,18 +1101,31 @@ void ISel::doCall(const ValueRecord &Ret, MachineInstr *CallMI,
|
|||
unsigned ArgReg;
|
||||
switch (getClassB(Args[i].Ty)) {
|
||||
case cByte:
|
||||
case cShort: {
|
||||
// Promote arg to 32 bits wide into a temporary register...
|
||||
unsigned R = makeAnotherReg(Type::UIntTy);
|
||||
promote32(R, Args[i]);
|
||||
addRegOffset(BuildMI(BB, X86::MOV32mr, 5),
|
||||
X86::ESP, ArgOffset).addReg(R);
|
||||
case cShort:
|
||||
if (Args[i].Val && isa<ConstantInt>(Args[i].Val)) {
|
||||
// Zero/Sign extend constant, then stuff into memory.
|
||||
ConstantInt *Val = cast<ConstantInt>(Args[i].Val);
|
||||
Val = cast<ConstantInt>(ConstantExpr::getCast(Val, Type::IntTy));
|
||||
addRegOffset(BuildMI(BB, X86::MOV32mi, 5), X86::ESP, ArgOffset)
|
||||
.addImm(Val->getRawValue() & 0xFFFFFFFF);
|
||||
} else {
|
||||
// Promote arg to 32 bits wide into a temporary register...
|
||||
ArgReg = makeAnotherReg(Type::UIntTy);
|
||||
promote32(ArgReg, Args[i]);
|
||||
addRegOffset(BuildMI(BB, X86::MOV32mr, 5),
|
||||
X86::ESP, ArgOffset).addReg(ArgReg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case cInt:
|
||||
ArgReg = Args[i].Val ? getReg(Args[i].Val) : Args[i].Reg;
|
||||
addRegOffset(BuildMI(BB, X86::MOV32mr, 5),
|
||||
X86::ESP, ArgOffset).addReg(ArgReg);
|
||||
if (Args[i].Val && isa<ConstantInt>(Args[i].Val)) {
|
||||
unsigned Val = cast<ConstantInt>(Args[i].Val)->getRawValue();
|
||||
addRegOffset(BuildMI(BB, X86::MOV32mi, 5),
|
||||
X86::ESP, ArgOffset).addImm(Val);
|
||||
} else {
|
||||
ArgReg = Args[i].Val ? getReg(Args[i].Val) : Args[i].Reg;
|
||||
addRegOffset(BuildMI(BB, X86::MOV32mr, 5),
|
||||
X86::ESP, ArgOffset).addReg(ArgReg);
|
||||
}
|
||||
break;
|
||||
case cLong:
|
||||
ArgReg = Args[i].Val ? getReg(Args[i].Val) : Args[i].Reg;
|
||||
|
|
Loading…
Reference in New Issue