Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/56505 )
Change subject: arch-x86: Remove plumbing for macroop emitting.
......................................................................
arch-x86: Remove plumbing for macroop emitting.
Now that macroops are emitted when assembled, we don't need to plumb
around all the now unused types of output and can simplify a lot of
code.
Change-Id: I985842af92d5ed42775a5a3b8e6e1fa0f4ce22e9
---
M src/arch/x86/isa/formats/cond.isa
M src/arch/x86/isa/formats/multi.isa
M src/arch/x86/isa/formats/string.isa
M src/arch/x86/isa/macroop.isa
M src/arch/x86/isa/specialize.isa
5 files changed, 56 insertions(+), 101 deletions(-)
diff --git a/src/arch/x86/isa/formats/cond.isa
b/src/arch/x86/isa/formats/cond.isa
index 1212fd3..3b48da8 100644
--- a/src/arch/x86/isa/formats/cond.isa
+++ b/src/arch/x86/isa/formats/cond.isa
@@ -35,39 +35,29 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
def format CondInst(cond, *opTypeSet) {{
- blocks = OutputBlocks()
+ if_decode = specializeInst(Name, iter(opTypeSet), EmulEnv())
+ else_decode = specializeInst('UD2', iter([]), EmulEnv())
- if_blocks = specializeInst(Name, iter(opTypeSet), EmulEnv())
- blocks.append(if_blocks)
- else_blocks = specializeInst('UD2', iter([]), EmulEnv())
- blocks.append(else_blocks)
-
- (header_output, decoder_output,
- decode_block, exec_output) = blocks.makeList()
- decode_block = '\tif (%s) {\n%s\n\t} else {\n%s\n}\n' % \
- (cond, if_blocks.decode_block, else_blocks.decode_block)
+ decode_block = '''
+ if (%(cond)s) {
+ %(if_decode)s
+ } else {
+ %(else_decode)s
+ }
+ ''' % {'cond': cond, 'if_decode': if_decode, 'else_decode':
else_decode}
}};
def format Cpl0CondInst(cond, *opTypeSet) {{
- blocks = OutputBlocks()
+ if_decode = specializeInst(Name, iter(opTypeSet), EmulEnv())
+ else_decode = specializeInst('UD2', iter([]), EmulEnv())
- if_blocks = specializeInst(Name, iter(opTypeSet), EmulEnv())
- blocks.append(if_blocks)
- else_blocks = specializeInst('UD2', iter([]), EmulEnv())
- blocks.append(else_blocks)
-
- (header_output, decoder_output,
- decode_block, exec_output) = blocks.makeList()
decode_block = '''
if (%(cond)s) {
- %(if_block)s
+ %(if_decode)s
} else {
- %(else_block)s
+ %(else_decode)s
}
- ''' % {'cond': cond,
- 'if_block': if_blocks.decode_block,
- 'else_block': else_blocks.decode_block
- }
+ ''' % {'cond': cond, 'if_decode': if_decode, 'else_decode':
else_decode}
decode_block = '''
if (emi.mode.cpl != 0) {
return new DecodeFaultInst("%(Name)s", emi,
diff --git a/src/arch/x86/isa/formats/multi.isa
b/src/arch/x86/isa/formats/multi.isa
index 7742321..f879ffe 100644
--- a/src/arch/x86/isa/formats/multi.isa
+++ b/src/arch/x86/isa/formats/multi.isa
@@ -42,15 +42,11 @@
//////////////////////////////////////////////////////////////////////////
def format Inst(*opTypeSet) {{
- blocks = specializeInst(Name, iter(opTypeSet), EmulEnv())
- (header_output, decoder_output,
- decode_block, exec_output) = blocks.makeList()
+ decode_block = specializeInst(Name, iter(opTypeSet), EmulEnv())
}};
def format Cpl0Inst(*opTypeSet) {{
- blocks = specializeInst(Name, iter(opTypeSet), EmulEnv())
- (header_output, decoder_output,
- decode_block, exec_output) = blocks.makeList()
+ decode_block = specializeInst(Name, iter(opTypeSet), EmulEnv())
decode_block = '''
if (emi.mode.cpl != 0) {
return new DecodeFaultInst("%(Name)s", emi,
@@ -65,7 +61,5 @@
switcher = {}
for count, opTypeSet in enumerate(opTypeSets):
switcher[count] = specializeInst(Name, iter(opTypeSet), EmulEnv())
- blocks = doSplitDecode(switchVal, switcher)
- (header_output, decoder_output,
- decode_block, exec_output) = blocks.makeList()
+ decode_block = doSplitDecode(switchVal, switcher)
}};
diff --git a/src/arch/x86/isa/formats/string.isa
b/src/arch/x86/isa/formats/string.isa
index 6943060..6e2a9a2 100644
--- a/src/arch/x86/isa/formats/string.isa
+++ b/src/arch/x86/isa/formats/string.isa
@@ -42,54 +42,34 @@
//////////////////////////////////////////////////////////////////////////
def format StringTestInst(*opTypeSet) {{
- allBlocks = OutputBlocks()
+ decode = specializeInst(Name, iter(opTypeSet), EmulEnv())
+ e_decode = specializeInst(Name + "_E", iter(opTypeSet), EmulEnv())
+ n_decode = specializeInst(Name + "_N", iter(opTypeSet), EmulEnv())
- regBlocks = specializeInst(Name, iter(opTypeSet), EmulEnv())
- eBlocks = specializeInst(Name + "_E", iter(opTypeSet), EmulEnv())
- nBlocks = specializeInst(Name + "_N", iter(opTypeSet), EmulEnv())
-
- for blocks in (regBlocks, eBlocks, nBlocks):
- allBlocks.header_output += blocks.header_output
- allBlocks.decoder_output += blocks.decoder_output
- allBlocks.exec_output += blocks.exec_output
-
- allBlocks.decode_block = '''
+ decode_block = '''
if (LEGACY_REP) {
- %s
+ %(e_decode)s
} else if (LEGACY_REPNE) {
- %s
+ %(n_decode)s
} else {
- %s
+ %(decode)s
}
- ''' % (eBlocks.decode_block, nBlocks.decode_block,
regBlocks.decode_block)
-
- (header_output, decoder_output,
- decode_block, exec_output) = allBlocks.makeList()
+ ''' % {'e_decode': e_decode, 'n_decode': n_decode, 'decode': decode}
}};
def format StringInst(*opTypeSet) {{
- allBlocks = OutputBlocks()
+ decode = specializeInst(Name, iter(opTypeSet), EmulEnv())
+ e_decode = specializeInst(Name + "_E", iter(opTypeSet), EmulEnv())
- regBlocks = specializeInst(Name, iter(opTypeSet), EmulEnv())
- eBlocks = specializeInst(Name + "_E", iter(opTypeSet), EmulEnv())
-
- for blocks in (regBlocks, eBlocks):
- allBlocks.header_output += blocks.header_output
- allBlocks.decoder_output += blocks.decoder_output
- allBlocks.exec_output += blocks.exec_output
-
- allBlocks.decode_block = '''
+ decode_block = '''
if (LEGACY_REP) {
- %s
+ %(e_decode)s
} else if (LEGACY_REPNE) {
// The repne prefix is illegal
return new MicroFault(machInst, "illprefix", 0,
std::make_shared<InvalidOpcode>(), 0);
} else {
- %s
+ %(decode)s
}
- ''' % (eBlocks.decode_block, regBlocks.decode_block)
-
- (header_output, decoder_output,
- decode_block, exec_output) = allBlocks.makeList()
+ ''' % {'e_decode': e_decode, 'decode': decode}
}};
diff --git a/src/arch/x86/isa/macroop.isa b/src/arch/x86/isa/macroop.isa
index 1fed9d5..6ab0b6f 100644
--- a/src/arch/x86/isa/macroop.isa
+++ b/src/arch/x86/isa/macroop.isa
@@ -94,13 +94,3 @@
raise Exception("Conflicting register sizes " +
"{} and {}!".format(self.size, size))
}};
-
-let {{
- def genMacroop(Name, env):
- blocks = OutputBlocks()
- if not Name in macroopDict:
- raise Exception("Unrecognized instruction: {}".format(Name))
- macroop = macroopDict[Name]
- blocks.decode_block = "return %s;\n" % macroop.getAllocator(env)
- return blocks
-}};
diff --git a/src/arch/x86/isa/specialize.isa
b/src/arch/x86/isa/specialize.isa
index cc5f833..5cfbd5e 100644
--- a/src/arch/x86/isa/specialize.isa
+++ b/src/arch/x86/isa/specialize.isa
@@ -47,18 +47,13 @@
# Each element of the dict is a list containing a function and then the
# arguments to pass to it.
def doSplitDecode(switchVal, vals, default=None):
- blocks = OutputBlocks()
- blocks.decode_block = 'switch(%s) {\n' % switchVal
+ decode = 'switch(%s) {\n' % switchVal
for val, ret in vals.items():
- ret = copy.copy(ret)
- ret.decode_block = '\tcase %s: %s\n' % (val, ret.decode_block)
- blocks.append(ret)
+ decode += '\tcase %s: %s\n' % (val, ret)
if default:
- default = copy.copy(default)
- default.decode_block = '\tdefault: %s\n' % default.decode_block
- blocks.append(default)
- blocks.decode_block += '}\n'
- return blocks
+ decode += '\tdefault: %s\n' % default
+ decode += '}\n'
+ return decode
}};
let {{
@@ -67,28 +62,20 @@
def doRipRelativeDecode(Name, op_type_iter, env):
norm_iter, rip_iter = itertools.tee(op_type_iter)
norm_env = copy.copy(env)
- norm_blocks = specializeInst(Name + "_M", norm_iter, norm_env)
+ norm = specializeInst(Name + "_M", norm_iter, norm_env)
rip_env = copy.copy(env)
- rip_blocks = specializeInst(Name + "_P", rip_iter, rip_env)
+ rip = specializeInst(Name + "_P", rip_iter, rip_env)
- blocks = OutputBlocks()
- blocks.append(norm_blocks)
- blocks.append(rip_blocks)
-
- blocks.decode_block = '''
+ return '''
if (machInst.modRM.mod == 0 && machInst.modRM.rm == 5 &&
machInst.mode.submode == SixtyFourBitMode) {
%(rip)s
} else {
%(norm)s
- }''' % {'rip': rip_blocks.decode_block,
- 'norm': norm_blocks.decode_block}
- return blocks
+ }''' % {'rip': rip, 'norm': norm}
def doBadInstDecode():
- blocks = OutputBlocks()
- blocks.decode_Block = 'return new Unknown(machInst);'
- return blocks
+ return 'return new Unknown(machInst);'
class OpType(object):
parser = re.compile(r'(?P<tag>[A-Z]+)(?P<size>[a-z]*)|'
@@ -242,5 +229,6 @@
# Generate code to return a macroop of the given name which will
# operate in the 'emulation environment' env
- return genMacroop(Name, env)
+ return f'return new x86_macroop::{Name}(machInst, ' \
+ f'{env.getAllocator()});\n'
}};
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/56505
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: I985842af92d5ed42775a5a3b8e6e1fa0f4ce22e9
Gerrit-Change-Number: 56505
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