58e067bcb9b26704680489a7b84c0d03387dd56c
[oota-llvm.git] / lib / CodeGen / MachinePassRegistry.cpp
1 //===-- CodeGen/MachineInstr.cpp ------------------------------------------===//
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 contains the machine function pass registry for register allocators
11 // and instruction schedulers.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "llvm/CodeGen/MachinePassRegistry.h"
16
17 using namespace llvm;
18
19 void MachinePassRegistryListener::anchor() { }
20
21 /// Add - Adds a function pass to the registration list.
22 ///
23 void MachinePassRegistry::Add(MachinePassRegistryNode *Node) {
24   Node->setNext(List);
25   List = Node;
26   if (Listener) Listener->NotifyAdd(Node->getName(),
27                                     Node->getCtor(),
28                                     Node->getDescription());
29 }
30
31
32 /// Remove - Removes a function pass from the registration list.
33 ///
34 void MachinePassRegistry::Remove(MachinePassRegistryNode *Node) {
35   for (MachinePassRegistryNode **I = &List; *I; I = (*I)->getNextAddress()) {
36     if (*I == Node) {
37       if (Listener) Listener->NotifyRemove(Node->getName());
38       *I = (*I)->getNext();
39       break;
40     }
41   }
42 }