Legend:
Library
Module
Module type
Parameter
Class
Class type
Description of the execution target.
An abstract description of the system on which a program is intended to be run. The description precisely describes various architectual and microarchitectual details of the target system, and could be extended with further details either internally, by adding more fields (and functions to this module) or storing those options in Options.t; or externally, by maintaining finite mappings from Target.t to corresponding properties.
The Target.t has a lightweight immediate representation, which is portable across OCaml runtime and persistent across versions of BAP and OCaml.
ascending is identical to compare. descending x y = ascending y x. These are intended to be mnemonic when used like List.sort ~compare:ascending and List.sort
~cmp:descending, since they cause the list to be sorted in ascending or descending order, respectively.
This function only needs implementation if t exposed to be a polymorphic variant. Despite what the type reads, this does *not* produce a function after reading; instead it takes the constructor tag (int) before reading and reads the rest of the variant t afterwards.
val declare :
?parent:t->?bits:int ->?byte:int ->?data:(_, _)Mem.tVar.t->?code:(_, _)Mem.tVar.t->?data_alignment:int ->?code_alignment:int ->?vars:unit Var.t list->?regs:(role list * unit Var.t list) list->?aliasing:alias list->?endianness:endianness->?system:system->?abi:abi->?fabi:fabi->?filetype:filetype->?options:options->?nicknames:string list->?package:string ->string ->t
declare ?package name declares a new execution target.
The packaged name of the target must be unique and the target shall be declared during the module registration (commonly as a toplevel definition of a module that implements the target support package).
The newly declared target inherits all the parameters from the parent target unless they are explicitly overriden.
For the description of parameters see the corresponding accessor functions in this module.
If the target architecture has register aliases, i.e., registers that correspond to some parts of other registers, then they should be properly described with the aliasing parameter, using the Alias language, in which each register that has aliases is structurally defined in terms of its subparts.
since 2.3.0 has the [regs] optional parameter.
since 2.4.0 has the [aliasing] optional parameters.
register <variants> t generates and registers a list of targets.
For a list of possible target properties generate a set of unique targets and declare them. To generate a unique name the following scheme is used,
<name>-<system>-<abi><fabi>-<format>+<option>...v}
where if a property is [:unknown] then it is not listed in
the name (including the separator, if necessary).
E.g.,
{v
arm-linux-gnueabihf-elf
armv7-linux-gnueabihf+m3
since 2.5.0
val register :
?systems:system list->?abis:abi list->?fabis:fabi list->?filetypes:filetype list->?options:options list->?package:string ->t->
unit
lookup ?package name lookups a target with the given name.
If name is unqualified then it is qualified with the package (which itself defaults to "user"), otherwise the package parameter is ignored.
Returns None if the target with the given name wasn't declared.
val select :
?unique:bool ->?strict:bool ->?parent:t->?system:system->?abi:abi->?fabi:fabi->?filetype:filetype->?options:options->unit ->t
select <reqs> () selects a target that matches requirements.
Selects the least specific target that belongs to parent and matches the specified requirements. If unique is true and there is no single match then raises an exception, otherwise returns the first in the family order match (i.e., the least specific of the matches).
If there are no matching targets returns parent if strict is false, otherwise fails with an exception.
The matching procedure uses the domain structure of the corresponding parameters. A target matches the constraint if all properties of the target matches the corresponding parameters. A property matches a parameter if the property is greater or equal (in the domain order) than the parameter.
val filter :
?strict:bool ->?parent:t->?system:system->?abi:abi->?fabi:fabi->?filetype:filetype->?options:options->unit ->t list
filter <reqs> () selects targets that matches requirements.
Filters targets that belong to parent and match the specified requirements. The targets are returned in the family order, i.e., the least specific target is comming first. This is the same order in which family list targets.
The matching procedure uses the domain structure of the corresponding parameters. A target matches the constraint if all properties of the target matches the corresponding parameters. A property matches a parameter if the property is greater or equal (in the domain order) than the parameter.
matching t name is true when name matches either the unqualified name of the target itsef or one of its ancestors; or if the name matches one of the target nicknames or the target parents nicknames.
E.g., matches target "mips".
before2.5.0
the nicknames of the ancestors weren't taken into account @after 2.5.0 uses the ancestors nicknames for matching
partition targets partitions targets into families.
The partition is a list where each element is a list of family members with the family parent coming as the first member and all other members ordered in the ascending order of their hierarchy, i.e., for each p::fs in families ()family p is p:fs. The families itself are partitioned by the lexical order of the unqualified names of the family parents.
vars target is the set of all registers and memories.
The set includes both general-purpose, floating-points, and status registers, as well variables that denote memories and other entities specific to the target. The set includes all variables that were passed to the target definition, through data, code, vars, and regs variables.
regs ?exclude ?roles target returns a set of registers.
If the roles list is passed then narrows down the list to registers that have all the specified roles. If exclude is specified then excludes all registers that have those roles.
val reg : ?exclude:role list->?unique:bool ->t->role->unit Var.t option
reg target role returns a register with the given role.
Returns a register from a set of registers regs ~roles:[role] ?exlude t. If the set is not singleton and unique is true (defaults to false) returns None.