1 //===- Thumb1InstrInfo.h - Thumb-1 Instruction Information ----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the Thumb-1 implementation of the TargetInstrInfo class.
12 //===----------------------------------------------------------------------===//
14 #ifndef THUMB1INSTRUCTIONINFO_H
15 #define THUMB1INSTRUCTIONINFO_H
17 #include "llvm/Target/TargetInstrInfo.h"
19 #include "ARMInstrInfo.h"
20 #include "Thumb1RegisterInfo.h"
25 class Thumb1InstrInfo : public ARMBaseInstrInfo {
26 Thumb1RegisterInfo RI;
28 explicit Thumb1InstrInfo(const ARMSubtarget &STI);
30 // Return the non-pre/post incrementing version of 'Opc'. Return 0
31 // if there is not such an opcode.
32 unsigned getUnindexedOpcode(unsigned Opc) const;
34 // Return the opcode that implements 'Op', or 0 if no opcode
35 unsigned getOpcode(ARMII::Op Op) const;
37 // If 'opcode' is an instruction with an unsigned offset that also
38 // has a version with a signed offset, return the opcode for the
39 // version with the signed offset. In 'NumBits' return the number of
40 // bits for the signed offset.
41 unsigned unsignedOffsetOpcodeToSigned(unsigned opcode,
42 unsigned *NumBits) const;
44 // Return true if the block does not fall through.
45 bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const;
47 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
48 /// such, whenever a client has an instance of instruction info, it should
49 /// always be able to get register info as well (through this method).
51 const Thumb1RegisterInfo &getRegisterInfo() const { return RI; }
53 bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
54 MachineBasicBlock::iterator MI,
55 const std::vector<CalleeSavedInfo> &CSI) const;
56 bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
57 MachineBasicBlock::iterator MI,
58 const std::vector<CalleeSavedInfo> &CSI) const;
60 bool isMoveInstr(const MachineInstr &MI,
61 unsigned &SrcReg, unsigned &DstReg,
62 unsigned &SrcSubIdx, unsigned &DstSubIdx) const;
63 unsigned isLoadFromStackSlot(const MachineInstr *MI,
64 int &FrameIndex) const;
65 unsigned isStoreToStackSlot(const MachineInstr *MI,
66 int &FrameIndex) const;
68 bool copyRegToReg(MachineBasicBlock &MBB,
69 MachineBasicBlock::iterator I,
70 unsigned DestReg, unsigned SrcReg,
71 const TargetRegisterClass *DestRC,
72 const TargetRegisterClass *SrcRC) const;
73 void storeRegToStackSlot(MachineBasicBlock &MBB,
74 MachineBasicBlock::iterator MBBI,
75 unsigned SrcReg, bool isKill, int FrameIndex,
76 const TargetRegisterClass *RC) const;
78 void storeRegToAddr(MachineFunction &MF, unsigned SrcReg, bool isKill,
79 SmallVectorImpl<MachineOperand> &Addr,
80 const TargetRegisterClass *RC,
81 SmallVectorImpl<MachineInstr*> &NewMIs) const;
83 void loadRegFromStackSlot(MachineBasicBlock &MBB,
84 MachineBasicBlock::iterator MBBI,
85 unsigned DestReg, int FrameIndex,
86 const TargetRegisterClass *RC) const;
88 void loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
89 SmallVectorImpl<MachineOperand> &Addr,
90 const TargetRegisterClass *RC,
91 SmallVectorImpl<MachineInstr*> &NewMIs) const;
93 bool canFoldMemoryOperand(const MachineInstr *MI,
94 const SmallVectorImpl<unsigned> &Ops) const;
96 MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
98 const SmallVectorImpl<unsigned> &Ops,
99 int FrameIndex) const;
101 MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
103 const SmallVectorImpl<unsigned> &Ops,
104 MachineInstr* LoadMI) const {
110 #endif // THUMB1INSTRUCTIONINFO_H