LLVM: lib/SandboxIR/BasicBlock.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

13

15

16BBIterator &BBIterator::operator++() {

17 auto ItE = BB->end();

18 assert(It != ItE && "Already at end!");

19 ++It;

20 if (It == ItE)

21 return *this;

23 unsigned Num = NextI.getNumOfIRInstrs();

24 assert(Num > 0 && "Bad getNumOfIRInstrs()");

25 It = std::next(It, Num - 1);

26 return *this;

27}

28

29BBIterator &BBIterator::operator--() {

30 assert(It != BB->begin() && "Already at begin!");

31 if (It == BB->end()) {

32 --It;

33 return *this;

34 }

36 unsigned Num = CurrI.getNumOfIRInstrs();

37 assert(Num > 0 && "Bad getNumOfIRInstrs()");

38 assert(std::prev(It, Num - 1) != BB->begin() && "Already at begin!");

39 It = std::prev(It, Num);

40 return *this;

41}

43BasicBlock *BBIterator::getNodeParent() const {

44 llvm::BasicBlock *Parent = const_cast<BBIterator *>(this)->It.getNodeParent();

46}

47

48BasicBlock::iterator::pointer

51}

52

55 auto *F = BB->getParent();

56 if (F == nullptr)

57

58 return nullptr;

60}

61

62void BasicBlock::buildBasicBlockFromLLVMIR(llvm::BasicBlock *LLVMBB) {

65 Ctx.getOrCreateValue(I);

67

69 continue;

70 Ctx.getOrCreateValue(Op);

71 }

72 }

73#if !defined(NDEBUG)

75#endif

76}

77

81 if (!BB->empty()) {

82 auto *V = Ctx.getValue(&*BB->begin());

83 assert(V != nullptr && "No SandboxIR for BB->begin()!");

85 unsigned Num = I->getNumOfIRInstrs();

86 assert(Num >= 1u && "Bad getNumOfIRInstrs()");

87 It = std::next(It, Num - 1);

88 }

90}

91

93 auto *TerminatorV =

96}

97

102 assert(SBI != nullptr && "Expected Instr!");

103 return *SBI;

104}

105

110 assert(SBI != nullptr && "Expected Instr!");

111 return *SBI;

112}

113

114#ifndef NDEBUG

115void BasicBlock::dumpOS(raw_ostream &OS) const {

117 const auto &Name = BB->getName();

118 OS << Name;

119 if (!Name.empty())

120 OS << ":\n";

121

122

124 return Ctx.getValue(&I) == nullptr;

126 OS << "<Crash-proof mode!>\n";

129 Value *SBV = Ctx.getValue(&IRef);

130 if (SBV == nullptr)

131 OS << IRef << " *** No SandboxIR ***\n";

132 else {

134 if (SBI == nullptr) {

135 OS << IRef << " *** Not a SBInstruction!!! ***\n";

136 } else {

137 if (Visited.insert(SBI).second)

138 OS << *SBI << "\n";

139 }

140 }

141 }

142 } else {

143 for (auto &SBI : *this) {

144 SBI.dumpOS(OS);

145 OS << "\n";

146 }

147 }

148}

149

150void BasicBlock::verify() const {

152 for (const auto &I : *this) {

153 I.verify();

154 }

155}

156#endif

157

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

MachineInstr unsigned OpIdx

LLVM Basic Block Representation.

iterator begin()

Instruction iterator methods.

const Function * getParent() const

Return the enclosing method, or null if none.

reverse_iterator rbegin()

const Instruction & back() const

const Instruction & front() const

InstListType::iterator iterator

Instruction iterators...

const Instruction * getTerminator() const LLVM_READONLY

Returns the terminator instruction if the block is well formed or null if the block is not well forme...

Implements a dense probed hash-table based set.

LLVM Value Representation.

LLVM_ABI StringRef getName() const

Return a constant reference to the value's name.

std::pair< iterator, bool > insert(const ValueT &V)

This class implements an extremely fast bulk output stream that can only output to a stream.

A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...

Context & getContext() const

void verify() const final

LLVM_ABI Instruction * getTerminator() const

auto enumerate(FirstRange &&First, RestRanges &&...Rest)

Given two or more input ranges, returns a new range whose values are tuples (A, B,...

decltype(auto) dyn_cast(const From &Val)

dyn_cast - Return the argument parameter cast to the specified type.

auto cast_or_null(const Y &Val)

bool any_of(R &&range, UnaryPredicate P)

Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.

auto reverse(ContainerTy &&C)

bool isa(const From &Val)

isa - Return true if the parameter to the template is an instance of one of the template type argu...

DWARFExpression::Operation Op

decltype(auto) cast(const From &Val)

cast - Return the argument parameter cast to the specified type.