LLVM: include/llvm/IR/ValueHandle.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13#ifndef LLVM_IR_VALUEHANDLE_H

14#define LLVM_IR_VALUEHANDLE_H

15

21#include

22

23namespace llvm {

24

25

26

27

28

29

32

33protected:

34

35

36

37

39

42

44 : PrevPair(nullptr, Kind), Val(RHS.getValPtr()) {

46 AddToExistingUseList(RHS.getPrevPtr());

47 }

48

49private:

52 Value *Val = nullptr;

53

54 void setValPtr(Value *V) { Val = V; }

55

56public:

58 : PrevPair(nullptr, Kind) {}

60 : PrevPair(nullptr, Kind), Val(V) {

62 AddToUseList();

63 }

64

69

72 return RHS;

75 setValPtr(RHS);

77 AddToUseList();

78 return RHS;

79 }

80

83 return RHS.getValPtr();

86 setValPtr(RHS.getValPtr());

88 AddToExistingUseList(RHS.getPrevPtr());

90 }

91

95 assert(V && "Dereferencing deleted ValueHandle");

96 return *V;

97 }

98

99protected:

101

107

108

110

111

112

113

114

116

117public:

118

121

122private:

123

126 void setPrevPtr(ValueHandleBase **Ptr) { PrevPair.setPointer(Ptr); }

127

128

129

130

131

133

134

136

137

138 LLVM_ABI void AddToUseList();

139};

140

141

142

143

144

146public:

151

153

160

164};

165

166

167

178

179

197

198

199

200

201

202

203

204

206public:

211

213

220

224

228};

229

230

231

239

241 return WVH;

242 }

243};

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260template

262#if LLVM_ENABLE_ABI_BREAKING_CHECKS

264#endif

265{

267

268#if LLVM_ENABLE_ABI_BREAKING_CHECKS

271#else

273 Value *getRawValPtr() const { return ThePtr; }

274 void setRawValPtr(Value *P) { ThePtr = P; }

275#endif

276

277 static Value *GetAsValue(Value *V) { return V; }

278 static Value *GetAsValue(const Value *V) { return const_cast<Value*>(V); }

279

280 ValueTy *getValPtr() const { return static_cast<ValueTy *>(getRawValPtr()); }

281 void setValPtr(ValueTy *P) { setRawValPtr(GetAsValue(P)); }

282

283public:

284#if LLVM_ENABLE_ABI_BREAKING_CHECKS

288#else

292#endif

293

294 operator ValueTy*() const {

295 return getValPtr();

296 }

297

299 setValPtr(RHS);

300 return getValPtr();

301 }

303 setValPtr(RHS.getValPtr());

304 return getValPtr();

305 }

306

307 ValueTy *operator->() const { return getValPtr(); }

308 ValueTy &operator*() const { return *getValPtr(); }

309};

310

311

312

313template

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

334

335public:

337 assert(InnerHandle.pointsToAliveValue() &&

338 "TrackingVH must be non-null and valid on dereference!");

339

340

341

342

343

345 "Tracked Value was replaced by one with an invalid type!");

347 }

348

354

355

356

359

360public:

363

364 operator ValueTy*() const {

366 }

367

372

375};

376

377

378

379

380

381

382

383

385 virtual void anchor();

386protected:

390

394

395public:

399

403

404

405

406

407

408

409

410

411

412

413

414

416

417

418

419

420

421

422

423

425};

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445template

447#if LLVM_ENABLE_ABI_BREAKING_CHECKS

449#endif

