ScEpTIC.llvmir_parser.instructions_parser package

Submodules

ScEpTIC.llvmir_parser.instructions_parser.aggregate_operations module

ScEpTIC.llvmir_parser.instructions_parser.aggregate_operations.is_aggregate_operation(text)

Returns if a given instruction is an aggregate operation.

ScEpTIC.llvmir_parser.instructions_parser.aggregate_operations.parse_aggregate_operation(text)

Parses an aggregate operation. They are not available in C language, so are not supported for the simulation.

ScEpTIC.llvmir_parser.instructions_parser.binary_operations module

ScEpTIC.llvmir_parser.instructions_parser.binary_operations.extract_type(text, is_function_return_type=True, is_function_attr=True)

Returns the type and the offset of the type in a given string.

ScEpTIC.llvmir_parser.instructions_parser.binary_operations.get_specific_attr_parser(op_code)

Returns the optional parser for specific attributes.

ScEpTIC.llvmir_parser.instructions_parser.binary_operations.is_binary_operation(text)

Returns if a given instruction is a binary operation.

ScEpTIC.llvmir_parser.instructions_parser.binary_operations.is_bitwise(operation_code)

Returns if a given istruction is a bitwise binary operation.

ScEpTIC.llvmir_parser.instructions_parser.binary_operations.parse_binary_operation(text)

Parses and returns a binary operation.

Binary Operations:
  • add

  • fadd

  • sub

  • fsub

  • mul

  • fmul

  • udiv

  • sdiv

  • fdiv

  • urem

  • srem

  • frem

Bitwise Binary Operations:
  • shl

  • lsrh

  • asrh

  • and

  • or

  • xor

%target = <opcode> [optional_attributes] <type> <operand_1>, <operand_2>

ScEpTIC.llvmir_parser.instructions_parser.binary_operations.parse_fp_specific_attr(text, operation_code)

Parses and removes floating point “fast-math flags” specific attributes. It returns the list of found attributes.

ScEpTIC.llvmir_parser.instructions_parser.binary_operations.parse_int_div_specific_attr(text, operation_code)

Parses and removes integer_division specific attributes. It returns the list of found attributes.

ScEpTIC.llvmir_parser.instructions_parser.binary_operations.parse_int_specific_attr(text, operation_code)

Parses and removes integer specific attributes. It returns the list of found attributes.

ScEpTIC.llvmir_parser.instructions_parser.binary_operations.parse_operand(text, is_typed=False)

Parses an operand and returns a corresponding dict with keys {‘type’, ‘value’, ‘vector_type’}

ScEpTIC.llvmir_parser.instructions_parser.binary_operations.parse_result_target(text)

Returns the target virtual register of the result and the offset of the text.

ScEpTIC.llvmir_parser.instructions_parser.binary_operations.parse_type_and_operands(text)

Parses type and operands of a binary operation. It returns a dict with keys {‘op1’, ‘op2’}

ScEpTIC.llvmir_parser.instructions_parser.conversion_operations module

ScEpTIC.llvmir_parser.instructions_parser.conversion_operations.is_conversion_operation(text, has_target=True)

Return if an instruction is a conversion operation.

ScEpTIC.llvmir_parser.instructions_parser.conversion_operations.parse_conversion_operation(text, has_target=True)

Parses and returns a conversion operation. %target = op_code <type> <value> to <type>

ScEpTIC.llvmir_parser.instructions_parser.memory_operations module

ScEpTIC.llvmir_parser.instructions_parser.memory_operations.is_memory_operation(text)

Return if an instruction is a memory operation.

ScEpTIC.llvmir_parser.instructions_parser.memory_operations.is_memory_operation_with_return(text, operation_code=None)

Return if an instruction is a memory operation with a return.

ScEpTIC.llvmir_parser.instructions_parser.memory_operations.is_memory_operation_without_return(text, operation_code=None)

Return if an instruction is a memory operation without a return.

