blob: 18f64203f44d2f2644731ef6e48a9e7081bd3e24 [file] [log] [blame]
Tanya Lattner6e19b212005-03-29 20:33:42 +00001//===-- DependenceAnalyzer.h - Dependence Analyzer--------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_DEPENDENCEANALYZER_H
14#define LLVM_DEPENDENCEANALYZER_H
15
16#include "llvm/Instructions.h"
17#include "llvm/Function.h"
18#include "llvm/Pass.h"
19#include "llvm/Analysis/AliasAnalysis.h"
20#include "llvm/Target/TargetData.h"
21#include <vector>
22
23namespace llvm {
24
25 //class to represent a dependence
26 struct Dependence {
27
28 enum DataDepType {
29 TrueDep, AntiDep, OutputDep, NonDateDep,
30 };
31
32 Dependence(int diff, DataDepType dep) : iteDiff(diff), depType(dep) {}
33 unsigned getIteDiff() { return iteDiff; }
34 unsigned getDepType() { return depType; }
35
36 private:
37
38 unsigned iteDiff;
39 unsigned depType;
40 };
41
42
43 struct DependenceResult {
44 std::vector<Dependence> dependences;
45 DependenceResult(const std::vector<Dependence> &d) : dependences(d) {}
46 };
47
48
49 class DependenceAnalyzer : public FunctionPass {
50 AliasAnalysis *AA;
51 TargetData *TD;
52
53 public:
54 DependenceAnalyzer() { AA = 0; TD = 0; }
55 virtual bool runOnFunction(Function &F);
56 virtual const char* getPassName() const { return "DependenceAnalyzer"; }
57
58 // getAnalysisUsage
59 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
60 AU.addRequired<AliasAnalysis>();
61 AU.addRequired<TargetData>();
62 }
63
64 //get dependence info
65 DependenceResult getDependenceInfo(Instruction *inst1, Instruction *inst2);
66
67 };
68
69}
70
71
72
73#endif