From ed4f4fbfba7d4eb2091480d9c0a4f00feb8af1db Mon Sep 17 00:00:00 2001 From: Sanjiv Gupta Date: Tue, 12 May 2009 04:30:38 +0000 Subject: [PATCH] Mark mayLoad, mayStore for insns correctly and use them to check if an insn is accessing memory during mem sel optimization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71537 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/PIC16/PIC16InstrInfo.h | 20 +------------------- lib/Target/PIC16/PIC16InstrInfo.td | 8 ++++++-- lib/Target/PIC16/PIC16MemSelOpt.cpp | 10 +++++++--- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/lib/Target/PIC16/PIC16InstrInfo.h b/lib/Target/PIC16/PIC16InstrInfo.h index 60b02ab6b47..0b676796987 100644 --- a/lib/Target/PIC16/PIC16InstrInfo.h +++ b/lib/Target/PIC16/PIC16InstrInfo.h @@ -64,25 +64,7 @@ public: unsigned &SrcReg, unsigned &DstReg, unsigned &SrcSubIdx, unsigned &DstSubIdx) const; - static inline bool hasNoMemOperand (const MachineInstr &MI) { - - if (MI.getNumOperands() == 0) return true; - - switch (MI.getOpcode()) { - default: return false; // Beware - case PIC16::movlw_lo_1: - case PIC16::movlw_hi_1: - case PIC16::movlw_lo_2: - case PIC16::movlw_hi_2: - return true; - } - } - - - - -}; - + }; } // namespace llvm #endif diff --git a/lib/Target/PIC16/PIC16InstrInfo.td b/lib/Target/PIC16/PIC16InstrInfo.td index 6c11bd5355d..db798e434c0 100644 --- a/lib/Target/PIC16/PIC16InstrInfo.td +++ b/lib/Target/PIC16/PIC16InstrInfo.td @@ -132,7 +132,7 @@ include "PIC16InstrFormats.td" //===----------------------------------------------------------------------===// // W = W Op F : Load the value from F and do Op to W. -let isTwoAddress = 1 in +let isTwoAddress = 1, mayLoad = 1 in class BinOpFW OpCode, string OpcStr, SDNode OpNode>: ByteFormat OpCode, string OpcStr, SDNode OpNode>: // This insn class is not marked as TwoAddress because the reg is // being used as a source operand only. (Remember a TwoAddress insn // needs a copyRegToReg.) +let mayStore = 1 in class BinOpWF OpCode, string OpcStr, SDNode OpNode>: ByteFormat; // Direct store. // Input operands are: val = W, ptrlo = GA, offset = offset, ptrhi = banksel. +let mayStore = 1 in class MOVWF_INSN OpCode, SDNode OpNodeDest, SDNode Op>: ByteFormat<0, (outs), (ins GPR:$val, i8imm:$offset, i8mem:$ptrlo, i8imm:$ptrhi), @@ -297,6 +299,7 @@ def store_indirect : // Direct load. // Input Operands are: ptrlo = GA, offset = offset, ptrhi = banksel. // Output: dst = W +let mayLoad = 1 in class MOVF_INSN OpCode, SDNode OpNodeSrc, SDNode Op>: ByteFormat<0, (outs GPR:$dst), (ins i8imm:$offset, i8mem:$ptrlo, i8imm:$ptrhi), @@ -357,7 +360,7 @@ def addwfc: BinOpWF<0, "addwfc", adde>; // With Carry. } // W -= [F] ; load from F and sub the value from W. -let isTwoAddress = 1 in +let isTwoAddress = 1, mayLoad = 1 in class SUBFW OpCode, string OpcStr, SDNode OpNode>: ByteFormat; } // [F] -= W ; +let mayStore = 1 in class SUBWF OpCode, string OpcStr, SDNode OpNode>: ByteFormatgetNumOperands(); - // If this insn has only one operand, probably it is not going to - // access any data memory. - if (PIC16InstrInfo::hasNoMemOperand(*MI)) return Changed; + if (NumOperands == 0) return false; + + + // If this insn is not going to access any memory, return. + const TargetInstrDesc &TID = TII->get(MI->getOpcode()); + if (! (TID.isCall() || TID.mayLoad() || TID.mayStore())) + return false; // Scan for the memory address operand. // FIXME: Should we use standard interfaces like memoperands_iterator, -- 2.34.1