target/hexagon: move GETPC() calls to top level helpers
authorMatheus Tavares Bernardino <quic_mathbern@quicinc.com>
Sun, 8 Oct 2023 22:09:43 +0000 (15:09 -0700)
committerBrian Cain <bcain@quicinc.com>
Wed, 18 Oct 2023 23:56:17 +0000 (16:56 -0700)
commit3bd8359379c899f813049f1dd9e8f8a8817d8c98
tree724db0541465902d80863be646fda746dd9a092b
parentdeaca3fd30d3a8829160f8d3705d65ad83176800
target/hexagon: move GETPC() calls to top level helpers

As docs/devel/loads-stores.rst states:

  ``GETPC()`` should be used with great care: calling
  it in other functions that are *not* the top level
  ``HELPER(foo)`` will cause unexpected behavior. Instead, the
  value of ``GETPC()`` should be read from the helper and passed
  if needed to the functions that the helper calls.

Let's fix the GETPC() usage in Hexagon, making sure it's always called
from top level helpers and passed down to the places where it's
needed. There are a few snippets where that is not currently the case:

- probe_store(), which is only called from two helpers, so it's easy to
  move GETPC() up.

- mem_load*() functions, which are also called directly from helpers,
  but through the MEM_LOAD*() set of macros. Note that this are only
  used when compiling with --disable-hexagon-idef-parser.

  In this case, we also take this opportunity to simplify the code,
  unifying the mem_load*() functions.

- HELPER(probe_hvx_stores), when called from another helper, ends up
  using its own GETPC() expansion instead of the top level caller.

Signed-off-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com>
Reviewed-by: Taylor Simpson <ltaylorsimpson@gmail.com>
Message-Id: <2c74c3696946edba7cc5b2942cf296a5af532052.1689070412.git.quic_mathbern@quicinc.com>-ne
Reviewed-by: Brian Cain <bcain@quicinc.com>
Signed-off-by: Brian Cain <bcain@quicinc.com>
Message-Id: <20231008220945.983643-2-bcain@quicinc.com>
target/hexagon/macros.h
target/hexagon/op_helper.c
target/hexagon/op_helper.h