LLVM API Documentation

XCoreTargetTransformInfo.cpp
Go to the documentation of this file.
00001 //===-- XCoreTargetTransformInfo.cpp - XCore specific TTI pass ----------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 /// \file
00010 /// This file implements a TargetTransformInfo analysis pass specific to the
00011 /// XCore target machine. It uses the target's detailed information to provide
00012 /// more precise answers to certain TTI queries, while letting the target
00013 /// independent and default TTI implementations handle the rest.
00014 ///
00015 //===----------------------------------------------------------------------===//
00016 
00017 #include "XCore.h"
00018 #include "llvm/Analysis/TargetTransformInfo.h"
00019 #include "llvm/Support/Debug.h"
00020 #include "llvm/Target/CostTable.h"
00021 #include "llvm/Target/TargetLowering.h"
00022 using namespace llvm;
00023 
00024 #define DEBUG_TYPE "xcoretti"
00025 
00026 // Declare the pass initialization routine locally as target-specific passes
00027 // don't have a target-wide initialization entry point, and so we rely on the
00028 // pass constructor initialization.
00029 namespace llvm {
00030 void initializeXCoreTTIPass(PassRegistry &);
00031 }
00032 
00033 namespace {
00034 
00035 class XCoreTTI final : public ImmutablePass, public TargetTransformInfo {
00036 public:
00037   XCoreTTI() : ImmutablePass(ID) {
00038     llvm_unreachable("This pass cannot be directly constructed");
00039   }
00040 
00041   XCoreTTI(const XCoreTargetMachine *TM)
00042       : ImmutablePass(ID) {
00043     initializeXCoreTTIPass(*PassRegistry::getPassRegistry());
00044   }
00045 
00046   void initializePass() override {
00047     pushTTIStack(this);
00048   }
00049 
00050   void getAnalysisUsage(AnalysisUsage &AU) const override {
00051     TargetTransformInfo::getAnalysisUsage(AU);
00052   }
00053 
00054   static char ID;
00055 
00056   void *getAdjustedAnalysisPointer(const void *ID) override {
00057     if (ID == &TargetTransformInfo::ID)
00058       return (TargetTransformInfo*)this;
00059     return this;
00060   }
00061 
00062   unsigned getNumberOfRegisters(bool Vector) const override {
00063     if (Vector) {
00064        return 0;
00065     }
00066     return 12;
00067   }
00068 };
00069 
00070 } // end anonymous namespace
00071 
00072 INITIALIZE_AG_PASS(XCoreTTI, TargetTransformInfo, "xcoretti",
00073                    "XCore Target Transform Info", true, true, false)
00074 char XCoreTTI::ID = 0;
00075 
00076 
00077 ImmutablePass *
00078 llvm::createXCoreTargetTransformInfoPass(const XCoreTargetMachine *TM) {
00079   return new XCoreTTI(TM);
00080 }