Place SDNodeOrdering.h in the directory it's used.
[oota-llvm.git] / lib / CodeGen / SelectionDAG / SDNodeOrdering.h
1 //===-- llvm/CodeGen/SDNodeOrdering.h - SDNode Ordering ---------*- 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 declares the SDNodeOrdering class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CODEGEN_SDNODEORDERING_H
15 #define LLVM_CODEGEN_SDNODEORDERING_H
16
17 #include "llvm/ADT/DenseMap.h"
18
19 namespace llvm {
20
21 class SDNode;
22
23 /// SDNodeOrdering - Maps a unique (monotonically increasing) value to each
24 /// SDNode that roughly corresponds to the ordering of the original LLVM
25 /// instruction. This is used for turning off scheduling, because we'll forgo
26 /// the normal scheduling algorithms and output the instructions according to
27 /// this ordering.
28 class SDNodeOrdering {
29   DenseMap<const SDNode*, unsigned> OrderMap;
30
31   void operator=(const SDNodeOrdering&);   // Do not implement.
32   SDNodeOrdering(const SDNodeOrdering&);   // Do not implement.
33 public:
34   SDNodeOrdering() {}
35
36   void add(const SDNode *Node, unsigned O) {
37     assert(O && "Invalid ordering!");
38     OrderMap[Node] = O;
39   }
40   void remove(const SDNode *Node) {
41     DenseMap<const SDNode*, unsigned>::iterator Itr = OrderMap.find(Node);
42     if (Itr != OrderMap.end())
43       OrderMap.erase(Itr);
44   }
45   void clear() {
46     OrderMap.clear();
47   }
48   unsigned getOrder(const SDNode *Node) {
49     unsigned Order = OrderMap[Node];
50     assert(Order && "Node isn't in ordering map!");
51     return Order;
52   }
53 };
54
55 } // end llvm namespace
56
57 #endif