mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-11 06:06:52 +00:00
Improve code for passing constant longs as arguments to function calls.
For example, on this instruction: call void %test(long 1234) Instead of this: mov %EAX, 1234 mov %ECX, 0 mov DWORD PTR [%ESP], %EAX mov DWORD PTR [%ESP + 4], %ECX call test We now emit this: mov DWORD PTR [%ESP], 1234 mov DWORD PTR [%ESP + 4], 0 call test llvm-svn: 12686
This commit is contained in:
parent
2738d6d4a4
commit
8cdbb1fe84
@ -1339,11 +1339,19 @@ void ISel::doCall(const ValueRecord &Ret, MachineInstr *CallMI,
|
||||
}
|
||||
break;
|
||||
case cLong:
|
||||
ArgReg = Args[i].Val ? getReg(Args[i].Val) : Args[i].Reg;
|
||||
addRegOffset(BuildMI(BB, X86::MOV32mr, 5),
|
||||
X86::ESP, ArgOffset).addReg(ArgReg);
|
||||
addRegOffset(BuildMI(BB, X86::MOV32mr, 5),
|
||||
X86::ESP, ArgOffset+4).addReg(ArgReg+1);
|
||||
if (Args[i].Val && isa<ConstantInt>(Args[i].Val)) {
|
||||
uint64_t Val = cast<ConstantInt>(Args[i].Val)->getRawValue();
|
||||
addRegOffset(BuildMI(BB, X86::MOV32mi, 5),
|
||||
X86::ESP, ArgOffset).addImm(Val & ~0U);
|
||||
addRegOffset(BuildMI(BB, X86::MOV32mi, 5),
|
||||
X86::ESP, ArgOffset+4).addImm(Val >> 32ULL);
|
||||
} else {
|
||||
ArgReg = Args[i].Val ? getReg(Args[i].Val) : Args[i].Reg;
|
||||
addRegOffset(BuildMI(BB, X86::MOV32mr, 5),
|
||||
X86::ESP, ArgOffset).addReg(ArgReg);
|
||||
addRegOffset(BuildMI(BB, X86::MOV32mr, 5),
|
||||
X86::ESP, ArgOffset+4).addReg(ArgReg+1);
|
||||
}
|
||||
ArgOffset += 4; // 8 byte entry, not 4.
|
||||
break;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user