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

1

2

3

4

5

6

7

8

11

13

15

17 assert(Use.LLVMUse != nullptr && "Already at end!");

20 return *this;

22

24

25

27 assert(LLVMUse != nullptr && "Already at end!");

28 LLVMUse = LLVMUse->getNext();

29 if (LLVMUse == nullptr) {

30 Use.Usr = nullptr;

31 return *this;

32 }

33 auto *Ctx = Use.Ctx;

34 auto *LLVMUser = LLVMUse->getUser();

35 Use.Usr = cast_or_nullsandboxir::User(Ctx->getValue(LLVMUser));

36 return *this;

37}

38

43}

44

51

54 int OtherOpNo = Other.Use.getOperandNo();

55 return ThisOpNo - OtherOpNo;

56}

57

60 assert(isallvm::User(Val) && "Non-users have no operands!");

63 LLVMUse = &castllvm::User(Val)->getOperandUse(OpIdx);

64 else

65 LLVMUse = castllvm::User(Val)->op_end();

66 return Use(LLVMUse, const_cast<User *>(this), Ctx);

68

69#ifndef NDEBUG

72 "Use not found in this SBUser's operands!");

73}

74#endif

75

77 switch (From->getSubclassID()) {

78#define DEF_VALUE(ID, CLASS)

79#define DEF_USER(ID, CLASS) \

80 case ClassID::ID: \

81 return true;

82#define DEF_INSTR(ID, OPC, CLASS) \

83 case ClassID::ID: \

84 return true;

85#include "llvm/SandboxIR/Values.def"

86 default:

87 return false;

88 }

89}

90

92 assert(isallvm::User(Val) && "No operands!");

94

95 castllvm::User(Val)->setOperand(OperandIdx, Operand->Val);

97

100 if (Tracker.isTracking()) {

101 for (auto OpIdx : seq(0, getNumOperands())) {

103 if (Use.get() == FromV)

104 Tracker.emplaceIfTracking(Use);

105 }

106 }

107

108 return castllvm::User(Val)->replaceUsesOfWith(FromV->Val, ToV->Val);

109}

110

111#ifndef NDEBUG

114

116#endif

117

118}

BlockVerifier::State From

ppc ctr loops PowerPC CTR Loops Verify

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

A Use represents the edge between a Value definition and its users.

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

sandboxir::Value * getValue(llvm::Value *V) const

Iterator for the Use edges of a User's operands.

OperandUseIterator()=default

OperandUseIterator operator-(unsigned Num) const

value_type operator*() const

OperandUseIterator & operator++()

OperandUseIterator operator+(unsigned Num) const

bool emplaceIfTracking(ArgsT... Args)

A convenience wrapper for track() that constructs and tracks the Change object if tracking is enabled...

Tracks the change of the source Value of a sandboxir::Use.

Represents a Def-use/Use-def edge in SandboxIR.

unsigned getOperandNo() const

class User * getUser() const

Iterator for the Use edges of a Value's users.

UserUseIterator & operator++()

A sandboxir::User has operands.

void verifyUserOfLLVMUse(const llvm::Use &Use) const

virtual void setOperand(unsigned OperandIdx, Value *Operand)

bool replaceUsesOfWith(Value *FromV, Value *ToV)

Replaces any operands that match FromV with ToV.

Use getOperandUseDefault(unsigned OpIdx, bool Verify) const

\Returns the Use edge that corresponds to OpIdx.

static bool classof(const Value *From)

For isa/dyn_cast.

virtual Use getOperandUseInternal(unsigned OpIdx, bool Verify) const =0

\Returns the Use for the OpIdx'th operand.

void dumpCommonHeader(raw_ostream &OS) const final

virtual unsigned getNumOperands() const

Use getOperandUse(unsigned OpIdx) const

\Returns the operand edge for OpIdx.

A SandboxIR Value has users. This is the base class.

llvm::Value * Val

The LLVM Value that corresponds to this SandboxIR Value.

virtual void dumpCommonHeader(raw_ostream &OS) const

Context & Ctx

All values point to the context.