mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-13 16:03:58 +00:00
Fix one of the things in the todo file, and get a bit closer to folding
constant offsets from statics into the address arithmetic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24999 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
443045a816
commit
50fb3c4986
@ -331,6 +331,7 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
|
||||
// Computing the address of a global symbol, not calling it.
|
||||
GlobalValue *GV = MO.getGlobal();
|
||||
std::string Name = Mang->getValueName(GV);
|
||||
int offset = MO.getOffset();
|
||||
|
||||
// External or weakly linked global variables need non-lazily-resolved stubs
|
||||
if (!PPCGenerateStaticCode) {
|
||||
|
@ -927,7 +927,7 @@ SDOperand PPCDAGToDAGISel::Select(SDOperand Op) {
|
||||
break;
|
||||
}
|
||||
case ISD::AND: {
|
||||
unsigned Imm;
|
||||
unsigned Imm, Imm2;
|
||||
// If this is an and of a value rotated between 0 and 31 bits and then and'd
|
||||
// with a mask, emit rlwinm
|
||||
if (isIntImmediate(N->getOperand(1), Imm) && (isShiftedMask_32(Imm) ||
|
||||
@ -947,6 +947,20 @@ SDOperand PPCDAGToDAGISel::Select(SDOperand Op) {
|
||||
return CurDAG->SelectNodeTo(N, PPC::RLWINM, MVT::i32, Val, getI32Imm(SH),
|
||||
getI32Imm(MB), getI32Imm(ME));
|
||||
}
|
||||
// ISD::OR doesn't get all the bitfield insertion fun.
|
||||
// (and (or x, c1), c2) where isRunOfOnes(~(c1^c2)) is a bitfield insert
|
||||
if (isIntImmediate(N->getOperand(1), Imm) &&
|
||||
N->getOperand(0).getOpcode() == ISD::OR &&
|
||||
isIntImmediate(N->getOperand(0).getOperand(1), Imm2)) {
|
||||
unsigned SH, MB, ME;
|
||||
Imm = ~(Imm^Imm2);
|
||||
if (isRunOfOnes(Imm, MB, ME)) {
|
||||
SDOperand Tmp1 = Select(N->getOperand(0).getOperand(0));
|
||||
SDOperand Tmp2 = Select(N->getOperand(0).getOperand(1));
|
||||
return CurDAG->getTargetNode(PPC::RLWIMI, MVT::i32, Tmp1, Tmp2,
|
||||
getI32Imm(SH), getI32Imm(MB), getI32Imm(ME));
|
||||
}
|
||||
}
|
||||
|
||||
// Other cases are autogenerated.
|
||||
break;
|
||||
|
@ -362,8 +362,9 @@ SDOperand PPCTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
|
||||
return Lo;
|
||||
}
|
||||
case ISD::GlobalAddress: {
|
||||
GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
|
||||
SDOperand GA = DAG.getTargetGlobalAddress(GV, MVT::i32);
|
||||
GlobalAddressSDNode *GSDN = cast<GlobalAddressSDNode>(Op);
|
||||
GlobalValue *GV = GSDN->getGlobal();
|
||||
SDOperand GA = DAG.getTargetGlobalAddress(GV, MVT::i32, GSDN->getOffset());
|
||||
SDOperand Zero = DAG.getConstant(0, MVT::i32);
|
||||
|
||||
if (PPCGenerateStaticCode) {
|
||||
|
@ -3,10 +3,15 @@ TODO:
|
||||
* implement do-loop -> bdnz transform
|
||||
* implement powerpc-64 for darwin
|
||||
* use stfiwx in float->int
|
||||
* be able to combine sequences like the following into 2 instructions:
|
||||
|
||||
* Fold add and sub with constant into non-extern, non-weak addresses so this:
|
||||
lis r2, ha16(l2__ZTV4Cell)
|
||||
la r2, lo16(l2__ZTV4Cell)(r2)
|
||||
addi r2, r2, 8
|
||||
becomes:
|
||||
lis r2, ha16(l2__ZTV4Cell+8)
|
||||
la r2, lo16(l2__ZTV4Cell+8)(r2)
|
||||
|
||||
|
||||
* Teach LLVM how to codegen this:
|
||||
unsigned short foo(float a) { return a; }
|
||||
@ -24,10 +29,6 @@ _foo:
|
||||
rlwinm r3, r2, 0, 16, 31
|
||||
blr
|
||||
|
||||
and:
|
||||
extern int X, Y; int* test(int C) { return C? &X : &Y; }
|
||||
as one load when using --enable-pic.
|
||||
|
||||
* Support 'update' load/store instructions. These are cracked on the G5, but
|
||||
are still a codesize win.
|
||||
|
||||
@ -170,37 +171,6 @@ things like this, rather than forcing llvm to generate the equivalent
|
||||
|
||||
===-------------------------------------------------------------------------===
|
||||
|
||||
Compile this (standard bitfield insert of a constant):
|
||||
void %test(uint* %tmp1) {
|
||||
%tmp2 = load uint* %tmp1 ; <uint> [#uses=1]
|
||||
%tmp5 = or uint %tmp2, 257949696 ; <uint> [#uses=1]
|
||||
%tmp6 = and uint %tmp5, 4018143231 ; <uint> [#uses=1]
|
||||
store uint %tmp6, uint* %tmp1
|
||||
ret void
|
||||
}
|
||||
|
||||
to:
|
||||
|
||||
_test:
|
||||
lwz r0,0(r3)
|
||||
li r2,123
|
||||
rlwimi r0,r2,21,3,10
|
||||
stw r0,0(r3)
|
||||
blr
|
||||
|
||||
instead of:
|
||||
|
||||
_test:
|
||||
lis r2, -4225
|
||||
lwz r4, 0(r3)
|
||||
ori r2, r2, 65535
|
||||
oris r4, r4, 3936
|
||||
and r2, r4, r2
|
||||
stw r2, 0(r3)
|
||||
blr
|
||||
|
||||
===-------------------------------------------------------------------------===
|
||||
|
||||
Compile this:
|
||||
|
||||
int %f1(int %a, int %b) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user