1 //===-- XCoreTargetTransformInfo.cpp - XCore specific TTI pass ----------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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.
15 //===----------------------------------------------------------------------===//
18 #include "llvm/Analysis/TargetTransformInfo.h"
19 #include "llvm/Support/Debug.h"
20 #include "llvm/Target/CostTable.h"
21 #include "llvm/Target/TargetLowering.h"
24 #define DEBUG_TYPE "xcoretti"
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.
30 void initializeXCoreTTIPass(PassRegistry &);
35 class XCoreTTI final : public ImmutablePass, public TargetTransformInfo {
37 XCoreTTI() : ImmutablePass(ID) {
38 llvm_unreachable("This pass cannot be directly constructed");
41 XCoreTTI(const XCoreTargetMachine *TM)
43 initializeXCoreTTIPass(*PassRegistry::getPassRegistry());
46 virtual void initializePass() override {
50 virtual void getAnalysisUsage(AnalysisUsage &AU) const override {
51 TargetTransformInfo::getAnalysisUsage(AU);
56 virtual void *getAdjustedAnalysisPointer(const void *ID) override {
57 if (ID == &TargetTransformInfo::ID)
58 return (TargetTransformInfo*)this;
62 unsigned getNumberOfRegisters(bool Vector) const override {
70 } // end anonymous namespace
72 INITIALIZE_AG_PASS(XCoreTTI, TargetTransformInfo, "xcoretti",
73 "XCore Target Transform Info", true, true, false)
74 char XCoreTTI::ID = 0;
78 llvm::createXCoreTargetTransformInfoPass(const XCoreTargetMachine *TM) {
79 return new XCoreTTI(TM);