MachinePassRegistry.cpp revision 193323
1193323Sed//===-- CodeGen/MachineInstr.cpp ------------------------------------------===//
2193323Sed//
3193323Sed//                     The LLVM Compiler Infrastructure
4193323Sed//
5193323Sed// This file is distributed under the University of Illinois Open Source
6193323Sed// License. See LICENSE.TXT for details.
7193323Sed//
8193323Sed//===----------------------------------------------------------------------===//
9193323Sed//
10193323Sed// This file contains the machine function pass registry for register allocators
11193323Sed// and instruction schedulers.
12193323Sed//
13193323Sed//===----------------------------------------------------------------------===//
14193323Sed
15193323Sed#include "llvm/CodeGen/MachinePassRegistry.h"
16193323Sed
17193323Sedusing namespace llvm;
18193323Sed
19193323Sed
20193323Sed/// Add - Adds a function pass to the registration list.
21193323Sed///
22193323Sedvoid MachinePassRegistry::Add(MachinePassRegistryNode *Node) {
23193323Sed  Node->setNext(List);
24193323Sed  List = Node;
25193323Sed  if (Listener) Listener->NotifyAdd(Node->getName(),
26193323Sed                                    Node->getCtor(),
27193323Sed                                    Node->getDescription());
28193323Sed}
29193323Sed
30193323Sed
31193323Sed/// Remove - Removes a function pass from the registration list.
32193323Sed///
33193323Sedvoid MachinePassRegistry::Remove(MachinePassRegistryNode *Node) {
34193323Sed  for (MachinePassRegistryNode **I = &List; *I; I = (*I)->getNextAddress()) {
35193323Sed    if (*I == Node) {
36193323Sed      if (Listener) Listener->NotifyRemove(Node->getName());
37193323Sed      *I = (*I)->getNext();
38193323Sed      break;
39193323Sed    }
40193323Sed  }
41193323Sed}
42