450{

452

453

454 static Value *GetAsValue(Value *V) { return V; }

455 static Value *GetAsValue(const Value *V) { return const_cast<Value *>(V); }

456

457#if LLVM_ENABLE_ABI_BREAKING_CHECKS

458

459

460

461

462

463

464 bool Poisoned = false;

465

468

469

470 void deleted() override {

471 assert(!Poisoned && "Tried to delete an already poisoned handle!");

472 Poisoned = true;

473 RemoveFromUseList();

474 }

475

476

477 void allUsesReplacedWith(Value *) override {

478 assert(!Poisoned && "Tried to RAUW an already poisoned handle!");

479 Poisoned = true;

480 RemoveFromUseList();

481 }

482#else

483 Value *ThePtr = nullptr;

484

485 Value *getRawValPtr() const { return ThePtr; }

486 void setRawValPtr(Value *P) { ThePtr = P; }

487#endif

488

489 ValueTy *getValPtr() const {

490#if LLVM_ENABLE_ABI_BREAKING_CHECKS

491 assert(!Poisoned && "Accessed a poisoned value handle!");

492#endif

493 return static_cast<ValueTy *>(getRawValPtr());

494 }

495 void setValPtr(ValueTy *P) { setRawValPtr(GetAsValue(P)); }

496

497public:

499#if LLVM_ENABLE_ABI_BREAKING_CHECKS

503

504 ~PoisoningVH() {

505 if (Poisoned)

506 clearValPtr();

507 }

508

510 if (Poisoned)

511 clearValPtr();

513 Poisoned = RHS.Poisoned;

514 return *this;

515 }

516#else

518#endif

519

520 operator ValueTy *() const { return getValPtr(); }

521

522 ValueTy *operator->() const { return getValPtr(); }

523 ValueTy &operator*() const { return *getValPtr(); }

524};

525

526

533

539

543

546 RHS.getRawValPtr());

547 }

548

549

550

551

555

559};

560

561}

562

563#endif

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

This file defines DenseMapInfo traits for DenseMap.

This file defines the PointerIntPair class.

Value handle that asserts if the Value is deleted.

Definition ValueHandle.h:265

ValueTy * operator=(ValueTy *RHS)

Definition ValueHandle.h:298

AssertingVH()

Definition ValueHandle.h:289

ValueTy & operator*() const

Definition ValueHandle.h:308

ValueTy * operator=(const AssertingVH< ValueTy > &RHS)

Definition ValueHandle.h:302

ValueTy * operator->() const

Definition ValueHandle.h:307

AssertingVH(ValueTy *P)

Definition ValueHandle.h:290

AssertingVH(const AssertingVH &)=default

Value handle with callbacks on RAUW and destruction.

Definition ValueHandle.h:384

virtual void allUsesReplacedWith(Value *)

Callback for Value RAUW.

Definition ValueHandle.h:424

CallbackVH(const Value *P)

Definition ValueHandle.h:398

CallbackVH & operator=(const CallbackVH &)=default

CallbackVH(Value *P)

Definition ValueHandle.h:397

CallbackVH(const CallbackVH &)=default

CallbackVH()

Definition ValueHandle.h:396

virtual void deleted()

Callback for Value destruction.

Definition ValueHandle.h:415

void setValPtr(Value *P)

Definition ValueHandle.h:391

PointerIntPair - This class implements a pair of a pointer and small integer.

PointerTy getPointer() const

Value handle that poisons itself if the Value is deleted.

Definition ValueHandle.h:450

ValueTy & operator*() const

Definition ValueHandle.h:523

ValueTy * operator->() const

Definition ValueHandle.h:522

PoisoningVH(ValueTy *P)

Definition ValueHandle.h:517

ValueTy * operator->() const

Definition ValueHandle.h:373

ValueTy * getValPtr() const

Definition ValueHandle.h:336

static Value * GetAsValue(const Value *V)

Definition ValueHandle.h:358

static Value * GetAsValue(Value *V)

Definition ValueHandle.h:357

ValueTy & operator*() const

Definition ValueHandle.h:374

void setValPtr(ValueTy *P)

Definition ValueHandle.h:349

ValueTy * operator=(ValueTy *RHS)

Definition ValueHandle.h:368

TrackingVH(ValueTy *P)

Definition ValueHandle.h:362

This is the common base class of value handles.

Definition ValueHandle.h:30

Value & operator*() const

Definition ValueHandle.h:93

ValueHandleBase(HandleBaseKind Kind, Value *V)

Definition ValueHandle.h:59

static bool isValid(Value *V)

Definition ValueHandle.h:102

LLVM_ABI void RemoveFromUseList()

Remove this ValueHandle from its current use list.

Value * operator->() const

Definition ValueHandle.h:92

Value * operator=(Value *RHS)

Definition ValueHandle.h:70

Value * operator=(const ValueHandleBase &RHS)

