Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(534)

Unified Diff: src/IceInst.h

Issue 709533002: Subzero: Implement InstList in terms of llvm::ilist<> . (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Add a comment explaining the ilist traits specialization Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceDefs.h ('k') | src/IceOperand.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceInst.h
diff --git a/src/IceInst.h b/src/IceInst.h
index 7c96e3f9e9b4cd74e4162bca5303f05ae3350e30..71da0b3d19f13dce0801b15fe126e07dcad37349 100644
--- a/src/IceInst.h
+++ b/src/IceInst.h
@@ -34,7 +34,7 @@ namespace Ice {
// InstHighLevel and InstTarget. High-level ICE instructions inherit
// from InstHighLevel, and low-level (target-specific) ICE
// instructions inherit from InstTarget.
-class Inst {
+class Inst : public llvm::ilist_node<Inst> {
Inst(const Inst &) = delete;
Inst &operator=(const Inst &) = delete;
@@ -838,4 +838,22 @@ protected:
} // end of namespace Ice
+// Override the default ilist traits so that Inst's private ctor and
+// deleted dtor aren't invoked.
+template <>
+struct llvm::ilist_traits<Ice::Inst> : public llvm::ilist_default_traits<
+ Ice::Inst> {
+ Ice::Inst *createSentinel() const {
+ return static_cast<Ice::Inst *>(&Sentinel);
+ }
+ static void destroySentinel(Ice::Inst *) {}
+ Ice::Inst *provideInitialHead() const { return createSentinel(); }
+ Ice::Inst *ensureHead(Ice::Inst *) const { return createSentinel(); }
+ static void noteHead(Ice::Inst *, Ice::Inst *) {}
+ void deleteNode(Ice::Inst *) {}
+
+private:
+ mutable ilist_half_node<Ice::Inst> Sentinel;
+};
+
#endif // SUBZERO_SRC_ICEINST_H
« no previous file with comments | « src/IceDefs.h ('k') | src/IceOperand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698