On 08/29/2015 07:58 AM, Peter Maydell wrote:
On 24 August 2015 at 17:17, Richard Henderson <r...@twiddle.net> wrote:
Signed-off-by: Richard Henderson <r...@twiddle.net>
---
  target-tilegx/translate.c | 99 +++++++++++++++++++++++++++++++++++++++++++++--
  1 file changed, 96 insertions(+), 3 deletions(-)

diff --git a/target-tilegx/translate.c b/target-tilegx/translate.c
index a2d597d..066d351 100644
--- a/target-tilegx/translate.c
+++ b/target-tilegx/translate.c
@@ -106,9 +106,64 @@ static void gen_exception(DisasContext *dc, TileExcp num)
      dc->exit_tb = true;
  }

+static bool check_gr(DisasContext *dc, uint8_t reg)
+{
+    if (likely(reg < TILEGX_R_COUNT)) {
+        return true;
+    }
+
+    switch (reg) {
+    case TILEGX_R_SN:
+    case TILEGX_R_ZERO:
+        break;
+    case TILEGX_R_IDN0:
+    case TILEGX_R_IDN1:
+        gen_exception(dc, TILEGX_EXCP_REG_IDN_ACCESS);
+        break;
+    case TILEGX_R_UDN0:
+    case TILEGX_R_UDN1:
+    case TILEGX_R_UDN2:
+    case TILEGX_R_UDN3:
+        gen_exception(dc, TILEGX_EXCP_REG_UDN_ACCESS);

Why does this function generate an exception immediately
rather than returning a TILEGX_EXCP_* code the way the
decode framework seems to be set up to work?

So that we can simply return a TCGv from the load_gr and dest_gr functions, and their users don't have to check for an error code.

r~

Reply via email to