From d786ac1bffb0a11ed7afa39ecde4d723f024b6f6 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 14 Aug 2021 18:09:35 +0100 Subject: [PATCH] end loop condition in svp64 bc pseudo-code --- openpower/isa/svbranch.mdwn | 1 + src/openpower/decoder/isa/caller.py | 14 ++++---------- src/openpower/decoder/pseudo/pywriter.py | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/openpower/isa/svbranch.mdwn b/openpower/isa/svbranch.mdwn index 7caa7d3f..0c15a04d 100644 --- a/openpower/isa/svbranch.mdwn +++ b/openpower/isa/svbranch.mdwn @@ -66,6 +66,7 @@ Pseudo-code: if AA then NIA <-iea EXTS(BD || 0b00) else NIA <-iea CIA + EXTS(BD || 0b00) lr_ok <- 0b1 + end_loop <- 0b1 if LK & lr_ok then LR <-iea CIA + 4 Special Registers Altered: diff --git a/src/openpower/decoder/isa/caller.py b/src/openpower/decoder/isa/caller.py index 0026f332..6ff2435a 100644 --- a/src/openpower/decoder/isa/caller.py +++ b/src/openpower/decoder/isa/caller.py @@ -807,8 +807,7 @@ class ISACaller: self.namespace['sz'] = SelectableInt(sz, 1) self.namespace['SNZ'] = SelectableInt(bc_snz, 1) # use these to detect if the branch took place - self.namespace['ctr_ok'] = SelectableInt(0, 1) - self.namespace['cond_ok'] = SelectableInt(0, 1) + self.namespace['end_loop'] = SelectableInt(0, 1) def handle_carry_(self, inputs, outputs, already_done): inv_a = yield self.dec2.e.do.invert_in @@ -1797,10 +1796,9 @@ class ISACaller: self.namespace['SVSTATE'] = self.svstate # check if this was an sv.bc* and if so did it succeed if self.is_svp64_mode and insn_name.startswith("sv.bc"): - ctr_ok = self.namespace['ctr_ok'] - cond_ok = self.namespace['cond_ok'] - log("branch ctr/cond", ctr_ok, cond_ok) - if ctr_ok.value and cond_ok.value : + end_loop = self.namespace['end_loop'] + log("branch ctr/cond", end_loop) + if end_loop.value: self.svp64_reset_loop() self.update_pc_next() return True @@ -1868,10 +1866,6 @@ def inject(): args[0].namespace['NIA'], args[0].namespace['SVSTATE']) args[0].namespace = func_globals - if 'cond_ok' in args[0].namespace: - log("args[0] cond_ok ctr_ok", - args[0].namespace['cond_ok'], - args[0].namespace['ctr_ok']) #exec (func.__code__, func_globals) # finally: diff --git a/src/openpower/decoder/pseudo/pywriter.py b/src/openpower/decoder/pseudo/pywriter.py index 8cde6d19..efca91c9 100644 --- a/src/openpower/decoder/pseudo/pywriter.py +++ b/src/openpower/decoder/pseudo/pywriter.py @@ -96,7 +96,7 @@ class PyISAWriter(ISA): # blech! this works in combination with ISACaller # @inject decorator, which works by injecting # global variables into the function namespace. - for blech in ['NIA', 'cond_ok', 'ctr_ok']: + for blech in ['NIA', 'end_loop']: if blech in pycode: # HACK - TODO fix f.write(" global %s\n" % blech) pycode = pycode.split("\n") -- 2.30.2