Definition ValueHandle.h:81

~ValueHandleBase()

Definition ValueHandle.h:65

Value * getValPtr() const

Definition ValueHandle.h:100

static LLVM_ABI void ValueIsDeleted(Value *V)

void clearValPtr()

Clear the underlying pointer without clearing the use list.

Definition ValueHandle.h:115

ValueHandleBase(HandleBaseKind Kind)

Definition ValueHandle.h:57

static LLVM_ABI void ValueIsRAUWd(Value *Old, Value *New)

HandleBaseKind

This indicates what sub class the handle actually is.

Definition ValueHandle.h:38

@ Weak

Definition ValueHandle.h:38

@ Assert

Definition ValueHandle.h:38

@ Callback

Definition ValueHandle.h:38

@ WeakTracking

Definition ValueHandle.h:38

friend class Value

Definition ValueHandle.h:31

ValueHandleBase(HandleBaseKind Kind, const ValueHandleBase &RHS)

Definition ValueHandle.h:43

ValueHandleBase(const ValueHandleBase &RHS)

Definition ValueHandle.h:40

LLVM Value Representation.

Value handle that is nullable, but tries to track the Value.

Definition ValueHandle.h:205

WeakTrackingVH()

Definition ValueHandle.h:207

WeakTrackingVH(Value *P)

Definition ValueHandle.h:208

WeakTrackingVH(const WeakTrackingVH &RHS)

Definition ValueHandle.h:209

Value * operator=(const ValueHandleBase &RHS)

Definition ValueHandle.h:217

Value * operator=(Value *RHS)

Definition ValueHandle.h:214

WeakTrackingVH & operator=(const WeakTrackingVH &RHS)=default

bool pointsToAliveValue() const

Definition ValueHandle.h:225

A nullable Value handle that is nullable.

Definition ValueHandle.h:145

WeakVH(Value *P)

Definition ValueHandle.h:148

WeakVH(const WeakVH &RHS)

Definition ValueHandle.h:149

WeakVH & operator=(const WeakVH &RHS)=default

WeakVH()

Definition ValueHandle.h:147

Value * operator=(const ValueHandleBase &RHS)

Definition ValueHandle.h:157

Value * operator=(Value *RHS)

Definition ValueHandle.h:154

This is an optimization pass for GlobalISel generic memory operations.

bool isa(const From &Val)

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

FunctionAddr VTableAddr Next

decltype(auto) cast(const From &Val)

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

static bool isEqual(const T *LHS, const PoisoningVH< T > &RHS)

Definition ValueHandle.h:556

static PoisoningVH< T > getTombstoneKey()

Definition ValueHandle.h:534

static unsigned getHashValue(const T *Val)

Definition ValueHandle.h:552

static unsigned getHashValue(const PoisoningVH< T > &Val)

Definition ValueHandle.h:540

static bool isEqual(const PoisoningVH< T > &LHS, const PoisoningVH< T > &RHS)

Definition ValueHandle.h:544

static PoisoningVH< T > getEmptyKey()

Definition ValueHandle.h:528

static bool isEqual(const WeakVH &LHS, const WeakVH &RHS)

Definition ValueHandle.h:193

static unsigned getHashValue(const WeakVH &Val)

Definition ValueHandle.h:189

static WeakVH getEmptyKey()

Definition ValueHandle.h:181

static WeakVH getTombstoneKey()

Definition ValueHandle.h:185

An information struct used to provide DenseMap with the various necessary components for a given valu...

Value * SimpleType

Definition ValueHandle.h:233

static SimpleType getSimplifiedValue(WeakTrackingVH &WVH)

Definition ValueHandle.h:235

static SimpleType getSimplifiedValue(WeakVH &WVH)

Definition ValueHandle.h:171

Value * SimpleType

Definition ValueHandle.h:169

Value * SimpleType

Definition ValueHandle.h:238

Value * SimpleType

Definition ValueHandle.h:174

static SimpleType getSimplifiedValue(const WeakVH &WVH)

Definition ValueHandle.h:176

Define a template that can be specialized by smart pointers to reflect the fact that they are automat...

static SimpleType & getSimplifiedValue(From &Val)