New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MMIO: Cleanup Mapping class by using templates instead of macros. #605
Conversation
|
Pushed a new version, which fixes the MMIO UnitTest. This also nicely illustrates one of the interface changes. |
|
I'm not yet sure what's happening on the OSX build bot, but I'll look into it. |
|
I kinda like the first version better...altho it could be more readable (as in words, not code): |
|
The second version is in no way what is committed in the repository.
|
|
I think you misunderstood the point of that comparison. I wasn't pointing out how the new code is superior to the old one, but instead I was asking for opinions on how to replace the old macro code with non-preprocessor code. In any case, both versions should be equivalent to the old code unless I am missing something. EDIT: Added the old code to the comparison for reference. |
| // Getter functions for the handler arrays. | ||
| // TODO: Clean this up using std::get<Unit> once we enable C++14 usage. | ||
| template<typename Unit> | ||
| ReadHandler<Unit>& GetReadHandler(size_t index) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
What's the status of this? OSX is still not building, and no status on compiler code being emitted. Please do not abuse the PR list as your personal TODO list. |
|
At the time I submitted this PR I thought everything would be fine, so it's not an abuse of the PR list as a TODO list. I haven't had some time to work on this any further yet, but I'll get to it eventually. |
|
(I don't know why the buildbot is showing success; the OSX buildbot still fails) I think I might be hitting this compiler bug: http://llvm.org/bugs/show_bug.cgi?id=18345 |
|
Okay, should be final now. It's not very pretty, but it compiles on clang and maybe works even better than the previous version. If there are no reasons not to merge this, I'd stash the two commits together and then merge this. |
MMIO: Cleanup Mapping class by using templates instead of macros.
|
If this against my expectations causes any performance regressions, we can just revert it. However, currently it looks like the new version is completely equivalent to the old one with regards to the generated assembly code. |
|
why is it so mysterious? just look at the compiled code. On Sun, Jul 27, 2014 at 10:28 AM, Tony Wasserka notifications@github.com
|
|
What are you talking about? I did look at the compiled code, as explained in the commit comments (.. the link to which I unfortunately don't have anymore because it got lost during rebase), and couldn't see any relevant differences in the generated assembly code. |
|
OK....I missed the response on the pre-rebase version. |
The MMIO mapping interface was using lots of macros before to use the same code for different MMIO register sizes. This branch replaces the macro usage with templates.
Macros aren't a particular modern way of using C++ to begin with, but in this case I think using templates instead of macros indeed makes the code a lot more readable. Additionally, I was able to clean up the interface a lot because the C++ overloading restrictions don't affect templated code.
For what it's worth, I'm not sure if
is any cleaner than
Opinions on that? (having written this in comparison, I got to say myself that the second version is probably better)
For reference, the version of this code living in current master is