Consolidate the GPOpt stuff to all use the Subtarget, instead of still

depending on the command line option.  Now the command line option just
sets the subtarget as appropriate.  G5 opts will now default to on on
G5-enabled nightly testers among other machines.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22688 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2005-08-05 22:05:03 +00:00
parent 8c4a8735ec
commit 3c304a3ba1
6 changed files with 48 additions and 42 deletions

View File

@ -33,7 +33,6 @@ FunctionPass *createPPC64ISelPattern(TargetMachine &TM);
FunctionPass *createDarwinAsmPrinter(std::ostream &OS, TargetMachine &TM); FunctionPass *createDarwinAsmPrinter(std::ostream &OS, TargetMachine &TM);
FunctionPass *createAIXAsmPrinter(std::ostream &OS, TargetMachine &TM); FunctionPass *createAIXAsmPrinter(std::ostream &OS, TargetMachine &TM);
extern bool GPOPT;
extern bool PICEnabled; extern bool PICEnabled;
extern PPCTargetEnum PPCTarget; extern PPCTargetEnum PPCTarget;
} // end namespace llvm; } // end namespace llvm;

View File

@ -19,6 +19,7 @@
#define DEBUG_TYPE "asmprinter" #define DEBUG_TYPE "asmprinter"
#include "PowerPC.h" #include "PowerPC.h"
#include "PowerPCTargetMachine.h" #include "PowerPCTargetMachine.h"
#include "PowerPCSubtarget.h"
#include "llvm/Constants.h" #include "llvm/Constants.h"
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/Module.h" #include "llvm/Module.h"
@ -440,7 +441,8 @@ void DarwinAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
} }
bool DarwinAsmPrinter::doInitialization(Module &M) { bool DarwinAsmPrinter::doInitialization(Module &M) {
if (GPOPT) O << "\t.machine ppc970\n"; if (TM.getSubtarget<PPCSubtarget>().isGigaProcessor())
O << "\t.machine ppc970\n";
AsmPrinter::doInitialization(M); AsmPrinter::doInitialization(M);
return false; return false;
} }

View File

