+def format_arity(node):
+ if "arity_override" in node:
+ return node["arity_override"]
+ arity = node['arity']
+ if arity == "dynamic":
+ return "oparity_dynamic"
+ if arity == "variable":
+ return "oparity_variable"
+ if arity == 0:
+ return "oparity_zero"
+ if arity == 1:
+ return "oparity_unary"
+ if arity == 2:
+ return "oparity_binary"
+ if arity == 3:
+ return "oparity_trinary"
+ return "oparity_any"
+
+def format_pinned(node):
+ pinned = node["pinned"]
+ if pinned == "yes":
+ return "op_pin_state_pinned"
+ if pinned == "no":
+ return "op_pin_state_floats"
+ if pinned == "exception":
+ return "op_pin_state_exc_pinned"
+ if pinned == "memory":
+ return "op_pin_state_mem_pinned"
+ print "WARNING: Unknown pinned state %s in format pined" % pinned
+ return ""
+
+def format_flags(node):
+ flags = node['flags']
+ flags = re.split("\s*,\s*", flags)
+ flags = map(lambda x : "irop_flag_" + x, flags)
+ return " | ".join(flags)
+
+def format_attr_size(node):
+ if "attr_struct" not in node:
+ return "0"
+ return "sizeof(%s)" % node['attr_struct']
+
+def format_opindex(node):
+ if "op_index" in node:
+ return node["op_index"]
+ return "-1"
+
+def filter_isnot(list, flag):
+ result = []
+ for nodename, node in list:
+ if flag in node:
+ continue
+ result.append((nodename, node))
+ return result
+