Skip to content
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

Generate a read proc with a static reg arg #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dwhall
Copy link
Contributor

@dwhall dwhall commented Jan 14, 2024

The static register argument to the read() proc allows Nim to optimize
the code and the result is faster execution. To use this feature,
the calling Nim source code must be of the form:

var regval = PERIPHERAL.REGISTER.read()

or

const reg = PERIPHERAL.REGISTER
var regval = reg.read()

The following calling conventions will use the legacy read() that will not be optimized:

let reg = PERIPHERAL.REGISTER
var regval = reg.read()

var reg = PERIPHERAL.REGISTER
var regval = reg.read()

The static register argument to the read() proc allows Nim to optimize
 the code and the result is faster execution.  To use this feature,
the calling Nim source code must be of the form:

  var regval = PERIPHERAL.REGISTER.read()

or

  const reg = PERIPHERAL.REGISTER
  var regval = reg.read()

The following calling conventions will use the legacy read()
that will not be optimized:

  let reg = PERIPHERAL.REGISTER
  var regval = reg.read()

  var reg = PERIPHERAL.REGISTER
  var regval = reg.read()
@dwhall
Copy link
Contributor Author

dwhall commented Jan 14, 2024

Read more about the details of this change here. I've found since that was written that applying static to the write() proc is not helpful.

If this PR's change works and doesn't hurt the consumers of this project, we should also consider applying a similar change to modifyIt()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant