XCoreTargetTransformInfo.cpp revision 263508
1//===-- XCoreTargetTransformInfo.cpp - XCore specific TTI pass ----------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9/// \file 10/// This file implements a TargetTransformInfo analysis pass specific to the 11/// XCore target machine. It uses the target's detailed information to provide 12/// more precise answers to certain TTI queries, while letting the target 13/// independent and default TTI implementations handle the rest. 14/// 15//===----------------------------------------------------------------------===// 16 17#define DEBUG_TYPE "xcoretti" 18#include "XCore.h" 19#include "llvm/Analysis/TargetTransformInfo.h" 20#include "llvm/Support/Debug.h" 21#include "llvm/Target/TargetLowering.h" 22#include "llvm/Target/CostTable.h" 23using namespace llvm; 24 25// Declare the pass initialization routine locally as target-specific passes 26// don't havve a target-wide initialization entry point, and so we rely on the 27// pass constructor initialization. 28namespace llvm { 29void initializeXCoreTTIPass(PassRegistry &); 30} 31 32namespace { 33 34class XCoreTTI : public ImmutablePass, public TargetTransformInfo { 35public: 36 XCoreTTI() : ImmutablePass(ID) { 37 llvm_unreachable("This pass cannot be directly constructed"); 38 } 39 40 XCoreTTI(const XCoreTargetMachine *TM) 41 : ImmutablePass(ID) { 42 initializeXCoreTTIPass(*PassRegistry::getPassRegistry()); 43 } 44 45 virtual void initializePass() { 46 pushTTIStack(this); 47 } 48 49 virtual void finalizePass() { 50 popTTIStack(); 51 } 52 53 virtual void getAnalysisUsage(AnalysisUsage &AU) const { 54 TargetTransformInfo::getAnalysisUsage(AU); 55 } 56 57 static char ID; 58 59 virtual void *getAdjustedAnalysisPointer(const void *ID) { 60 if (ID == &TargetTransformInfo::ID) 61 return (TargetTransformInfo*)this; 62 return this; 63 } 64 65 unsigned getNumberOfRegisters(bool Vector) const { 66 if (Vector) { 67 return 0; 68 } 69 return 12; 70 } 71}; 72 73} // end anonymous namespace 74 75INITIALIZE_AG_PASS(XCoreTTI, TargetTransformInfo, "xcoretti", 76 "XCore Target Transform Info", true, true, false) 77char XCoreTTI::ID = 0; 78 79 80ImmutablePass * 81llvm::createXCoreTargetTransformInfoPass(const XCoreTargetMachine *TM) { 82 return new XCoreTTI(TM); 83} 84