mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-18 12:29:21 +00:00
Handle loading of 0x????0000 constants with a single instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22858 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
cffc32b6e2
commit
3285aadce9
@ -1738,12 +1738,16 @@ unsigned ISel::SelectExpr(SDOperand N, bool Recording) {
|
||||
case MVT::i32:
|
||||
{
|
||||
int v = (int)cast<ConstantSDNode>(N)->getSignExtended();
|
||||
if (v < 32768 && v >= -32768) {
|
||||
BuildMI(BB, PPC::LI, 1, Result).addSImm(v);
|
||||
} else {
|
||||
unsigned Hi = Hi16(v);
|
||||
unsigned Lo = Lo16(v);
|
||||
if (Hi && Lo) {
|
||||
Tmp1 = MakeIntReg();
|
||||
BuildMI(BB, PPC::LIS, 1, Tmp1).addSImm(v >> 16);
|
||||
BuildMI(BB, PPC::ORI, 2, Result).addReg(Tmp1).addImm(v & 0xFFFF);
|
||||
BuildMI(BB, PPC::LIS, 1, Tmp1).addSImm(Hi);
|
||||
BuildMI(BB, PPC::ORI, 2, Result).addReg(Tmp1).addImm(Lo);
|
||||
} else if (Lo) {
|
||||
BuildMI(BB, PPC::LI, 1, Result).addSImm(Lo);
|
||||
} else {
|
||||
BuildMI(BB, PPC::LIS, 1, Result).addSImm(Hi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user