diff options
author | Nate Begeman <natebegeman@mac.com> | 2005-08-04 07:12:09 +0000 |
---|---|---|
committer | Nate Begeman <natebegeman@mac.com> | 2005-08-04 07:12:09 +0000 |
commit | 8c00f8cdc7ae0cdd18d91b3a31a70da0f78aa04f (patch) | |
tree | a9f7fccc3fbb3bc12c1be6158d0e0d4e0710fc0f /lib | |
parent | 49f72e68cf6eb77b5791310513d94dc64dc6ea7d (diff) | |
download | external_llvm-8c00f8cdc7ae0cdd18d91b3a31a70da0f78aa04f.zip external_llvm-8c00f8cdc7ae0cdd18d91b3a31a70da0f78aa04f.tar.gz external_llvm-8c00f8cdc7ae0cdd18d91b3a31a70da0f78aa04f.tar.bz2 |
Add Subtarget support to PowerPC. Next up, using it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22644 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/PowerPC/PPCSubtarget.cpp | 54 | ||||
-rw-r--r-- | lib/Target/PowerPC/PPCSubtarget.h | 48 | ||||
-rw-r--r-- | lib/Target/PowerPC/PPCTargetMachine.cpp | 8 | ||||
-rw-r--r-- | lib/Target/PowerPC/PowerPCTargetMachine.h | 12 | ||||
-rw-r--r-- | lib/Target/X86/X86Subtarget.cpp | 2 | ||||
-rw-r--r-- | lib/Target/X86/X86Subtarget.h | 2 |
6 files changed, 116 insertions, 10 deletions
diff --git a/lib/Target/PowerPC/PPCSubtarget.cpp b/lib/Target/PowerPC/PPCSubtarget.cpp new file mode 100644 index 0000000..4fae1a2 --- /dev/null +++ b/lib/Target/PowerPC/PPCSubtarget.cpp @@ -0,0 +1,54 @@ +//===- PowerPCSubtarget.cpp - PPC Subtarget Information ---------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by Nate Begeman and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the PPC specific subclass of TargetSubtarget. +// +//===----------------------------------------------------------------------===// + +#include "PowerPCSubtarget.h" +#include "llvm/Module.h" + +#if defined(__APPLE__) +#include <mach/mach.h> +#include <mach/mach_host.h> +#include <mach/host_info.h> +#include <mach/machine.h> + +static boolean_t IsGP() { + host_basic_info_data_t hostInfo; + mach_msg_type_number_t infoCount; + + infoCount = HOST_BASIC_INFO_COUNT; + host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)&hostInfo, + &infoCount); + + return ((hostInfo.cpu_type == CPU_TYPE_POWERPC) && + (hostInfo.cpu_subtype == CPU_SUBTYPE_POWERPC_970)); +} +#endif + +using namespace llvm; + +PPCSubtarget::PPCSubtarget(const Module &M) + : TargetSubtarget(), stackAlignment(16), isGigaProcessor(false), isAIX(false), + isDarwin(false) { + // Set the boolean corresponding to the current target triple, or the default + // if one cannot be determined, to true. + const std::string& TT = M.getTargetTriple(); + if (TT.length() > 5) { + isDarwin = TT.find("darwin") != std::string::npos; + } else if (TT.empty()) { +#if defined(_POWER) + isAIX = true; +#elif defined(__APPLE__) + isDarwin = true; + isGigaProcessor = IsGP(); +#endif + } +} diff --git a/lib/Target/PowerPC/PPCSubtarget.h b/lib/Target/PowerPC/PPCSubtarget.h new file mode 100644 index 0000000..c114351 --- /dev/null +++ b/lib/Target/PowerPC/PPCSubtarget.h @@ -0,0 +1,48 @@ +//=====-- PowerPCSubtarget.h - Define Subtarget for the PPC ---*- C++ -*--====// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by Nate Begeman and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares the X86 specific subclass of TargetSubtarget. +// +//===----------------------------------------------------------------------===// + +#ifndef POWERPCSUBTARGET_H +#define POWERPCSUBTARGET_H + +#include "llvm/Target/TargetSubtarget.h" + +namespace llvm { +class Module; + +class PPCSubtarget : public TargetSubtarget { +protected: + /// stackAlignment - The minimum alignment known to hold of the stack frame on + /// entry to the function and which must be maintained by every function. + unsigned stackAlignment; + + /// Used by the ISel to turn in optimizations for POWER4-derived architectures + bool isGigaProcessor; + bool isAIX; + bool isDarwin; +public: + /// This constructor initializes the data members to match that + /// of the specified module. + /// + PPCSubtarget(const Module &M); + + /// getStackAlignment - Returns the minimum alignment known to hold of the + /// stack frame on entry to the function and which must be maintained by every + /// function for this subtarget. + unsigned getStackAlignment() const { return stackAlignment; } + + bool IsAIX() const { return isAIX; } + bool IsDarwin() const { return isDarwin; } +}; +} // End llvm namespace + +#endif diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp index e156f5e..8393a3b 100644 --- a/lib/Target/PowerPC/PPCTargetMachine.cpp +++ b/lib/Target/PowerPC/PPCTargetMachine.cpp @@ -59,10 +59,10 @@ namespace { PowerPCTargetMachine::PowerPCTargetMachine(const std::string &name, IntrinsicLowering *IL, + const Module &M, const TargetData &TD, const PowerPCFrameInfo &TFI) - : TargetMachine(name, IL, TD), FrameInfo(TFI) -{} +: TargetMachine(name, IL, TD), FrameInfo(TFI), Subtarget(M) {} unsigned PPC32TargetMachine::getJITMatchQuality() { #if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER) @@ -177,14 +177,14 @@ void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) { /// PowerPCTargetMachine ctor - Create an ILP32 architecture model /// PPC32TargetMachine::PPC32TargetMachine(const Module &M, IntrinsicLowering *IL) - : PowerPCTargetMachine(PPC32ID, IL, + : PowerPCTargetMachine(PPC32ID, IL, M, TargetData(PPC32ID,false,4,4,4,4,4,4,2,1,1), PowerPCFrameInfo(*this, false)), JITInfo(*this) {} /// PPC64TargetMachine ctor - Create a LP64 architecture model /// PPC64TargetMachine::PPC64TargetMachine(const Module &M, IntrinsicLowering *IL) - : PowerPCTargetMachine(PPC64ID, IL, + : PowerPCTargetMachine(PPC64ID, IL, M, TargetData(PPC64ID,false,8,4,4,4,4,4,2,1,1), PowerPCFrameInfo(*this, true)) {} diff --git a/lib/Target/PowerPC/PowerPCTargetMachine.h b/lib/Target/PowerPC/PowerPCTargetMachine.h index da85051..4a92acf 100644 --- a/lib/Target/PowerPC/PowerPCTargetMachine.h +++ b/lib/Target/PowerPC/PowerPCTargetMachine.h @@ -14,9 +14,11 @@ #ifndef POWERPC_TARGETMACHINE_H #define POWERPC_TARGETMACHINE_H -#include "PowerPCFrameInfo.h" #include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetFrameInfo.h" #include "llvm/PassManager.h" +#include "PowerPCFrameInfo.h" +#include "PowerPCSubtarget.h" namespace llvm { @@ -24,13 +26,15 @@ class GlobalValue; class IntrinsicLowering; class PowerPCTargetMachine : public TargetMachine { - PowerPCFrameInfo FrameInfo; - + PowerPCFrameInfo FrameInfo; + PPCSubtarget Subtarget; protected: PowerPCTargetMachine(const std::string &name, IntrinsicLowering *IL, - const TargetData &TD, const PowerPCFrameInfo &TFI); + const Module &M, const TargetData &TD, + const PowerPCFrameInfo &TFI); public: virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; } + virtual const TargetSubtarget *getSubtargetImpl() const{ return &Subtarget; } virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out, CodeGenFileType FileType); diff --git a/lib/Target/X86/X86Subtarget.cpp b/lib/Target/X86/X86Subtarget.cpp index f2ebdd4..ed8b871 100644 --- a/lib/Target/X86/X86Subtarget.cpp +++ b/lib/Target/X86/X86Subtarget.cpp @@ -1,4 +1,4 @@ -//===- X86Subtarget.cpp - X86 Instruction Information -----------*- C++ -*-===// +//===-- X86Subtarget.cpp - X86 Subtarget Information ------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // diff --git a/lib/Target/X86/X86Subtarget.h b/lib/Target/X86/X86Subtarget.h index 1e980f8..bf764d3 100644 --- a/lib/Target/X86/X86Subtarget.h +++ b/lib/Target/X86/X86Subtarget.h @@ -1,4 +1,4 @@ -//=====-- X86Subtarget.h - Define TargetMachine for the X86 ---*- C++ -*--====// +//=====---- X86Subtarget.h - Define Subtarget for the X86 -----*- C++ -*--====// // // The LLVM Compiler Infrastructure // |