From b3b67cdf69eb44e05989100cf38cb6807c4f2a46 Mon Sep 17 00:00:00 2001 From: Rohan Jacob-Rao Date: Tue, 11 Aug 2015 15:22:32 -0700 Subject: [PATCH] Add metadata types to AST. --- infer/src/llvm/lAst.ml | 9 +++++++++ infer/src/llvm/lParser.mly | 16 ++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/infer/src/llvm/lAst.ml b/infer/src/llvm/lAst.ml index b90d34d35..8c064d4e0 100644 --- a/infer/src/llvm/lAst.ml +++ b/infer/src/llvm/lAst.ml @@ -35,6 +35,15 @@ type typ = | Tlabel | Tmetadata +type metadata = + | MetadataVar of int + | MetadataString of string + | MetadataNode of metadata_component list + +and metadata_component = + | TypOperand of typ option * operand + | Metadata of metadata + type instr = | Ret of (typ * operand) option | UncondBranch of variable diff --git a/infer/src/llvm/lParser.mly b/infer/src/llvm/lParser.mly index ec4c35325..d45714844 100644 --- a/infer/src/llvm/lParser.mly +++ b/infer/src/llvm/lParser.mly @@ -170,22 +170,22 @@ target_triple: metadata_def: | name = NAMED_METADATA EQUALS numbered_metadata_node { () } - | num = NUMBERED_METADATA EQUALS metadata_node { () } + | metadata_id = NUMBERED_METADATA EQUALS metadata_node { () } numbered_metadata_node: - | METADATA_NODE_BEGIN separated_list(COMMA, NUMBERED_METADATA) RBRACE { () } + | METADATA_NODE_BEGIN metadata_ids = separated_list(COMMA, NUMBERED_METADATA) RBRACE { metadata_ids } metadata_node: - | METADATA? METADATA_NODE_BEGIN separated_list(COMMA, metadata_component) RBRACE { () } + | METADATA? METADATA_NODE_BEGIN components = separated_list(COMMA, metadata_component) RBRACE { MetadataNode components } metadata_component: - | tp = typ? op = operand { () } - | METADATA? metadata_value { () } + | tp = typ? op = operand { TypOperand (tp, op) } + | METADATA? value = metadata_value { Metadata value } metadata_value: - | NUMBERED_METADATA { () } - | METADATA_STRING { () } - | metadata_node { () } + | i = NUMBERED_METADATA { MetadataVar i } + | str = METADATA_STRING { MetadataString str } + | node = metadata_node { node } func_def: | DEFINE ret_tp = ret_typ name = variable LPAREN