From f47aa77982509d14bcc84cd47ec38f588b6ac832 Mon Sep 17 00:00:00 2001
From: Angus Gratton <gus@projectgus.com>
Date: Tue, 15 Sep 2015 15:09:42 +1000
Subject: [PATCH] Moved DoubleLoadStorageHandler to end of functions, improve
 fast path l8ui performance

This allows a conditional branch that previously required a full jump instruction not to require it.
---
 core/exception_unaligned_load.S.inc | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/core/exception_unaligned_load.S.inc b/core/exception_unaligned_load.S.inc
index 5540f72..03c9830 100644
--- a/core/exception_unaligned_load.S.inc
+++ b/core/exception_unaligned_load.S.inc
@@ -94,15 +94,6 @@ InnerLoadStoreExceptionHandler:
 	rfe
 
 
-	.literal_position
-/* "Fix" LoadStoreException exceptions that are l8/l16 from an Instruction region,
-   DoubleException exception variant (ie load happened in a level1 exception handler). */
-DoubleExceptionLoadStoreHandler:
-	addi sp, sp, -0x18
-	s32i a2, sp, 0x08
-	rsr.epc2 a2
-	j InnerLoadStoreExceptionHandler
-
 /* Check the load instruction a2 for an l16si/16ui instruction
 
    First test for a signed vs unsigned load.
@@ -187,4 +178,13 @@ DoubleExceptionLoadStoreHandler:
 	wsr.excsave1 a4
 	j .Lafter_write_value
 
+	.literal_position
+/* "Fix" LoadStoreException exceptions that are l8/l16 from an Instruction region,
+   DoubleException exception variant (ie load happened in a level1 exception handler). */
+DoubleExceptionLoadStoreHandler:
+	addi sp, sp, -0x18
+	s32i a2, sp, 0x08
+	rsr.epc2 a2
+	j InnerLoadStoreExceptionHandler
+
 /* End of InnerUserLoadStoreExceptionHandler */