tcg: Introduce tcg_tbrel_diff
authorRichard Henderson <richard.henderson@linaro.org>
Thu, 5 Nov 2020 00:15:07 +0000 (16:15 -0800)
committerRichard Henderson <richard.henderson@linaro.org>
Thu, 7 Jan 2021 15:09:42 +0000 (05:09 -1000)
Reviewed-by: Joelle van Dyne <j@getutm.app>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
include/tcg/tcg.h

index e744a1ce02459660ec0a82e91bdbd6114685afc3..e6fce9a049d715fdd00cb3e633444718edbc2207 100644 (file)
@@ -1146,6 +1146,19 @@ static inline ptrdiff_t tcg_pcrel_diff(TCGContext *s, const void *target)
     return tcg_ptr_byte_diff(target, tcg_splitwx_to_rx(s->code_ptr));
 }
 
+/**
+ * tcg_tbrel_diff
+ * @s: the tcg context
+ * @target: address of the target
+ *
+ * Produce a difference, from the beginning of the current TB code
+ * to the destination address.
+ */
+static inline ptrdiff_t tcg_tbrel_diff(TCGContext *s, const void *target)
+{
+    return tcg_ptr_byte_diff(target, tcg_splitwx_to_rx(s->code_buf));
+}
+
 /**
  * tcg_current_code_size
  * @s: the tcg context