diff options
author | David Malcolm <dmalcolm@redhat.com> | 2014-08-27 19:56:45 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2014-08-27 19:56:45 +0000 |
commit | 84fa8d9c4ed2aa3ffc3dded1f3ac9b5bb9ac29e0 (patch) | |
tree | 57d0d3617696d35854f93f5402c37f095a9381ad /gcc/rtl.h | |
parent | 3dc99c19a5203597ca0bf8f39aea7028f17e80ba (diff) | |
download | gcc-84fa8d9c4ed2aa3ffc3dded1f3ac9b5bb9ac29e0.zip gcc-84fa8d9c4ed2aa3ffc3dded1f3ac9b5bb9ac29e0.tar.gz gcc-84fa8d9c4ed2aa3ffc3dded1f3ac9b5bb9ac29e0.tar.bz2 |
Introduce rtx_sequence subclass of rtx_def
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
Diffstat (limited to 'gcc/rtl.h')
-rw-r--r-- | gcc/rtl.h | 52 |
1 files changed, 52 insertions, 0 deletions
@@ -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. |