> On April 29, 2014, 6:38 a.m., Nilay Vaish wrote:
> > Is it possible write some preprocessing macro that generates both the
> > enum and the quoted strings?
> 
> Andrew Bardsley wrote:
>     It would be desirable to keep enums and string representations in sync 
> that way, but it's more world-reorganisation than I feel this patch 
> immediately demands.
>     
>     To make things a bit better I've changed the array into a switch 
> statement so that the order of the enumeration elements no longer matters, 
> removed flags will cause an error and added flags will at least fall back on 
> printing their int representations.
> 
> Ali Saidi wrote:
>     I'd prefer to leave it as is, but just put a static_assert in the code 
> that at least fails compilation if something is added in one but not both 
> places.
> 
> Andrew Bardsley wrote:
>     To match the static_assert in arch/arm/faults.hh, presumably.  Any 
> thoughts, Nilay?
> 
> Steve Reinhardt wrote:
>     The python Enum class (in src/python/m5/params.py) does what you want, I 
> think.  See, for example, OpClass in src/cpu/FuncUnit.py, which generates 
> build/*/enums/OpClass.{cc,hh}.  This was originally designed to support enums 
> being used as SimObject parameters, but there's no reason it has to be 
> limited to that.
> 
> Andrew Bardsley wrote:
>     I've put the static_assert in as suggested.  Using Enum would 
> significantly complicate using StaticInst::Flags, not least because it 
> changes the scoping of the enumeration elements (assuming that it's used 
> without modification).
> 
> Steve Reinhardt wrote:
>     It would be nice if the python code had more flexibility to deal with 
> different scopes, but it seems like you could get around the issue with a 
> 'using' declaration, right?
>
> 
> Steve Reinhardt wrote:
>     Actually a typedef would probably make more sense... define the enum as 
> StaticInstFlags, then inside StaticInst put:
>     
>     typedef Enums::StaticInstFlags Flags;
>     
>
> 
> Andrew Bardsley wrote:
>     Yeah, that would work.  Adding an option to allowing a namespace to be 
> specified so the enum elements didn't have to occupy the same namespace as 
> all other enums would make it better.
>     
>     I think the extra complexity from adding another auto generated 
> dependency makes the idea much less attractive though.
>
> 
> Steve Reinhardt wrote:
>     Yes, the ability to specify a different namespace (or elide it 
> altogether) is what I meant when I said "It would be nice if the python code 
> had more flexibility".  If you'd like to add that, please do, but I was 
> trying to put forward a simpler solution.
>     
>     I don't see how yet another dependency makes this less attractive... we 
> already have dozens, if not hundreds, so one more is really in the noise.  
> All you have to do is '#include "enums/StaticInstFlags.hh"'  in 
> static_inst.hh and scons should take care of everything else.
> 
> Andrew Bardsley wrote:
>     Yeah, I was reacting to your "flexibility" comment, Steve.  The 
> 'namespace' thing was a just a suggestion for that ;)
>     
>     There are a lot of dependencies, yes, but this one feels like it 
> compromises the grep-ability of the uncompiled codebase as most of the other 
> dependencies for static_inst.hh are hidden behind common names in TheISA and 
> similar structures.
> 
> Steve Reinhardt wrote:
>     I suppose there is a downside in terms of spreading things across more 
> files, but I think the automated generation of the enum and the strings from 
> a single list outweighs that, and I think it would be hard to automate this 
> process without having the enum in a separate file.  Basically Nilay wished 
> for a tool like this, and I'm pointing out that we already have one, and it 
> seems odd not to use it.
>     
>     In particular, a big problem here seems to be that you weren't aware of 
> this facility and thus went off and had to spend time coming up with your own 
> solution.  While that's unfortunate, I'm concerned that putting in the manual 
> solution you have here will cause other developers to believe that this is 
> the best we can do, and then they'll also replicate this unnecessary effort 
> because they still won't be aware that there's a more automated mechanism 
> available.
>     
>     If there are some small tweaks that would make it more palatable, let's 
> talk.  I actually don't think that the namespace tweaks you mentioned would 
> be that hard.  Then again, I'm not sure they address your objection either... 
> I think all it would do would be to let you get rid of the typedef and move 
> the #include of the enum definition inside the class StaticInst declaration, 
> and that's not a very big change (and I'm not even sure it's an improvement).
>     
>     Or we could just rewrite everything in Ada... the one positive memory I 
> have of that language is that you could get at the string representations of 
> enums for free.
> 
> Nathan Binkert wrote:
>     Another tool that you can use is protobuf (which I believe is already a 
> dependency).  You can create enums in a .proto file and protoc will generate 
> the machinery that you guys are talking about.

At the moment protobuf is optional (perhaps we want to reconsider this decision 
in the future).


- Andreas


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://reviews.gem5.org/r/2254/#review5042
-----------------------------------------------------------


On April 29, 2014, 4:47 p.m., Andreas Hansson wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://reviews.gem5.org/r/2254/
> -----------------------------------------------------------
> 
> (Updated April 29, 2014, 4:47 p.m.)
> 
> 
> Review request for Default.
> 
> 
> Repository: gem5
> 
> 
> Description
> -------
> 
> Changeset 10204:1eaca056de71
> ---------------------------
> cpu: Add flag name printing to StaticInst
> 
> This patch adds a the member function StaticInst::printFlags to allow all
> of an instruction's flags to be printed without using the individual
> is... member functions or resorting to exposing the 'flags' vector
> 
> 
> Diffs
> -----
> 
>   src/cpu/static_inst.hh e40b35147270 
>   src/cpu/static_inst.cc e40b35147270 
> 
> Diff: http://reviews.gem5.org/r/2254/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Andreas Hansson
> 
>

_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to