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 static MCRegisterInfo *createPPCMCRegisterInfo(StringRef TT) {
41 bool isPPC64 = (TheTriple.getArch() == Triple::ppc64);
42 unsigned Flavour = isPPC64 ? 0 : 1;
43 unsigned RA = isPPC64 ? PPC::LR8 : PPC::LR;
45 MCRegisterInfo *X = new MCRegisterInfo();
46 InitPPCMCRegisterInfo(X, RA, Flavour, Flavour);
50 static MCSubtargetInfo *createPPCMCSubtargetInfo(StringRef TT, StringRef CPU,
52 MCSubtargetInfo *X = new MCSubtargetInfo();
53 InitPPCMCSubtargetInfo(X, TT, CPU, FS);
57 static MCAsmInfo *createPPCMCAsmInfo(const Target &T, StringRef TT) {
59 bool isPPC64 = TheTriple.getArch() == Triple::ppc64;
62 if (TheTriple.isOSDarwin())
63 MAI = new PPCMCAsmInfoDarwin(isPPC64);
65 MAI = new PPCLinuxMCAsmInfo(isPPC64);
67 // Initial state of the frame pointer is R1.
68 MachineLocation Dst(MachineLocation::VirtualFP);
69 MachineLocation Src(PPC::R1, 0);
70 MAI->addInitialFrameState(0, Dst, Src);
75 MCCodeGenInfo *createPPCMCCodeGenInfo(StringRef TT, Reloc::Model RM,
76 CodeModel::Model CM) {
77 MCCodeGenInfo *X = new MCCodeGenInfo();
79 if (RM == Reloc::Default) {
82 RM = Reloc::DynamicNoPIC;
86 X->InitMCCodeGenInfo(RM, CM);
90 extern "C" void LLVMInitializePowerPCTargetMC() {
91 // Register the MC asm info.
92 RegisterMCAsmInfoFn C(ThePPC32Target, createPPCMCAsmInfo);
93 RegisterMCAsmInfoFn D(ThePPC64Target, createPPCMCAsmInfo);
95 // Register the MC codegen info.
96 TargetRegistry::RegisterMCCodeGenInfo(ThePPC32Target, createPPCMCCodeGenInfo);
97 TargetRegistry::RegisterMCCodeGenInfo(ThePPC64Target, createPPCMCCodeGenInfo);
99 // Register the MC instruction info.
100 TargetRegistry::RegisterMCInstrInfo(ThePPC32Target, createPPCMCInstrInfo);
101 TargetRegistry::RegisterMCInstrInfo(ThePPC64Target, createPPCMCInstrInfo);
103 // Register the MC register info.
104 TargetRegistry::RegisterMCRegInfo(ThePPC32Target, createPPCMCRegisterInfo);
105 TargetRegistry::RegisterMCRegInfo(ThePPC64Target, createPPCMCRegisterInfo);
107 // Register the MC subtarget info.
108 TargetRegistry::RegisterMCSubtargetInfo(ThePPC32Target,
109 createPPCMCSubtargetInfo);
110 TargetRegistry::RegisterMCSubtargetInfo(ThePPC64Target,
111 createPPCMCSubtargetInfo);