ScEpTIC.llvmir_parser.instructions_parser.memory_operations.parse_alloca_operation(text)

Parses and returns an alloca operation. <result> = alloca [inalloca] <type> [, <ty> <NumElements>] [, align <alignment>] [, addrspace(<num>)]

ScEpTIC.llvmir_parser.instructions_parser.memory_operations.parse_getelementptr_operation(text, has_target=True)

Parses and returns a getelementptr operation. <result> = getelementptr inbounds <ty>, <ty>* <ptrval>{, [inrange] <ty> <idx>}*

ScEpTIC.llvmir_parser.instructions_parser.memory_operations.parse_load_operation(text)

Parses and returns a load operation. <result> = load [volatile] <ty>, <ty>* <pointer>[, align <alignment>] <result> = load atomic [volatile] <ty>, <ty>* <pointer> [syncscope(“<target-scope>”)] <ordering>, align <alignment>

ScEpTIC.llvmir_parser.instructions_parser.memory_operations.parse_memory_operation(text)
Parses and returns a memory operation.
  • alloca

  • load

  • getelementptr

  • store

ScEpTIC.llvmir_parser.instructions_parser.memory_operations.parse_store_operation(text)

Parses and returns a store operation. store [volatile] <ty> <value>, <ty>* <pointer>[, align <alignment>] store atomic [volatile] <ty> <value>, <ty>* <pointer> [syncscope(“<target-scope>”)] <ordering>, align <alignment>

ScEpTIC.llvmir_parser.instructions_parser.other_operations module

ScEpTIC.llvmir_parser.instructions_parser.other_operations.is_call_instruction(text)

Returns if a given instruction is is a call one.

ScEpTIC.llvmir_parser.instructions_parser.other_operations.is_other_operation(text, operation_code=None)

Returns if a given instruction is is an icmp or fcmp operation.

ScEpTIC.llvmir_parser.instructions_parser.other_operations.is_valid_cond(cond, operation_code)

Returns if a given condition is a valid one for a given operation.

ScEpTIC.llvmir_parser.instructions_parser.other_operations.parse_call_instruction(text)

Parses and returns a call instruction. <result> = [tail | musttail | notail ] call [fast-math flags] [cconv] [ret attrs] <ty>|<fnty> <fnptrval>(<function args>) [fn attrs]

[ operand bundles ]

ScEpTIC.llvmir_parser.instructions_parser.other_operations.parse_calling_convention(text)

Parses and removes calling conventions attributes of call instruction.

ScEpTIC.llvmir_parser.instructions_parser.other_operations.parse_cmp_operation(text)

Parses and returns an icmp/fcmp operation. <result> = icmp <cond> <ty> <op1>, <op2> <result> = fcmp [fast-math flags]* <cond> <ty> <op1>, <op2>

ScEpTIC.llvmir_parser.instructions_parser.other_operations.parse_cond_type_operands(text, operation_code)

Parses and returns the condition, the type and the operands of an operation as a dict with keys {‘op1’, ‘op2’, ‘condition’} If the condition is not a valid one, it raises an exception.

ScEpTIC.llvmir_parser.instructions_parser.other_operations.parse_other_operation(text)
Parses and return the other operations, which are:
  • icmp, fcmp

  • phi

  • select

  • va_arg

  • call

ScEpTIC.llvmir_parser.instructions_parser.other_operations.parse_phi_operation(text)

Parses and returns a phi operation. <result> = phi <ty> [ <val0>, <label0>], …

ScEpTIC.llvmir_parser.instructions_parser.other_operations.parse_return_parameter_attr(text)

Parses and removes return attributes of call instruction.

ScEpTIC.llvmir_parser.instructions_parser.other_operations.parse_select_operation(text)

Parses a select operation. <result> = select selty <cond>, <ty> <val1>, <ty> <val2>

ScEpTIC.llvmir_parser.instructions_parser.other_operations.parse_tail_specific_attr(text)

