arch: Add some format strings to the parser for reg indexes.
There are two new strings, reg_idx_arr_decl which declares the source and dest register index arrays, and set_reg_idx_arr which installs them in the base class. The set_reg_idx_arr code needs to implicitly figure out what type to use based on the type of the "this" pointer. The name of the containing class is not *necessarily* the same as class_name, since the generated code can use that name, something based on that name, or whatever else it wants. No other format string (other than class_name itself) uses the class name internally, so we can't count on that working in existing ISA definitions. Change-Id: Id995a46896e71a2fcf3103c34a1e1e67e24f88f4 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/36878 Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -105,6 +105,21 @@ class Template(object):
|
||||
|
||||
operands = SubOperandList(self.parser, compositeCode, d.operands)
|
||||
|
||||
myDict['reg_idx_arr_decl'] = \
|
||||
'RegId srcRegIdxArr[%d]; RegId destRegIdxArr[%d]' % \
|
||||
(d.operands.numSrcRegs, d.operands.numDestRegs)
|
||||
|
||||
# The reinterpret casts are largely because an array with a known
|
||||
# size cannot be passed as an argument which is an array with an
|
||||
# unknown size in C++.
|
||||
myDict['set_reg_idx_arr'] = '''
|
||||
setRegIdxArrays(
|
||||
reinterpret_cast<RegIdArrayPtr>(
|
||||
&std::remove_pointer_t<decltype(this)>::srcRegIdxArr),
|
||||
reinterpret_cast<RegIdArrayPtr>(
|
||||
&std::remove_pointer_t<decltype(this)>::destRegIdxArr));
|
||||
'''
|
||||
|
||||
myDict['op_decl'] = operands.concatAttrStrings('op_decl')
|
||||
if operands.readPC or operands.setPC:
|
||||
myDict['op_decl'] += 'TheISA::PCState __parserAutoPCState;\n'
|
||||
|
||||
Reference in New Issue
Block a user