Closed kathlenehurt-sifive closed 6 months ago
I made this a draft so it doesn't get accidentally merged before I get some feedback on it.
I might have to duck and run after suggesting this... :laughing:
What if the Form implementations are in a .cpp and the header just has the basic static const
definitions? I.e. drop the inline
and reduce the forms files a LOT -- might speed up compile time dramatically.
I might have to duck and run after suggesting this... 😆 What if the Form implementations are in a .cpp and the header just has the basic
static const
definitions? I.e. drop theinline
and reduce the forms files a LOT -- might speed up compile time dramatically.
That's good idea! I'll do that.
To be able to move the Form implementations into source files, I'll also need to do the same for the Extractor classes. However, I'd like to refactor the Extractor classes to reduce code duplication first.
I'll open a new PR to refactor the Extractor classes and move the Form and Extractor class implementations into source files.
Actually, I figured out how to move the Form implementations into source files. I just needed to remove an unused member (func_fields_
) of the Extractor classes. I also went ahead and moved the ExtractorForms and ExtractorDerived files the new impl
dir to prepare for more refactoring. The Mavis test runs and passes.
@klingaard and @bdutro-sv this PR is ready to go. I'd like to add a rule to require PRs to be approved by one of the three of us. What do you think?
CC: @bdutro (he's no longer at SiFive) :grin:
@jeffnye-gh -- you might be interested in looking at this one.
The goal of this refactoring effort was to reduce the size of
impl/Form.h
by removing the duplicate methods defined in every Form class (getName()
,getField()
,getOpcodeFields()
,print()
, etc.).Firstly, several classes have been renamed:
The file
impl/Form.h
has been split into several new files inimpl/forms
. I also renamedmavis/FormIF.h
tomavis/Form.h
.All Form classes now only contain public static members (see the
Form_AMO
class inimps/forms/CommonForms.h
for an example). These methods have been implemented in theForm
class inmavis/Form.h
. Without any static methods, there are some places where direct access to these static members is required, mainly in the Extractors. For example, calls toForm_AMO::getName()
have been replaced withForm_AMO::name
.Next, I'd like to look at reducing code duplication in the Extractor classes, but that will come in a later PR.