2012-02-18 20:03:15 +08:00
|
|
|
//===-- SparcInstrInfo.h - Sparc Instruction Information --------*- C++ -*-===//
|
2006-02-05 13:50:24 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-02-05 13:50:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains the Sparc implementation of the TargetInstrInfo class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_SPARC_SPARCINSTRINFO_H
|
|
|
|
#define LLVM_LIB_TARGET_SPARC_SPARCINSTRINFO_H
|
2006-02-05 13:50:24 +08:00
|
|
|
|
|
|
|
#include "SparcRegisterInfo.h"
|
2012-03-18 02:46:09 +08:00
|
|
|
#include "llvm/Target/TargetInstrInfo.h"
|
2006-02-05 13:50:24 +08:00
|
|
|
|
2011-07-02 01:57:27 +08:00
|
|
|
#define GET_INSTRINFO_HEADER
|
|
|
|
#include "SparcGenInstrInfo.inc"
|
|
|
|
|
2006-02-05 13:50:24 +08:00
|
|
|
namespace llvm {
|
|
|
|
|
2015-03-12 13:55:26 +08:00
|
|
|
class SparcSubtarget;
|
|
|
|
|
2006-02-05 13:50:24 +08:00
|
|
|
/// SPII - This namespace holds all of the target specific flags that
|
|
|
|
/// instruction info tracks.
|
|
|
|
///
|
|
|
|
namespace SPII {
|
|
|
|
enum {
|
|
|
|
Pseudo = (1<<0),
|
|
|
|
Load = (1<<1),
|
|
|
|
Store = (1<<2),
|
|
|
|
DelaySlot = (1<<3)
|
|
|
|
};
|
2006-05-25 01:04:05 +08:00
|
|
|
}
|
2006-02-05 13:50:24 +08:00
|
|
|
|
2011-07-02 01:57:27 +08:00
|
|
|
class SparcInstrInfo : public SparcGenInstrInfo {
|
2006-02-05 13:50:24 +08:00
|
|
|
const SparcRegisterInfo RI;
|
2007-12-31 14:32:00 +08:00
|
|
|
const SparcSubtarget& Subtarget;
|
2013-11-19 08:57:56 +08:00
|
|
|
virtual void anchor();
|
2006-02-05 13:50:24 +08:00
|
|
|
public:
|
2008-03-26 06:06:05 +08:00
|
|
|
explicit SparcInstrInfo(SparcSubtarget &ST);
|
2006-02-05 13:50:24 +08: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).
|
|
|
|
///
|
2014-04-29 15:57:13 +08:00
|
|
|
const SparcRegisterInfo &getRegisterInfo() const { return RI; }
|
2006-02-05 13:50:24 +08:00
|
|
|
|
|
|
|
/// isLoadFromStackSlot - If the specified machine instruction is a direct
|
|
|
|
/// load from a stack slot, return the virtual or physical register number of
|
|
|
|
/// the destination along with the FrameIndex of the loaded stack slot. If
|
|
|
|
/// not, return 0. This predicate must return 0 if the instruction has
|
|
|
|
/// any side effects other than loading from the stack slot.
|
2016-06-30 08:01:54 +08:00
|
|
|
unsigned isLoadFromStackSlot(const MachineInstr &MI,
|
2014-04-29 15:57:13 +08:00
|
|
|
int &FrameIndex) const override;
|
2013-06-05 02:33:25 +08:00
|
|
|
|
2006-02-05 13:50:24 +08:00
|
|
|
/// isStoreToStackSlot - If the specified machine instruction is a direct
|
|
|
|
/// store to a stack slot, return the virtual or physical register number of
|
|
|
|
/// the source reg along with the FrameIndex of the loaded stack slot. If
|
|
|
|
/// not, return 0. This predicate must return 0 if the instruction has
|
|
|
|
/// any side effects other than storing to the stack slot.
|
2016-06-30 08:01:54 +08:00
|
|
|
unsigned isStoreToStackSlot(const MachineInstr &MI,
|
2014-04-29 15:57:13 +08:00
|
|
|
int &FrameIndex) const override;
|
|
|
|
|
|
|
|
bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
|
|
|
|
MachineBasicBlock *&FBB,
|
|
|
|
SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
bool AllowModify = false) const override ;
|
|
|
|
|
|
|
|
unsigned RemoveBranch(MachineBasicBlock &MBB) const override;
|
|
|
|
|
|
|
|
unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
|
2015-06-12 03:30:37 +08:00
|
|
|
MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,
|
2016-06-12 23:39:02 +08:00
|
|
|
const DebugLoc &DL) const override;
|
2014-04-29 15:57:13 +08:00
|
|
|
|
[SPARC] Revamp AnalyzeBranch and add ReverseBranchCondition.
AnalyzeBranch on X86 (and, previously, SPARC, which implementation was
copied from X86) tries to modify the branches based on block
layout (e.g. checking isLayoutSuccessor), when AllowModify is true.
The rest of the architectures leave that up to the caller, which can
call InsertBranch, RemoveBranch, and ReverseBranchCondition as
appropriate. That appears to be the preferred way to do it nowadays.
This commit makes SPARC like the rest: replaces AnalyzeBranch with an
implementation cribbed from AArch64, and adds a ReverseBranchCondition
implementation.
Additionally, a test-case has been added (also cribbed from AArch64)
demonstrating that redundant branch sequences no longer get emitted.
E.g., it used to emit code like this:
bne .LBB1_2
nop
ba .LBB1_1
nop
.LBB1_2:
And now emits:
cmp %i0, 42
be .LBB1_1
nop
llvm-svn: 257572
2016-01-13 12:44:14 +08:00
|
|
|
bool
|
|
|
|
ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;
|
|
|
|
|
2016-06-12 23:39:02 +08:00
|
|
|
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
|
|
|
|
const DebugLoc &DL, unsigned DestReg, unsigned SrcReg,
|
2014-04-29 15:57:13 +08:00
|
|
|
bool KillSrc) const override;
|
|
|
|
|
|
|
|
void storeRegToStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MBBI,
|
|
|
|
unsigned SrcReg, bool isKill, int FrameIndex,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const override;
|
|
|
|
|
|
|
|
void loadRegFromStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MBBI,
|
|
|
|
unsigned DestReg, int FrameIndex,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const override;
|
2013-06-05 02:33:25 +08:00
|
|
|
|
2009-09-16 01:46:24 +08:00
|
|
|
unsigned getGlobalBaseReg(MachineFunction *MF) const;
|
2016-04-26 18:37:14 +08:00
|
|
|
|
|
|
|
// Lower pseudo instructions after register allocation.
|
2016-06-30 08:01:54 +08:00
|
|
|
bool expandPostRAPseudo(MachineInstr &MI) const override;
|
2006-02-05 13:50:24 +08:00
|
|
|
};
|
|
|
|
|
2015-06-23 17:49:53 +08:00
|
|
|
}
|
2006-02-05 13:50:24 +08:00
|
|
|
|
|
|
|
#endif
|