From e270c78b73a7feac9c95aee780f7eab40fd6083d Mon Sep 17 00:00:00 2001 From: Sandipan Das Date: Thu, 7 Jun 2018 14:45:03 +0530 Subject: [PATCH] arch-power: Add fixed-point compare instructions This adds the following compare instructions: * Compare Ranged Byte (cmprb) * Compare Equal Byte (cmpeqb) Change-Id: I44765b3a9a8f0a3d81ecd6984efce3fd01ba4b24 Signed-off-by: Sandipan Das --- src/arch/power/isa/decoder.isa | 22 ++++++++++++++++++++++ src/arch/power/isa/formats/integer.isa | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/arch/power/isa/decoder.isa b/src/arch/power/isa/decoder.isa index bf1eaf941..2154de279 100644 --- a/src/arch/power/isa/decoder.isa +++ b/src/arch/power/isa/decoder.isa @@ -474,6 +474,28 @@ 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({{ + 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 3fa058bef..a22e4fd95 100644 --- a/src/arch/power/isa/formats/integer.isa +++ b/src/arch/power/isa/formats/integer.isa @@ -65,7 +65,7 @@ def template IntRcOeConstructor {{ let {{ -readXERCode = 'Xer xer = XER;' +readXERCode = 'Xer xer M5_VAR_USED = XER;' setXERCode = 'XER = xer;' -- 2.30.2