jon.recoil.org

Module Asm_targets.Asm_label

A label in a specific section within the assembly stream. They may be either numeric or textual. (Numeric ones are converted to textual ones by this module.) The argument to String should not include any platform-specific prefix (such as "L", ".L", etc).

Label's numeric or textual names are unique within the assembly stream for a single compilation unit, even across sections. Asm_label keeps track of the section a label belongs to, and doesn't check uniqueness.

Note: Labels are not symbols in the usual sense---they are a construct in the assembler's metalanguage and not accessible in the object file---although on macOS the terminology for labels appears to be "assembler local symbols".

type t

Create a fresh integer-valued label (using the new_label function passed to initialize, below).

Create an integer-valued label. The int must be positive.

val create_string : Asm_targets.Asm_section.t -> string -> Asm_targets.Asm_label.t

Create a textual label. The supplied name must not require escaping.

val create_string_unchecked : Asm_targets.Asm_section.t -> string -> Asm_targets.Asm_label.t

Create a textual label. Argument string is not checked, so use with caution.

Create a special label for a local symbol.

val encode : Asm_targets.Asm_label.t -> string

Convert a label to the corresponding textual form, suitable for direct emission into an assembly file. This may be useful e.g. when emitting an instruction referencing a label.

val initialize : new_label:(unit -> int) -> unit

To be called by the emitter at the very start of code generation. new_label should always be Cmm.new_label. Needed to avoid a circular dependency.

Which section a label is in.

include Identifiable.S with type t := Asm_targets.Asm_label.t
include Identifiable.Thing with type t := Asm_targets.Asm_label.T.t
include Stdlib.Hashtbl.HashedType with type t := Asm_targets.Asm_label.T.t

The equality predicate used to compare keys.

val hash : Asm_targets.Asm_label.T.t -> int

A hashing function on keys. It must be such that if two keys are equal according to equal, then they have identical hash values as computed by hash. Examples: suitable (equal, hash) pairs for arbitrary key types include

  • ((=), hash) for comparing objects by structure (provided objects do not contain floats)
  • ((fun x y -> compare x y = 0), hash) for comparing objects by structure and handling Stdlib.nan correctly
  • ((==), hash) for comparing objects by physical equality (e.g. for mutable or cyclic objects).
include Stdlib.Map.OrderedType with type t := Asm_targets.Asm_label.T.t

A total ordering function over the keys. This is a two-argument function f such that f e1 e2 is zero if the keys e1 and e2 are equal, f e1 e2 is strictly negative if e1 is smaller than e2, and f e1 e2 is strictly positive if e1 is greater than e2. Example: a suitable ordering function is the generic structural comparison function Stdlib.compare.

Retrieve a distinguished label that is suitable for identifying the start of the given section within a given compilation unit's assembly file. This function supports only DWARF sections. To support more, additional sections and labels have to be emitted in Asm_directives.debug_header.

Like for_section, but for DWARF sections only.