From 79d0e9f3d1c9c88ee301a0551b60f6aa8cadb48f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 28 Sep 2005 23:07:13 +0000 Subject: [PATCH] Codegen ADD X, IMM -> addis/addi if needed. This implements PowerPC/fold-li.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23514 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/PowerPC/PPCInstrInfo.td | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/Target/PowerPC/PPCInstrInfo.td b/lib/Target/PowerPC/PPCInstrInfo.td index a39aaaa6051..4f3715eaf7a 100644 --- a/lib/Target/PowerPC/PPCInstrInfo.td +++ b/lib/Target/PowerPC/PPCInstrInfo.td @@ -218,6 +218,13 @@ def HI16 : SDNodeXFormgetValue() >> 16); }]>; +def HA16 : SDNodeXFormgetValue(); + 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))>; -- 2.34.1