blob: cb204fdb3492f1f2b0c90a6a2dc5d22715bc2867 [file] [log] [blame]
Jim Laskey9ff542f2006-08-01 18:29:48 +00001//===-- CodeGen/MachineInstr.cpp ------------------------------------------===//
Jim Laskeyc6a0a112006-08-01 16:31:08 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Jim Laskeyc6a0a112006-08-01 16:31:08 +00007//
8//===----------------------------------------------------------------------===//
Jim Laskey9ff542f2006-08-01 18:29:48 +00009//
10// This file contains the machine function pass registry for register allocators
11// and instruction schedulers.
12//
13//===----------------------------------------------------------------------===//
Jim Laskeyc6a0a112006-08-01 16:31:08 +000014
15#include "llvm/CodeGen/MachinePassRegistry.h"
Jim Laskeyc6a0a112006-08-01 16:31:08 +000016
17using namespace llvm;
18
David Blaikie2d24e2a2011-12-20 02:50:00 +000019void MachinePassRegistryListener::anchor() { }
Jim Laskeyeb577ba2006-08-02 12:30:23 +000020
Andrew Trickfc728fb2012-04-19 01:34:10 +000021/// setDefault - Set the default constructor by name.
22void 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 Laskeyeb577ba2006-08-02 12:30:23 +000034/// Add - Adds a function pass to the registration list.
Jim Laskeyc6a0a112006-08-01 16:31:08 +000035///
Jim Laskeyeb577ba2006-08-02 12:30:23 +000036void 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 Laskeyc6a0a112006-08-01 16:31:08 +000043
44
Jim Laskeyeb577ba2006-08-02 12:30:23 +000045/// Remove - Removes a function pass from the registration list.
Jim Laskeyc6a0a112006-08-01 16:31:08 +000046///
Jim Laskeyeb577ba2006-08-02 12:30:23 +000047void 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}