blob: 6223fb743311c9970edebf656641ec839ab1538e [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//===----------------------------------------------------------------------===//
Misha Brukmanb4402432005-04-21 23:30:14 +00009//
10//
Tanya Lattner6e19b212005-03-29 20:33:42 +000011//===----------------------------------------------------------------------===//
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 {
Misha Brukmanb4402432005-04-21 23:30:14 +000027
Tanya Lattner6e19b212005-03-29 20:33:42 +000028 enum DataDepType {
29 TrueDep, AntiDep, OutputDep, NonDateDep,
30 };
Misha Brukmanb4402432005-04-21 23:30:14 +000031
Tanya Lattner6e19b212005-03-29 20:33:42 +000032 Dependence(int diff, DataDepType dep) : iteDiff(diff), depType(dep) {}
33 unsigned getIteDiff() { return iteDiff; }
34 unsigned getDepType() { return depType; }
Misha Brukmanb4402432005-04-21 23:30:14 +000035
Tanya Lattner6e19b212005-03-29 20:33:42 +000036 private:
Misha Brukmanb4402432005-04-21 23:30:14 +000037
Tanya Lattner6e19b212005-03-29 20:33:42 +000038 unsigned iteDiff;
39 unsigned depType;
40 };
41
Misha Brukmanb4402432005-04-21 23:30:14 +000042
Tanya Lattner6e19b212005-03-29 20:33:42 +000043 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;
Misha Brukmanb4402432005-04-21 23:30:14 +000052
Tanya Lattner6e19b212005-03-29 20:33:42 +000053 public:
54 DependenceAnalyzer() { AA = 0; TD = 0; }
55 virtual bool runOnFunction(Function &F);
56 virtual const char* getPassName() const { return "DependenceAnalyzer"; }
Misha Brukmanb4402432005-04-21 23:30:14 +000057
Tanya Lattner6e19b212005-03-29 20:33:42 +000058 // 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