XCoreTargetTransformInfo.cpp revision dce4a407a24b04eebc6a376f8e62b41aaa7b071f
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#include "XCore.h" 18#include "llvm/Analysis/TargetTransformInfo.h" 19#include "llvm/Support/Debug.h" 20#include "llvm/Target/CostTable.h" 21#include "llvm/Target/TargetLowering.h" 22using namespace llvm; 23 24#define DEBUG_TYPE "xcoretti" 25 26// Declare the pass initialization routine locally as target-specific passes 27// don't have a target-wide initialization entry point, and so we rely on the 28// pass constructor initialization. 29namespace llvm { 30void initializeXCoreTTIPass(PassRegistry &); 31} 32 33namespace { 34 35class XCoreTTI final : public ImmutablePass, public TargetTransformInfo { 36public: 37 XCoreTTI() : ImmutablePass(ID) { 38 llvm_unreachable("This pass cannot be directly constructed"); 39 } 40 41 XCoreTTI(const XCoreTargetMachine *TM) 42 : ImmutablePass(ID) { 43 initializeXCoreTTIPass(*PassRegistry::getPassRegistry()); 44 } 45 46 virtual void initializePass() override { 47 pushTTIStack(this); 48 } 49 50 virtual void getAnalysisUsage(AnalysisUsage &AU) const override { 51 TargetTransformInfo::getAnalysisUsage(AU); 52 } 53 54 static char ID; 55 56 virtual void *getAdjustedAnalysisPointer(const void *ID) override { 57 if (ID == &TargetTransformInfo::ID) 58 return (TargetTransformInfo*)this; 59 return this; 60 } 61 62 unsigned getNumberOfRegisters(bool Vector) const override { 63 if (Vector) { 64 return 0; 65 } 66 return 12; 67 } 68}; 69 70} // end anonymous namespace 71 72INITIALIZE_AG_PASS(XCoreTTI, TargetTransformInfo, "xcoretti", 73 "XCore Target Transform Info", true, true, false) 74char XCoreTTI::ID = 0; 75 76 77ImmutablePass * 78llvm::createXCoreTargetTransformInfoPass(const XCoreTargetMachine *TM) { 79 return new XCoreTTI(TM); 80} 81