Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. //===- SSAContext.h ---------------------------------------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. /// \file
  9. ///
  10. /// This file declares a specialization of the GenericSSAContext<X>
  11. /// class template for LLVM IR.
  12. ///
  13. //===----------------------------------------------------------------------===//
  14.  
  15. #ifndef LLVM_IR_SSACONTEXT_H
  16. #define LLVM_IR_SSACONTEXT_H
  17.  
  18. #include "llvm/ADT/GenericSSAContext.h"
  19. #include "llvm/IR/BasicBlock.h"
  20. #include "llvm/IR/ModuleSlotTracker.h"
  21. #include "llvm/Support/Printable.h"
  22.  
  23. #include <memory>
  24.  
  25. namespace llvm {
  26. class BasicBlock;
  27. class Function;
  28. class Instruction;
  29. class Value;
  30. template <typename> class SmallVectorImpl;
  31. template <typename, bool> class DominatorTreeBase;
  32.  
  33. inline auto instrs(const BasicBlock &BB) {
  34.   return llvm::make_range(BB.begin(), BB.end());
  35. }
  36.  
  37. template <> class GenericSSAContext<Function> {
  38.   Function *F;
  39.  
  40. public:
  41.   using BlockT = BasicBlock;
  42.   using FunctionT = Function;
  43.   using InstructionT = Instruction;
  44.   using ValueRefT = Value *;
  45.   using ConstValueRefT = const Value *;
  46.   static Value *ValueRefNull;
  47.   using DominatorTreeT = DominatorTreeBase<BlockT, false>;
  48.  
  49.   void setFunction(Function &Fn);
  50.   Function *getFunction() const { return F; }
  51.  
  52.   static BasicBlock *getEntryBlock(Function &F);
  53.   static const BasicBlock *getEntryBlock(const Function &F);
  54.  
  55.   static void appendBlockDefs(SmallVectorImpl<Value *> &defs,
  56.                               BasicBlock &block);
  57.   static void appendBlockDefs(SmallVectorImpl<const Value *> &defs,
  58.                               const BasicBlock &block);
  59.  
  60.   static void appendBlockTerms(SmallVectorImpl<Instruction *> &terms,
  61.                                BasicBlock &block);
  62.   static void appendBlockTerms(SmallVectorImpl<const Instruction *> &terms,
  63.                                const BasicBlock &block);
  64.  
  65.   static bool comesBefore(const Instruction *lhs, const Instruction *rhs);
  66.   static bool isConstantValuePhi(const Instruction &Instr);
  67.   const BasicBlock *getDefBlock(const Value *value) const;
  68.  
  69.   Printable print(const BasicBlock *Block) const;
  70.   Printable print(const Instruction *Inst) const;
  71.   Printable print(const Value *Value) const;
  72. };
  73.  
  74. using SSAContext = GenericSSAContext<Function>;
  75.  
  76. } // namespace llvm
  77.  
  78. #endif // LLVM_IR_SSACONTEXT_H
  79.