1 //===- PowerPCSubtarget.cpp - PPC Subtarget Information ---------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
10 // This file implements the PPC specific subclass of TargetSubtarget.
12 //===----------------------------------------------------------------------===//
14 #include "PowerPCSubtarget.h"
15 #include "llvm/Module.h"
17 #if defined(__APPLE__)
18 #include <mach/mach.h>
19 #include <mach/mach_host.h>
20 #include <mach/host_info.h>
21 #include <mach/machine.h>
23 static boolean_t IsGP() {
24 host_basic_info_data_t hostInfo;
25 mach_msg_type_number_t infoCount;
27 infoCount = HOST_BASIC_INFO_COUNT;
28 host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)&hostInfo,
31 return ((hostInfo.cpu_type == CPU_TYPE_POWERPC) &&
32 (hostInfo.cpu_subtype == CPU_SUBTYPE_POWERPC_970));
38 PPCSubtarget::PPCSubtarget(const Module &M)
39 : TargetSubtarget(), stackAlignment(16), isGigaProcessor(false), isAIX(false),
41 // Set the boolean corresponding to the current target triple, or the default
42 // if one cannot be determined, to true.
43 const std::string& TT = M.getTargetTriple();
44 if (TT.length() > 5) {
45 isDarwin = TT.find("darwin") != std::string::npos;
46 #if defined(__APPLE__)
47 isGigaProcessor = IsGP();
49 } else if (TT.empty()) {
52 #elif defined(__APPLE__)
54 isGigaProcessor = IsGP();