mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
eb66b33867
I did this a long time ago with a janky python script, but now clang-format has built-in support for this. I fed clang-format every line with a #include and let it re-sort things according to the precise LLVM rules for include ordering baked into clang-format these days. I've reverted a number of files where the results of sorting includes isn't healthy. Either places where we have legacy code relying on particular include ordering (where possible, I'll fix these separately) or where we have particular formatting around #include lines that I didn't want to disturb in this patch. This patch is *entirely* mechanical. If you get merge conflicts or anything, just ignore the changes in this patch and run clang-format over your #include lines in the files. Sorry for any noise here, but it is important to keep these things stable. I was seeing an increasing number of patches with irrelevant re-ordering of #include lines because clang-format was used. This patch at least isolates that churn, makes it easy to skip when resolving conflicts, and gets us to a clean baseline (again). llvm-svn: 304787
145 lines
5.3 KiB
C++
145 lines
5.3 KiB
C++
//===-- Thumb1InstrInfo.cpp - Thumb-1 Instruction Information -------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file contains the Thumb-1 implementation of the TargetInstrInfo class.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "Thumb1InstrInfo.h"
|
|
#include "ARMSubtarget.h"
|
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
|
#include "llvm/CodeGen/MachineMemOperand.h"
|
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
|
#include "llvm/MC/MCInst.h"
|
|
|
|
using namespace llvm;
|
|
|
|
Thumb1InstrInfo::Thumb1InstrInfo(const ARMSubtarget &STI)
|
|
: ARMBaseInstrInfo(STI), RI() {}
|
|
|
|
/// Return the noop instruction to use for a noop.
|
|
void Thumb1InstrInfo::getNoop(MCInst &NopInst) const {
|
|
NopInst.setOpcode(ARM::tMOVr);
|
|
NopInst.addOperand(MCOperand::createReg(ARM::R8));
|
|
NopInst.addOperand(MCOperand::createReg(ARM::R8));
|
|
NopInst.addOperand(MCOperand::createImm(ARMCC::AL));
|
|
NopInst.addOperand(MCOperand::createReg(0));
|
|
}
|
|
|
|
unsigned Thumb1InstrInfo::getUnindexedOpcode(unsigned Opc) const {
|
|
return 0;
|
|
}
|
|
|
|
void Thumb1InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
|
|
MachineBasicBlock::iterator I,
|
|
const DebugLoc &DL, unsigned DestReg,
|
|
unsigned SrcReg, bool KillSrc) const {
|
|
// Need to check the arch.
|
|
MachineFunction &MF = *MBB.getParent();
|
|
const ARMSubtarget &st = MF.getSubtarget<ARMSubtarget>();
|
|
|
|
assert(ARM::GPRRegClass.contains(DestReg, SrcReg) &&
|
|
"Thumb1 can only copy GPR registers");
|
|
|
|
if (st.hasV6Ops() || ARM::hGPRRegClass.contains(SrcReg)
|
|
|| !ARM::tGPRRegClass.contains(DestReg))
|
|
BuildMI(MBB, I, DL, get(ARM::tMOVr), DestReg)
|
|
.addReg(SrcReg, getKillRegState(KillSrc))
|
|
.add(predOps(ARMCC::AL));
|
|
else {
|
|
// FIXME: Can also use 'mov hi, $src; mov $dst, hi',
|
|
// with hi as either r10 or r11.
|
|
|
|
const TargetRegisterInfo *RegInfo = st.getRegisterInfo();
|
|
if (MBB.computeRegisterLiveness(RegInfo, ARM::CPSR, I)
|
|
== MachineBasicBlock::LQR_Dead) {
|
|
BuildMI(MBB, I, DL, get(ARM::tMOVSr), DestReg)
|
|
.addReg(SrcReg, getKillRegState(KillSrc))
|
|
->addRegisterDead(ARM::CPSR, RegInfo);
|
|
return;
|
|
}
|
|
|
|
// 'MOV lo, lo' is unpredictable on < v6, so use the stack to do it
|
|
BuildMI(MBB, I, DL, get(ARM::tPUSH))
|
|
.add(predOps(ARMCC::AL))
|
|
.addReg(SrcReg, getKillRegState(KillSrc));
|
|
BuildMI(MBB, I, DL, get(ARM::tPOP))
|
|
.add(predOps(ARMCC::AL))
|
|
.addReg(DestReg, getDefRegState(true));
|
|
}
|
|
}
|
|
|
|
void Thumb1InstrInfo::
|
|
storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
|
|
unsigned SrcReg, bool isKill, int FI,
|
|
const TargetRegisterClass *RC,
|
|
const TargetRegisterInfo *TRI) const {
|
|
assert((RC == &ARM::tGPRRegClass ||
|
|
(TargetRegisterInfo::isPhysicalRegister(SrcReg) &&
|
|
isARMLowRegister(SrcReg))) && "Unknown regclass!");
|
|
|
|
if (RC == &ARM::tGPRRegClass ||
|
|
(TargetRegisterInfo::isPhysicalRegister(SrcReg) &&
|
|
isARMLowRegister(SrcReg))) {
|
|
DebugLoc DL;
|
|
if (I != MBB.end()) DL = I->getDebugLoc();
|
|
|
|
MachineFunction &MF = *MBB.getParent();
|
|
MachineFrameInfo &MFI = MF.getFrameInfo();
|
|
MachineMemOperand *MMO = MF.getMachineMemOperand(
|
|
MachinePointerInfo::getFixedStack(MF, FI), MachineMemOperand::MOStore,
|
|
MFI.getObjectSize(FI), MFI.getObjectAlignment(FI));
|
|
BuildMI(MBB, I, DL, get(ARM::tSTRspi))
|
|
.addReg(SrcReg, getKillRegState(isKill))
|
|
.addFrameIndex(FI)
|
|
.addImm(0)
|
|
.addMemOperand(MMO)
|
|
.add(predOps(ARMCC::AL));
|
|
}
|
|
}
|
|
|
|
void Thumb1InstrInfo::
|
|
loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
|
|
unsigned DestReg, int FI,
|
|
const TargetRegisterClass *RC,
|
|
const TargetRegisterInfo *TRI) const {
|
|
assert((RC == &ARM::tGPRRegClass ||
|
|
(TargetRegisterInfo::isPhysicalRegister(DestReg) &&
|
|
isARMLowRegister(DestReg))) && "Unknown regclass!");
|
|
|
|
if (RC == &ARM::tGPRRegClass ||
|
|
(TargetRegisterInfo::isPhysicalRegister(DestReg) &&
|
|
isARMLowRegister(DestReg))) {
|
|
DebugLoc DL;
|
|
if (I != MBB.end()) DL = I->getDebugLoc();
|
|
|
|
MachineFunction &MF = *MBB.getParent();
|
|
MachineFrameInfo &MFI = MF.getFrameInfo();
|
|
MachineMemOperand *MMO = MF.getMachineMemOperand(
|
|
MachinePointerInfo::getFixedStack(MF, FI), MachineMemOperand::MOLoad,
|
|
MFI.getObjectSize(FI), MFI.getObjectAlignment(FI));
|
|
BuildMI(MBB, I, DL, get(ARM::tLDRspi), DestReg)
|
|
.addFrameIndex(FI)
|
|
.addImm(0)
|
|
.addMemOperand(MMO)
|
|
.add(predOps(ARMCC::AL));
|
|
}
|
|
}
|
|
|
|
void Thumb1InstrInfo::expandLoadStackGuard(
|
|
MachineBasicBlock::iterator MI) const {
|
|
MachineFunction &MF = *MI->getParent()->getParent();
|
|
const TargetMachine &TM = MF.getTarget();
|
|
if (TM.isPositionIndependent())
|
|
expandLoadStackGuardBase(MI, ARM::tLDRLIT_ga_pcrel, ARM::tLDRi);
|
|
else
|
|
expandLoadStackGuardBase(MI, ARM::tLDRLIT_ga_abs, ARM::tLDRi);
|
|
}
|