Bill Wendling | b4e6a5d | 2009-12-18 23:32:53 +0000 | [diff] [blame] | 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 | |
Bill Wendling | 29b49fc | 2009-12-19 00:05:07 +0000 | [diff] [blame] | 21 | class SDNode; |
| 22 | |
Bill Wendling | b4e6a5d | 2009-12-18 23:32:53 +0000 | [diff] [blame] | 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) { |
Bill Wendling | b4e6a5d | 2009-12-18 23:32:53 +0000 | [diff] [blame] | 37 | OrderMap[Node] = O; |
| 38 | } |
| 39 | void remove(const SDNode *Node) { |
| 40 | DenseMap<const SDNode*, unsigned>::iterator Itr = OrderMap.find(Node); |
| 41 | if (Itr != OrderMap.end()) |
| 42 | OrderMap.erase(Itr); |
| 43 | } |
| 44 | void clear() { |
| 45 | OrderMap.clear(); |
| 46 | } |
| 47 | unsigned getOrder(const SDNode *Node) { |
Bill Wendling | 3ea58b6 | 2009-12-22 21:35:02 +0000 | [diff] [blame] | 48 | return OrderMap[Node]; |
Bill Wendling | b4e6a5d | 2009-12-18 23:32:53 +0000 | [diff] [blame] | 49 | } |
| 50 | }; |
| 51 | |
| 52 | } // end llvm namespace |
| 53 | |
| 54 | #endif |