Nate Begeman | 8c00f8c | 2005-08-04 07:12:09 +0000 | [diff] [blame^] | 1 | //===- PowerPCSubtarget.cpp - PPC Subtarget Information ---------*- C++ -*-===// |
| 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. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "PowerPCSubtarget.h" |
| 15 | #include "llvm/Module.h" |
| 16 | |
| 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> |
| 22 | |
| 23 | static boolean_t IsGP() { |
| 24 | host_basic_info_data_t hostInfo; |
| 25 | mach_msg_type_number_t infoCount; |
| 26 | |
| 27 | infoCount = HOST_BASIC_INFO_COUNT; |
| 28 | host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)&hostInfo, |
| 29 | &infoCount); |
| 30 | |
| 31 | return ((hostInfo.cpu_type == CPU_TYPE_POWERPC) && |
| 32 | (hostInfo.cpu_subtype == CPU_SUBTYPE_POWERPC_970)); |
| 33 | } |
| 34 | #endif |
| 35 | |
| 36 | using namespace llvm; |
| 37 | |
| 38 | PPCSubtarget::PPCSubtarget(const Module &M) |
| 39 | : TargetSubtarget(), stackAlignment(16), isGigaProcessor(false), isAIX(false), |
| 40 | isDarwin(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 | } else if (TT.empty()) { |
| 47 | #if defined(_POWER) |
| 48 | isAIX = true; |
| 49 | #elif defined(__APPLE__) |
| 50 | isDarwin = true; |
| 51 | isGigaProcessor = IsGP(); |
| 52 | #endif |
| 53 | } |
| 54 | } |