mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-15 07:34:33 +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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12686 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
33f7fa317b
commit
92900a65a3
@ -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;
|
||||
|
||||
|
@ -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