Added llvmgcc version to allow tests to be xfailed by frontend version.
[llvm-complete.git] / lib / Target / PowerPC / PPCSubtarget.cpp
blob0ef85dfd29249ab5f8032ec38c795fa9d1cda45c
1 //===- PowerPCSubtarget.cpp - PPC Subtarget Information -------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file was developed by Nate Begeman and is distributed under the
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the PPC specific subclass of TargetSubtarget.
12 //===----------------------------------------------------------------------===//
14 #include "PPCSubtarget.h"
15 #include "PPC.h"
16 #include "llvm/Module.h"
17 #include "llvm/Support/CommandLine.h"
18 #include "PPCGenSubtarget.inc"
20 using namespace llvm;
21 PPCTargetEnum llvm::PPCTarget = TargetDefault;
23 namespace llvm {
24 cl::opt<PPCTargetEnum, true>
25 PPCTargetArg(cl::desc("Force generation of code for a specific PPC target:"),
26 cl::values(
27 clEnumValN(TargetAIX, "aix", " Enable AIX codegen"),
28 clEnumValN(TargetDarwin,"darwin",
29 " Enable Darwin codegen"),
30 clEnumValEnd),
31 cl::location(PPCTarget), cl::init(TargetDefault));
34 #if defined(__APPLE__)
35 #include <mach/mach.h>
36 #include <mach/mach_host.h>
37 #include <mach/host_info.h>
38 #include <mach/machine.h>
40 /// GetCurrentPowerPCFeatures - Returns the current CPUs features.
41 static const char *GetCurrentPowerPCCPU() {
42 host_basic_info_data_t hostInfo;
43 mach_msg_type_number_t infoCount;
45 infoCount = HOST_BASIC_INFO_COUNT;
46 host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)&hostInfo,
47 &infoCount);
49 if (hostInfo.cpu_type != CPU_TYPE_POWERPC) return "generic";
51 switch(hostInfo.cpu_subtype) {
52 case CPU_SUBTYPE_POWERPC_601: return "601";
53 case CPU_SUBTYPE_POWERPC_602: return "602";
54 case CPU_SUBTYPE_POWERPC_603: return "603";
55 case CPU_SUBTYPE_POWERPC_603e: return "603e";
56 case CPU_SUBTYPE_POWERPC_603ev: return "603ev";
57 case CPU_SUBTYPE_POWERPC_604: return "604";
58 case CPU_SUBTYPE_POWERPC_604e: return "604e";
59 case CPU_SUBTYPE_POWERPC_620: return "620";
60 case CPU_SUBTYPE_POWERPC_750: return "750";
61 case CPU_SUBTYPE_POWERPC_7400: return "7400";
62 case CPU_SUBTYPE_POWERPC_7450: return "7450";
63 case CPU_SUBTYPE_POWERPC_970: return "970";
64 default: ;
67 return "generic";
69 #endif
72 PPCSubtarget::PPCSubtarget(const Module &M, const std::string &FS)
73 : StackAlignment(16)
74 , InstrItins()
75 , IsGigaProcessor(false)
76 , Is64Bit(false)
77 , Has64BitRegs(false)
78 , HasAltivec(false)
79 , HasFSQRT(false)
80 , HasSTFIWX(false)
81 , IsAIX(false)
82 , IsDarwin(false) {
84 // Determine default and user specified characteristics
85 std::string CPU = "generic";
86 #if defined(__APPLE__)
87 CPU = GetCurrentPowerPCCPU();
88 #endif
90 // Parse features string.
91 ParseSubtargetFeatures(FS, CPU);
93 // Set the boolean corresponding to the current target triple, or the default
94 // if one cannot be determined, to true.
95 const std::string& TT = M.getTargetTriple();
96 if (TT.length() > 5) {
97 IsDarwin = TT.find("darwin") != std::string::npos;
98 } else if (TT.empty()) {
99 #if defined(_POWER)
100 IsAIX = true;
101 #elif defined(__APPLE__)
102 IsDarwin = true;
103 #endif