diff --git a/infer/src/llvm/lAst.ml b/infer/src/llvm/lAst.ml index 8c064d4e0..6c331cb30 100644 --- a/infer/src/llvm/lAst.ml +++ b/infer/src/llvm/lAst.ml @@ -35,14 +35,18 @@ type typ = | Tlabel | Tmetadata -type metadata = +type metadata_value = | MetadataVar of int | MetadataString of string | MetadataNode of metadata_component list and metadata_component = | TypOperand of typ option * operand - | Metadata of metadata + | MetadataVal of metadata_value + +type metadata_mapping = + | NameMapping of string * int list + | NumberMapping of int * metadata_component list type instr = | Ret of (typ * operand) option diff --git a/infer/src/llvm/lParser.mly b/infer/src/llvm/lParser.mly index d45714844..d0baea623 100644 --- a/infer/src/llvm/lParser.mly +++ b/infer/src/llvm/lParser.mly @@ -153,7 +153,7 @@ %% prog: - | targets defs = func_def* metadata_def* EOF { Prog defs } + | targets defs = func_def* mappings = metadata_def* EOF { Prog defs } targets: | { (None, None) } @@ -169,23 +169,23 @@ target_triple: | TARGET TRIPLE EQUALS str = CONSTANT_STRING { str } metadata_def: - | name = NAMED_METADATA EQUALS numbered_metadata_node { () } - | metadata_id = NUMBERED_METADATA EQUALS metadata_node { () } + | name = NAMED_METADATA EQUALS metadata_ids = numbered_metadata_node { NameMapping (name, metadata_ids) } + | metadata_id = NUMBERED_METADATA EQUALS components = metadata_node { NumberMapping (metadata_id, components) } numbered_metadata_node: | METADATA_NODE_BEGIN metadata_ids = separated_list(COMMA, NUMBERED_METADATA) RBRACE { metadata_ids } metadata_node: - | METADATA? METADATA_NODE_BEGIN components = separated_list(COMMA, metadata_component) RBRACE { MetadataNode components } + | METADATA? METADATA_NODE_BEGIN components = separated_list(COMMA, metadata_component) RBRACE { components } metadata_component: | tp = typ? op = operand { TypOperand (tp, op) } - | METADATA? value = metadata_value { Metadata value } + | METADATA? value = metadata_value { MetadataVal value } metadata_value: | i = NUMBERED_METADATA { MetadataVar i } | str = METADATA_STRING { MetadataString str } - | node = metadata_node { node } + | components = metadata_node { MetadataNode components } func_def: | DEFINE ret_tp = ret_typ name = variable LPAREN