Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/57018 )
Change subject: arch-x86: Simplify and consolidate ld/st microop
definitions.
......................................................................
arch-x86: Simplify and consolidate ld/st microop definitions.
A lot of mechanism was repeated between the various flavors of microop
base class in python. This code can mostly be consolidated. One
exception are the __init__ methods which are still pretty repetitive,
but they are often slightly different and provide the top level
interface to those microops. Having specific signatures which exactly
match how the microops can/should be used is valuable in that case, and
worth a little repetition.
Change-Id: Ie440ac3b8dcbd1b3d00e33a1b1209d4fde0a966e
---
M src/arch/x86/ucasmlib/arch/x86/microops/ldstop.py
1 file changed, 50 insertions(+), 96 deletions(-)
diff --git a/src/arch/x86/ucasmlib/arch/x86/microops/ldstop.py
b/src/arch/x86/ucasmlib/arch/x86/microops/ldstop.py
index 5d46c71..960fc18 100644
--- a/src/arch/x86/ucasmlib/arch/x86/microops/ldstop.py
+++ b/src/arch/x86/ucasmlib/arch/x86/microops/ldstop.py
@@ -63,66 +63,30 @@
if uncacheable:
self.instFlags += " | Request::UNCACHEABLE"
- def getAllocator(self, microFlags):
- allocator = '''new %(class_name)s(machInst, macrocodeBlock,
- %(flags)s, %(dataSize)s, %(addressSize)s, %(memFlags)s,
- %(data)s, %(scale)s, %(index)s, %(base)s,
- %(disp)s, %(segment)s)''' % {
- "class_name" : self.className,
- "flags" : self.microFlagsText(microFlags) + self.instFlags,
- "scale" : self.scale, "index" : self.index,
- "base" : self.base,
- "disp" : self.disp,
- "segment" : self.segment, "data" : self.data,
- "dataSize" : self.dataSize, "addressSize" : self.addressSize,
- "memFlags" : self.memFlags}
- return allocator
-
-class BigLdStOp(X86Microop):
- def __init__(self, data, segment, addr, disp,
- dataSize, addressSize, baseFlags, atCPL0, prefetch, nonSpec,
- uncacheable):
- super().__init__()
- self.data = data
- [self.scale, self.index, self.base] = addr
- self.disp = disp
- self.segment = segment
- self.dataSize = dataSize
- self.addressSize = addressSize
- self.memFlags = baseFlags
- if atCPL0:
- self.memFlags += " | CPL0FlagBit"
- self.instFlags = ""
- if prefetch:
- self.memFlags += " | Request::PREFETCH"
- self.instFlags += " | (1ULL << StaticInst::IsDataPrefetch)"
- if nonSpec:
- self.instFlags += " | (1ULL << StaticInst::IsNonSpeculative)"
- if uncacheable:
- self.instFlags += " | Request::UNCACHEABLE"
+ allocatorTemplate = '''new {self.className}(machInst, macrocodeBlock,
+ {flags}, {self.dataSize}, {self.addressSize},
+ {self.memFlags}, {self.data}, {self.scale},
+ {self.index}, {self.base}, {self.disp}, {self.segment})
+ '''
def getAllocator(self, microFlags):
- allocString = '''
- (%(dataSize)s >= 4) ?
- (StaticInstPtr)(new %(class_name)sBig(machInst,
- macrocodeBlock, %(flags)s, %(dataSize)s,
- %(addressSize)s, %(memFlags)s, %(data)s, %(scale)s,
- %(index)s, %(base)s, %(disp)s, %(segment)s)) :
- (StaticInstPtr)(new %(class_name)s(machInst,
- macrocodeBlock, %(flags)s, %(dataSize)s,
- %(addressSize)s, %(memFlags)s, %(data)s, %(scale)s,
- %(index)s, %(base)s, %(disp)s, %(segment)s))
+ return self.allocatorTemplate.format(self=self,
+ flags=self.microFlagsText(microFlags))
+
+class BigLdStOp(LdStOp):
+ allocatorTemplate = '''
+ ({self.dataSize} >= 4) ?
+ (StaticInstPtr)(new {self.className}Big(machInst,
+ macrocodeBlock, {flags}, {self.dataSize},
+ {self.addressSize}, {self.memFlags}, {self.data},
+ {self.scale}, {self.index}, {self.base}, {self.disp},
+ {self.segment})) :
+ (StaticInstPtr)(new {self.className}(machInst,
+ macrocodeBlock, {flags}, {self.dataSize},
+ {self.addressSize}, {self.memFlags}, {self.data},
+ {self.scale}, {self.index}, {self.base}, {self.disp},
+ {self.segment}))
'''
- allocator = allocString % {
- "class_name" : self.className,
- "flags" : self.microFlagsText(microFlags) + self.instFlags,
- "scale" : self.scale, "index" : self.index,
- "base" : self.base,
- "disp" : self.disp,
- "segment" : self.segment, "data" : self.data,
- "dataSize" : self.dataSize, "addressSize" : self.addressSize,
- "memFlags" : self.memFlags}
- return allocator
class LdStSplitOp(LdStOp):
def __init__(self, data, segment, addr, disp,
@@ -133,51 +97,24 @@
uncacheable)
(self.dataLow, self.dataHi) = data
- def getAllocator(self, microFlags):
- allocString = '''(StaticInstPtr)(new %(class_name)s(machInst,
- macrocodeBlock, %(flags)s, %(dataLow)s, %(dataHi)s,
- %(scale)s, %(index)s, %(base)s, %(disp)s, %(segment)s,
- %(dataSize)s, %(addressSize)s, %(memFlags)s))
+ allocatorTemplate = '''(StaticInstPtr)(new {self.className}(machInst,
+ macrocodeBlock, {flags}, {self.dataLow}, {self.dataHi},
+ {self.scale}, {self.index}, {self.base}, {self.disp},
+ {self.segment}, {self.dataSize}, {self.addressSize},
+ {self.memFlags}))
'''
- allocator = allocString % {
- "class_name" : self.className,
- "flags" : self.microFlagsText(microFlags) + self.instFlags,
- "scale" : self.scale, "index" : self.index,
- "base" : self.base,
- "disp" : self.disp,
- "segment" : self.segment,
- "dataLow" : self.dataLow, "dataHi" : self.dataHi,
- "dataSize" : self.dataSize, "addressSize" : self.addressSize,
- "memFlags" : self.memFlags}
- return allocator
-class MemNoDataOp(X86Microop):
+class MemNoDataOp(LdStOp):
def __init__(self, segment, addr, disp=0,
dataSize="env.dataSize", addressSize="env.addressSize",
baseFlags="0"):
- super().__init__()
- [self.scale, self.index, self.base] = addr
- self.disp = disp
- self.segment = segment
- self.dataSize = dataSize
- self.addressSize = addressSize
- self.instFlags = ""
- self.memFlags = baseFlags
+ super().__init__(0, segment, addr, disp,
+ dataSize, addressSize, baseFlags, False, False, False, False)
- def getAllocator(self, microFlags):
- allocator = '''new %(class_name)s(machInst, macrocodeBlock,
- %(flags)s, %(dataSize)s, %(addressSize)s, %(memFlags)s,
- %(scale)s, %(index)s, %(base)s, %(disp)s,
- %(segment)s)''' % {
- "class_name" : self.className,
- "flags" : self.microFlagsText(microFlags) + self.instFlags,
- "scale" : self.scale, "index" : self.index,
- "base" : self.base,
- "disp" : self.disp,
- "segment" : self.segment,
- "dataSize" : self.dataSize, "addressSize" : self.addressSize,
- "memFlags" : self.memFlags}
- return allocator
+ allocatorTemplate = '''new {self.className}(machInst, macrocodeBlock,
+ {flags}, {self.dataSize}, {self.addressSize},
{self.memFlags},
+ {self.scale}, {self.index}, {self.base}, {self.disp},
+ {self.segment})'''
loadops = []
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/57018
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ie440ac3b8dcbd1b3d00e33a1b1209d4fde0a966e
Gerrit-Change-Number: 57018
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s