+static inline void
+generate_trap(DisasContext *ctx, int class, int tin)
+{
+ TCGv_i32 classtemp = tcg_const_i32(class);
+ gen_save_pc(ctx->pc);
+ /* upper context cannot be saved, if the context list is empty */
+ if (class != TRAPC_SYSCALL) {
+ gen_helper_svucx(cpu_env);
+ }
+ /* Tin is loaded into d[15] */
+ tcg_gen_movi_tl(cpu_gpr_d[15], tin);
+ /* The return address in A[11] is updated. */
+ if (class == TRAPC_SYSCALL) {
+ tcg_gen_movi_tl(cpu_gpr_a[11], ctx->next_pc);
+ } else {
+ tcg_gen_movi_tl(cpu_gpr_a[11], ctx->pc);
+ }
+ gen_helper_raise_exception_err(cpu_env, classtemp, 0);
+ tcg_temp_free(classtemp);
+}