mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Remove support for 64b PPC, it's been broken for a long time. It'll be
back once a DAG->DAG ISel exists. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22778 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7ac17529d2
commit
8f331325a2
@ -8,12 +8,11 @@
|
||||
##===----------------------------------------------------------------------===##
|
||||
LEVEL = ../../..
|
||||
LIBRARYNAME = LLVMPowerPC
|
||||
TARGET = PowerPC PPC32 PPC64
|
||||
TARGET = PowerPC PPC32
|
||||
|
||||
# Make sure that tblgen is run, first thing.
|
||||
BUILT_SOURCES = PowerPCGenInstrNames.inc PowerPCGenRegisterNames.inc \
|
||||
PowerPCGenAsmWriter.inc PPC32GenCodeEmitter.inc \
|
||||
PPC32GenRegisterInfo.h.inc PPC32GenRegisterInfo.inc PPC32GenInstrInfo.inc \
|
||||
PPC64GenRegisterInfo.h.inc PPC64GenRegisterInfo.inc PPC64GenInstrInfo.inc
|
||||
PPC32GenRegisterInfo.h.inc PPC32GenRegisterInfo.inc PPC32GenInstrInfo.inc
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
@ -1,35 +0,0 @@
|
||||
//===-- PPC64CodeEmitter.cpp - JIT Code Emitter for PPC64 -----*- C++ -*-=//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "PPC64JITInfo.h"
|
||||
#include "PPC64TargetMachine.h"
|
||||
using namespace llvm;
|
||||
|
||||
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to get
|
||||
/// machine code emitted. This uses a MachineCodeEmitter object to handle
|
||||
/// actually outputting the machine code and resolving things like the address
|
||||
/// of functions. This method should returns true if machine code emission is
|
||||
/// not supported.
|
||||
///
|
||||
bool PPC64TargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM,
|
||||
MachineCodeEmitter &MCE) {
|
||||
return true;
|
||||
// It should go something like this:
|
||||
// PM.add(new Emitter(MCE)); // Machine code emitter pass for PPC64
|
||||
// Delete machine code for this function after emitting it:
|
||||
// PM.add(createMachineCodeDeleter());
|
||||
}
|
||||
|
||||
void PPC64JITInfo::replaceMachineCodeForFunction (void *Old, void *New) {
|
||||
assert (0 && "PPC64JITInfo::replaceMachineCodeForFunction not implemented");
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,59 +0,0 @@
|
||||
//===- PPC64InstrInfo.cpp - PowerPC64 Instruction Information ---*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains the PowerPC implementation of the TargetInstrInfo class.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "PowerPC.h"
|
||||
#include "PPC64InstrInfo.h"
|
||||
#include "PPC64GenInstrInfo.inc"
|
||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||
#include <iostream>
|
||||
using namespace llvm;
|
||||
|
||||
PPC64InstrInfo::PPC64InstrInfo()
|
||||
: TargetInstrInfo(PPC64Insts, sizeof(PPC64Insts)/sizeof(PPC64Insts[0])) { }
|
||||
|
||||
bool PPC64InstrInfo::isMoveInstr(const MachineInstr& MI,
|
||||
unsigned& sourceReg,
|
||||
unsigned& destReg) const {
|
||||
MachineOpCode oc = MI.getOpcode();
|
||||
if (oc == PPC::OR) { // or r1, r2, r2
|
||||
assert(MI.getNumOperands() == 3 &&
|
||||
MI.getOperand(0).isRegister() &&
|
||||
MI.getOperand(1).isRegister() &&
|
||||
MI.getOperand(2).isRegister() &&
|
||||
"invalid PPC OR instruction!");
|
||||
if (MI.getOperand(1).getReg() == MI.getOperand(2).getReg()) {
|
||||
sourceReg = MI.getOperand(1).getReg();
|
||||
destReg = MI.getOperand(0).getReg();
|
||||
return true;
|
||||
}
|
||||
} else if (oc == PPC::ADDI) { // addi r1, r2, 0
|
||||
assert(MI.getNumOperands() == 3 &&
|
||||
MI.getOperand(0).isRegister() &&
|
||||
MI.getOperand(2).isImmediate() &&
|
||||
"invalid PPC ADDI instruction!");
|
||||
if (MI.getOperand(1).isRegister() && MI.getOperand(2).getImmedValue()==0) {
|
||||
sourceReg = MI.getOperand(1).getReg();
|
||||
destReg = MI.getOperand(0).getReg();
|
||||
return true;
|
||||
}
|
||||
} else if (oc == PPC::FMR) { // fmr r1, r2
|
||||
assert(MI.getNumOperands() == 2 &&
|
||||
MI.getOperand(0).isRegister() &&
|
||||
MI.getOperand(1).isRegister() &&
|
||||
"invalid PPC FMR instruction");
|
||||
sourceReg = MI.getOperand(1).getReg();
|
||||
destReg = MI.getOperand(0).getReg();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
//===- PPC64InstrInfo.h - PowerPC64 Instruction Information -----*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains the PowerPC64 implementation of the TargetInstrInfo class.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef POWERPC64_INSTRUCTIONINFO_H
|
||||
#define POWERPC64_INSTRUCTIONINFO_H
|
||||
|
||||
#include "PowerPCInstrInfo.h"
|
||||
#include "PPC64RegisterInfo.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class PPC64InstrInfo : public TargetInstrInfo {
|
||||
const PPC64RegisterInfo RI;
|
||||
public:
|
||||
PPC64InstrInfo();
|
||||
|
||||
/// 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; }
|
||||
|
||||
//
|
||||
// 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& sourceReg,
|
||||
unsigned& destReg) const;
|
||||
|
||||
static unsigned invertPPCBranchOpcode(unsigned Opcode) {
|
||||
switch (Opcode) {
|
||||
default: assert(0 && "Unknown PPC branch opcode!");
|
||||
case PPC::BEQ: return PPC::BNE;
|
||||
case PPC::BNE: return PPC::BEQ;
|
||||
case PPC::BLT: return PPC::BGE;
|
||||
case PPC::BGE: return PPC::BLT;
|
||||
case PPC::BGT: return PPC::BLE;
|
||||
case PPC::BLE: return PPC::BGT;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -1,35 +0,0 @@
|
||||
//===- PPC64JITInfo.h - PowerPC/AIX impl. of the JIT interface -*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains the PowerPC/AIX implementation of the TargetJITInfo class.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef POWERPC_AIX_JITINFO_H
|
||||
#define POWERPC_AIX_JITINFO_H
|
||||
|
||||
#include "PowerPCJITInfo.h"
|
||||
|
||||
namespace llvm {
|
||||
class TargetMachine;
|
||||
|
||||
class PPC64JITInfo : public PowerPCJITInfo {
|
||||
public:
|
||||
PPC64JITInfo(TargetMachine &tm) : PowerPCJITInfo(tm) {}
|
||||
|
||||
/// replaceMachineCodeForFunction - Make it so that calling the function
|
||||
/// whose machine code is at OLD turns into a call to NEW, perhaps by
|
||||
/// overwriting OLD with a branch to NEW. This is used for self-modifying
|
||||
/// code.
|
||||
///
|
||||
virtual void replaceMachineCodeForFunction(void *Old, void *New);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -1,317 +0,0 @@
|
||||
//===- PPC64RegisterInfo.cpp - PowerPC64 Register Information ---*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains the PowerPC64 implementation of the MRegisterInfo class.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define DEBUG_TYPE "reginfo"
|
||||
#include "PowerPC.h"
|
||||
#include "PowerPCInstrBuilder.h"
|
||||
#include "PPC64RegisterInfo.h"
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/Type.h"
|
||||
#include "llvm/CodeGen/ValueTypes.h"
|
||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/CodeGen/MachineFrameInfo.h"
|
||||
#include "llvm/Target/TargetFrameInfo.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetOptions.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
using namespace llvm;
|
||||
|
||||
PPC64RegisterInfo::PPC64RegisterInfo()
|
||||
: PPC64GenRegisterInfo(PPC::ADJCALLSTACKDOWN, PPC::ADJCALLSTACKUP) {
|
||||
ImmToIdxMap[PPC::LD] = PPC::LDX; ImmToIdxMap[PPC::STD] = PPC::STDX;
|
||||
ImmToIdxMap[PPC::LBZ] = PPC::LBZX; ImmToIdxMap[PPC::STB] = PPC::STBX;
|
||||
ImmToIdxMap[PPC::LHZ] = PPC::LHZX; ImmToIdxMap[PPC::LHA] = PPC::LHAX;
|
||||
ImmToIdxMap[PPC::LWZ] = PPC::LWZX; ImmToIdxMap[PPC::LWA] = PPC::LWAX;
|
||||
ImmToIdxMap[PPC::LFS] = PPC::LFSX; ImmToIdxMap[PPC::LFD] = PPC::LFDX;
|
||||
ImmToIdxMap[PPC::STH] = PPC::STHX; ImmToIdxMap[PPC::STW] = PPC::STWX;
|
||||
ImmToIdxMap[PPC::STFS] = PPC::STFSX; ImmToIdxMap[PPC::STFD] = PPC::STFDX;
|
||||
ImmToIdxMap[PPC::ADDI] = PPC::ADD;
|
||||
}
|
||||
|
||||
static const TargetRegisterClass *getClass(unsigned SrcReg) {
|
||||
if (PPC64::FPRCRegisterClass->contains(SrcReg))
|
||||
return PPC64::FPRCRegisterClass;
|
||||
assert(PPC64::GPRCRegisterClass->contains(SrcReg) && "Reg not FPR or GPR");
|
||||
return PPC64::GPRCRegisterClass;
|
||||
}
|
||||
|
||||
static unsigned getIdx(const TargetRegisterClass *RC) {
|
||||
if (RC == PPC64::GPRCRegisterClass) {
|
||||
switch (RC->getSize()) {
|
||||
default: assert(0 && "Invalid data size!");
|
||||
case 1: return 0;
|
||||
case 2: return 1;
|
||||
case 4: return 2;
|
||||
case 8: return 3;
|
||||
}
|
||||
} else if (RC == PPC64::FPRCRegisterClass) {
|
||||
switch (RC->getSize()) {
|
||||
default: assert(0 && "Invalid data size!");
|
||||
case 4: return 4;
|
||||
case 8: return 5;
|
||||
}
|
||||
}
|
||||
std::cerr << "Invalid register class to getIdx()!\n";
|
||||
abort();
|
||||
}
|
||||
|
||||
void
|
||||
PPC64RegisterInfo::storeRegToStackSlot(MachineBasicBlock &MBB,
|
||||
MachineBasicBlock::iterator MI,
|
||||
unsigned SrcReg, int FrameIdx) const {
|
||||
static const unsigned Opcode[] = {
|
||||
PPC::STB, PPC::STH, PPC::STW, PPC::STD, PPC::STFS, PPC::STFD
|
||||
};
|
||||
unsigned OC = Opcode[getIdx(getClass(SrcReg))];
|
||||
if (SrcReg == PPC::LR) {
|
||||
BuildMI(MBB, MI, PPC::MFLR, 1, PPC::R11).addReg(PPC::LR);
|
||||
BuildMI(MBB, MI, PPC::IMPLICIT_DEF, 0, PPC::R0);
|
||||
addFrameReference(BuildMI(MBB, MI, OC, 3).addReg(PPC::R11),FrameIdx);
|
||||
} else {
|
||||
BuildMI(MBB, MI, PPC::IMPLICIT_DEF, 0, PPC::R0);
|
||||
addFrameReference(BuildMI(MBB, MI, OC, 3).addReg(SrcReg),FrameIdx);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PPC64RegisterInfo::loadRegFromStackSlot(MachineBasicBlock &MBB,
|
||||
MachineBasicBlock::iterator MI,
|
||||
unsigned DestReg, int FrameIdx) const{
|
||||
static const unsigned Opcode[] = {
|
||||
PPC::LBZ, PPC::LHZ, PPC::LWZ, PPC::LD, PPC::LFS, PPC::LFD
|
||||
};
|
||||
unsigned OC = Opcode[getIdx(getClass(DestReg))];
|
||||
if (DestReg == PPC::LR) {
|
||||
BuildMI(MBB, MI, PPC::IMPLICIT_DEF, 0, PPC::R0);
|
||||
addFrameReference(BuildMI(MBB, MI, OC, 2, PPC::R11), FrameIdx);
|
||||
BuildMI(MBB, MI, PPC::MTLR, 1).addReg(PPC::R11);
|
||||
} else {
|
||||
BuildMI(MBB, MI, PPC::IMPLICIT_DEF, 0, PPC::R0);
|
||||
addFrameReference(BuildMI(MBB, MI, OC, 2, DestReg), FrameIdx);
|
||||
}
|
||||
}
|
||||
|
||||
void PPC64RegisterInfo::copyRegToReg(MachineBasicBlock &MBB,
|
||||
MachineBasicBlock::iterator MI,
|
||||
unsigned DestReg, unsigned SrcReg,
|
||||
const TargetRegisterClass *RC) const {
|
||||
MachineInstr *I;
|
||||
|
||||
if (RC == PPC64::GPRCRegisterClass) {
|
||||
BuildMI(MBB, MI, PPC::OR, 2, DestReg).addReg(SrcReg).addReg(SrcReg);
|
||||
} else if (RC == PPC64::FPRCRegisterClass) {
|
||||
BuildMI(MBB, MI, PPC::FMR, 1, DestReg).addReg(SrcReg);
|
||||
} else {
|
||||
std::cerr << "Attempt to copy register that is not GPR or FPR";
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Stack Frame Processing methods
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// hasFP - Return true if the specified function should have a dedicated frame
|
||||
// pointer register. This is true if the function has variable sized allocas or
|
||||
// if frame pointer elimination is disabled.
|
||||
//
|
||||
static bool hasFP(MachineFunction &MF) {
|
||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||
return MFI->hasVarSizedObjects();
|
||||
}
|
||||
|
||||
void PPC64RegisterInfo::
|
||||
eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
|
||||
MachineBasicBlock::iterator I) const {
|
||||
if (hasFP(MF)) {
|
||||
// If we have a frame pointer, convert as follows:
|
||||
// ADJCALLSTACKDOWN -> addi, r1, r1, -amount
|
||||
// ADJCALLSTACKUP -> addi, r1, r1, amount
|
||||
MachineInstr *Old = I;
|
||||
unsigned Amount = Old->getOperand(0).getImmedValue();
|
||||
if (Amount != 0) {
|
||||
// We need to keep the stack aligned properly. To do this, we round the
|
||||
// amount of space needed for the outgoing arguments up to the next
|
||||
// alignment boundary.
|
||||
unsigned Align = MF.getTarget().getFrameInfo()->getStackAlignment();
|
||||
Amount = (Amount+Align-1)/Align*Align;
|
||||
|
||||
// Replace the pseudo instruction with a new instruction...
|
||||
if (Old->getOpcode() == PPC::ADJCALLSTACKDOWN) {
|
||||
MBB.insert(I, BuildMI(PPC::ADDI, 2, PPC::R1).addReg(PPC::R1)
|
||||
.addSImm(-Amount));
|
||||
} else {
|
||||
assert(Old->getOpcode() == PPC::ADJCALLSTACKUP);
|
||||
MBB.insert(I, BuildMI(PPC::ADDI, 2, PPC::R1).addReg(PPC::R1)
|
||||
.addSImm(Amount));
|
||||
}
|
||||
}
|
||||
}
|
||||
MBB.erase(I);
|
||||
}
|
||||
|
||||
void
|
||||
PPC64RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II) const {
|
||||
unsigned i = 0;
|
||||
MachineInstr &MI = *II;
|
||||
MachineBasicBlock &MBB = *MI.getParent();
|
||||
MachineFunction &MF = *MBB.getParent();
|
||||
|
||||
while (!MI.getOperand(i).isFrameIndex()) {
|
||||
++i;
|
||||
assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!");
|
||||
}
|
||||
|
||||
int FrameIndex = MI.getOperand(i).getFrameIndex();
|
||||
|
||||
// Replace the FrameIndex with base register with GPR1 (SP) or GPR31 (FP).
|
||||
MI.SetMachineOperandReg(i, hasFP(MF) ? PPC::R31 : PPC::R1);
|
||||
|
||||
// Take into account whether it's an add or mem instruction
|
||||
unsigned OffIdx = (i == 2) ? 1 : 2;
|
||||
|
||||
// Now add the frame object offset to the offset from r1.
|
||||
int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex) +
|
||||
MI.getOperand(OffIdx).getImmedValue();
|
||||
|
||||
// If we're not using a Frame Pointer that has been set to the value of the
|
||||
// SP before having the stack size subtracted from it, then add the stack size
|
||||
// to Offset to get the correct offset.
|
||||
Offset += MF.getFrameInfo()->getStackSize();
|
||||
|
||||
if (Offset > 32767 || Offset < -32768) {
|
||||
// Insert a set of r0 with the full offset value before the ld, st, or add
|
||||
MachineBasicBlock *MBB = MI.getParent();
|
||||
MBB->insert(II, BuildMI(PPC::LIS, 1, PPC::R0).addSImm(Offset >> 16));
|
||||
MBB->insert(II, BuildMI(PPC::ORI, 2, PPC::R0).addReg(PPC::R0)
|
||||
.addImm(Offset));
|
||||
// convert into indexed form of the instruction
|
||||
// sth 0:rA, 1:imm 2:(rB) ==> sthx 0:rA, 2:rB, 1:r0
|
||||
// addi 0:rA 1:rB, 2, imm ==> add 0:rA, 1:rB, 2:r0
|
||||
unsigned NewOpcode =
|
||||
const_cast<std::map<unsigned, unsigned>& >(ImmToIdxMap)[MI.getOpcode()];
|
||||
assert(NewOpcode && "No indexed form of load or store available!");
|
||||
MI.setOpcode(NewOpcode);
|
||||
MI.SetMachineOperandReg(1, MI.getOperand(i).getReg());
|
||||
MI.SetMachineOperandReg(2, PPC::R0);
|
||||
} else {
|
||||
MI.SetMachineOperandConst(OffIdx, MachineOperand::MO_SignExtendedImmed,
|
||||
Offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PPC64RegisterInfo::emitPrologue(MachineFunction &MF) const {
|
||||
MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB
|
||||
MachineBasicBlock::iterator MBBI = MBB.begin();
|
||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||
MachineInstr *MI;
|
||||
|
||||
// Get the number of bytes to allocate from the FrameInfo
|
||||
unsigned NumBytes = MFI->getStackSize();
|
||||
|
||||
// If we have calls, we cannot use the red zone to store callee save registers
|
||||
// and we must set up a stack frame, so calculate the necessary size here.
|
||||
if (MFI->hasCalls()) {
|
||||
// We reserve argument space for call sites in the function immediately on
|
||||
// entry to the current function. This eliminates the need for add/sub
|
||||
// brackets around call sites.
|
||||
NumBytes += MFI->getMaxCallFrameSize();
|
||||
}
|
||||
|
||||
// Do we need to allocate space on the stack?
|
||||
if (NumBytes == 0) return;
|
||||
|
||||
// Add the size of R1 to NumBytes size for the store of R1 to the bottom
|
||||
// of the stack and round the size to a multiple of the alignment.
|
||||
unsigned Align = MF.getTarget().getFrameInfo()->getStackAlignment();
|
||||
unsigned GPRSize = getSpillSize(PPC::R1)/8;
|
||||
unsigned Size = hasFP(MF) ? GPRSize + GPRSize : GPRSize;
|
||||
NumBytes = (NumBytes+Size+Align-1)/Align*Align;
|
||||
|
||||
// Update frame info to pretend that this is part of the stack...
|
||||
MFI->setStackSize(NumBytes);
|
||||
|
||||
// adjust stack pointer: r1 -= numbytes
|
||||
if (NumBytes <= 32768) {
|
||||
MI=BuildMI(PPC::STDU,3).addReg(PPC::R1).addSImm(-NumBytes).addReg(PPC::R1);
|
||||
MBB.insert(MBBI, MI);
|
||||
} else {
|
||||
int NegNumbytes = -NumBytes;
|
||||
MI = BuildMI(PPC::LIS, 1, PPC::R0).addSImm(NegNumbytes >> 16);
|
||||
MBB.insert(MBBI, MI);
|
||||
MI = BuildMI(PPC::ORI, 2, PPC::R0).addReg(PPC::R0)
|
||||
.addImm(NegNumbytes & 0xFFFF);
|
||||
MBB.insert(MBBI, MI);
|
||||
MI = BuildMI(PPC::STDUX, 3).addReg(PPC::R1).addReg(PPC::R1).addReg(PPC::R0);
|
||||
MBB.insert(MBBI, MI);
|
||||
}
|
||||
|
||||
if (hasFP(MF)) {
|
||||
MI = BuildMI(PPC::STD, 3).addReg(PPC::R31).addSImm(GPRSize).addReg(PPC::R1);
|
||||
MBB.insert(MBBI, MI);
|
||||
MI = BuildMI(PPC::OR, 2, PPC::R31).addReg(PPC::R1).addReg(PPC::R1);
|
||||
MBB.insert(MBBI, MI);
|
||||
}
|
||||
}
|
||||
|
||||
void PPC64RegisterInfo::emitEpilogue(MachineFunction &MF,
|
||||
MachineBasicBlock &MBB) const {
|
||||
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||
MachineBasicBlock::iterator MBBI = prior(MBB.end());
|
||||
MachineInstr *MI;
|
||||
assert(MBBI->getOpcode() == PPC::BLR &&
|
||||
"Can only insert epilog into returning blocks");
|
||||
|
||||
// Get the number of bytes allocated from the FrameInfo...
|
||||
unsigned NumBytes = MFI->getStackSize();
|
||||
|
||||
if (NumBytes != 0) {
|
||||
if (hasFP(MF)) {
|
||||
MI = BuildMI(PPC::OR, 2, PPC::R1).addReg(PPC::R31).addReg(PPC::R31);
|
||||
MBB.insert(MBBI, MI);
|
||||
MI = BuildMI(PPC::LD, 2, PPC::R31).addSImm(4).addReg(PPC::R31);
|
||||
MBB.insert(MBBI, MI);
|
||||
}
|
||||
MI = BuildMI(PPC::LD, 2, PPC::R1).addSImm(0).addReg(PPC::R1);
|
||||
MBB.insert(MBBI, MI);
|
||||
}
|
||||
}
|
||||
|
||||
#include "PPC64GenRegisterInfo.inc"
|
||||
|
||||
const TargetRegisterClass*
|
||||
PPC64RegisterInfo::getRegClassForType(const Type* Ty) const {
|
||||
switch (Ty->getTypeID()) {
|
||||
default: assert(0 && "Invalid type to getClass!");
|
||||
case Type::BoolTyID:
|
||||
case Type::SByteTyID:
|
||||
case Type::UByteTyID:
|
||||
case Type::ShortTyID:
|
||||
case Type::UShortTyID:
|
||||
case Type::IntTyID:
|
||||
case Type::UIntTyID:
|
||||
case Type::PointerTyID:
|
||||
case Type::LongTyID:
|
||||
case Type::ULongTyID: return &GPRCInstance;
|
||||
|
||||
case Type::FloatTyID:
|
||||
case Type::DoubleTyID: return &FPRCInstance;
|
||||
}
|
||||
}
|
||||
|
@ -1,56 +0,0 @@
|
||||
//===- PPC64RegisterInfo.h - PowerPC64 Register Information Impl -*- C++ -*-==//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains the PowerPC implementation of the MRegisterInfo class.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef POWERPC64_REGISTERINFO_H
|
||||
#define POWERPC64_REGISTERINFO_H
|
||||
|
||||
#include "PowerPC.h"
|
||||
#include "PPC64GenRegisterInfo.h.inc"
|
||||
#include <map>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class Type;
|
||||
|
||||
class PPC64RegisterInfo : public PPC64GenRegisterInfo {
|
||||
std::map<unsigned, unsigned> ImmToIdxMap;
|
||||
public:
|
||||
PPC64RegisterInfo();
|
||||
const TargetRegisterClass* getRegClassForType(const Type* Ty) const;
|
||||
|
||||
/// Code Generation virtual methods...
|
||||
void storeRegToStackSlot(MachineBasicBlock &MBB,
|
||||
MachineBasicBlock::iterator MBBI,
|
||||
unsigned SrcReg, int FrameIndex) const;
|
||||
|
||||
void loadRegFromStackSlot(MachineBasicBlock &MBB,
|
||||
MachineBasicBlock::iterator MBBI,
|
||||
unsigned DestReg, int FrameIndex) const;
|
||||
|
||||
void copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
|
||||
unsigned DestReg, unsigned SrcReg,
|
||||
const TargetRegisterClass *RC) const;
|
||||
|
||||
void eliminateCallFramePseudoInstr(MachineFunction &MF,
|
||||
MachineBasicBlock &MBB,
|
||||
MachineBasicBlock::iterator I) const;
|
||||
|
||||
void eliminateFrameIndex(MachineBasicBlock::iterator II) const;
|
||||
|
||||
void emitPrologue(MachineFunction &MF) const;
|
||||
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
@ -1,43 +0,0 @@
|
||||
//===-- PPC64TargetMachine.h - Define TargetMachine for PowerPC64 -*- C++ -*-=//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file declares the PowerPC specific subclass of TargetMachine.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef POWERPC64_TARGETMACHINE_H
|
||||
#define POWERPC64_TARGETMACHINE_H
|
||||
|
||||
#include "PowerPCTargetMachine.h"
|
||||
#include "PPC64InstrInfo.h"
|
||||
#include "llvm/PassManager.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class IntrinsicLowering;
|
||||
|
||||
class PPC64TargetMachine : public PowerPCTargetMachine {
|
||||
PPC64InstrInfo InstrInfo;
|
||||
|
||||
public:
|
||||
PPC64TargetMachine(const Module &M, IntrinsicLowering *IL);
|
||||
virtual const PPC64InstrInfo *getInstrInfo() const { return &InstrInfo; }
|
||||
virtual const MRegisterInfo *getRegisterInfo() const {
|
||||
return &InstrInfo.getRegisterInfo();
|
||||
}
|
||||
|
||||
static unsigned getModuleMatchQuality(const Module &M);
|
||||
|
||||
bool addPassesToEmitMachineCode(FunctionPassManager &PM,
|
||||
MachineCodeEmitter &MCE);
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
@ -14,9 +14,7 @@
|
||||
#include "PowerPCTargetMachine.h"
|
||||
#include "PowerPCFrameInfo.h"
|
||||
#include "PPC32TargetMachine.h"
|
||||
#include "PPC64TargetMachine.h"
|
||||
#include "PPC32JITInfo.h"
|
||||
#include "PPC64JITInfo.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/PassManager.h"
|
||||
#include "llvm/Analysis/Verifier.h"
|
||||
@ -35,16 +33,10 @@ static cl::opt<bool> EnablePPCLSR("enable-lsr-for-ppc", cl::Hidden,
|
||||
|
||||
namespace {
|
||||
const std::string PPC32ID = "PowerPC/32bit";
|
||||
const std::string PPC64ID = "PowerPC/64bit";
|
||||
|
||||
// Register the targets
|
||||
RegisterTarget<PPC32TargetMachine>
|
||||
X("ppc32", " PowerPC 32-bit");
|
||||
|
||||
#if 0
|
||||
RegisterTarget<PPC64TargetMachine>
|
||||
Y("ppc64", " PowerPC 64-bit (unimplemented)");
|
||||
#endif
|
||||
}
|
||||
|
||||
PowerPCTargetMachine::PowerPCTargetMachine(const std::string &name,
|
||||
@ -75,8 +67,6 @@ bool PowerPCTargetMachine::addPassesToEmitFile(PassManager &PM,
|
||||
CodeGenFileType FileType) {
|
||||
if (FileType != TargetMachine::AssemblyFile) return true;
|
||||
|
||||
bool LP64 = (0 != dynamic_cast<PPC64TargetMachine *>(this));
|
||||
|
||||
if (EnablePPCLSR) {
|
||||
PM.add(createLoopStrengthReducePass());
|
||||
PM.add(createVerifierPass());
|
||||
@ -98,9 +88,7 @@ bool PowerPCTargetMachine::addPassesToEmitFile(PassManager &PM,
|
||||
PM.add(createUnreachableBlockEliminationPass());
|
||||
|
||||
// Default to pattern ISel
|
||||
if (LP64)
|
||||
PM.add(createPPC64ISelPattern(*this));
|
||||
else if (PatternISelTriState == 0)
|
||||
if (PatternISelTriState == 0)
|
||||
PM.add(createPPC32ISelSimple(*this));
|
||||
else
|
||||
PM.add(createPPC32ISelPattern(*this));
|
||||
@ -138,8 +126,6 @@ void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
|
||||
// The JIT does not support or need PIC.
|
||||
PICEnabled = false;
|
||||
|
||||
bool LP64 = (0 != dynamic_cast<PPC64TargetMachine *>(&TM));
|
||||
|
||||
if (EnablePPCLSR) {
|
||||
PM.add(createLoopStrengthReducePass());
|
||||
PM.add(createCFGSimplificationPass());
|
||||
@ -160,9 +146,7 @@ void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
|
||||
PM.add(createUnreachableBlockEliminationPass());
|
||||
|
||||
// Default to pattern ISel
|
||||
if (LP64)
|
||||
PM.add(createPPC64ISelPattern(TM));
|
||||
else if (PatternISelTriState == 0)
|
||||
if (PatternISelTriState == 0)
|
||||
PM.add(createPPC32ISelSimple(TM));
|
||||
else
|
||||
PM.add(createPPC32ISelPattern(TM));
|
||||
@ -184,13 +168,6 @@ PPC32TargetMachine::PPC32TargetMachine(const Module &M, IntrinsicLowering *IL)
|
||||
TargetData(PPC32ID,false,4,4,4,4,4,4,2,1,1),
|
||||
PowerPCFrameInfo(*this, false)), JITInfo(*this) {}
|
||||
|
||||
/// PPC64TargetMachine ctor - Create a LP64 architecture model
|
||||
///
|
||||
PPC64TargetMachine::PPC64TargetMachine(const Module &M, IntrinsicLowering *IL)
|
||||
: PowerPCTargetMachine(PPC64ID, IL, M,
|
||||
TargetData(PPC64ID,false,8,4,4,4,4,4,2,1,1),
|
||||
PowerPCFrameInfo(*this, true)) {}
|
||||
|
||||
unsigned PPC32TargetMachine::getModuleMatchQuality(const Module &M) {
|
||||
// We strongly match "powerpc-*".
|
||||
std::string TT = M.getTargetTriple();
|
||||
@ -206,14 +183,3 @@ unsigned PPC32TargetMachine::getModuleMatchQuality(const Module &M) {
|
||||
|
||||
return getJITMatchQuality()/2;
|
||||
}
|
||||
|
||||
unsigned PPC64TargetMachine::getModuleMatchQuality(const Module &M) {
|
||||
if (M.getEndianness() == Module::BigEndian &&
|
||||
M.getPointerSize() == Module::Pointer64)
|
||||
return 10; // Direct match
|
||||
else if (M.getEndianness() != Module::AnyEndianness ||
|
||||
M.getPointerSize() != Module::AnyPointerSize)
|
||||
return 0; // Match for some other target
|
||||
|
||||
return getJITMatchQuality()/2;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user