Binary Format¶
Code Metadata¶
A Code Metadata item is a piece of information logically attached to an instruction.
An item is associated with a format, which defines the item’s payload.
All code metadata items of a format named T are grouped under a custom section named ‘metadata.code.T’. The following parametrized grammar rules define the generic structure of a code metadata section of format T.
Where \(\mathit{off}\) is the byte offset of the attached instruction, relative to the beginning of the \(\href{../../core/binary/modules.html#binary-func}{\mathtt{func}}\) declaration, and \(\mathit{data}\) is a further payload, whose content depends on the format \(T\).
\(\href{binary.html#binary-codemetadata}{\mathtt{codemetadatafunc}}\) entries must appear in order of increasing \(x\), and duplicate id values are not allowed. \(\href{binary.html#binary-codemetadata}{\mathtt{codemetadata}}\) entries must appear in order of increasing \(\mathit{off}\), and duplicate offset values are not allowed.
Branch Hints¶
A Branch Hint is a code metadata item with format branch_hint.
It can only be attached to \(\href{../../core/syntax/instructions.html#syntax-instr-control}{\mathsf{br\_if}}\) and \(\href{../../core/syntax/instructions.html#syntax-instr-control}{\mathsf{if}}\) instructions.
Its payload indicates whether the branch is likely or unlikely to be taken.
All branch hints for a module are contained in a single code metadata section with name ‘metadata.code.branch_hint’.
A value of \(\href{binary.html#binary-branchhints}{\mathtt{likely}}\) means that the branch is likely to be taken, while a value of \(\href{binary.html#binary-branchhints}{\mathtt{unlikely}}\) means the opposite. A branch with no hints is considered equally likely to be taken or not.