Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/36878 )
Change subject: arch: Add some format strings to the parser for reg indexes.
......................................................................
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 later has a lot of casts in it since pointer to
members apparently need a static_cast to change from a derived class to
a base class, and then will no longer implicitly cast from an array with
a known bound to an unknown bound, requiring a second cast.
The set_reg_idx_arr code also 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
---
M src/arch/isa_parser/isa_parser.py
1 file changed, 17 insertions(+), 0 deletions(-)
diff --git a/src/arch/isa_parser/isa_parser.py
b/src/arch/isa_parser/isa_parser.py
index 999d92f..2cacf20 100755
--- a/src/arch/isa_parser/isa_parser.py
+++ b/src/arch/isa_parser/isa_parser.py
@@ -105,6 +105,23 @@
operands = SubOperandList(self.parser, compositeCode,
d.operands)
+ myDict['reg_idx_arr_decl'] = \
+ 'RegId srcRegIdxArr[%d]; RegId destRegIdxArr[%d]' % \
+ (d.operands.numSrcRegs, d.operands.numDestRegs)
+
+ # Unfortunately we need two static casts, one to remove the
known
+ # size, and one to change the class. The second is supposed to
be
+ # necessary, but I didn't expect the first.
+ myDict['set_reg_idx_arr'] = '''
+ setRegIdxArrays(
+ static_cast<RegId (StaticInst::*)[]>(
+ static_cast<RegId
(std::remove_pointer_t<decltype(this)>::*)[]>(
+ &std::remove_pointer_t<decltype(this)>::srcRegIdxArr)),
+ static_cast<RegId (StaticInst::*) []>(
+ static_cast<RegId
(std::remove_pointer_t<decltype(this)>::*)[]>(
+ &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'
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/36878
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: Id995a46896e71a2fcf3103c34a1e1e67e24f88f4
Gerrit-Change-Number: 36878
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s