2011-07-14 20:59:42 +00:00
|
|
|
//===-- PPCMCTargetDesc.cpp - PowerPC Target Descriptions -------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file provides PowerPC specific target descriptions.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "PPCMCTargetDesc.h"
|
2011-07-14 23:50:31 +00:00
|
|
|
#include "PPCMCAsmInfo.h"
|
2011-07-25 21:20:24 +00:00
|
|
|
#include "InstPrinter/PPCInstPrinter.h"
|
2011-07-18 22:29:13 +00:00
|
|
|
#include "llvm/MC/MachineLocation.h"
|
2011-08-23 20:15:21 +00:00
|
|
|
#include "llvm/MC/MCCodeGenInfo.h"
|
2011-07-14 20:59:42 +00:00
|
|
|
#include "llvm/MC/MCInstrInfo.h"
|
|
|
|
#include "llvm/MC/MCRegisterInfo.h"
|
2011-07-25 19:53:23 +00:00
|
|
|
#include "llvm/MC/MCStreamer.h"
|
2011-07-14 20:59:42 +00:00
|
|
|
#include "llvm/MC/MCSubtargetInfo.h"
|
2011-08-24 18:08:43 +00:00
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
2011-07-14 20:59:42 +00:00
|
|
|
|
|
|
|
#define GET_INSTRINFO_MC_DESC
|
|
|
|
#include "PPCGenInstrInfo.inc"
|
|
|
|
|
|
|
|
#define GET_SUBTARGETINFO_MC_DESC
|
|
|
|
#include "PPCGenSubtargetInfo.inc"
|
|
|
|
|
|
|
|
#define GET_REGINFO_MC_DESC
|
|
|
|
#include "PPCGenRegisterInfo.inc"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2011-07-14 23:50:31 +00:00
|
|
|
static MCInstrInfo *createPPCMCInstrInfo() {
|
2011-07-14 20:59:42 +00:00
|
|
|
MCInstrInfo *X = new MCInstrInfo();
|
|
|
|
InitPPCMCInstrInfo(X);
|
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
2011-07-18 20:57:22 +00:00
|
|
|
static MCRegisterInfo *createPPCMCRegisterInfo(StringRef TT) {
|
|
|
|
Triple TheTriple(TT);
|
|
|
|
bool isPPC64 = (TheTriple.getArch() == Triple::ppc64);
|
|
|
|
unsigned Flavour = isPPC64 ? 0 : 1;
|
|
|
|
unsigned RA = isPPC64 ? PPC::LR8 : PPC::LR;
|
|
|
|
|
|
|
|
MCRegisterInfo *X = new MCRegisterInfo();
|
|
|
|
InitPPCMCRegisterInfo(X, RA, Flavour, Flavour);
|
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
2011-07-14 23:50:31 +00:00
|
|
|
static MCSubtargetInfo *createPPCMCSubtargetInfo(StringRef TT, StringRef CPU,
|
|
|
|
StringRef FS) {
|
2011-07-14 20:59:42 +00:00
|
|
|
MCSubtargetInfo *X = new MCSubtargetInfo();
|
|
|
|
InitPPCMCSubtargetInfo(X, TT, CPU, FS);
|
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
2011-07-18 22:29:13 +00:00
|
|
|
static MCAsmInfo *createPPCMCAsmInfo(const Target &T, StringRef TT) {
|
2011-07-14 23:50:31 +00:00
|
|
|
Triple TheTriple(TT);
|
|
|
|
bool isPPC64 = TheTriple.getArch() == Triple::ppc64;
|
2011-07-18 22:29:13 +00:00
|
|
|
|
|
|
|
MCAsmInfo *MAI;
|
2011-07-14 23:50:31 +00:00
|
|
|
if (TheTriple.isOSDarwin())
|
2011-07-18 22:29:13 +00:00
|
|
|
MAI = new PPCMCAsmInfoDarwin(isPPC64);
|
|
|
|
else
|
|
|
|
MAI = new PPCLinuxMCAsmInfo(isPPC64);
|
|
|
|
|
|
|
|
// Initial state of the frame pointer is R1.
|
|
|
|
MachineLocation Dst(MachineLocation::VirtualFP);
|
|
|
|
MachineLocation Src(PPC::R1, 0);
|
|
|
|
MAI->addInitialFrameState(0, Dst, Src);
|
|
|
|
|
|
|
|
return MAI;
|
2011-07-14 23:50:31 +00:00
|
|
|
}
|
|
|
|
|
2011-07-23 00:01:04 +00:00
|
|
|
static MCCodeGenInfo *createPPCMCCodeGenInfo(StringRef TT, Reloc::Model RM,
|
2011-11-16 08:38:26 +00:00
|
|
|
CodeModel::Model CM,
|
|
|
|
CodeGenOpt::Level OL) {
|
2011-07-19 06:37:02 +00:00
|
|
|
MCCodeGenInfo *X = new MCCodeGenInfo();
|
|
|
|
|
|
|
|
if (RM == Reloc::Default) {
|
|
|
|
Triple T(TT);
|
|
|
|
if (T.isOSDarwin())
|
|
|
|
RM = Reloc::DynamicNoPIC;
|
|
|
|
else
|
|
|
|
RM = Reloc::Static;
|
|
|
|
}
|
2011-11-16 08:38:26 +00:00
|
|
|
X->InitMCCodeGenInfo(RM, CM, OL);
|
2011-07-19 06:37:02 +00:00
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
2011-07-25 19:53:23 +00:00
|
|
|
// This is duplicated code. Refactor this.
|
2011-07-26 00:42:34 +00:00
|
|
|
static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
|
2011-07-25 23:24:55 +00:00
|
|
|
MCContext &Ctx, MCAsmBackend &MAB,
|
2011-07-25 19:53:23 +00:00
|
|
|
raw_ostream &OS,
|
|
|
|
MCCodeEmitter *Emitter,
|
|
|
|
bool RelaxAll,
|
|
|
|
bool NoExecStack) {
|
|
|
|
if (Triple(TT).isOSDarwin())
|
2011-07-25 23:24:55 +00:00
|
|
|
return createMachOStreamer(Ctx, MAB, OS, Emitter, RelaxAll);
|
2011-07-25 19:53:23 +00:00
|
|
|
|
2011-08-02 15:54:03 +00:00
|
|
|
return createELFStreamer(Ctx, MAB, OS, Emitter, RelaxAll, NoExecStack);
|
2011-07-25 19:53:23 +00:00
|
|
|
}
|
|
|
|
|
2011-07-25 21:20:24 +00:00
|
|
|
static MCInstPrinter *createPPCMCInstPrinter(const Target &T,
|
|
|
|
unsigned SyntaxVariant,
|
2011-09-07 17:24:38 +00:00
|
|
|
const MCAsmInfo &MAI,
|
|
|
|
const MCSubtargetInfo &STI) {
|
2011-07-25 21:20:24 +00:00
|
|
|
return new PPCInstPrinter(MAI, SyntaxVariant);
|
|
|
|
}
|
|
|
|
|
2011-07-22 21:58:54 +00:00
|
|
|
extern "C" void LLVMInitializePowerPCTargetMC() {
|
|
|
|
// Register the MC asm info.
|
|
|
|
RegisterMCAsmInfoFn C(ThePPC32Target, createPPCMCAsmInfo);
|
|
|
|
RegisterMCAsmInfoFn D(ThePPC64Target, createPPCMCAsmInfo);
|
|
|
|
|
|
|
|
// Register the MC codegen info.
|
2011-07-19 06:37:02 +00:00
|
|
|
TargetRegistry::RegisterMCCodeGenInfo(ThePPC32Target, createPPCMCCodeGenInfo);
|
|
|
|
TargetRegistry::RegisterMCCodeGenInfo(ThePPC64Target, createPPCMCCodeGenInfo);
|
2011-07-22 21:58:54 +00:00
|
|
|
|
|
|
|
// Register the MC instruction info.
|
|
|
|
TargetRegistry::RegisterMCInstrInfo(ThePPC32Target, createPPCMCInstrInfo);
|
|
|
|
TargetRegistry::RegisterMCInstrInfo(ThePPC64Target, createPPCMCInstrInfo);
|
|
|
|
|
|
|
|
// Register the MC register info.
|
|
|
|
TargetRegistry::RegisterMCRegInfo(ThePPC32Target, createPPCMCRegisterInfo);
|
|
|
|
TargetRegistry::RegisterMCRegInfo(ThePPC64Target, createPPCMCRegisterInfo);
|
|
|
|
|
|
|
|
// Register the MC subtarget info.
|
|
|
|
TargetRegistry::RegisterMCSubtargetInfo(ThePPC32Target,
|
|
|
|
createPPCMCSubtargetInfo);
|
|
|
|
TargetRegistry::RegisterMCSubtargetInfo(ThePPC64Target,
|
|
|
|
createPPCMCSubtargetInfo);
|
2011-07-25 19:53:23 +00:00
|
|
|
|
|
|
|
// Register the MC Code Emitter
|
2011-07-26 00:42:34 +00:00
|
|
|
TargetRegistry::RegisterMCCodeEmitter(ThePPC32Target, createPPCMCCodeEmitter);
|
|
|
|
TargetRegistry::RegisterMCCodeEmitter(ThePPC64Target, createPPCMCCodeEmitter);
|
2011-07-25 19:53:23 +00:00
|
|
|
|
|
|
|
// Register the asm backend.
|
2011-07-25 23:24:55 +00:00
|
|
|
TargetRegistry::RegisterMCAsmBackend(ThePPC32Target, createPPCAsmBackend);
|
|
|
|
TargetRegistry::RegisterMCAsmBackend(ThePPC64Target, createPPCAsmBackend);
|
2011-07-25 19:53:23 +00:00
|
|
|
|
|
|
|
// Register the object streamer.
|
2011-07-26 00:42:34 +00:00
|
|
|
TargetRegistry::RegisterMCObjectStreamer(ThePPC32Target, createMCStreamer);
|
|
|
|
TargetRegistry::RegisterMCObjectStreamer(ThePPC64Target, createMCStreamer);
|
2011-07-25 21:20:24 +00:00
|
|
|
|
|
|
|
// Register the MCInstPrinter.
|
|
|
|
TargetRegistry::RegisterMCInstPrinter(ThePPC32Target, createPPCMCInstPrinter);
|
|
|
|
TargetRegistry::RegisterMCInstPrinter(ThePPC64Target, createPPCMCInstPrinter);
|
2011-07-19 06:37:02 +00:00
|
|
|
}
|