1 //===-- PPCMCTargetDesc.cpp - PowerPC Target Descriptions -------*- 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 provides PowerPC specific target descriptions.
12 //===----------------------------------------------------------------------===//
14 #include "PPCMCTargetDesc.h"
15 #include "PPCMCAsmInfo.h"
16 #include "llvm/MC/MachineLocation.h"
17 #include "llvm/MC/MCInstrInfo.h"
18 #include "llvm/MC/MCRegisterInfo.h"
19 #include "llvm/MC/MCSubtargetInfo.h"
20 #include "llvm/Target/TargetRegistry.h"
22 #define GET_INSTRINFO_MC_DESC
23 #include "PPCGenInstrInfo.inc"
25 #define GET_SUBTARGETINFO_MC_DESC
26 #include "PPCGenSubtargetInfo.inc"
28 #define GET_REGINFO_MC_DESC
29 #include "PPCGenRegisterInfo.inc"
33 static MCInstrInfo *createPPCMCInstrInfo() {
34 MCInstrInfo *X = new MCInstrInfo();
35 InitPPCMCInstrInfo(X);
39 extern "C" void LLVMInitializePowerPCMCInstrInfo() {
40 TargetRegistry::RegisterMCInstrInfo(ThePPC32Target, createPPCMCInstrInfo);
41 TargetRegistry::RegisterMCInstrInfo(ThePPC64Target, createPPCMCInstrInfo);
44 static MCRegisterInfo *createPPCMCRegisterInfo(StringRef TT) {
46 bool isPPC64 = (TheTriple.getArch() == Triple::ppc64);
47 unsigned Flavour = isPPC64 ? 0 : 1;
48 unsigned RA = isPPC64 ? PPC::LR8 : PPC::LR;
50 MCRegisterInfo *X = new MCRegisterInfo();
51 InitPPCMCRegisterInfo(X, RA, Flavour, Flavour);
55 extern "C" void LLVMInitializePowerPCMCRegisterInfo() {
56 TargetRegistry::RegisterMCRegInfo(ThePPC32Target, createPPCMCRegisterInfo);
57 TargetRegistry::RegisterMCRegInfo(ThePPC64Target, createPPCMCRegisterInfo);
60 static MCSubtargetInfo *createPPCMCSubtargetInfo(StringRef TT, StringRef CPU,
62 MCSubtargetInfo *X = new MCSubtargetInfo();
63 InitPPCMCSubtargetInfo(X, TT, CPU, FS);
67 extern "C" void LLVMInitializePowerPCMCSubtargetInfo() {
68 TargetRegistry::RegisterMCSubtargetInfo(ThePPC32Target,
69 createPPCMCSubtargetInfo);
70 TargetRegistry::RegisterMCSubtargetInfo(ThePPC64Target,
71 createPPCMCSubtargetInfo);
74 static MCAsmInfo *createPPCMCAsmInfo(const Target &T, StringRef TT) {
76 bool isPPC64 = TheTriple.getArch() == Triple::ppc64;
79 if (TheTriple.isOSDarwin())
80 MAI = new PPCMCAsmInfoDarwin(isPPC64);
82 MAI = new PPCLinuxMCAsmInfo(isPPC64);
84 // Initial state of the frame pointer is R1.
85 MachineLocation Dst(MachineLocation::VirtualFP);
86 MachineLocation Src(PPC::R1, 0);
87 MAI->addInitialFrameState(0, Dst, Src);
92 extern "C" void LLVMInitializePowerPCMCAsmInfo() {
93 RegisterMCAsmInfoFn C(ThePPC32Target, createPPCMCAsmInfo);
94 RegisterMCAsmInfoFn D(ThePPC64Target, createPPCMCAsmInfo);