From: Gabe Black Date: Sun, 1 Nov 2020 11:47:14 +0000 (-0800) Subject: arch: Add some format strings to the parser for reg indexes. X-Git-Tag: develop-gem5-snapshot~449 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=995e1d2331f2b4c7fbf289763d1639c339e87023;p=gem5.git 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 Maintainer: Giacomo Travaglini Tested-by: kokoro --- diff --git a/src/arch/isa_parser/isa_parser.py b/src/arch/isa_parser/isa_parser.py index 999d92f40..ff54889fe 100755 --- a/src/arch/isa_parser/isa_parser.py +++ b/src/arch/isa_parser/isa_parser.py @@ -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( + &std::remove_pointer_t::srcRegIdxArr), + reinterpret_cast( + &std::remove_pointer_t::destRegIdxArr)); + ''' + myDict['op_decl'] = operands.concatAttrStrings('op_decl') if operands.readPC or operands.setPC: myDict['op_decl'] += 'TheISA::PCState __parserAutoPCState;\n'