MachineSSAContext.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- MachineSSAContext.h --------------------------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. /// \file
  14. ///
  15. /// This file declares a specialization of the GenericSSAContext<X>
  16. /// template class for Machine IR.
  17. ///
  18. //===----------------------------------------------------------------------===//
  19. #ifndef LLVM_CODEGEN_MACHINESSACONTEXT_H
  20. #define LLVM_CODEGEN_MACHINESSACONTEXT_H
  21. #include "llvm/ADT/GenericSSAContext.h"
  22. #include "llvm/CodeGen/MachineRegisterInfo.h"
  23. #include "llvm/Support/Printable.h"
  24. #include <memory>
  25. namespace llvm {
  26. class MachineInstr;
  27. class MachineBasicBlock;
  28. class MachineFunction;
  29. class Register;
  30. template <typename, bool> class DominatorTreeBase;
  31. inline auto successors(MachineBasicBlock *BB) { return BB->successors(); }
  32. inline auto predecessors(MachineBasicBlock *BB) { return BB->predecessors(); }
  33. template <> class GenericSSAContext<MachineFunction> {
  34. const MachineRegisterInfo *RegInfo = nullptr;
  35. MachineFunction *MF;
  36. public:
  37. using BlockT = MachineBasicBlock;
  38. using FunctionT = MachineFunction;
  39. using InstructionT = MachineInstr;
  40. using ValueRefT = Register;
  41. using DominatorTreeT = DominatorTreeBase<BlockT, false>;
  42. static MachineBasicBlock *getEntryBlock(MachineFunction &F);
  43. void setFunction(MachineFunction &Fn);
  44. MachineFunction *getFunction() const { return MF; }
  45. Printable print(MachineBasicBlock *Block) const;
  46. Printable print(MachineInstr *Inst) const;
  47. Printable print(Register Value) const;
  48. };
  49. using MachineSSAContext = GenericSSAContext<MachineFunction>;
  50. } // namespace llvm
  51. #endif // LLVM_CODEGEN_MACHINESSACONTEXT_H
  52. #ifdef __GNUC__
  53. #pragma GCC diagnostic pop
  54. #endif