2009-11-08 06:00:39 +08:00
|
|
|
//===- Thumb1InstrInfo.cpp - Thumb-1 Instruction Information ----*- C++ -*-===//
|
2009-06-27 05:28:53 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2009-07-03 06:18:33 +08:00
|
|
|
// This file contains the Thumb-1 implementation of the TargetInstrInfo class.
|
2009-06-27 05:28:53 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-11-07 07:52:48 +08:00
|
|
|
#include "Thumb1InstrInfo.h"
|
2009-06-27 05:28:53 +08:00
|
|
|
#include "ARM.h"
|
|
|
|
#include "ARMMachineFunctionInfo.h"
|
|
|
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
2010-05-22 09:47:14 +08:00
|
|
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
2009-11-02 06:04:35 +08:00
|
|
|
#include "llvm/CodeGen/MachineMemOperand.h"
|
|
|
|
#include "llvm/CodeGen/PseudoSourceValue.h"
|
2009-06-27 05:28:53 +08:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2009-07-03 06:18:33 +08:00
|
|
|
#include "Thumb1InstrInfo.h"
|
2009-06-27 05:28:53 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2009-11-02 08:10:38 +08:00
|
|
|
Thumb1InstrInfo::Thumb1InstrInfo(const ARMSubtarget &STI)
|
|
|
|
: ARMBaseInstrInfo(STI), RI(*this, STI) {
|
2009-06-27 05:28:53 +08:00
|
|
|
}
|
|
|
|
|
2009-07-11 14:43:01 +08:00
|
|
|
unsigned Thumb1InstrInfo::getUnindexedOpcode(unsigned Opc) const {
|
2009-07-09 00:09:28 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-07-11 14:33:54 +08:00
|
|
|
void Thumb1InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator I, DebugLoc DL,
|
|
|
|
unsigned DestReg, unsigned SrcReg,
|
|
|
|
bool KillSrc) const {
|
2011-07-01 07:38:17 +08:00
|
|
|
AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::tMOVr), DestReg)
|
2011-07-01 06:10:46 +08:00
|
|
|
.addReg(SrcReg, getKillRegState(KillSrc)));
|
2010-07-11 14:33:54 +08:00
|
|
|
assert(ARM::GPRRegClass.contains(DestReg, SrcReg) &&
|
|
|
|
"Thumb1 can only copy GPR registers");
|
2009-06-27 05:28:53 +08:00
|
|
|
}
|
|
|
|
|
2009-07-03 06:18:33 +08:00
|
|
|
void Thumb1InstrInfo::
|
2009-06-27 05:28:53 +08:00
|
|
|
storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
|
|
|
|
unsigned SrcReg, bool isKill, int FI,
|
2010-05-07 03:06:44 +08:00
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const {
|
2009-08-13 13:40:51 +08:00
|
|
|
assert((RC == ARM::tGPRRegisterClass ||
|
|
|
|
(TargetRegisterInfo::isPhysicalRegister(SrcReg) &&
|
|
|
|
isARMLowRegister(SrcReg))) && "Unknown regclass!");
|
2009-06-27 05:28:53 +08:00
|
|
|
|
2010-01-16 06:21:03 +08:00
|
|
|
if (RC == ARM::tGPRRegisterClass ||
|
|
|
|
(TargetRegisterInfo::isPhysicalRegister(SrcReg) &&
|
|
|
|
isARMLowRegister(SrcReg))) {
|
2010-05-07 03:06:44 +08:00
|
|
|
DebugLoc DL;
|
|
|
|
if (I != MBB.end()) DL = I->getDebugLoc();
|
|
|
|
|
2009-11-02 06:04:35 +08:00
|
|
|
MachineFunction &MF = *MBB.getParent();
|
|
|
|
MachineFrameInfo &MFI = *MF.getFrameInfo();
|
|
|
|
MachineMemOperand *MMO =
|
2010-09-21 12:39:43 +08:00
|
|
|
MF.getMachineMemOperand(
|
|
|
|
MachinePointerInfo(PseudoSourceValue::getFixedStack(FI)),
|
|
|
|
MachineMemOperand::MOStore,
|
2009-11-02 06:04:35 +08:00
|
|
|
MFI.getObjectSize(FI),
|
|
|
|
MFI.getObjectAlignment(FI));
|
2011-06-30 04:26:39 +08:00
|
|
|
AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::tSTRspi))
|
2009-07-11 14:43:01 +08:00
|
|
|
.addReg(SrcReg, getKillRegState(isKill))
|
2009-11-02 06:04:35 +08:00
|
|
|
.addFrameIndex(FI).addImm(0).addMemOperand(MMO));
|
2009-06-27 05:28:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-03 06:18:33 +08:00
|
|
|
void Thumb1InstrInfo::
|
2009-06-27 05:28:53 +08:00
|
|
|
loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
|
|
|
|
unsigned DestReg, int FI,
|
2010-05-07 03:06:44 +08:00
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const {
|
2009-08-13 13:40:51 +08:00
|
|
|
assert((RC == ARM::tGPRRegisterClass ||
|
|
|
|
(TargetRegisterInfo::isPhysicalRegister(DestReg) &&
|
|
|
|
isARMLowRegister(DestReg))) && "Unknown regclass!");
|
2009-06-27 05:28:53 +08:00
|
|
|
|
2010-01-16 06:21:03 +08:00
|
|
|
if (RC == ARM::tGPRRegisterClass ||
|
|
|
|
(TargetRegisterInfo::isPhysicalRegister(DestReg) &&
|
|
|
|
isARMLowRegister(DestReg))) {
|
2010-05-07 03:06:44 +08:00
|
|
|
DebugLoc DL;
|
|
|
|
if (I != MBB.end()) DL = I->getDebugLoc();
|
|
|
|
|
2009-11-02 06:04:35 +08:00
|
|
|
MachineFunction &MF = *MBB.getParent();
|
|
|
|
MachineFrameInfo &MFI = *MF.getFrameInfo();
|
|
|
|
MachineMemOperand *MMO =
|
2010-09-21 12:39:43 +08:00
|
|
|
MF.getMachineMemOperand(
|
|
|
|
MachinePointerInfo(PseudoSourceValue::getFixedStack(FI)),
|
|
|
|
MachineMemOperand::MOLoad,
|
2009-11-02 06:04:35 +08:00
|
|
|
MFI.getObjectSize(FI),
|
|
|
|
MFI.getObjectAlignment(FI));
|
2011-06-30 04:26:39 +08:00
|
|
|
AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::tLDRspi), DestReg)
|
2009-11-02 06:04:35 +08:00
|
|
|
.addFrameIndex(FI).addImm(0).addMemOperand(MMO));
|
2009-06-27 05:28:53 +08:00
|
|
|
}
|
|
|
|
}
|