2007-01-19 15:51:42 +08:00
|
|
|
//===- ARMInstrInfo.h - ARM Instruction Information -------------*- C++ -*-===//
|
2006-05-15 06:18:28 +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
|
2006-05-15 06:18:28 +08: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-08 05:01:51 +08:00
|
|
|
#include "ARM.h"
|
2006-05-15 06:18:28 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
2007-01-19 15:51:42 +08:00
|
|
|
class ARMSubtarget;
|
|
|
|
|
|
|
|
/// ARMII - This namespace holds all of the target specific flags that
|
|
|
|
/// instruction info tracks.
|
|
|
|
///
|
|
|
|
namespace ARMII {
|
|
|
|
enum {
|
|
|
|
//===------------------------------------------------------------------===//
|
|
|
|
// Instruction Flags.
|
|
|
|
|
|
|
|
//===------------------------------------------------------------------===//
|
2008-11-04 02:38:31 +08:00
|
|
|
// This four-bit field describes the addressing mode used.
|
2007-01-19 15:51:42 +08:00
|
|
|
|
|
|
|
AddrModeMask = 0xf,
|
2009-06-30 10:15:48 +08:00
|
|
|
AddrModeNone = 0,
|
|
|
|
AddrMode1 = 1,
|
|
|
|
AddrMode2 = 2,
|
|
|
|
AddrMode3 = 3,
|
|
|
|
AddrMode4 = 4,
|
|
|
|
AddrMode5 = 5,
|
2009-07-02 07:16:05 +08:00
|
|
|
AddrMode6 = 6,
|
|
|
|
AddrModeT1_1 = 7,
|
|
|
|
AddrModeT1_2 = 8,
|
|
|
|
AddrModeT1_4 = 9,
|
|
|
|
AddrModeT1_s = 10, // i8 * 4 for pc and sp relative data
|
|
|
|
AddrModeT2_i12 = 11,
|
|
|
|
AddrModeT2_i8 = 12,
|
|
|
|
AddrModeT2_so = 13,
|
|
|
|
AddrModeT2_pc = 14, // +/- i12 for pc relative data
|
|
|
|
AddrModeT2_i8s4 = 15, // i8 * 4
|
2007-01-19 15:51:42 +08: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,
|
2009-06-27 05:28:53 +08:00
|
|
|
|
2007-01-19 15:51:42 +08:00
|
|
|
// IndexMode - Unindex, pre-indexed, or post-indexed. Only valid for load
|
2009-06-27 05:28:53 +08:00
|
|
|
// and store ops
|
2007-01-19 15:51:42 +08:00
|
|
|
IndexModeShift = 7,
|
|
|
|
IndexModeMask = 3 << IndexModeShift,
|
|
|
|
IndexModePre = 1,
|
|
|
|
IndexModePost = 2,
|
2009-06-27 05:28:53 +08:00
|
|
|
|
2008-11-06 02:35:52 +08:00
|
|
|
//===------------------------------------------------------------------===//
|
|
|
|
// Instruction encoding formats.
|
|
|
|
//
|
2009-07-08 09:46:35 +08:00
|
|
|
FormShift = 9,
|
|
|
|
FormMask = 0x3f << FormShift,
|
2007-08-07 09:37:15 +08:00
|
|
|
|
2007-08-31 07:34:14 +08:00
|
|
|
// Pseudo instructions
|
2008-11-14 07:36:57 +08:00
|
|
|
Pseudo = 0 << FormShift,
|
2007-08-07 09:37:15 +08:00
|
|
|
|
2007-08-31 07:34:14 +08:00
|
|
|
// Multiply instructions
|
2008-11-14 07:36:57 +08:00
|
|
|
MulFrm = 1 << FormShift,
|
2007-08-31 07:34:14 +08:00
|
|
|
|
|
|
|
// Branch instructions
|
2008-11-14 07:36:57 +08:00
|
|
|
BrFrm = 2 << FormShift,
|
|
|
|
BrMiscFrm = 3 << FormShift,
|
2007-08-31 07:34:14 +08:00
|
|
|
|
|
|
|
// Data Processing instructions
|
2008-11-14 07:36:57 +08:00
|
|
|
DPFrm = 4 << FormShift,
|
|
|
|
DPSoRegFrm = 5 << FormShift,
|
2007-08-31 07:34:14 +08:00
|
|
|
|
|
|
|
// Load and Store
|
2008-11-14 07:36:57 +08:00
|
|
|
LdFrm = 6 << FormShift,
|
|
|
|
StFrm = 7 << FormShift,
|
|
|
|
LdMiscFrm = 8 << FormShift,
|
|
|
|
StMiscFrm = 9 << FormShift,
|
|
|
|
LdStMulFrm = 10 << FormShift,
|
2007-08-31 07:34:14 +08:00
|
|
|
|
|
|
|
// Miscellaneous arithmetic instructions
|
2008-11-14 07:36:57 +08:00
|
|
|
ArithMiscFrm = 11 << FormShift,
|
2008-11-07 06:15:19 +08:00
|
|
|
|
|
|
|
// Extend instructions
|
2008-11-14 07:36:57 +08:00
|
|
|
ExtFrm = 12 << FormShift,
|
2007-08-31 07:34:14 +08:00
|
|
|
|
2008-11-11 10:11:05 +08:00
|
|
|
// VFP formats
|
2008-11-14 07:36:57 +08:00
|
|
|
VFPUnaryFrm = 13 << FormShift,
|
|
|
|
VFPBinaryFrm = 14 << FormShift,
|
|
|
|
VFPConv1Frm = 15 << FormShift,
|
|
|
|
VFPConv2Frm = 16 << FormShift,
|
|
|
|
VFPConv3Frm = 17 << FormShift,
|
|
|
|
VFPConv4Frm = 18 << FormShift,
|
|
|
|
VFPConv5Frm = 19 << FormShift,
|
|
|
|
VFPLdStFrm = 20 << FormShift,
|
|
|
|
VFPLdStMulFrm = 21 << FormShift,
|
|
|
|
VFPMiscFrm = 22 << FormShift,
|
2007-08-31 07:34:14 +08:00
|
|
|
|
2008-11-11 10:11:05 +08:00
|
|
|
// Thumb format
|
2008-11-14 07:36:57 +08:00
|
|
|
ThumbFrm = 23 << FormShift,
|
2007-08-31 07:34:14 +08:00
|
|
|
|
2009-06-23 07:27:02 +08:00
|
|
|
// NEON format
|
|
|
|
NEONFrm = 24 << FormShift,
|
|
|
|
NEONGetLnFrm = 25 << FormShift,
|
|
|
|
NEONSetLnFrm = 26 << FormShift,
|
|
|
|
NEONDupFrm = 27 << FormShift,
|
|
|
|
|
2009-07-08 09:46:35 +08:00
|
|
|
//===------------------------------------------------------------------===//
|
|
|
|
// Misc flags.
|
|
|
|
|
|
|
|
// UnaryDP - Indicates this is a unary data processing instruction, i.e.
|
|
|
|
// it doesn't have a Rn operand.
|
|
|
|
UnaryDP = 1 << 15,
|
|
|
|
|
|
|
|
// Xform16Bit - Indicates this Thumb2 instruction may be transformed into
|
|
|
|
// a 16-bit Thumb instruction if certain conditions are met.
|
|
|
|
Xform16Bit = 1 << 16,
|
|
|
|
|
2008-11-06 02:35:52 +08:00
|
|
|
//===------------------------------------------------------------------===//
|
2007-08-31 07:34:14 +08:00
|
|
|
// Field shifts - such shifts are used to set field while generating
|
|
|
|
// machine instructions.
|
2008-11-11 10:11:05 +08:00
|
|
|
M_BitShift = 5,
|
2008-11-12 15:34:37 +08:00
|
|
|
ShiftImmShift = 5,
|
2008-11-07 09:41:35 +08:00
|
|
|
ShiftShift = 7,
|
2008-11-11 10:11:05 +08:00
|
|
|
N_BitShift = 7,
|
2008-11-12 15:34:37 +08:00
|
|
|
ImmHiShift = 8,
|
2008-11-07 06:15:19 +08: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,
|
2008-11-11 10:11:05 +08:00
|
|
|
D_BitShift = 22,
|
2008-11-07 06:15:19 +08:00
|
|
|
U_BitShift = 23,
|
|
|
|
P_BitShift = 24,
|
|
|
|
I_BitShift = 25,
|
|
|
|
CondShift = 28
|
2007-01-19 15:51:42 +08:00
|
|
|
};
|
|
|
|
}
|
2006-05-15 06:18:28 +08:00
|
|
|
|
2009-06-27 05:28:53 +08:00
|
|
|
class ARMBaseInstrInfo : public TargetInstrInfoImpl {
|
|
|
|
protected:
|
|
|
|
// Can be only subclassed.
|
|
|
|
explicit ARMBaseInstrInfo(const ARMSubtarget &STI);
|
2006-05-15 06:18:28 +08:00
|
|
|
public:
|
2007-01-19 15:51:42 +08:00
|
|
|
virtual MachineInstr *convertToThreeAddress(MachineFunction::iterator &MFI,
|
|
|
|
MachineBasicBlock::iterator &MBBI,
|
2008-07-03 07:41:07 +08:00
|
|
|
LiveVariables *LV) const;
|
2006-10-25 00:47:57 +08:00
|
|
|
|
2009-07-03 06:18:33 +08:00
|
|
|
virtual const ARMBaseRegisterInfo &getRegisterInfo() const =0;
|
|
|
|
|
2007-01-19 15:51:42 +08:00
|
|
|
// Branch analysis.
|
|
|
|
virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
|
|
|
|
MachineBasicBlock *&FBB,
|
2009-02-09 15:14:22 +08:00
|
|
|
SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
bool AllowModify) const;
|
2007-05-18 08:18:17 +08:00
|
|
|
virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
|
|
|
|
virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
|
|
|
|
MachineBasicBlock *FBB,
|
2008-08-15 06:49:33 +08:00
|
|
|
const SmallVectorImpl<MachineOperand> &Cond) const;
|
2009-06-27 05:28:53 +08:00
|
|
|
|
|
|
|
virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const;
|
|
|
|
virtual
|
|
|
|
bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const;
|
|
|
|
|
|
|
|
// Predication support.
|
|
|
|
virtual bool isPredicated(const MachineInstr *MI) const;
|
|
|
|
|
|
|
|
ARMCC::CondCodes getPredicate(const MachineInstr *MI) const {
|
|
|
|
int PIdx = MI->findFirstPredOperandIdx();
|
|
|
|
return PIdx != -1 ? (ARMCC::CondCodes)MI->getOperand(PIdx).getImm()
|
|
|
|
: ARMCC::AL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
/// GetInstSize - Returns the size of the specified MachineInstr.
|
|
|
|
///
|
|
|
|
virtual unsigned GetInstSizeInBytes(const MachineInstr* MI) const;
|
2009-06-27 20:16:40 +08:00
|
|
|
|
2009-06-27 05:28:53 +08:00
|
|
|
/// Return true if the instruction is a register to register move and return
|
|
|
|
/// the source and dest operands and their sub-register indices by reference.
|
|
|
|
virtual bool isMoveInstr(const MachineInstr &MI,
|
|
|
|
unsigned &SrcReg, unsigned &DstReg,
|
|
|
|
unsigned &SrcSubIdx, unsigned &DstSubIdx) const;
|
|
|
|
|
|
|
|
virtual unsigned isLoadFromStackSlot(const MachineInstr *MI,
|
|
|
|
int &FrameIndex) const;
|
|
|
|
virtual unsigned isStoreToStackSlot(const MachineInstr *MI,
|
|
|
|
int &FrameIndex) const;
|
|
|
|
|
2008-08-27 02:03:31 +08:00
|
|
|
virtual bool copyRegToReg(MachineBasicBlock &MBB,
|
2007-12-31 14:32:00 +08:00
|
|
|
MachineBasicBlock::iterator I,
|
|
|
|
unsigned DestReg, unsigned SrcReg,
|
|
|
|
const TargetRegisterClass *DestRC,
|
|
|
|
const TargetRegisterClass *SrcRC) const;
|
2008-01-02 05:11:32 +08: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;
|
2009-06-27 05:28:53 +08:00
|
|
|
|
2009-06-27 20:16:40 +08:00
|
|
|
virtual bool canFoldMemoryOperand(const MachineInstr *MI,
|
|
|
|
const SmallVectorImpl<unsigned> &Ops) const;
|
2009-07-03 06:18:33 +08:00
|
|
|
|
2008-12-04 02:43:12 +08:00
|
|
|
virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
|
|
|
|
MachineInstr* MI,
|
2009-07-03 06:18:33 +08:00
|
|
|
const SmallVectorImpl<unsigned> &Ops,
|
2008-12-04 02:43:12 +08:00
|
|
|
int FrameIndex) const;
|
|
|
|
|
|
|
|
virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
|
|
|
|
MachineInstr* MI,
|
2009-07-03 06:18:33 +08:00
|
|
|
const SmallVectorImpl<unsigned> &Ops,
|
|
|
|
MachineInstr* LoadMI) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ARMInstrInfo : public ARMBaseInstrInfo {
|
|
|
|
ARMRegisterInfo RI;
|
|
|
|
public:
|
|
|
|
explicit ARMInstrInfo(const ARMSubtarget &STI);
|
|
|
|
|
|
|
|
/// 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).
|
|
|
|
///
|
|
|
|
const ARMRegisterInfo &getRegisterInfo() const { return RI; }
|
|
|
|
|
|
|
|
void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
|
|
|
|
unsigned DestReg, const MachineInstr *Orig) const;
|
2006-05-15 06:18:28 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|