1*9880d681SAndroid Build Coastguard Worker //===-- CodeGen/MachineInstr.cpp ------------------------------------------===// 2*9880d681SAndroid Build Coastguard Worker // 3*9880d681SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 4*9880d681SAndroid Build Coastguard Worker // 5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source 6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details. 7*9880d681SAndroid Build Coastguard Worker // 8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 9*9880d681SAndroid Build Coastguard Worker // 10*9880d681SAndroid Build Coastguard Worker // This file contains the machine function pass registry for register allocators 11*9880d681SAndroid Build Coastguard Worker // and instruction schedulers. 12*9880d681SAndroid Build Coastguard Worker // 13*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 14*9880d681SAndroid Build Coastguard Worker 15*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/MachinePassRegistry.h" 16*9880d681SAndroid Build Coastguard Worker 17*9880d681SAndroid Build Coastguard Worker using namespace llvm; 18*9880d681SAndroid Build Coastguard Worker anchor()19*9880d681SAndroid Build Coastguard Workervoid MachinePassRegistryListener::anchor() { } 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard Worker /// setDefault - Set the default constructor by name. setDefault(StringRef Name)22*9880d681SAndroid Build Coastguard Workervoid MachinePassRegistry::setDefault(StringRef Name) { 23*9880d681SAndroid Build Coastguard Worker MachinePassCtor Ctor = nullptr; 24*9880d681SAndroid Build Coastguard Worker for(MachinePassRegistryNode *R = getList(); R; R = R->getNext()) { 25*9880d681SAndroid Build Coastguard Worker if (R->getName() == Name) { 26*9880d681SAndroid Build Coastguard Worker Ctor = R->getCtor(); 27*9880d681SAndroid Build Coastguard Worker break; 28*9880d681SAndroid Build Coastguard Worker } 29*9880d681SAndroid Build Coastguard Worker } 30*9880d681SAndroid Build Coastguard Worker assert(Ctor && "Unregistered pass name"); 31*9880d681SAndroid Build Coastguard Worker setDefault(Ctor); 32*9880d681SAndroid Build Coastguard Worker } 33*9880d681SAndroid Build Coastguard Worker 34*9880d681SAndroid Build Coastguard Worker /// Add - Adds a function pass to the registration list. 35*9880d681SAndroid Build Coastguard Worker /// Add(MachinePassRegistryNode * Node)36*9880d681SAndroid Build Coastguard Workervoid MachinePassRegistry::Add(MachinePassRegistryNode *Node) { 37*9880d681SAndroid Build Coastguard Worker Node->setNext(List); 38*9880d681SAndroid Build Coastguard Worker List = Node; 39*9880d681SAndroid Build Coastguard Worker if (Listener) Listener->NotifyAdd(Node->getName(), 40*9880d681SAndroid Build Coastguard Worker Node->getCtor(), 41*9880d681SAndroid Build Coastguard Worker Node->getDescription()); 42*9880d681SAndroid Build Coastguard Worker } 43*9880d681SAndroid Build Coastguard Worker 44*9880d681SAndroid Build Coastguard Worker 45*9880d681SAndroid Build Coastguard Worker /// Remove - Removes a function pass from the registration list. 46*9880d681SAndroid Build Coastguard Worker /// Remove(MachinePassRegistryNode * Node)47*9880d681SAndroid Build Coastguard Workervoid MachinePassRegistry::Remove(MachinePassRegistryNode *Node) { 48*9880d681SAndroid Build Coastguard Worker for (MachinePassRegistryNode **I = &List; *I; I = (*I)->getNextAddress()) { 49*9880d681SAndroid Build Coastguard Worker if (*I == Node) { 50*9880d681SAndroid Build Coastguard Worker if (Listener) Listener->NotifyRemove(Node->getName()); 51*9880d681SAndroid Build Coastguard Worker *I = (*I)->getNext(); 52*9880d681SAndroid Build Coastguard Worker break; 53*9880d681SAndroid Build Coastguard Worker } 54*9880d681SAndroid Build Coastguard Worker } 55*9880d681SAndroid Build Coastguard Worker } 56