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"
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
//===------------------------------------------------------------------===//
|
|
|
|
// This three-bit field describes the addressing mode used. Zero is unused
|
|
|
|
// so that we can tell if we forgot to set a value.
|
|
|
|
|
|
|
|
AddrModeMask = 0xf,
|
2007-08-07 09:37:15 +08:00
|
|
|
AddrModeNone = 0,
|
2007-01-19 15:51:42 +08:00
|
|
|
AddrMode1 = 1,
|
|
|
|
AddrMode2 = 2,
|
|
|
|
AddrMode3 = 3,
|
|
|
|
AddrMode4 = 4,
|
|
|
|
AddrMode5 = 5,
|
|
|
|
AddrModeT1 = 6,
|
|
|
|
AddrModeT2 = 7,
|
|
|
|
AddrModeT4 = 8,
|
|
|
|
AddrModeTs = 9, // i8 * 4 for pc and sp relative data
|
|
|
|
|
|
|
|
// 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,
|
|
|
|
|
|
|
|
// Opcode
|
|
|
|
OpcodeShift = 9,
|
2007-08-07 09:37:15 +08:00
|
|
|
OpcodeMask = 0xf << OpcodeShift,
|
|
|
|
|
|
|
|
// Format
|
|
|
|
FormShift = 13,
|
|
|
|
FormMask = 31 << FormShift,
|
|
|
|
|
2007-08-31 07:34:14 +08:00
|
|
|
// Pseudo instructions
|
2007-08-07 09:37:15 +08:00
|
|
|
Pseudo = 1 << FormShift,
|
|
|
|
|
2007-08-31 07:34:14 +08:00
|
|
|
// Multiply instructions
|
2007-08-07 09:37:15 +08:00
|
|
|
MulFrm = 2 << FormShift,
|
2007-08-31 07:34:14 +08:00
|
|
|
MulSMLAW = 3 << FormShift,
|
|
|
|
MulSMULW = 4 << FormShift,
|
|
|
|
MulSMLA = 5 << FormShift,
|
|
|
|
MulSMUL = 6 << FormShift,
|
|
|
|
|
|
|
|
// Branch instructions
|
|
|
|
Branch = 7 << FormShift,
|
|
|
|
BranchMisc = 8 << FormShift,
|
|
|
|
|
|
|
|
// Data Processing instructions
|
|
|
|
DPRdIm = 9 << FormShift,
|
|
|
|
DPRdReg = 10 << FormShift,
|
|
|
|
DPRdSoReg = 11 << FormShift,
|
|
|
|
DPRdMisc = 12 << FormShift,
|
|
|
|
|
|
|
|
DPRnIm = 13 << FormShift,
|
|
|
|
DPRnReg = 14 << FormShift,
|
|
|
|
DPRnSoReg = 15 << FormShift,
|
|
|
|
|
|
|
|
DPRIm = 16 << FormShift,
|
|
|
|
DPRReg = 17 << FormShift,
|
|
|
|
DPRSoReg = 18 << FormShift,
|
|
|
|
|
|
|
|
DPRImS = 19 << FormShift,
|
|
|
|
DPRRegS = 20 << FormShift,
|
|
|
|
DPRSoRegS = 21 << FormShift,
|
|
|
|
|
|
|
|
// Load and Store
|
|
|
|
LdFrm = 22 << FormShift,
|
|
|
|
StFrm = 23 << FormShift,
|
|
|
|
|
|
|
|
// Miscellaneous arithmetic instructions
|
|
|
|
ArithMisc = 24 << FormShift,
|
|
|
|
|
|
|
|
// Thumb format
|
|
|
|
ThumbFrm = 25 << FormShift,
|
|
|
|
|
|
|
|
// VFP format
|
|
|
|
VPFFrm = 26 << FormShift,
|
|
|
|
|
|
|
|
// Field shifts - such shifts are used to set field while generating
|
|
|
|
// machine instructions.
|
|
|
|
RegRsShift = 8,
|
|
|
|
RegRdShift = 12,
|
|
|
|
RegRnShift = 16,
|
|
|
|
L_BitShift = 20,
|
|
|
|
S_BitShift = 20,
|
|
|
|
U_BitShift = 23,
|
|
|
|
IndexShift = 24,
|
|
|
|
I_BitShift = 25
|
2007-01-19 15:51:42 +08:00
|
|
|
};
|
|
|
|
}
|
2006-05-15 06:18:28 +08:00
|
|
|
|
2008-01-01 09:03:04 +08:00
|
|
|
class ARMInstrInfo : public TargetInstrInfoImpl {
|
2006-05-15 06:18:28 +08:00
|
|
|
const ARMRegisterInfo RI;
|
|
|
|
public:
|
2007-01-19 15:51:42 +08:00
|
|
|
ARMInstrInfo(const ARMSubtarget &STI);
|
2006-05-15 06:18:28 +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).
|
|
|
|
///
|
|
|
|
virtual const MRegisterInfo &getRegisterInfo() const { return RI; }
|
|
|
|
|
2006-08-09 04:35:03 +08:00
|
|
|
/// getPointerRegClass - Return the register class to use to hold pointers.
|
|
|
|
/// This is used for addressing modes.
|
|
|
|
virtual const TargetRegisterClass *getPointerRegClass() const;
|
|
|
|
|
2006-05-15 06:18:28 +08: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 15:51:42 +08:00
|
|
|
virtual unsigned isLoadFromStackSlot(MachineInstr *MI, int &FrameIndex) const;
|
|
|
|
virtual unsigned isStoreToStackSlot(MachineInstr *MI, int &FrameIndex) const;
|
|
|
|
|
|
|
|
virtual MachineInstr *convertToThreeAddress(MachineFunction::iterator &MFI,
|
|
|
|
MachineBasicBlock::iterator &MBBI,
|
|
|
|
LiveVariables &LV) const;
|
2006-10-25 00:47:57 +08:00
|
|
|
|
2007-01-19 15:51:42 +08:00
|
|
|
// Branch analysis.
|
|
|
|
virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
|
|
|
|
MachineBasicBlock *&FBB,
|
|
|
|
std::vector<MachineOperand> &Cond) const;
|
2007-05-18 08:18:17 +08:00
|
|
|
virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
|
|
|
|
virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
|
|
|
|
MachineBasicBlock *FBB,
|
|
|
|
const std::vector<MachineOperand> &Cond) const;
|
2007-12-31 14:32:00 +08:00
|
|
|
virtual void copyRegToReg(MachineBasicBlock &MBB,
|
|
|
|
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;
|
2008-01-05 07:57:37 +08: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 09:35:02 +08:00
|
|
|
|
|
|
|
virtual MachineInstr* foldMemoryOperand(MachineInstr* MI,
|
|
|
|
SmallVectorImpl<unsigned> &Ops,
|
|
|
|
int FrameIndex) const;
|
|
|
|
|
|
|
|
virtual MachineInstr* foldMemoryOperand(MachineInstr* MI,
|
|
|
|
SmallVectorImpl<unsigned> &Ops,
|
|
|
|
MachineInstr* LoadMI) const {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool canFoldMemoryOperand(MachineInstr *MI,
|
|
|
|
SmallVectorImpl<unsigned> &Ops) const;
|
|
|
|
|
2007-01-19 15:51:42 +08:00
|
|
|
virtual bool BlockHasNoFallThrough(MachineBasicBlock &MBB) const;
|
|
|
|
virtual bool ReverseBranchCondition(std::vector<MachineOperand> &Cond) const;
|
2007-05-16 10:01:49 +08:00
|
|
|
|
|
|
|
// Predication support.
|
2007-05-30 02:42:18 +08:00
|
|
|
virtual bool isPredicated(const MachineInstr *MI) const;
|
2007-05-23 15:22:05 +08:00
|
|
|
|
2007-05-30 02:42:18 +08:00
|
|
|
virtual
|
|
|
|
bool PredicateInstruction(MachineInstr *MI,
|
|
|
|
const std::vector<MachineOperand> &Pred) const;
|
2007-05-23 15:22:05 +08:00
|
|
|
|
2007-05-30 02:42:18 +08:00
|
|
|
virtual
|
|
|
|
bool SubsumesPredicate(const std::vector<MachineOperand> &Pred1,
|
2007-10-19 03:29:45 +08:00
|
|
|
const std::vector<MachineOperand> &Pred2) const;
|
2007-07-11 02:08:01 +08:00
|
|
|
|
|
|
|
virtual bool DefinesPredicate(MachineInstr *MI,
|
|
|
|
std::vector<MachineOperand> &Pred) const;
|
2006-05-15 06:18:28 +08:00
|
|
|
};
|
|
|
|
|
2007-01-30 07:45:17 +08:00
|
|
|
// Utility routines
|
|
|
|
namespace ARM {
|
|
|
|
/// GetInstSize - Returns the size of the specified MachineInstr.
|
|
|
|
///
|
|
|
|
unsigned GetInstSize(MachineInstr *MI);
|
|
|
|
|
|
|
|
/// GetFunctionSize - Returns the size of the specified MachineFunction.
|
|
|
|
///
|
|
|
|
unsigned GetFunctionSize(MachineFunction &MF);
|
|
|
|
}
|
2006-05-15 06:18:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|