LLVM: include/llvm/ADT/ilist_node.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15#ifndef LLVM_ADT_ILIST_NODE_H

16#define LLVM_ADT_ILIST_NODE_H

17

20

21#include <type_traits>

22

23namespace llvm {

24

26

28

29

30

31

33public:

34 inline const ParentTy *getParent() const {

35 return static_cast<const NodeTy *>(this)->getNodeBaseParent();

36 }

38 return static_cast<NodeTy *>(this)->getNodeBaseParent();

39 }

41 return static_cast<NodeTy *>(this)->setNodeBaseParent(Parent);

42 }

43};

45

46}

47

48template <class OptionsT, bool IsReverse, bool IsConst> class ilist_iterator;

49template <class OptionsT, bool IsReverse, bool IsConst>

52

53

54template <class OptionsT, bool IsReverse, bool IsConst>

56 std::conditional_t<OptionsT::has_iterator_bits,

59

60

61

62

63

64

65

66

67

68template

70 : OptionsT::node_base_type,

72 typename OptionsT::parent_ty> {

73 using value_type = typename OptionsT::value_type;

74 using node_base_type = typename OptionsT::node_base_type;

75 using list_base_type = typename OptionsT::list_base_type;

76

77 friend typename OptionsT::list_base_type;

80

82 typename OptionsT::parent_ty>;

91

92protected:

99

101

102private:

104 return static_cast<ilist_node_impl *>(node_base_type::getPrev());

105 }

106

108 return static_cast<ilist_node_impl *>(node_base_type::getNext());

109 }

110

112 return static_cast<ilist_node_impl *>(node_base_type::getPrev());

113 }

114

116 return static_cast<ilist_node_impl *>(node_base_type::getNext());

117 }

118

121

122public:

125

129

133

134

135 using node_base_type::isKnownSentinel;

136

137

138

139

140

141

142

143

144

145

146 template

147 std::enable_if_t<T::is_sentinel_tracking_explicit, bool> isSentinel() const {

148 return node_base_type::isSentinel();

149 }

150};

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207template <class T, class... Options>

210 typename ilist_detail::compute_node_options<T, Options...>::type> {

212 "Unrecognized node option!");

213};

214

216

217

218

219

220

221

222

224protected:

225 template

229

230 template

235

236 template

238 return static_cast<typename OptionsT::pointer>(N);

239 }

240

241 template

242 static typename OptionsT::const_pointer

244 return static_cast<typename OptionsT::const_pointer>(N);

245 }

246

247 template

249 return N.getPrev();

250 }

251

252 template

254 return N.getNext();

255 }

256

257 template

260 return N.getPrev();

261 }

262

263 template

266 return N.getNext();

267 }

268};

269

271protected:

272 using pointer = typename OptionsT::pointer;

275

279

283

287

291};

292

293}

294

295template

297public:

299 this->initializeSentinel();

301 }

302

304 this->setPrev(this);

305 this->setNext(this);

306 }

307

308 bool empty() const { return this == this->getPrev(); }

309};

310

311

312

313

314

315template <typename NodeTy, typename ParentTy, class... Options>

317protected:

319

320private:

321

322

323

324

325

326 const ParentTy *getNodeParent() const {

327 return static_cast<const NodeTy *>(this)->getParent();

328 }

329

330public:

331

332

333

335

336

337 const auto &List =

338 getNodeParent()->*(ParentTy::getSublistAccess((NodeTy *)nullptr));

339 return List.getPrevNode(*static_cast<NodeTy *>(this));

340 }

341

342

346

347

349

350

351 const auto &List =

352 getNodeParent()->*(ParentTy::getSublistAccess((NodeTy *)nullptr));

353 return List.getNextNode(*static_cast<NodeTy *>(this));

354 }

355

356

360

361};

362

363}

364

365#endif

Mixin base class that is used to add getParent() and setParent(ParentTy*) methods to ilist_node_impl ...

Definition ilist_node.h:32

const ParentTy * getParent() const

