LLVM API Documentation

MachinePassRegistry.cpp
Go to the documentation of this file.
00001 //===-- CodeGen/MachineInstr.cpp ------------------------------------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains the machine function pass registry for register allocators
00011 // and instruction schedulers.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #include "llvm/CodeGen/MachinePassRegistry.h"
00016 
00017 using namespace llvm;
00018 
00019 void MachinePassRegistryListener::anchor() { }
00020 
00021 /// setDefault - Set the default constructor by name.
00022 void MachinePassRegistry::setDefault(StringRef Name) {
00023   MachinePassCtor Ctor = nullptr;
00024   for(MachinePassRegistryNode *R = getList(); R; R = R->getNext()) {
00025     if (R->getName() == Name) {
00026       Ctor = R->getCtor();
00027       break;
00028     }
00029   }
00030   assert(Ctor && "Unregistered pass name");
00031   setDefault(Ctor);
00032 }
00033 
00034 /// Add - Adds a function pass to the registration list.
00035 ///
00036 void MachinePassRegistry::Add(MachinePassRegistryNode *Node) {
00037   Node->setNext(List);
00038   List = Node;
00039   if (Listener) Listener->NotifyAdd(Node->getName(),
00040                                     Node->getCtor(),
00041                                     Node->getDescription());
00042 }
00043 
00044 
00045 /// Remove - Removes a function pass from the registration list.
00046 ///
00047 void MachinePassRegistry::Remove(MachinePassRegistryNode *Node) {
00048   for (MachinePassRegistryNode **I = &List; *I; I = (*I)->getNextAddress()) {
00049     if (*I == Node) {
00050       if (Listener) Listener->NotifyRemove(Node->getName());
00051       *I = (*I)->getNext();
00052       break;
00053     }
00054   }
00055 }