2
0

MachinePassRegistry.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #include "llvm/CodeGen/MachinePassRegistry.h"
  15. using namespace llvm;
  16. void MachinePassRegistryListener::anchor() { }
  17. /// setDefault - Set the default constructor by name.
  18. void MachinePassRegistry::setDefault(StringRef Name) {
  19. MachinePassCtor Ctor = nullptr;
  20. for(MachinePassRegistryNode *R = getList(); R; R = R->getNext()) {
  21. if (R->getName() == Name) {
  22. Ctor = R->getCtor();
  23. break;
  24. }
  25. }
  26. assert(Ctor && "Unregistered pass name");
  27. setDefault(Ctor);
  28. }
  29. /// Add - Adds a function pass to the registration list.
  30. ///
  31. void MachinePassRegistry::Add(MachinePassRegistryNode *Node) {
  32. Node->setNext(List);
  33. List = Node;
  34. if (Listener) Listener->NotifyAdd(Node->getName(),
  35. Node->getCtor(),
  36. Node->getDescription());
  37. }
  38. /// Remove - Removes a function pass from the registration list.
  39. ///
  40. void MachinePassRegistry::Remove(MachinePassRegistryNode *Node) {
  41. for (MachinePassRegistryNode **I = &List; *I; I = (*I)->getNextAddress()) {
  42. if (*I == Node) {
  43. if (Listener) Listener->NotifyRemove(Node->getName());
  44. *I = (*I)->getNext();
  45. break;
  46. }
  47. }
  48. }