diff options
| author | Chris Lattner <sabre@nondot.org> | 2005-09-28 23:07:13 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2005-09-28 23:07:13 +0000 |
| commit | d4e9e8b7ece4fe86fa203cd5df93a9dcba365470 (patch) | |
| tree | cb2f3e4fa5a9d052a4f61fe3d52be5b7b5ba57ed | |
| parent | a22f7a2e16426f7b5a676026878bf52f12e27575 (diff) | |
| download | bcm5719-llvm-d4e9e8b7ece4fe86fa203cd5df93a9dcba365470.tar.gz bcm5719-llvm-d4e9e8b7ece4fe86fa203cd5df93a9dcba365470.zip | |
Codegen ADD X, IMM -> addis/addi if needed.
This implements PowerPC/fold-li.ll
llvm-svn: 23514
| -rw-r--r-- | llvm/lib/Target/PowerPC/PowerPCInstrInfo.td | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/llvm/lib/Target/PowerPC/PowerPCInstrInfo.td b/llvm/lib/Target/PowerPC/PowerPCInstrInfo.td index a39aaaa6051..4f3715eaf7a 100644 --- a/llvm/lib/Target/PowerPC/PowerPCInstrInfo.td +++ b/llvm/lib/Target/PowerPC/PowerPCInstrInfo.td @@ -218,6 +218,13 @@ def HI16 : SDNodeXForm<imm, [{ return getI32Imm((unsigned)N->getValue() >> 16); }]>; +def HA16 : SDNodeXForm<imm, [{ + // Transformation function: shift the immediate value down into the low bits. + signed int Val = N->getValue(); + return getI32Imm((Val - (signed short)Val) >> 16); +}]>; + + def immSExt16 : PatLeaf<(imm), [{ // immSExt16 predicate - True if the immediate fits in a 16-bit sign extended // field. Used by instructions like 'addi'. @@ -801,10 +808,13 @@ def EQV1 : Pat<(xor (not GPRC:$in1), GPRC:$in2), def EQV2 : Pat<(xor GPRC:$in1, (not GPRC:$in2)), (EQV GPRC:$in1, GPRC:$in2)>; -// or by an arbitrary immediate. +// ADD an arbitrary immediate. +def : Pat<(add GPRC:$in, imm:$imm), + (ADDIS (ADDI GPRC:$in, (LO16 imm:$imm)), (HA16 imm:$imm))>; +// OR an arbitrary immediate. def : Pat<(or GPRC:$in, imm:$imm), (ORIS (ORI GPRC:$in, (LO16 imm:$imm)), (HI16 imm:$imm))>; -// xor by an arbitrary immediate. +// XOR an arbitrary immediate. def : Pat<(xor GPRC:$in, imm:$imm), (XORIS (XORI GPRC:$in, (LO16 imm:$imm)), (HI16 imm:$imm))>; |

