summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lib/Analysis/CostModel.cpp
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2020-08-03 15:06:44 +0000
committerpatrick <patrick@openbsd.org>2020-08-03 15:06:44 +0000
commitb64793999546ed8adebaeebd9d8345d18db8927d (patch)
tree4357c27b561d73b0e089727c6ed659f2ceff5f47 /gnu/llvm/lib/Analysis/CostModel.cpp
parentAdd support for UTF-8 DISPLAY-HINTs with octet length. For now only (diff)
downloadwireguard-openbsd-b64793999546ed8adebaeebd9d8345d18db8927d.tar.xz
wireguard-openbsd-b64793999546ed8adebaeebd9d8345d18db8927d.zip
Remove LLVM 8.0.1 files.
Diffstat (limited to 'gnu/llvm/lib/Analysis/CostModel.cpp')
-rw-r--r--gnu/llvm/lib/Analysis/CostModel.cpp112
1 files changed, 0 insertions, 112 deletions
diff --git a/gnu/llvm/lib/Analysis/CostModel.cpp b/gnu/llvm/lib/Analysis/CostModel.cpp
deleted file mode 100644
index 3d55bf20bb4..00000000000
--- a/gnu/llvm/lib/Analysis/CostModel.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-//===- CostModel.cpp ------ Cost Model Analysis ---------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines the cost model analysis. It provides a very basic cost
-// estimation for LLVM-IR. This analysis uses the services of the codegen
-// to approximate the cost of any IR instruction when lowered to machine
-// instructions. The cost results are unit-less and the cost number represents
-// the throughput of the machine assuming that all loads hit the cache, all
-// branches are predicted, etc. The cost numbers can be added in order to
-// compare two or more transformation alternatives.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/Analysis/Passes.h"
-#include "llvm/Analysis/TargetTransformInfo.h"
-#include "llvm/IR/Function.h"
-#include "llvm/Pass.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/Debug.h"
-#include "llvm/Support/raw_ostream.h"
-using namespace llvm;
-
-static cl::opt<TargetTransformInfo::TargetCostKind> CostKind(
- "cost-kind", cl::desc("Target cost kind"),
- cl::init(TargetTransformInfo::TCK_RecipThroughput),
- cl::values(clEnumValN(TargetTransformInfo::TCK_RecipThroughput,
- "throughput", "Reciprocal throughput"),
- clEnumValN(TargetTransformInfo::TCK_Latency,
- "latency", "Instruction latency"),
- clEnumValN(TargetTransformInfo::TCK_CodeSize,
- "code-size", "Code size")));
-
-#define CM_NAME "cost-model"
-#define DEBUG_TYPE CM_NAME
-
-namespace {
- class CostModelAnalysis : public FunctionPass {
-
- public:
- static char ID; // Class identification, replacement for typeinfo
- CostModelAnalysis() : FunctionPass(ID), F(nullptr), TTI(nullptr) {
- initializeCostModelAnalysisPass(
- *PassRegistry::getPassRegistry());
- }
-
- /// Returns the expected cost of the instruction.
- /// Returns -1 if the cost is unknown.
- /// Note, this method does not cache the cost calculation and it
- /// can be expensive in some cases.
- unsigned getInstructionCost(const Instruction *I) const {
- return TTI->getInstructionCost(I, TargetTransformInfo::TCK_RecipThroughput);
- }
-
- private:
- void getAnalysisUsage(AnalysisUsage &AU) const override;
- bool runOnFunction(Function &F) override;
- void print(raw_ostream &OS, const Module*) const override;
-
- /// The function that we analyze.
- Function *F;
- /// Target information.
- const TargetTransformInfo *TTI;
- };
-} // End of anonymous namespace
-
-// Register this pass.
-char CostModelAnalysis::ID = 0;
-static const char cm_name[] = "Cost Model Analysis";
-INITIALIZE_PASS_BEGIN(CostModelAnalysis, CM_NAME, cm_name, false, true)
-INITIALIZE_PASS_END (CostModelAnalysis, CM_NAME, cm_name, false, true)
-
-FunctionPass *llvm::createCostModelAnalysisPass() {
- return new CostModelAnalysis();
-}
-
-void
-CostModelAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
- AU.setPreservesAll();
-}
-
-bool
-CostModelAnalysis::runOnFunction(Function &F) {
- this->F = &F;
- auto *TTIWP = getAnalysisIfAvailable<TargetTransformInfoWrapperPass>();
- TTI = TTIWP ? &TTIWP->getTTI(F) : nullptr;
-
- return false;
-}
-
-void CostModelAnalysis::print(raw_ostream &OS, const Module*) const {
- if (!F)
- return;
-
- for (BasicBlock &B : *F) {
- for (Instruction &Inst : B) {
- unsigned Cost = TTI->getInstructionCost(&Inst, CostKind);
- if (Cost != (unsigned)-1)
- OS << "Cost Model: Found an estimated cost of " << Cost;
- else
- OS << "Cost Model: Unknown cost";
-
- OS << " for instruction: " << Inst << "\n";
- }
- }
-}