-
Notifications
You must be signed in to change notification settings - Fork 201
[WIP] Add more documentation for entities #1041
Conversation
Addresses bytecodealliance#1038 Document stackslots, funcrefs, heaps, sigrefs, and jumptables
@jyn514 I can explain Constant: it is an integer used to index into the ConstantPool to identify constant values held there (see https://github.com/CraneStation/cranelift/blob/dcaa7f5ba618d72c9dd24a29c9a485dc24ab0d07/cranelift-codegen/src/ir/constant.rs#L97). |
I see, and it's public because |
Also, I believe I had similar issues trying to fix some documentation warnings; in the end I went with something like |
That only works if the crate is imported into the current scope, though. I can't put |
Now that I look at its usages, I don't see it anywhere except in codegen so it might be able to be downgraded to |
cranelift-codegen/src/ir/entities.rs
Outdated
/// [`import_signature`](cranelift_frontend::FunctionBuilder::import_signature). | ||
/// | ||
/// You can retrieve the [`Signature`](super::Signature) that was used to create a `SigRef` with | ||
/// [`signature`](cranelift_frontend::FunctionBuilder::signature). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func.dfg.signatures
Maybe rust-lang/rust#43466 (comment) is fixed somewhere? Not exactly sure... |
But if there is absolutely no way to link to external crates then I guess my vote would be for the direct link. |
- pointer -> reference - mention `stack_store` - mention `Switch` as an alternative to `br_table` - mention `func.dfg.signatures`
@jyn514, for |
Thanks for taking a stab at this! Note that all of these implement EntityRef, so they're all handles to some data living somewhere else. For instance Constant has ConstantData, etc. I remember proposing to constantly suffix them with "Ref" or something, but this was a long time ago and I'm unsure what the outcome of the discussion was.
|
I do use it to attach a comment to a specific instruction in the clif ir written by cg_clif. |
Getting slightly off-topic now - is there any way that It looks like the only rustc-specific code is |
Is this a WASM thing? It mentions a sandbox in the documentation, and I don't see a way to construct it from |
Please note that currently comments get inserted after the specified inst, as there is no way to know what the next inst id will be. |
This is ready for review as soon as I fix the broken links. @abrown recommended permalinks to docs.rs, should I do that? |
@jyn514 I'm fine merging this but we need to fix the build issues: https://dev.azure.com/CraneStation/Cranelift/_build/results?buildId=897&view=logs. |
Ok, I'll change it to link directly to docs.rs, then. |
See bytecodealliance#1041 (comment), there doesn't currently seem to be a way to link to a type in a dependent crate.
This is ready for review. |
@jyn514 thanks for the fix! |
…ecodealliance#1041) Also fixes broken links to point to docs.rs; see bytecodealliance/cranelift#1041 (comment), there doesn't currently seem to be a way to link to a type in a dependent crate.
Addresses #1038
Document stackslots, funcrefs, heaps, sigrefs, and jumptables.
Also adds more inter-crate links.
Undocumented
Constant
- [WIP] Add more documentation for entities #1041 (comment)GlobalValue
- [WIP] Add more documentation for entities #1041 (comment)Table
- [WIP] Add more documentation for entities #1041 (comment)Inst
- [WIP] Add more documentation for entities #1041 (comment)Issues
I can't find a way to link to a type/function in a different crate if that crate isn't currently in scope for the code. For example, the documentation for JumpTable links to
FunctionBuilder::create_jump_table
, but the link is broken (it points tocranelift_codegen/ir/entities/cranelift_frontend::FunctionBuilder::create_jump_table
, which is clearly wrong).There are two ways I can think to resolve this:
https://docs.rs/cranelift-module/*/cranelift_module/struct.Module.html
. This has the downside that it will always point to the latest version (and won't work locally or offline).