~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/lib/CodeGen/ScheduleDAGInstrs.h

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//==- ScheduleDAGInstrs.h - MachineInstr Scheduling --------------*- C++ -*-==//
 
2
//
 
3
//                     The LLVM Compiler Infrastructure
 
4
//
 
5
// This file is distributed under the University of Illinois Open Source
 
6
// License. See LICENSE.TXT for details.
 
7
//
 
8
//===----------------------------------------------------------------------===//
 
9
//
 
10
// This file implements the ScheduleDAGInstrs class, which implements
 
11
// scheduling for a MachineInstr-based dependency graph.
 
12
//
 
13
//===----------------------------------------------------------------------===//
 
14
 
 
15
#ifndef SCHEDULEDAGINSTRS_H
 
16
#define SCHEDULEDAGINSTRS_H
 
17
 
 
18
#include "llvm/CodeGen/MachineDominators.h"
 
19
#include "llvm/CodeGen/MachineLoopInfo.h"
 
20
#include "llvm/CodeGen/ScheduleDAG.h"
 
21
#include "llvm/Support/Compiler.h"
 
22
#include "llvm/Target/TargetRegisterInfo.h"
 
23
#include "llvm/ADT/DenseMap.h"
 
24
#include "llvm/ADT/SmallSet.h"
 
25
#include <map>
 
26
 
 
27
namespace llvm {
 
28
  class MachineLoopInfo;
 
29
  class MachineDominatorTree;
 
30
 
 
31
  /// LoopDependencies - This class analyzes loop-oriented register
 
32
  /// dependencies, which are used to guide scheduling decisions.
 
33
  /// For example, loop induction variable increments should be
 
34
  /// scheduled as soon as possible after the variable's last use.
 
35
  ///
 
36
  class VISIBILITY_HIDDEN LoopDependencies {
 
37
    const MachineLoopInfo &MLI;
 
38
    const MachineDominatorTree &MDT;
 
39
 
 
40
  public:
 
41
    typedef std::map<unsigned, std::pair<const MachineOperand *, unsigned> >
 
42
      LoopDeps;
 
43
    LoopDeps Deps;
 
44
 
 
45
    LoopDependencies(const MachineLoopInfo &mli,
 
46
                     const MachineDominatorTree &mdt) :
 
47
      MLI(mli), MDT(mdt) {}
 
48
 
 
49
    /// VisitLoop - Clear out any previous state and analyze the given loop.
 
50
    ///
 
51
    void VisitLoop(const MachineLoop *Loop) {
 
52
      Deps.clear();
 
53
      MachineBasicBlock *Header = Loop->getHeader();
 
54
      SmallSet<unsigned, 8> LoopLiveIns;
 
55
      for (MachineBasicBlock::livein_iterator LI = Header->livein_begin(),
 
56
           LE = Header->livein_end(); LI != LE; ++LI)
 
57
        LoopLiveIns.insert(*LI);
 
58
 
 
59
      const MachineDomTreeNode *Node = MDT.getNode(Header);
 
60
      const MachineBasicBlock *MBB = Node->getBlock();
 
61
      assert(Loop->contains(MBB) &&
 
62
             "Loop does not contain header!");
 
63
      VisitRegion(Node, MBB, Loop, LoopLiveIns);
 
64
    }
 
65
 
 
66
  private:
 
67
    void VisitRegion(const MachineDomTreeNode *Node,
 
68
                     const MachineBasicBlock *MBB,
 
69
                     const MachineLoop *Loop,
 
70
                     const SmallSet<unsigned, 8> &LoopLiveIns) {
 
71
      unsigned Count = 0;
 
72
      for (MachineBasicBlock::const_iterator I = MBB->begin(), E = MBB->end();
 
73
           I != E; ++I, ++Count) {
 
74
        const MachineInstr *MI = I;
 
75
        for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
 
76
          const MachineOperand &MO = MI->getOperand(i);
 
77
          if (!MO.isReg() || !MO.isUse())
 
78
            continue;
 
79
          unsigned MOReg = MO.getReg();
 
80
          if (LoopLiveIns.count(MOReg))
 
81
            Deps.insert(std::make_pair(MOReg, std::make_pair(&MO, Count)));
 
82
        }
 
83
      }
 
84
 
 
85
      const std::vector<MachineDomTreeNode*> &Children = Node->getChildren();
 
86
      for (std::vector<MachineDomTreeNode*>::const_iterator I =
 
87
           Children.begin(), E = Children.end(); I != E; ++I) {
 
88
        const MachineDomTreeNode *ChildNode = *I;
 
89
        MachineBasicBlock *ChildBlock = ChildNode->getBlock();
 
90
        if (Loop->contains(ChildBlock))
 
91
          VisitRegion(ChildNode, ChildBlock, Loop, LoopLiveIns);
 
92
      }
 
93
    }
 
94
  };
 
95
 
 
96
  /// ScheduleDAGInstrs - A ScheduleDAG subclass for scheduling lists of
 
97
  /// MachineInstrs.
 
98
  class VISIBILITY_HIDDEN ScheduleDAGInstrs : public ScheduleDAG {
 
99
    const MachineLoopInfo &MLI;
 
100
    const MachineDominatorTree &MDT;
 
101
    const MachineFrameInfo *MFI;
 
102
 
 
103
    /// Defs, Uses - Remember where defs and uses of each physical register
 
104
    /// are as we iterate upward through the instructions. This is allocated
 
105
    /// here instead of inside BuildSchedGraph to avoid the need for it to be
 
106
    /// initialized and destructed for each block.
 
107
    std::vector<SUnit *> Defs[TargetRegisterInfo::FirstVirtualRegister];
 
108
    std::vector<SUnit *> Uses[TargetRegisterInfo::FirstVirtualRegister];
 
109
 
 
110
    /// PendingLoads - Remember where unknown loads are after the most recent
 
111
    /// unknown store, as we iterate. As with Defs and Uses, this is here
 
112
    /// to minimize construction/destruction.
 
113
    std::vector<SUnit *> PendingLoads;
 
114
 
 
115
    /// LoopRegs - Track which registers are used for loop-carried dependencies.
 
116
    ///
 
117
    LoopDependencies LoopRegs;
 
118
 
 
119
    /// LoopLiveInRegs - Track which regs are live into a loop, to help guide
 
120
    /// back-edge-aware scheduling.
 
121
    ///
 
122
    SmallSet<unsigned, 8> LoopLiveInRegs;
 
123
 
 
124
  public:
 
125
    MachineBasicBlock::iterator Begin;    // The beginning of the range to
 
126
                                          // be scheduled. The range extends
 
127
                                          // to InsertPos.
 
128
    unsigned InsertPosIndex;              // The index in BB of InsertPos.
 
129
 
 
130
    explicit ScheduleDAGInstrs(MachineFunction &mf,
 
131
                               const MachineLoopInfo &mli,
 
132
                               const MachineDominatorTree &mdt);
 
133
 
 
134
    virtual ~ScheduleDAGInstrs() {}
 
135
 
 
136
    /// NewSUnit - Creates a new SUnit and return a ptr to it.
 
137
    ///
 
138
    SUnit *NewSUnit(MachineInstr *MI) {
 
139
#ifndef NDEBUG
 
140
      const SUnit *Addr = SUnits.empty() ? 0 : &SUnits[0];
 
141
#endif
 
142
      SUnits.push_back(SUnit(MI, (unsigned)SUnits.size()));
 
143
      assert((Addr == 0 || Addr == &SUnits[0]) &&
 
144
             "SUnits std::vector reallocated on the fly!");
 
145
      SUnits.back().OrigNode = &SUnits.back();
 
146
      return &SUnits.back();
 
147
    }
 
148
 
 
149
    /// Run - perform scheduling.
 
150
    ///
 
151
    void Run(MachineBasicBlock *bb,
 
152
             MachineBasicBlock::iterator begin,
 
153
             MachineBasicBlock::iterator end,
 
154
             unsigned endindex);
 
155
 
 
156
    /// BuildSchedGraph - Build SUnits from the MachineBasicBlock that we are
 
157
    /// input.
 
158
    virtual void BuildSchedGraph(AliasAnalysis *AA);
 
159
 
 
160
    /// ComputeLatency - Compute node latency.
 
161
    ///
 
162
    virtual void ComputeLatency(SUnit *SU);
 
163
 
 
164
    /// ComputeOperandLatency - Override dependence edge latency using
 
165
    /// operand use/def information
 
166
    ///
 
167
    virtual void ComputeOperandLatency(SUnit *Def, SUnit *Use,
 
168
                                       SDep& dep) const;
 
169
 
 
170
    virtual MachineBasicBlock*
 
171
    EmitSchedule(DenseMap<MachineBasicBlock*, MachineBasicBlock*>*);
 
172
 
 
173
    /// StartBlock - Prepare to perform scheduling in the given block.
 
174
    ///
 
175
    virtual void StartBlock(MachineBasicBlock *BB);
 
176
 
 
177
    /// Schedule - Order nodes according to selected style, filling
 
178
    /// in the Sequence member.
 
179
    ///
 
180
    virtual void Schedule() = 0;
 
181
 
 
182
    /// FinishBlock - Clean up after scheduling in the given block.
 
183
    ///
 
184
    virtual void FinishBlock();
 
185
 
 
186
    virtual void dumpNode(const SUnit *SU) const;
 
187
 
 
188
    virtual std::string getGraphNodeLabel(const SUnit *SU) const;
 
189
  };
 
190
}
 
191
 
 
192
#endif