From: Giacomo Travaglini Date: Fri, 15 Dec 2017 10:03:19 +0000 (+0000) Subject: arch-arm: Instruction size methods in StaticInst class X-Git-Tag: v19.0.0.0~2420 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1e05c299820e1e795ba1bb090ec823db90833ec7;p=gem5.git arch-arm: Instruction size methods in StaticInst class This patch is introducing some methods in StaticInst so that is possible to get the instruction size in byte of the instruction (can be 2 bytes in Thumb) and the correct opcode (The machInst field contains some appended metadata) Change-Id: I3bed4d9fd7c77feaeded40ded192afe445d306ea Signed-off-by: Giacomo Travaglini Reviewed-by: Andreas Sandberg Reviewed-on: https://gem5-review.googlesource.com/6781 Maintainer: Andreas Sandberg --- diff --git a/src/arch/arm/insts/static_inst.hh b/src/arch/arm/insts/static_inst.hh index 431e81b07..4595646cb 100644 --- a/src/arch/arm/insts/static_inst.hh +++ b/src/arch/arm/insts/static_inst.hh @@ -423,6 +423,25 @@ class ArmStaticInst : public StaticInst { return intWidth; } + + /** Returns the byte size of current instruction */ + ssize_t + instSize() const + { + return (!machInst.thumb || machInst.bigThumb) ? 4 : 2; + } + + /** + * Returns the real encoding of the instruction: + * the machInst field is in fact always 64 bit wide and + * contains some instruction metadata, which means it differs + * from the real opcode. + */ + MachInst + encoding() const + { + return static_cast(mask(instSize() * 8)); + } }; }