Jim Laskey | 9ff542f | 2006-08-01 18:29:48 +0000 | [diff] [blame] | 1 | //===-- CodeGen/MachineInstr.cpp ------------------------------------------===// |
Jim Laskey | c6a0a11 | 2006-08-01 16:31:08 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Jim Laskey | c6a0a11 | 2006-08-01 16:31:08 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Jim Laskey | 9ff542f | 2006-08-01 18:29:48 +0000 | [diff] [blame] | 9 | // |
| 10 | // This file contains the machine function pass registry for register allocators |
| 11 | // and instruction schedulers. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
Jim Laskey | c6a0a11 | 2006-08-01 16:31:08 +0000 | [diff] [blame] | 14 | |
| 15 | #include "llvm/CodeGen/MachinePassRegistry.h" |
Jim Laskey | c6a0a11 | 2006-08-01 16:31:08 +0000 | [diff] [blame] | 16 | |
| 17 | using namespace llvm; |
| 18 | |
David Blaikie | 2d24e2a | 2011-12-20 02:50:00 +0000 | [diff] [blame] | 19 | void MachinePassRegistryListener::anchor() { } |
Jim Laskey | eb577ba | 2006-08-02 12:30:23 +0000 | [diff] [blame] | 20 | |
Andrew Trick | fc728fb | 2012-04-19 01:34:10 +0000 | [diff] [blame] | 21 | /// setDefault - Set the default constructor by name. |
| 22 | void MachinePassRegistry::setDefault(StringRef Name) { |
| 23 | MachinePassCtor Ctor = 0; |
| 24 | for(MachinePassRegistryNode *R = getList(); R; R = R->getNext()) { |
| 25 | if (R->getName() == Name) { |
| 26 | Ctor = R->getCtor(); |
| 27 | break; |
| 28 | } |
| 29 | } |
| 30 | assert(Ctor && "Unregistered pass name"); |
| 31 | setDefault(Ctor); |
| 32 | } |
| 33 | |
Jim Laskey | eb577ba | 2006-08-02 12:30:23 +0000 | [diff] [blame] | 34 | /// Add - Adds a function pass to the registration list. |
Jim Laskey | c6a0a11 | 2006-08-01 16:31:08 +0000 | [diff] [blame] | 35 | /// |
Jim Laskey | eb577ba | 2006-08-02 12:30:23 +0000 | [diff] [blame] | 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()); |
| 42 | } |
Jim Laskey | c6a0a11 | 2006-08-01 16:31:08 +0000 | [diff] [blame] | 43 | |
| 44 | |
Jim Laskey | eb577ba | 2006-08-02 12:30:23 +0000 | [diff] [blame] | 45 | /// Remove - Removes a function pass from the registration list. |
Jim Laskey | c6a0a11 | 2006-08-01 16:31:08 +0000 | [diff] [blame] | 46 | /// |
Jim Laskey | eb577ba | 2006-08-02 12:30:23 +0000 | [diff] [blame] | 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; |
| 53 | } |
| 54 | } |
| 55 | } |