diff options
author | Gabe Black <gblack@eecs.umich.edu> | 2007-08-26 20:36:46 -0700 |
---|---|---|
committer | Gabe Black <gblack@eecs.umich.edu> | 2007-08-26 20:36:46 -0700 |
commit | 506bf83595d0f941ade9e55a192c1d831fc4c90c (patch) | |
tree | 91473d4a02f175b19c26351f1e116de59659972c /src/arch/x86/isa/insts/string/compare_strings.py | |
parent | 00d9036c6221ce619cc933305b814e4784b15afa (diff) | |
download | gem5-506bf83595d0f941ade9e55a192c1d831fc4c90c.tar.xz |
X86: Implement cmps (string compare)
--HG--
extra : convert_revision : 0d6b783b2246b8ad8d91e4c63e407307ee11c651
Diffstat (limited to 'src/arch/x86/isa/insts/string/compare_strings.py')
-rw-r--r-- | src/arch/x86/isa/insts/string/compare_strings.py | 70 |
1 files changed, 57 insertions, 13 deletions
diff --git a/src/arch/x86/isa/insts/string/compare_strings.py b/src/arch/x86/isa/insts/string/compare_strings.py index 1484c4706..71b8511b4 100644 --- a/src/arch/x86/isa/insts/string/compare_strings.py +++ b/src/arch/x86/isa/insts/string/compare_strings.py @@ -53,16 +53,60 @@ # # Authors: Gabe Black -microcode = "" -#let {{ -# class CMPS(Inst): -# "GenFault ${new UnimpInstFault}" -# class CMPSB(Inst): -# "GenFault ${new UnimpInstFault}" -# class CMPSW(Inst): -# "GenFault ${new UnimpInstFault}" -# class CMPSD(Inst): -# "GenFault ${new UnimpInstFault}" -# class CMPSQ(Inst): -# "GenFault ${new UnimpInstFault}" -#}}; +microcode = ''' +def macroop CMPS_M_M { + # Find the constant we need to either add or subtract from rdi + ruflag t0, 10 + movi t3, t3, dsz, flags=(CEZF,), dataSize=asz + subi t4, t0, dsz, dataSize=asz + mov t3, t3, t4, flags=(nCEZF,), dataSize=asz + + ld t1, seg, [1, t0, rsi] + ld t2, es, [1, t0, rdi] + sub t0, t1, t2, flags=(OF, SF, ZF, AF, PF, CF) + + add rdi, rdi, t3, dataSize=asz + add rsi, rsi, t3, dataSize=asz +}; + +# +# Versions which have the rep prefix. These could benefit from some loop +# unrolling. +# + +def macroop CMPS_E_M_M { + # Find the constant we need to either add or subtract from rdi + ruflag t0, 10 + movi t3, t3, dsz, flags=(CEZF,), dataSize=asz + subi t4, t0, dsz, dataSize=asz + mov t3, t3, t4, flags=(nCEZF,), dataSize=asz + + ld t1, seg, [1, t0, rsi] + ld t2, es, [1, t0, rdi] + sub t0, t1, t2, flags=(OF, SF, ZF, AF, PF, CF) + + subi rcx, rcx, 1, flags=(EZF,), dataSize=asz + add rdi, rdi, t3, dataSize=asz + add rsi, rsi, t3, dataSize=asz + bri t0, 4, flags=(CSTRZnEZF,) + fault "NoFault" +}; + +def macroop CMPS_N_M_M { + # Find the constant we need to either add or subtract from rdi + ruflag t0, 10 + movi t3, t3, dsz, flags=(CEZF,), dataSize=asz + subi t4, t0, dsz, dataSize=asz + mov t3, t3, t4, flags=(nCEZF,), dataSize=asz + + ld t1, seg, [1, t0, rsi] + ld t2, es, [1, t0, rdi] + sub t0, t1, t2, flags=(OF, SF, ZF, AF, PF, CF) + + subi rcx, rcx, 1, flags=(EZF,), dataSize=asz + add rdi, rdi, t3, dataSize=asz + add rsi, rsi, t3, dataSize=asz + bri t0, 4, flags=(CSTRnZnEZF,) + fault "NoFault" +}; +''' |