2007-01-19 07:51:42 +00:00
|
|
|
//===- ARMInstrInfo.h - ARM Instruction Information -------------*- C++ -*-===//
|
2006-05-14 22:18:28 +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
|
2006-05-14 22:18:28 +00:00
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains the ARM implementation of the TargetInstrInfo class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef ARMINSTRUCTIONINFO_H
|
|
|
|
#define ARMINSTRUCTIONINFO_H
|
|
|
|
|
|
|
|
#include "llvm/Target/TargetInstrInfo.h"
|
|
|
|
#include "ARMRegisterInfo.h"
|
2008-10-07 21:01:51 +00:00
|
|
|
#include "ARM.h"
|
2006-05-14 22:18:28 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
2007-01-19 07:51:42 +00:00
|
|
|
class ARMSubtarget;
|
|
|
|
|
|
|
|
/// ARMII - This namespace holds all of the target specific flags that
|
|
|
|
/// instruction info tracks.
|
|
|
|
///
|
|
|
|
namespace ARMII {
|
|
|
|
enum {
|
|
|
|
//===------------------------------------------------------------------===//
|
|
|
|
// Instruction Flags.
|
|
|
|
|
|
|
|
//===------------------------------------------------------------------===//
|
2008-11-03 18:38:31 +00:00
|
|
|
// This four-bit field describes the addressing mode used.
|
2007-01-19 07:51:42 +00:00
|
|
|
|
|
|
|
AddrModeMask = 0xf,
|
2007-08-07 01:37:15 +00:00
|
|
|
AddrModeNone = 0,
|
2007-01-19 07:51:42 +00:00
|
|
|
AddrMode1 = 1,
|
|
|
|
AddrMode2 = 2,
|
|
|
|
AddrMode3 = 3,
|
|
|
|
AddrMode4 = 4,
|
|
|
|
AddrMode5 = 5,
|
2008-11-05 18:35:52 +00:00
|
|
|
AddrModeT1 = 6,
|
|
|
|
AddrModeT2 = 7,
|
|
|
|
AddrModeT4 = 8,
|
|
|
|
AddrModeTs = 9, // i8 * 4 for pc and sp relative data
|
2007-01-19 07:51:42 +00:00
|
|
|
|
|
|
|
// Size* - Flags to keep track of the size of an instruction.
|
|
|
|
SizeShift = 4,
|
|
|
|
SizeMask = 7 << SizeShift,
|
|
|
|
SizeSpecial = 1, // 0 byte pseudo or special case.
|
|
|
|
Size8Bytes = 2,
|
|
|
|
Size4Bytes = 3,
|
|
|
|
Size2Bytes = 4,
|
|
|
|
|
|
|
|
// IndexMode - Unindex, pre-indexed, or post-indexed. Only valid for load
|
|
|
|
// and store ops
|
|
|
|
IndexModeShift = 7,
|
|
|
|
IndexModeMask = 3 << IndexModeShift,
|
|
|
|
IndexModePre = 1,
|
|
|
|
IndexModePost = 2,
|
|
|
|
|
2008-11-05 18:35:52 +00:00
|
|
|
//===------------------------------------------------------------------===//
|
|
|
|
// Misc flags.
|
|
|
|
|
|
|
|
// UnaryDP - Indicates this is a unary data processing instruction, i.e.
|
|
|
|
// it doesn't have a Rn operand.
|
2008-11-06 08:47:38 +00:00
|
|
|
UnaryDP = 1 << 9,
|
2008-11-05 18:35:52 +00:00
|
|
|
|
|
|
|
//===------------------------------------------------------------------===//
|
|
|
|
// Instruction encoding formats.
|
|
|
|
//
|
2008-11-06 08:47:38 +00:00
|
|
|
FormShift = 10,
|
2008-11-06 03:35:07 +00:00
|
|
|
FormMask = 0xf << FormShift,
|
2007-08-07 01:37:15 +00:00
|
|
|
|
2007-08-30 23:34:14 +00:00
|
|
|
// Pseudo instructions
|
2007-08-07 01:37:15 +00:00
|
|
|
Pseudo = 1 << FormShift,
|
|
|
|
|
2007-08-30 23:34:14 +00:00
|
|
|
// Multiply instructions
|
2008-11-06 01:21:28 +00:00
|
|
|
MulFrm = 2 << FormShift,
|
2007-08-30 23:34:14 +00:00
|
|
|
|
|
|
|
// Branch instructions
|
2008-11-06 17:48:05 +00:00
|
|
|
BrFrm = 3 << FormShift,
|
|
|
|
BrMiscFrm = 4 << FormShift,
|
2007-08-30 23:34:14 +00:00
|
|
|
|
|
|
|
// Data Processing instructions
|
2008-11-06 03:35:07 +00:00
|
|
|
DPFrm = 5 << FormShift,
|
|
|
|
DPSoRegFrm = 6 << FormShift,
|
2007-08-30 23:34:14 +00:00
|
|
|
|
|
|
|
// Load and Store
|
2008-11-06 03:35:07 +00:00
|
|
|
LdFrm = 7 << FormShift,
|
|
|
|
StFrm = 8 << FormShift,
|
|
|
|
LdMiscFrm = 9 << FormShift,
|
|
|
|
StMiscFrm = 10 << FormShift,
|
|
|
|
LdMulFrm = 11 << FormShift,
|
|
|
|
StMulFrm = 12 << FormShift,
|
2007-08-30 23:34:14 +00:00
|
|
|
|
|
|
|
// Miscellaneous arithmetic instructions
|
2008-11-06 22:15:19 +00:00
|
|
|
ArithMiscFrm= 13 << FormShift,
|
|
|
|
|
|
|
|
// Extend instructions
|
|
|
|
ExtFrm = 14 << FormShift,
|
2007-08-30 23:34:14 +00:00
|
|
|
|
|
|
|
// Thumb format
|
2008-11-06 22:15:19 +00:00
|
|
|
ThumbFrm = 15 << FormShift,
|
2007-08-30 23:34:14 +00:00
|
|
|
|
|
|
|
// VFP format
|
2008-11-06 22:15:19 +00:00
|
|
|
VPFFrm = 16 << FormShift,
|
2007-08-30 23:34:14 +00:00
|
|
|
|
2008-11-05 18:35:52 +00:00
|
|
|
//===------------------------------------------------------------------===//
|
2007-08-30 23:34:14 +00:00
|
|
|
// Field shifts - such shifts are used to set field while generating
|
|
|
|
// machine instructions.
|
2008-11-07 01:41:35 +00:00
|
|
|
ShiftShift = 7,
|
2008-11-06 22:15:19 +00:00
|
|
|
SoRotImmShift = 8,
|
|
|
|
RegRsShift = 8,
|
|
|
|
ExtRotImmShift = 10,
|
|
|
|
RegRdLoShift = 12,
|
|
|
|
RegRdShift = 12,
|
|
|
|
RegRdHiShift = 16,
|
|
|
|
RegRnShift = 16,
|
|
|
|
S_BitShift = 20,
|
|
|
|
W_BitShift = 21,
|
|
|
|
AM3_I_BitShift = 22,
|
|
|
|
U_BitShift = 23,
|
|
|
|
P_BitShift = 24,
|
|
|
|
I_BitShift = 25,
|
|
|
|
CondShift = 28
|
2007-01-19 07:51:42 +00:00
|
|
|
};
|
|
|
|
}
|
2006-05-14 22:18:28 +00:00
|
|
|
|
2008-01-01 01:03:04 +00:00
|
|
|
class ARMInstrInfo : public TargetInstrInfoImpl {
|
2006-05-14 22:18:28 +00:00
|
|
|
const ARMRegisterInfo RI;
|
|
|
|
public:
|
2008-03-25 22:06:05 +00:00
|
|
|
explicit ARMInstrInfo(const ARMSubtarget &STI);
|
2006-05-14 22:18:28 +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 ARMRegisterInfo &getRegisterInfo() const { return RI; }
|
2006-05-14 22:18:28 +00:00
|
|
|
|
2006-08-08 20:35:03 +00:00
|
|
|
/// getPointerRegClass - Return the register class to use to hold pointers.
|
|
|
|
/// This is used for addressing modes.
|
|
|
|
virtual const TargetRegisterClass *getPointerRegClass() const;
|
|
|
|
|
2006-05-14 22:18:28 +00:00
|
|
|
/// Return true if the instruction is a register to register move and
|
|
|
|
/// leave the source and dest operands in the passed parameters.
|
|
|
|
///
|
|
|
|
virtual bool isMoveInstr(const MachineInstr &MI,
|
|
|
|
unsigned &SrcReg, unsigned &DstReg) const;
|
2007-01-19 07:51:42 +00:00
|
|
|
virtual unsigned isLoadFromStackSlot(MachineInstr *MI, int &FrameIndex) const;
|
|
|
|
virtual unsigned isStoreToStackSlot(MachineInstr *MI, int &FrameIndex) const;
|
|
|
|
|
2008-03-31 20:40:39 +00:00
|
|
|
void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
|
|
|
|
unsigned DestReg, const MachineInstr *Orig) const;
|
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
virtual MachineInstr *convertToThreeAddress(MachineFunction::iterator &MFI,
|
|
|
|
MachineBasicBlock::iterator &MBBI,
|
2008-07-02 23:41:07 +00:00
|
|
|
LiveVariables *LV) const;
|
2006-10-24 16:47:57 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
// Branch analysis.
|
|
|
|
virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
|
|
|
|
MachineBasicBlock *&FBB,
|
2008-08-14 22:49:33 +00:00
|
|
|
SmallVectorImpl<MachineOperand> &Cond) const;
|
2007-05-18 00:18:17 +00:00
|
|
|
virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
|
|
|
|
virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
|
|
|
|
MachineBasicBlock *FBB,
|
2008-08-14 22:49:33 +00:00
|
|
|
const SmallVectorImpl<MachineOperand> &Cond) const;
|
2008-08-26 18:03:31 +00:00
|
|
|
virtual bool copyRegToReg(MachineBasicBlock &MBB,
|
2007-12-31 06:32:00 +00:00
|
|
|
MachineBasicBlock::iterator I,
|
|
|
|
unsigned DestReg, unsigned SrcReg,
|
|
|
|
const TargetRegisterClass *DestRC,
|
|
|
|
const TargetRegisterClass *SrcRC) const;
|
2008-01-01 21:11:32 +00:00
|
|
|
virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MBBI,
|
|
|
|
unsigned SrcReg, bool isKill, int FrameIndex,
|
|
|
|
const TargetRegisterClass *RC) const;
|
|
|
|
|
|
|
|
virtual void storeRegToAddr(MachineFunction &MF, unsigned SrcReg, bool isKill,
|
|
|
|
SmallVectorImpl<MachineOperand> &Addr,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
SmallVectorImpl<MachineInstr*> &NewMIs) const;
|
|
|
|
|
|
|
|
virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MBBI,
|
|
|
|
unsigned DestReg, int FrameIndex,
|
|
|
|
const TargetRegisterClass *RC) const;
|
|
|
|
|
|
|
|
virtual void loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
|
|
|
|
SmallVectorImpl<MachineOperand> &Addr,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
SmallVectorImpl<MachineInstr*> &NewMIs) const;
|
2008-01-04 23:57:37 +00:00
|
|
|
virtual bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
const std::vector<CalleeSavedInfo> &CSI) const;
|
|
|
|
virtual bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
const std::vector<CalleeSavedInfo> &CSI) const;
|
2008-01-07 01:35:02 +00:00
|
|
|
|
2008-02-08 21:20:40 +00:00
|
|
|
virtual MachineInstr* foldMemoryOperand(MachineFunction &MF,
|
|
|
|
MachineInstr* MI,
|
2008-10-16 01:49:15 +00:00
|
|
|
const SmallVectorImpl<unsigned> &Ops,
|
2008-01-07 01:35:02 +00:00
|
|
|
int FrameIndex) const;
|
|
|
|
|
2008-02-08 21:20:40 +00:00
|
|
|
virtual MachineInstr* foldMemoryOperand(MachineFunction &MF,
|
|
|
|
MachineInstr* MI,
|
2008-10-16 01:49:15 +00:00
|
|
|
const SmallVectorImpl<unsigned> &Ops,
|
2008-01-07 01:35:02 +00:00
|
|
|
MachineInstr* LoadMI) const {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-10-16 01:49:15 +00:00
|
|
|
virtual bool canFoldMemoryOperand(const MachineInstr *MI,
|
|
|
|
const SmallVectorImpl<unsigned> &Ops) const;
|
2008-01-07 01:35:02 +00:00
|
|
|
|
2008-10-16 01:49:15 +00:00
|
|
|
virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const;
|
2008-08-14 22:49:33 +00:00
|
|
|
virtual
|
|
|
|
bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const;
|
2007-05-16 02:01:49 +00:00
|
|
|
|
|
|
|
// Predication support.
|
2007-05-29 18:42:18 +00:00
|
|
|
virtual bool isPredicated(const MachineInstr *MI) const;
|
2007-05-23 07:22:05 +00:00
|
|
|
|
2008-10-07 19:05:35 +00:00
|
|
|
ARMCC::CondCodes getPredicate(const MachineInstr *MI) const {
|
|
|
|
int PIdx = MI->findFirstPredOperandIdx();
|
|
|
|
return PIdx != -1 ? (ARMCC::CondCodes)MI->getOperand(PIdx).getImm()
|
|
|
|
: ARMCC::AL;
|
|
|
|
}
|
|
|
|
|
2007-05-29 18:42:18 +00:00
|
|
|
virtual
|
|
|
|
bool PredicateInstruction(MachineInstr *MI,
|
2008-08-14 22:49:33 +00:00
|
|
|
const SmallVectorImpl<MachineOperand> &Pred) const;
|
2007-05-23 07:22:05 +00:00
|
|
|
|
2007-05-29 18:42:18 +00:00
|
|
|
virtual
|
2008-08-14 22:49:33 +00:00
|
|
|
bool SubsumesPredicate(const SmallVectorImpl<MachineOperand> &Pred1,
|
|
|
|
const SmallVectorImpl<MachineOperand> &Pred2) const;
|
2007-07-10 18:08:01 +00:00
|
|
|
|
|
|
|
virtual bool DefinesPredicate(MachineInstr *MI,
|
|
|
|
std::vector<MachineOperand> &Pred) const;
|
2008-04-16 20:10:13 +00:00
|
|
|
|
|
|
|
/// GetInstSize - Returns the size of the specified MachineInstr.
|
|
|
|
///
|
|
|
|
virtual unsigned GetInstSizeInBytes(const MachineInstr* MI) const;
|
2006-05-14 22:18:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|