Sort returned variables to make sure `overflow` is last
authorJacob Lifshay <programmerjake@gmail.com>
Mon, 5 Oct 2020 00:32:45 +0000 (17:32 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Mon, 5 Oct 2020 00:32:45 +0000 (17:32 -0700)
Fixes #509

src/soc/decoder/isa/caller.py

index 703721436b35e24464b8dbaf47ddb1e4cc6ca17d..bf84e05a4f6e5e4f383e89f51c3c7a2852f0a43e 100644 (file)
@@ -41,14 +41,34 @@ def swap_order(x, nbytes):
     return x
 
 
+REG_SORT_ORDER = {
+    # TODO (lkcl): adjust other registers that should be in a particular order
+    # probably CA, CA32, and CR
+    "RT": 0,
+    "RA": 0,
+    "RB": 0,
+    "RS": 0,
+    "CR": 0,
+    "LR": 0,
+    "CTR": 0,
+    "TAR": 0,
+    "CA": 0,
+    "CA32": 0,
+    "MSR": 0,
+
+    "overflow": 1,
+}
+
+
 def create_args(reglist, extra=None):
-    args = OrderedSet()
-    for reg in reglist:
-        args.add(reg)
-    args = list(args)
-    if extra:
-        args = [extra] + args
-    return args
+    regset = OrderedSet(reglist)
+    retval = []
+    for reg in regset:
+        retval.append(reg)
+    retval.sort(key=lambda reg: REG_SORT_ORDER[reg])
+    if extra is not None:
+        return [extra] + retval
+    return retval
 
 
 class Mem: