1 //===-- llvm/CodeGen/SDNodeOrdering.h - SDNode Ordering ---------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the SDNodeOrdering class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CODEGEN_SDNODEORDERING_H
15 #define LLVM_CODEGEN_SDNODEORDERING_H
17 #include "llvm/ADT/DenseMap.h"
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
28 class SDNodeOrdering {
29 DenseMap<const SDNode*, unsigned> OrderMap;
31 void operator=(const SDNodeOrdering&) LLVM_DELETED_FUNCTION;
32 SDNodeOrdering(const SDNodeOrdering&) LLVM_DELETED_FUNCTION;
36 void add(const SDNode *Node, unsigned NewOrder) {
37 unsigned &OldOrder = OrderMap[Node];
38 if (OldOrder == 0 || (OldOrder > 0 && NewOrder < OldOrder))
41 void remove(const SDNode *Node) {
42 DenseMap<const SDNode*, unsigned>::iterator Itr = OrderMap.find(Node);
43 if (Itr != OrderMap.end())
49 unsigned getOrder(const SDNode *Node) {
50 return OrderMap[Node];
54 } // end llvm namespace