diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2017-08-30 11:18:37 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-08-30 11:18:37 +0000 |
commit | d305ca88fc9b180a1790e02b144e921d17b393f0 (patch) | |
tree | a2c9e2b70bbf121f659d36303df886bad0895c81 /gcc/rtl.h | |
parent | 2123a9a50fb35109af6c2ba3bcfd71a1d5432954 (diff) | |
download | gcc-d305ca88fc9b180a1790e02b144e921d17b393f0.zip gcc-d305ca88fc9b180a1790e02b144e921d17b393f0.tar.gz gcc-d305ca88fc9b180a1790e02b144e921d17b393f0.tar.bz2 |
[59/77] Add a rtx_jump_table_data::get_data_mode helper
This patch adds a helper function to get the mode of the addresses
or offsets in a jump table. It also changes the final.c code to use
rtx_jump_table_data over rtx or rtx_insn in cases where it needed
to use the new helper. This in turn meant adding a safe_dyn_cast
equivalent of safe_as_a, to cope with null NEXT_INSNs.
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
gcc/
* is-a.h (safe_dyn_cast): New function.
* rtl.h (rtx_jump_table_data::get_data_mode): New function.
(jump_table_for_label): Likewise.
* final.c (final_addr_vec_align): Take an rtx_jump_table_data *
instead of an rtx_insn *.
(shorten_branches): Use dyn_cast instead of LABEL_P and
JUMP_TABLE_DATA_P. Use jump_table_for_label and
rtx_jump_table_data::get_data_mode.
(final_scan_insn): Likewise.
Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>
From-SVN: r251511
Diffstat (limited to 'gcc/rtl.h')
-rw-r--r-- | gcc/rtl.h | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -634,6 +634,7 @@ public: This method gets the underlying vec. */ inline rtvec get_labels () const; + inline scalar_int_mode get_data_mode () const; }; class GTY(()) rtx_barrier : public rtx_insn @@ -1477,6 +1478,24 @@ inline rtvec rtx_jump_table_data::get_labels () const return XVEC (pat, 1); /* presumably an ADDR_DIFF_VEC */ } +/* Return the mode of the data in the table, which is always a scalar + integer. */ + +inline scalar_int_mode +rtx_jump_table_data::get_data_mode () const +{ + return as_a <scalar_int_mode> (GET_MODE (PATTERN (this))); +} + +/* If LABEL is followed by a jump table, return the table, otherwise + return null. */ + +inline rtx_jump_table_data * +jump_table_for_label (const rtx_code_label *label) +{ + return safe_dyn_cast <rtx_jump_table_data *> (NEXT_INSN (label)); +} + #define RTX_FRAME_RELATED_P(RTX) \ (RTL_FLAG_CHECK6 ("RTX_FRAME_RELATED_P", (RTX), DEBUG_INSN, INSN, \ CALL_INSN, JUMP_INSN, BARRIER, SET)->frame_related) |