You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have emit::namer::Namer which controls what LLVM symbols are assigned to hugr functions. It is configured with a "prefix" and a bool controlling whether node ids are appended to symbols.
When the prefix is "hugr." and the bool is true, then a hugr function "main" with a node index 3, will lower to a symbol like "hugr.main.3".
This allows users to ensure that all hugr functions lower to a symbol starting with "hugr.", and that all hugr functions have unique, deterministic symbols. If the user ensures everything else (e.g. the functions and globals referenced in their lowerings) in the module has a different unique prefix, then they will never have any symbol clashes.
All "symbol computation logic" should go through an expanded and improved Namer, which is configured with a prefix tree of "namespaces", where every leaf has a unique prefix.
At present ConstExternalSymbol lowers directly to a reference to the symbol specified. This is annoying if you want to control what symbols a program is allowed to reference, one should be able to configure the Namer to prefix "hugr.external." to the symbol name, and the lowering for ConstExternalSymbol should delegate to the Namer.
We will soon (#52) be generating LLVM functions (i.e. destructors) which are not lowered hugr functions. The Namer should have a leaf in its prefix tree e.g. "hugr.destructors." which is prefixed to any destructor name. We also will need to figure out how to name the symbol from the type, and we may need internal mutablity and an incrementing "symbol id" to generate unique names. We need to pay attention to determinism, but I don't think we have to give it up.
Note that if destructors are going into "hugr.destructors.", then hugr functions should go into e.g. "hugr.user.", i.e they can't go into "hugr." because that is a prefix of "hugr.destructors.".
The text was updated successfully, but these errors were encountered:
We have
emit::namer::Namer
which controls what LLVM symbols are assigned to hugr functions. It is configured with a "prefix" and a bool controlling whether node ids are appended to symbols.When the prefix is "hugr." and the bool is true, then a hugr function "main" with a node index 3, will lower to a symbol like "hugr.main.3".
This allows users to ensure that all hugr functions lower to a symbol starting with "hugr.", and that all hugr functions have unique, deterministic symbols. If the user ensures everything else (e.g. the functions and globals referenced in their lowerings) in the module has a different unique prefix, then they will never have any symbol clashes.
All "symbol computation logic" should go through an expanded and improved
Namer
, which is configured with a prefix tree of "namespaces", where every leaf has a unique prefix.At present
ConstExternalSymbol
lowers directly to a reference to the symbol specified. This is annoying if you want to control what symbols a program is allowed to reference, one should be able to configure theNamer
to prefix "hugr.external." to the symbol name, and the lowering forConstExternalSymbol
should delegate to theNamer
.We will soon (#52) be generating LLVM functions (i.e. destructors) which are not lowered hugr functions. The Namer should have a leaf in its prefix tree e.g. "hugr.destructors." which is prefixed to any destructor name. We also will need to figure out how to name the symbol from the type, and we may need internal mutablity and an incrementing "symbol id" to generate unique names. We need to pay attention to determinism, but I don't think we have to give it up.
Note that if destructors are going into "hugr.destructors.", then hugr functions should go into e.g. "hugr.user.", i.e they can't go into "hugr." because that is a prefix of "hugr.destructors.".
The text was updated successfully, but these errors were encountered: