================
@@ -3186,6 +3151,197 @@ struct OperandTraits<BranchInst> : public 
VariadicOperandTraits<BranchInst> {};
 
 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BranchInst, Value)
 
+//===----------------------------------------------------------------------===//
+//                               UncondBrInst Class
+//===----------------------------------------------------------------------===//
+
+//===---------------------------------------------------------------------------
+/// Unconditional Branch instruction.
+///
+class UncondBrInst : public BranchInst {
+  constexpr static IntrusiveOperandsAllocMarker AllocMarker{1};
+
+  UncondBrInst(const UncondBrInst &BI);
+  LLVM_ABI explicit UncondBrInst(BasicBlock *IfTrue,
+                                 InsertPosition InsertBefore);
+
+protected:
+  // Note: Instruction needs to be a friend here to call cloneImpl.
+  friend class Instruction;
+
+  LLVM_ABI UncondBrInst *cloneImpl() const;
+
+public:
+  static UncondBrInst *Create(BasicBlock *IfTrue,
+                              InsertPosition InsertBefore = nullptr) {
+    return new (AllocMarker) UncondBrInst(IfTrue, InsertBefore);
+  }
+
+  /// Transparently provide more efficient getOperand methods.
+  DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+
+private:
+  // Hide methods.
+  using BranchInst::getCondition;
+  using BranchInst::isConditional;
+  using BranchInst::isUnconditional;
+  using BranchInst::setCondition;
+  using BranchInst::swapSuccessors;
+
+public:
+  unsigned getNumSuccessors() const { return 1; }
+
+  BasicBlock *getSuccessor(unsigned i = 0) const {
+    assert(i == 0 && "Successor # out of range for Branch!");
+    return cast_or_null<BasicBlock>(Op<-1>().get());
+  }
+
+  void setSuccessor(BasicBlock *NewSucc) { Op<-1>() = NewSucc; }
+  void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
+    assert(idx == 0 && "Successor # out of range for Branch!");
+    Op<-1>() = NewSucc;
+  }
+
+  iterator_range<succ_op_iterator> successors() {
+    return make_range(succ_op_iterator(value_op_begin()),
+                      succ_op_iterator(value_op_end()));
+  }
+
+  iterator_range<const_succ_op_iterator> successors() const {
+    return make_range(const_succ_op_iterator(value_op_begin()),
+                      const_succ_op_iterator(value_op_end()));
+  }
+
+  // Methods for support type inquiry through isa, cast, and dyn_cast:
+  static bool classof(const Instruction *I) {
+    return (I->getOpcode() == Instruction::UncondBr);
+  }
+  static bool classof(const Value *V) {
+    return isa<Instruction>(V) && classof(cast<Instruction>(V));
+  }
+};
+
+template <>
+struct OperandTraits<UncondBrInst>
+    : public FixedNumOperandTraits<UncondBrInst, 1> {};
+
+DEFINE_TRANSPARENT_OPERAND_ACCESSORS(UncondBrInst, Value)
+
+//===----------------------------------------------------------------------===//
+//                               CondBrInst Class
+//===----------------------------------------------------------------------===//
+
+//===---------------------------------------------------------------------------
+/// Conditional Branch instruction.
+///
+class CondBrInst : public BranchInst {
+  constexpr static IntrusiveOperandsAllocMarker AllocMarker{3};
+
+  CondBrInst(const CondBrInst &BI);
+  LLVM_ABI CondBrInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
+                      InsertPosition InsertBefore);
----------------
aengelke wrote:

I was just wondering whether we should use the opportunity for a consistent 
operand order? (i.e., have cond, true, false as written in the IR instead of 
the current true, false, cond.) Opinions?

https://github.com/llvm/llvm-project/pull/184027
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to