LLVM: include/llvm/Transforms/Utils/InstructionWorklist.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_TRANSFORMS_UTILS_INSTRUCTIONWORKLIST_H

10#define LLVM_TRANSFORMS_UTILS_INSTRUCTIONWORKLIST_H

11

20

21namespace llvm {

22

23

24

28

29

30

32

33public:

35

38

39 bool isEmpty() const { return Worklist.empty() && Deferred.empty(); }

40

41

42

43

45 if (Deferred.insert(I))

47 }

48

49

50

55

56

57

60 assert(I->getParent() && "Instruction not inserted yet?");

61

62 if (WorklistMap.insert(std::make_pair(I, Worklist.size())).second) {

64 Worklist.push_back(I);

65 }

66 }

67

72

74 if (Deferred.empty())

75 return nullptr;

76 return Deferred.pop_back_val();

77 }

78

80 Worklist.reserve(Size + 16);

81 WorklistMap.reserve(Size);

82 }

83

84

87 if (It != WorklistMap.end()) {

88

89 Worklist[It->second] = nullptr;

90 WorklistMap.erase(It);

91 }

92

93 Deferred.remove(I);

94 }

95

97 if (Worklist.empty())

98 return nullptr;

100 WorklistMap.erase(I);

101 return I;

102 }

103

104

105

107 for (User *U : I.users())

109 }

110

111

115

116

117 if (I->hasOneUse())

119 }

120 }

121

122

124 assert(WorklistMap.empty() && "Worklist empty, but map not?");

125 assert(Deferred.empty() && "Deferred instructions left over");

126

127

128 WorklistMap.clear();

129 }

130};

131

132}

133

134#endif

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

This file defines the DenseMap class.

This file implements a set that has insertion order iteration characteristics.

This file defines the SmallVector class.

DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT > iterator

void pushValue(Value *V)

Definition InstructionWorklist.h:68

Instruction * removeOne()

Definition InstructionWorklist.h:96

InstructionWorklist()=default

void pushUsersToWorkList(Instruction &I)

When an instruction is simplified, add all users of the instruction to the work lists because they mi...

Definition InstructionWorklist.h:106

void add(Instruction *I)

Add instruction to the worklist.

Definition InstructionWorklist.h:44

void push(Instruction *I)

Push the instruction onto the worklist stack.

Definition InstructionWorklist.h:58

InstructionWorklist & operator=(InstructionWorklist &&)=default

bool isEmpty() const

Definition InstructionWorklist.h:39

void addValue(Value *V)

Add value to the worklist if it is an instruction.

Definition InstructionWorklist.h:51

InstructionWorklist(InstructionWorklist &&)=default

void remove(Instruction *I)

Remove I from the worklist if it exists.

Definition InstructionWorklist.h:85

Instruction * popDeferred()

Definition InstructionWorklist.h:73

void zap()

Check that the worklist is empty and nuke the backing store for the map.

Definition InstructionWorklist.h:123

void handleUseCountDecrement(Value *V)

Should be called after decrementing the use-count on V.

Definition InstructionWorklist.h:112

void reserve(size_t Size)

Definition InstructionWorklist.h:79

A SetVector that performs no allocations if smaller than a certain size.

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

LLVM Value Representation.

This is an optimization pass for GlobalISel generic memory operations.

decltype(auto) dyn_cast(const From &Val)

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

LLVM_ABI raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

decltype(auto) cast(const From &Val)

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