@ -96,7 +96,7 @@ namespace {
setOperationAction(ISD::SREM , MVT::f32, Expand); setOperationAction(ISD::SREM , MVT::f32, Expand);
// If we're enabling GP optimizations, use hardware square root // If we're enabling GP optimizations, use hardware square root
if (!GPOPT) { if (!TM.getSubtarget<PPCSubtarget>().isGigaProcessor()) {
setOperationAction(ISD::FSQRT, MVT::f64, Expand); setOperationAction(ISD::FSQRT, MVT::f64, Expand);
setOperationAction(ISD::FSQRT, MVT::f32, Expand); setOperationAction(ISD::FSQRT, MVT::f32, Expand);
} }
@ -536,6 +536,7 @@ namespace {
Statistic<>Recorded("ppc-codegen", "Number of recording ops emitted"); Statistic<>Recorded("ppc-codegen", "Number of recording ops emitted");
Statistic<>FusedFP("ppc-codegen", "Number of fused fp operations"); Statistic<>FusedFP("ppc-codegen", "Number of fused fp operations");
Statistic<>FrameOff("ppc-codegen", "Number of frame idx offsets collapsed"); Statistic<>FrameOff("ppc-codegen", "Number of frame idx offsets collapsed");
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
/// ISel - PPC32 specific code to select PPC32 machine instructions for /// ISel - PPC32 specific code to select PPC32 machine instructions for
/// SelectionDAG operations. /// SelectionDAG operations.
@ -929,7 +930,9 @@ unsigned ISel::getConstDouble(double doubleVal, unsigned Result=0) {
void ISel::MoveCRtoGPR(unsigned CCReg, bool Inv, unsigned Idx, unsigned Result){ void ISel::MoveCRtoGPR(unsigned CCReg, bool Inv, unsigned Idx, unsigned Result){
unsigned IntCR = MakeReg(MVT::i32); unsigned IntCR = MakeReg(MVT::i32);
BuildMI(BB, PPC::MCRF, 1, PPC::CR7).addReg(CCReg); BuildMI(BB, PPC::MCRF, 1, PPC::CR7).addReg(CCReg);
BuildMI(BB, GPOPT ? PPC::MFOCRF : PPC::MFCR, 1, IntCR).addReg(PPC::CR7); bool GPOpt =
TLI.getTargetMachine().getSubtarget<PPCSubtarget>().isGigaProcessor();
BuildMI(BB, GPOpt ? PPC::MFOCRF : PPC::MFCR, 1, IntCR).addReg(PPC::CR7);
if (Inv) { if (Inv) {
unsigned Tmp1 = MakeReg(MVT::i32); unsigned Tmp1 = MakeReg(MVT::i32);
BuildMI(BB, PPC::RLWINM, 4, Tmp1).addReg(IntCR).addImm(32-(3-Idx)) BuildMI(BB, PPC::RLWINM, 4, Tmp1).addReg(IntCR).addImm(32-(3-Idx))

View File

@ -12,7 +12,23 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "PowerPCSubtarget.h" #include "PowerPCSubtarget.h"
#include "PowerPC.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/Support/CommandLine.h"
using namespace llvm;
PPCTargetEnum llvm::PPCTarget = TargetDefault;
namespace llvm {
cl::opt<PPCTargetEnum, true>
PPCTargetArg(cl::desc("Force generation of code for a specific PPC target:"),
cl::values(
clEnumValN(TargetAIX, "aix", " Enable AIX codegen"),
clEnumValN(TargetDarwin,"darwin"," Enable Darwin codegen"),
clEnumValEnd),
cl::location(PPCTarget), cl::init(TargetDefault));
cl::opt<bool> EnableGPOPT("enable-gpopt", cl::Hidden,
cl::desc("Enable optimizations for GP cpus"));
}
#if defined(__APPLE__) #if defined(__APPLE__)
#include <mach/mach.h> #include <mach/mach.h>
@ -33,25 +49,26 @@ static boolean_t IsGP() {
} }
#endif #endif
using namespace llvm;
PPCSubtarget::PPCSubtarget(const Module &M) PPCSubtarget::PPCSubtarget(const Module &M)
: TargetSubtarget(), stackAlignment(16), isGigaProcessor(false), isAIX(false), : StackAlignment(16), IsGigaProcessor(false), IsAIX(false), IsDarwin(false) {
isDarwin(false) {
// Set the boolean corresponding to the current target triple, or the default // Set the boolean corresponding to the current target triple, or the default
// if one cannot be determined, to true. // if one cannot be determined, to true.
const std::string& TT = M.getTargetTriple(); const std::string& TT = M.getTargetTriple();
if (TT.length() > 5) { if (TT.length() > 5) {
isDarwin = TT.find("darwin") != std::string::npos; IsDarwin = TT.find("darwin") != std::string::npos;
#if defined(__APPLE__) #if defined(__APPLE__)
isGigaProcessor = IsGP(); IsGigaProcessor = IsGP();
#endif #endif
} else if (TT.empty()) { } else if (TT.empty()) {
#if defined(_POWER) #if defined(_POWER)
isAIX = true; IsAIX = true;
#elif defined(__APPLE__) #elif defined(__APPLE__)
isDarwin = true; IsDarwin = true;
isGigaProcessor = IsGP(); IsGigaProcessor = IsGP();
#endif #endif
} }
// If GP opts are forced on by the commandline, do so now.
if (EnableGPOPT) IsGigaProcessor = true;
} }

View File

@ -23,12 +23,12 @@ class PPCSubtarget : public TargetSubtarget {
protected: protected:
/// stackAlignment - The minimum alignment known to hold of the stack frame on /// stackAlignment - The minimum alignment known to hold of the stack frame on
/// entry to the function and which must be maintained by every function. /// entry to the function and which must be maintained by every function.
unsigned stackAlignment; unsigned StackAlignment;
/// Used by the ISel to turn in optimizations for POWER4-derived architectures /// Used by the ISel to turn in optimizations for POWER4-derived architectures
bool isGigaProcessor; bool IsGigaProcessor;
bool isAIX; bool IsAIX;
bool isDarwin; bool IsDarwin;
public: public:
/// This constructor initializes the data members to match that /// This constructor initializes the data members to match that
/// of the specified module. /// of the specified module.
@ -38,10 +38,12 @@ public:
/// getStackAlignment - Returns the minimum alignment known to hold of the /// getStackAlignment - Returns the minimum alignment known to hold of the
/// stack frame on entry to the function and which must be maintained by every /// stack frame on entry to the function and which must be maintained by every
/// function for this subtarget. /// function for this subtarget.
unsigned getStackAlignment() const { return stackAlignment; } unsigned getStackAlignment() const { return StackAlignment; }
bool IsAIX() const { return isAIX; } bool isAIX() const { return IsAIX; }
bool IsDarwin() const { return isDarwin; } bool isDarwin() const { return IsDarwin; }
bool isGigaProcessor() const { return IsGigaProcessor; }
}; };
} // End llvm namespace } // End llvm namespace

View File

@ -30,25 +30,8 @@
#include <iostream> #include <iostream>
using namespace llvm; using namespace llvm;
bool llvm::GPOPT = false; static cl::opt<bool> EnablePPCLSR("enable-lsr-for-ppc", cl::Hidden,
PPCTargetEnum llvm::PPCTarget = TargetDefault; cl::desc("Enable LSR for PPC (beta)"));
namespace llvm {
cl::opt<PPCTargetEnum, true>
PPCTargetArg(
cl::desc("Force generation of code for a specific PPC target:"),
cl::values(
clEnumValN(TargetAIX, "aix", " Enable AIX codegen"),
clEnumValN(TargetDarwin,"darwin"," Enable Darwin codegen"),
clEnumValEnd),
cl::location(PPCTarget), cl::init(TargetDefault));
cl::opt<bool> EnablePPCLSR("enable-lsr-for-ppc",
cl::desc("Enable LSR for PPC (beta)"),
cl::Hidden);
cl::opt<bool, true> EnableGPOPT("enable-gpopt", cl::Hidden,
cl::location(GPOPT),
cl::desc("Enable optimizations for GP cpus"));
}
namespace { namespace {
const std::string PPC32ID = "PowerPC/32bit"; const std::string PPC32ID = "PowerPC/32bit";
@ -71,8 +54,8 @@ PowerPCTargetMachine::PowerPCTargetMachine(const std::string &name,
const PowerPCFrameInfo &TFI) const PowerPCFrameInfo &TFI)
: TargetMachine(name, IL, TD), FrameInfo(TFI), Subtarget(M) { : TargetMachine(name, IL, TD), FrameInfo(TFI), Subtarget(M) {
if (TargetDefault == PPCTarget) { if (TargetDefault == PPCTarget) {
if (Subtarget.IsAIX()) PPCTarget = TargetAIX; if (Subtarget.isAIX()) PPCTarget = TargetAIX;
if (Subtarget.IsDarwin()) PPCTarget = TargetDarwin; if (Subtarget.isDarwin()) PPCTarget = TargetDarwin;
} }
} }