Parses and removes tail attributes of call instruction. They are not useful in my analysis (used just for optimization)

ScEpTIC.llvmir_parser.instructions_parser.other_operations.parse_va_arg_instruction(text)

Parses a va_arg instruction and returns it. Note: THIS IS NOT FULLY SUPPORTED BY LLVM CODE GENERATOR ON MANY TARGETS

<resultval> = va_arg <va_list*> <arglist>, <argty> %tmp = va_arg i8* %ap2, i32 It returns a value of the specified argument type and increments the va_list to point to the next argument. The actual type of va_list is target specific.

ScEpTIC.llvmir_parser.instructions_parser.terminator_instructions module

ScEpTIC.llvmir_parser.instructions_parser.terminator_instructions.is_branch_instruction(text)

Returns if an instruction is a branch.

ScEpTIC.llvmir_parser.instructions_parser.terminator_instructions.is_conditional_branch_instruction(text)

Returns if an instruction is a conditional branch.

ScEpTIC.llvmir_parser.instructions_parser.terminator_instructions.is_ret_instruction(text)

Returns if an instruction is a retturn.

ScEpTIC.llvmir_parser.instructions_parser.terminator_instructions.is_switch_instruction(text)

Returns if an instruction is a switch

ScEpTIC.llvmir_parser.instructions_parser.terminator_instructions.is_terminator_instruction(text)

Returns if an instruction is a terminator instruction.

ScEpTIC.llvmir_parser.instructions_parser.terminator_instructions.is_unconditional_branch_instruction(text)

Returns if an instruction is an uncoditional branch.

ScEpTIC.llvmir_parser.instructions_parser.terminator_instructions.is_unreachable_instruction(text)

Returns if an instruction is an unreachable.

ScEpTIC.llvmir_parser.instructions_parser.terminator_instructions.parse_branch_instruction(text)

Parses and returns a branch instruction.

ScEpTIC.llvmir_parser.instructions_parser.terminator_instructions.parse_conditional_branch_instruction(text)

Parses and returns a conditional branch. br i1 <cond>, label <iftrue>, label <iffalse>

ScEpTIC.llvmir_parser.instructions_parser.terminator_instructions.parse_ret_instruction(text)

Parses and returns a ret instruction.

ScEpTIC.llvmir_parser.instructions_parser.terminator_instructions.parse_switch_instruction(text)

Parses and returns a switch instruction. switch <intty> <value>, label <defaultdest> [ <intty> <val>, label <dest> … ] switch i32 %val, label %otherwise [ i32 0, label %onzero i32 1, label %onone i32 2, label %ontwo ]

ScEpTIC.llvmir_parser.instructions_parser.terminator_instructions.parse_terminator_instruction(text)

Parses and returns a terminator instruction. Terminator instructions:

  • ret:

  • br

  • switch:

ScEpTIC.llvmir_parser.instructions_parser.terminator_instructions.parse_unconditional_branch_instruction(text)

Parses and returns an unconditional branch.

br label <target>

ScEpTIC.llvmir_parser.instructions_parser.terminator_instructions.parse_unreachable_instruction(text)

Parses and returns an unreachable instruction.

ScEpTIC.llvmir_parser.instructions_parser.vector_operations module

ScEpTIC.llvmir_parser.instructions_parser.vector_operations.is_vector_operation(text)

Returns if a given instruction is a vector operation.

ScEpTIC.llvmir_parser.instructions_parser.vector_operations.parse_vector_operation(text)

Parses a vector operation. They are not available in C language, so are not supported for my simulation.

Module contents

ScEpTIC.llvmir_parser.instructions_parser.parse_instruction(text, line_number, function_name)

Parses and returns an instruction

Types of instructions:
  • Terminator Instructions

  • Binary Operations

  • Bitwise Binary Operations

  • Vector Operations

  • Aggregate Operations

  • Memory Access and Addressing Operations

  • Conversion Operations

  • Other Operations