[PowerPC] Remove self-copies in pre-emit peephole
[llvm-core.git] / lib / CodeGen / MachinePassRegistry.cpp
blob3ee3e40b27e236d5d984c7dc3ed4618555f7834e
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.
13 //===----------------------------------------------------------------------===//
15 #include "llvm/CodeGen/MachinePassRegistry.h"
17 using namespace llvm;
19 void MachinePassRegistryListener::anchor() { }
21 /// setDefault - Set the default constructor by name.
22 void MachinePassRegistry::setDefault(StringRef Name) {
23 MachinePassCtor Ctor = nullptr;
24 for(MachinePassRegistryNode *R = getList(); R; R = R->getNext()) {
25 if (R->getName() == Name) {
26 Ctor = R->getCtor();
27 break;
30 assert(Ctor && "Unregistered pass name");
31 setDefault(Ctor);
34 /// Add - Adds a function pass to the registration list.
35 ///
36 void MachinePassRegistry::Add(MachinePassRegistryNode *Node) {
37 Node->setNext(List);
38 List = Node;
39 if (Listener) Listener->NotifyAdd(Node->getName(),
40 Node->getCtor(),
41 Node->getDescription());
45 /// Remove - Removes a function pass from the registration list.
46 ///
47 void MachinePassRegistry::Remove(MachinePassRegistryNode *Node) {
48 for (MachinePassRegistryNode **I = &List; *I; I = (*I)->getNextAddress()) {
49 if (*I == Node) {
50 if (Listener) Listener->NotifyRemove(Node->getName());
51 *I = (*I)->getNext();
52 break;