Definition ilist_node.h:34

ParentTy * getParent()

Definition ilist_node.h:37

void setParent(ParentTy *Parent)

Definition ilist_node.h:40

Iterator for intrusive lists based on ilist_node.

Iterator for intrusive lists based on ilist_node.

Implementation for an ilist node.

Definition ilist_node.h:72

ilist_node_impl()=default

ilist_select_iterator_type< OptionsT, false, true > const_self_iterator

Definition ilist_node.h:94

const_reverse_self_iterator getReverseIterator() const

Definition ilist_node.h:130

ilist_select_iterator_type< OptionsT, true, false > reverse_self_iterator

Definition ilist_node.h:95

const_self_iterator getIterator() const

Definition ilist_node.h:124

reverse_self_iterator getReverseIterator()

Definition ilist_node.h:126

std::enable_if_t< T::is_sentinel_tracking_explicit, bool > isSentinel() const

Check whether this is the sentinel node.

Definition ilist_node.h:147

ilist_select_iterator_type< OptionsT, true, true > const_reverse_self_iterator

Definition ilist_node.h:97

self_iterator getIterator()

Definition ilist_node.h:123

ilist_select_iterator_type< OptionsT, false, false > self_iterator

Definition ilist_node.h:93

NodeTy * getPrevNode()

Definition ilist_node.h:334

const NodeTy * getPrevNode() const

Get the previous node, or nullptr for the list head.

Definition ilist_node.h:343

NodeTy * getNextNode()

Get the next node, or nullptr for the list tail.

Definition ilist_node.h:348

const NodeTy * getNextNode() const

Get the next node, or nullptr for the list tail.

Definition ilist_node.h:357

ilist_node_with_parent()=default

Definition ilist_node.h:210

Definition ilist_node.h:296

void reset()

Definition ilist_node.h:303

bool empty() const

Definition ilist_node.h:308

ilist_sentinel()

Definition ilist_node.h:298

This is an optimization pass for GlobalISel generic memory operations.

std::conditional_t< OptionsT::has_iterator_bits, ilist_iterator_w_bits< OptionsT, IsReverse, IsConst >, ilist_iterator< OptionsT, IsReverse, IsConst > > ilist_select_iterator_type

Definition ilist_node.h:55

An access class for ilist_node private API.

Definition ilist_node.h:223

static ilist_node_impl< OptionsT > * getPrev(ilist_node_impl< OptionsT > &N)

Definition ilist_node.h:248

static const ilist_node_impl< OptionsT > * getNext(const ilist_node_impl< OptionsT > &N)

Definition ilist_node.h:265

static ilist_node_impl< OptionsT > * getNext(ilist_node_impl< OptionsT > &N)

Definition ilist_node.h:253

static const ilist_node_impl< OptionsT > * getPrev(const ilist_node_impl< OptionsT > &N)

Definition ilist_node.h:259

static ilist_node_impl< OptionsT > * getNodePtr(typename OptionsT::pointer N)

Definition ilist_node.h:226

static const ilist_node_impl< OptionsT > * getNodePtr(typename OptionsT::const_pointer N)

Definition ilist_node.h:232

static OptionsT::pointer getValuePtr(ilist_node_impl< OptionsT > *N)

Definition ilist_node.h:237

static OptionsT::const_pointer getValuePtr(const ilist_node_impl< OptionsT > *N)

Definition ilist_node.h:243

Definition ilist_node.h:270

static pointer getValuePtr(node_type *N)

Definition ilist_node.h:284

typename OptionsT::const_pointer const_pointer

Definition ilist_node.h:273

static const_pointer getValuePtr(const node_type *N)

Definition ilist_node.h:288

static const node_type * getNodePtr(const_pointer N)

Definition ilist_node.h:280

ilist_node_impl< OptionsT > node_type

Definition ilist_node.h:274

static node_type * getNodePtr(pointer N)

Definition ilist_node.h:276

typename OptionsT::pointer pointer

Definition ilist_node.h:272

Check whether options are valid.