]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Introduce rtx_sequence subclass of rtx_def
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 27 Aug 2014 19:56:45 +0000 (19:56 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Wed, 27 Aug 2014 19:56:45 +0000 (19:56 +0000)
gcc/
2014-08-27  David Malcolm  <dmalcolm@redhat.com>

* coretypes.h (class rtx_sequence): Add forward declaration.
* rtl.h (class rtx_sequence): New subclass of rtx_def, adding
invariant: GET_CODE (X) == SEQUENCE.
(is_a_helper <rtx_sequence *>::test): New.
(is_a_helper <const rtx_sequence *>::test): New.
(rtx_sequence::len): New.
(rtx_sequence::element): New.
(rtx_sequence::insn): New.

From-SVN: r214591

gcc/ChangeLog
gcc/coretypes.h
gcc/rtl.h

index b82355b0525d6d856c722c67a9f950cf2e5bd8ca..dce1cb407dfce4e4b4059c2e7442b2d8e97776ae 100644 (file)
@@ -1,3 +1,14 @@
+2014-08-27  David Malcolm  <dmalcolm@redhat.com>
+
+       * coretypes.h (class rtx_sequence): Add forward declaration.
+       * rtl.h (class rtx_sequence): New subclass of rtx_def, adding
+       invariant: GET_CODE (X) == SEQUENCE.
+       (is_a_helper <rtx_sequence *>::test): New.
+       (is_a_helper <const rtx_sequence *>::test): New.
+       (rtx_sequence::len): New.
+       (rtx_sequence::element): New.
+       (rtx_sequence::insn): New.
+
 2014-08-27  David Malcolm  <dmalcolm@redhat.com>
 
        * rtl.h (free_INSN_LIST_list): Strengthen param from rtx * to
index 99ddbdbaf145e8be7a15451fd5e07aa064615ffd..d5d4885a0ec32ba47d6b6c61ca1cc5508bb20f97 100644 (file)
@@ -61,6 +61,7 @@ typedef const struct rtx_def *const_rtx;
    Where possible, keep this list in the same order as in rtl.def.  */
 class rtx_def;
   class rtx_insn_list;           /* GET_CODE (X) == INSN_LIST */
+  class rtx_sequence;            /* GET_CODE (X) == SEQUENCE */
   class rtx_insn;
     class rtx_debug_insn;      /* DEBUG_INSN_P (X) */
     class rtx_nonjump_insn;    /* NONJUMP_INSN_P (X) */
index 0062a0c03f9ec11bf1d07b2631a1ac66ac83f60f..fe8201dca7287cd673937dbe718674bf637ef4b9 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -431,6 +431,41 @@ is_a_helper <rtx_insn_list *>::test (rtx rt)
   return rt->code == INSN_LIST;
 }
 
+/* A node with invariant GET_CODE (X) == SEQUENCE i.e. a vector of rtx,
+   typically (but not always) of rtx_insn *, used in the late passes.  */
+
+class GTY(()) rtx_sequence : public rtx_def
+{
+  /* No extra fields, but adds invariant: (GET_CODE (X) == SEQUENCE).  */
+
+public:
+  /* Get number of elements in sequence.  */
+  int len () const;
+
+  /* Get i-th element of the sequence.  */
+  rtx element (int index) const;
+
+  /* Get i-th element of the sequence, with a checked cast to
+     rtx_insn *.  */
+  rtx_insn *insn (int index) const;
+};
+
+template <>
+template <>
+inline bool
+is_a_helper <rtx_sequence *>::test (rtx rt)
+{
+  return rt->code == SEQUENCE;
+}
+
+template <>
+template <>
+inline bool
+is_a_helper <const rtx_sequence *>::test (const_rtx rt)
+{
+  return rt->code == SEQUENCE;
+}
+
 class GTY(()) rtx_insn : public rtx_def
 {
   /* No extra fields, but adds the invariant:
@@ -1212,6 +1247,23 @@ inline rtx_insn *rtx_insn_list::insn () const
   return safe_as_a <rtx_insn *> (tmp);
 }
 
+/* Methods of rtx_sequence.  */
+
+inline int rtx_sequence::len () const
+{
+  return XVECLEN (this, 0);
+}
+
+inline rtx rtx_sequence::element (int index) const
+{
+  return XVECEXP (this, 0, index);
+}
+
+inline rtx_insn *rtx_sequence::insn (int index) const
+{
+  return as_a <rtx_insn *> (XVECEXP (this, 0, index));
+}
+
 /* ACCESS MACROS for particular fields of insns.  */
 
 /* Holds a unique number for each insn.