2012-02-18 12:03:15 +00:00
|
|
|
//===-- PPCInstrInfo.h - PowerPC Instruction Information --------*- C++ -*-===//
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2004-08-17 04:55:41 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2004-08-17 04:55:41 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains the PowerPC implementation of the TargetInstrInfo class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-02-18 12:03:15 +00:00
|
|
|
#ifndef POWERPC_INSTRUCTIONINFO_H
|
|
|
|
#define POWERPC_INSTRUCTIONINFO_H
|
2004-08-17 04:55:41 +00:00
|
|
|
|
2005-10-14 23:51:18 +00:00
|
|
|
#include "PPC.h"
|
2005-10-14 23:59:06 +00:00
|
|
|
#include "PPCRegisterInfo.h"
|
2012-03-17 18:46:09 +00:00
|
|
|
#include "llvm/Target/TargetInstrInfo.h"
|
2004-08-17 04:55:41 +00:00
|
|
|
|
2011-07-01 17:57:27 +00:00
|
|
|
#define GET_INSTRINFO_HEADER
|
|
|
|
#include "PPCGenInstrInfo.inc"
|
|
|
|
|
2004-08-17 04:55:41 +00:00
|
|
|
namespace llvm {
|
2006-03-12 09:13:49 +00:00
|
|
|
|
|
|
|
/// PPCII - This namespace holds all of the PowerPC target-specific
|
|
|
|
/// per-instruction flags. These must match the corresponding definitions in
|
|
|
|
/// PPC.td and PPCInstrFormats.td.
|
|
|
|
namespace PPCII {
|
|
|
|
enum {
|
|
|
|
// PPC970 Instruction Flags. These flags describe the characteristics of the
|
|
|
|
// PowerPC 970 (aka G5) dispatch groups and how they are formed out of
|
|
|
|
// raw machine instructions.
|
|
|
|
|
|
|
|
/// PPC970_First - This instruction starts a new dispatch group, so it will
|
|
|
|
/// always be the first one in the group.
|
|
|
|
PPC970_First = 0x1,
|
2010-12-24 04:28:06 +00:00
|
|
|
|
2006-03-12 09:13:49 +00:00
|
|
|
/// PPC970_Single - This instruction starts a new dispatch group and
|
|
|
|
/// terminates it, so it will be the sole instruction in the group.
|
|
|
|
PPC970_Single = 0x2,
|
|
|
|
|
2006-03-13 05:15:10 +00:00
|
|
|
/// PPC970_Cracked - This instruction is cracked into two pieces, requiring
|
|
|
|
/// two dispatch pipes to be available to issue.
|
|
|
|
PPC970_Cracked = 0x4,
|
2010-12-24 04:28:06 +00:00
|
|
|
|
2006-03-12 09:13:49 +00:00
|
|
|
/// PPC970_Mask/Shift - This is a bitmask that selects the pipeline type that
|
|
|
|
/// an instruction is issued to.
|
2006-03-13 05:15:10 +00:00
|
|
|
PPC970_Shift = 3,
|
2006-05-24 17:04:05 +00:00
|
|
|
PPC970_Mask = 0x07 << PPC970_Shift
|
2006-03-12 09:13:49 +00:00
|
|
|
};
|
|
|
|
enum PPC970_Unit {
|
|
|
|
/// These are the various PPC970 execution unit pipelines. Each instruction
|
|
|
|
/// is one of these.
|
|
|
|
PPC970_Pseudo = 0 << PPC970_Shift, // Pseudo instruction
|
|
|
|
PPC970_FXU = 1 << PPC970_Shift, // Fixed Point (aka Integer/ALU) Unit
|
|
|
|
PPC970_LSU = 2 << PPC970_Shift, // Load Store Unit
|
|
|
|
PPC970_FPU = 3 << PPC970_Shift, // Floating Point Unit
|
|
|
|
PPC970_CRU = 4 << PPC970_Shift, // Control Register Unit
|
|
|
|
PPC970_VALU = 5 << PPC970_Shift, // Vector ALU
|
|
|
|
PPC970_VPERM = 6 << PPC970_Shift, // Vector Permute Unit
|
2006-05-24 17:04:05 +00:00
|
|
|
PPC970_BRU = 7 << PPC970_Shift // Branch Unit
|
2006-03-12 09:13:49 +00:00
|
|
|
};
|
2010-11-14 23:42:06 +00:00
|
|
|
} // end namespace PPCII
|
2010-12-24 04:28:06 +00:00
|
|
|
|
|
|
|
|
2011-07-01 17:57:27 +00:00
|
|
|
class PPCInstrInfo : public PPCGenInstrInfo {
|
2006-06-17 00:01:04 +00:00
|
|
|
PPCTargetMachine &TM;
|
2005-10-16 05:39:50 +00:00
|
|
|
const PPCRegisterInfo RI;
|
2008-03-10 22:49:16 +00:00
|
|
|
|
2008-07-07 23:14:23 +00:00
|
|
|
bool StoreRegToStackSlot(MachineFunction &MF,
|
|
|
|
unsigned SrcReg, bool isKill, int FrameIdx,
|
2008-03-10 22:49:16 +00:00
|
|
|
const TargetRegisterClass *RC,
|
2013-03-17 04:43:44 +00:00
|
|
|
SmallVectorImpl<MachineInstr*> &NewMIs,
|
2013-03-23 22:06:03 +00:00
|
|
|
bool &NonRI, bool &SpillsVRS) const;
|
2011-12-06 20:55:36 +00:00
|
|
|
bool LoadRegFromStackSlot(MachineFunction &MF, DebugLoc DL,
|
2008-07-07 23:14:23 +00:00
|
|
|
unsigned DestReg, int FrameIdx,
|
2008-03-10 22:49:16 +00:00
|
|
|
const TargetRegisterClass *RC,
|
2013-03-17 04:43:44 +00:00
|
|
|
SmallVectorImpl<MachineInstr*> &NewMIs,
|
2013-03-23 22:06:03 +00:00
|
|
|
bool &NonRI, bool &SpillsVRS) const;
|
2013-11-19 00:57:56 +00:00
|
|
|
virtual void anchor();
|
2004-08-17 04:55:41 +00:00
|
|
|
public:
|
2008-03-25 22:06:05 +00:00
|
|
|
explicit PPCInstrInfo(PPCTargetMachine &TM);
|
2004-08-17 04:55:41 +00:00
|
|
|
|
|
|
|
/// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
|
|
|
|
/// such, whenever a client has an instance of instruction info, it should
|
|
|
|
/// always be able to get register info as well (through this method).
|
|
|
|
///
|
2008-05-14 01:58:56 +00:00
|
|
|
virtual const PPCRegisterInfo &getRegisterInfo() const { return RI; }
|
2004-08-17 04:55:41 +00:00
|
|
|
|
Various bits of framework needed for precise machine-level selection
DAG scheduling during isel. Most new functionality is currently
guarded by -enable-sched-cycles and -enable-sched-hazard.
Added InstrItineraryData::IssueWidth field, currently derived from
ARM itineraries, but could be initialized differently on other targets.
Added ScheduleHazardRecognizer::MaxLookAhead to indicate whether it is
active, and if so how many cycles of state it holds.
Added SchedulingPriorityQueue::HasReadyFilter to allowing gating entry
into the scheduler's available queue.
ScoreboardHazardRecognizer now accesses the ScheduleDAG in order to
get information about it's SUnits, provides RecedeCycle for bottom-up
scheduling, correctly computes scoreboard depth, tracks IssueCount, and
considers potential stall cycles when checking for hazards.
ScheduleDAGRRList now models machine cycles and hazards (under
flags). It tracks MinAvailableCycle, drives the hazard recognizer and
priority queue's ready filter, manages a new PendingQueue, properly
accounts for stall cycles, etc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
ScheduleHazardRecognizer *
|
|
|
|
CreateTargetHazardRecognizer(const TargetMachine *TM,
|
|
|
|
const ScheduleDAG *DAG) const;
|
2011-12-02 04:58:02 +00:00
|
|
|
ScheduleHazardRecognizer *
|
|
|
|
CreateTargetPostRAHazardRecognizer(const InstrItineraryData *II,
|
|
|
|
const ScheduleDAG *DAG) const;
|
Various bits of framework needed for precise machine-level selection
DAG scheduling during isel. Most new functionality is currently
guarded by -enable-sched-cycles and -enable-sched-hazard.
Added InstrItineraryData::IssueWidth field, currently derived from
ARM itineraries, but could be initialized differently on other targets.
Added ScheduleHazardRecognizer::MaxLookAhead to indicate whether it is
active, and if so how many cycles of state it holds.
Added SchedulingPriorityQueue::HasReadyFilter to allowing gating entry
into the scheduler's available queue.
ScoreboardHazardRecognizer now accesses the ScheduleDAG in order to
get information about it's SUnits, provides RecedeCycle for bottom-up
scheduling, correctly computes scoreboard depth, tracks IssueCount, and
considers potential stall cycles when checking for hazards.
ScheduleDAGRRList now models machine cycles and hazards (under
flags). It tracks MinAvailableCycle, drives the hazard recognizer and
priority queue's ready filter, manages a new PendingQueue, properly
accounts for stall cycles, etc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
|
2013-12-12 00:19:11 +00:00
|
|
|
virtual
|
|
|
|
int getOperandLatency(const InstrItineraryData *ItinData,
|
|
|
|
const MachineInstr *DefMI, unsigned DefIdx,
|
|
|
|
const MachineInstr *UseMI, unsigned UseIdx) const;
|
|
|
|
virtual
|
|
|
|
int getOperandLatency(const InstrItineraryData *ItinData,
|
|
|
|
SDNode *DefNode, unsigned DefIdx,
|
|
|
|
SDNode *UseNode, unsigned UseIdx) const {
|
|
|
|
return PPCGenInstrInfo::getOperandLatency(ItinData, DefNode, DefIdx,
|
|
|
|
UseNode, UseIdx);
|
|
|
|
}
|
|
|
|
|
2012-06-19 21:14:34 +00:00
|
|
|
bool isCoalescableExtInstr(const MachineInstr &MI,
|
|
|
|
unsigned &SrcReg, unsigned &DstReg,
|
|
|
|
unsigned &SubIdx) const;
|
2008-11-18 19:49:32 +00:00
|
|
|
unsigned isLoadFromStackSlot(const MachineInstr *MI,
|
|
|
|
int &FrameIndex) const;
|
|
|
|
unsigned isStoreToStackSlot(const MachineInstr *MI,
|
|
|
|
int &FrameIndex) const;
|
2006-02-02 20:12:32 +00:00
|
|
|
|
2005-09-09 18:17:41 +00:00
|
|
|
// commuteInstruction - We can commute rlwimi instructions, but only if the
|
|
|
|
// rotate amt is zero. We also have to munge the immediates a bit.
|
2008-06-16 07:33:11 +00:00
|
|
|
virtual MachineInstr *commuteInstruction(MachineInstr *MI, bool NewMI) const;
|
2010-12-24 04:28:06 +00:00
|
|
|
|
|
|
|
virtual void insertNoop(MachineBasicBlock &MBB,
|
2006-03-05 23:49:55 +00:00
|
|
|
MachineBasicBlock::iterator MI) const;
|
|
|
|
|
2006-10-13 21:21:17 +00:00
|
|
|
|
|
|
|
// Branch analysis.
|
|
|
|
virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
|
|
|
|
MachineBasicBlock *&FBB,
|
2009-02-09 07:14:22 +00:00
|
|
|
SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
bool AllowModify) const;
|
2007-05-18 00:05:48 +00:00
|
|
|
virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
|
|
|
|
virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
|
|
|
|
MachineBasicBlock *FBB,
|
2010-06-17 22:43:56 +00:00
|
|
|
const SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
DebugLoc DL) const;
|
2013-04-05 23:29:01 +00:00
|
|
|
|
|
|
|
// Select analysis.
|
|
|
|
virtual bool canInsertSelect(const MachineBasicBlock&,
|
|
|
|
const SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
unsigned, unsigned, int&, int&, int&) const;
|
|
|
|
virtual void insertSelect(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI, DebugLoc DL,
|
|
|
|
unsigned DstReg,
|
|
|
|
const SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
unsigned TrueReg, unsigned FalseReg) const;
|
|
|
|
|
2010-07-11 07:31:00 +00:00
|
|
|
virtual void copyPhysReg(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator I, DebugLoc DL,
|
|
|
|
unsigned DestReg, unsigned SrcReg,
|
|
|
|
bool KillSrc) const;
|
2010-12-24 04:28:06 +00:00
|
|
|
|
2008-01-01 21:11:32 +00:00
|
|
|
virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MBBI,
|
|
|
|
unsigned SrcReg, bool isKill, int FrameIndex,
|
2010-05-06 19:06:44 +00:00
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const;
|
2008-01-01 21:11:32 +00:00
|
|
|
|
|
|
|
virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MBBI,
|
|
|
|
unsigned DestReg, int FrameIndex,
|
2010-05-06 19:06:44 +00:00
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const;
|
2010-12-24 04:28:06 +00:00
|
|
|
|
2008-08-14 22:49:33 +00:00
|
|
|
virtual
|
|
|
|
bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const;
|
2010-12-24 04:28:06 +00:00
|
|
|
|
2013-04-06 19:30:30 +00:00
|
|
|
virtual bool FoldImmediate(MachineInstr *UseMI, MachineInstr *DefMI,
|
|
|
|
unsigned Reg, MachineRegisterInfo *MRI) const;
|
|
|
|
|
2013-04-09 22:58:37 +00:00
|
|
|
// If conversion by predication (only supported by some branch instructions).
|
|
|
|
// All of the profitability checks always return true; it is always
|
|
|
|
// profitable to use the predicated branches.
|
|
|
|
virtual bool isProfitableToIfCvt(MachineBasicBlock &MBB,
|
|
|
|
unsigned NumCycles, unsigned ExtraPredCycles,
|
|
|
|
const BranchProbability &Probability) const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool isProfitableToIfCvt(MachineBasicBlock &TMBB,
|
|
|
|
unsigned NumT, unsigned ExtraT,
|
|
|
|
MachineBasicBlock &FMBB,
|
|
|
|
unsigned NumF, unsigned ExtraF,
|
2013-04-10 18:30:16 +00:00
|
|
|
const BranchProbability &Probability) const;
|
2013-04-09 22:58:37 +00:00
|
|
|
|
|
|
|
virtual bool isProfitableToDupForIfCvt(MachineBasicBlock &MBB,
|
|
|
|
unsigned NumCycles,
|
|
|
|
const BranchProbability
|
|
|
|
&Probability) const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool isProfitableToUnpredicate(MachineBasicBlock &TMBB,
|
|
|
|
MachineBasicBlock &FMBB) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Predication support.
|
|
|
|
bool isPredicated(const MachineInstr *MI) const;
|
|
|
|
|
|
|
|
virtual bool isUnpredicatedTerminator(const MachineInstr *MI) const;
|
|
|
|
|
|
|
|
virtual
|
|
|
|
bool PredicateInstruction(MachineInstr *MI,
|
|
|
|
const SmallVectorImpl<MachineOperand> &Pred) const;
|
|
|
|
|
|
|
|
virtual
|
|
|
|
bool SubsumesPredicate(const SmallVectorImpl<MachineOperand> &Pred1,
|
|
|
|
const SmallVectorImpl<MachineOperand> &Pred2) const;
|
|
|
|
|
|
|
|
virtual bool DefinesPredicate(MachineInstr *MI,
|
|
|
|
std::vector<MachineOperand> &Pred) const;
|
|
|
|
|
|
|
|
virtual bool isPredicable(MachineInstr *MI) const;
|
|
|
|
|
2013-04-18 22:15:08 +00:00
|
|
|
// Comparison optimization.
|
|
|
|
|
|
|
|
|
|
|
|
virtual bool analyzeCompare(const MachineInstr *MI,
|
|
|
|
unsigned &SrcReg, unsigned &SrcReg2,
|
|
|
|
int &Mask, int &Value) const;
|
|
|
|
|
|
|
|
virtual bool optimizeCompareInstr(MachineInstr *CmpInstr,
|
|
|
|
unsigned SrcReg, unsigned SrcReg2,
|
|
|
|
int Mask, int Value,
|
|
|
|
const MachineRegisterInfo *MRI) const;
|
|
|
|
|
2008-04-16 20:10:13 +00:00
|
|
|
/// GetInstSize - Return the number of bytes of code the specified
|
|
|
|
/// instruction may be. This returns the maximum number of bytes.
|
|
|
|
///
|
|
|
|
virtual unsigned GetInstSizeInBytes(const MachineInstr *MI) const;
|
2004-08-17 04:55:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|