From: Sandipan Das Date: Sat, 6 Feb 2021 11:51:00 +0000 (+0530) Subject: arch-power: Add character compare instructions X-Git-Tag: develop-gem5-snapshot~36 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=22535322445c80df4f8c0979200a2d1211fd5edc;p=gem5.git arch-power: Add character compare instructions This adds the following instructions. * Compare Ranged Byte (cmprb) * Compare Equal Byte (cmpeqb) Change-Id: I12a9135bf302acd741abe27cb557e8e8bba82edc Signed-off-by: Sandipan Das --- diff --git a/src/arch/power/isa/decoder.isa b/src/arch/power/isa/decoder.isa index 63d3afc14..d5b2a341b 100644 --- a/src/arch/power/isa/decoder.isa +++ b/src/arch/power/isa/decoder.isa @@ -458,6 +458,30 @@ decode PO default Unknown::unknown() { cr = makeCRField((uint32_t)Ra, (uint32_t)Rb, xer.so); } }}); + + 192: cmprb({{ + uint32_t src1 = Ra_ub; + uint32_t src2 = Rb_uw; + uint8_t src2lo = src2 & 0xff; + uint8_t src2hi = (src2 >>= 8) & 0xff; + uint32_t res = (src2lo <= src1) & (src1 <= src2hi); + if (length) { + src2lo = (src2 >>= 8) & 0xff; + src2hi = (src2 >>= 8) & 0xff; + res = ((src2lo <= src1) & (src1 <= src2hi)) | res; + } + cr = res << 2; + }}); + + 224: cmpeqb({{ + // Based on "Determine if a word has a byte equal to n" + // from https://graphics.stanford.edu/~seander/bithacks.html + const uint64_t m1 = 0x0101010101010101; + const uint64_t m2 = 0x8080808080808080; + uint64_t res = Rb ^ (Ra_ub * m1); + res = (res - m1) & ~res & m2; + cr = (res != 0) << 2; + }}); } // Integer logic instructions use source registers Rs and Rb, diff --git a/src/arch/power/isa/formats/integer.isa b/src/arch/power/isa/formats/integer.isa index 9a3e0d8fd..87763698b 100644 --- a/src/arch/power/isa/formats/integer.isa +++ b/src/arch/power/isa/formats/integer.isa @@ -71,7 +71,7 @@ def template IntRcOeConstructor {{ let {{ -readXERCode = 'Xer xer = XER;' +readXERCode = 'M5_VAR_USED Xer xer = XER;' setXERCode = 'XER = xer;'