1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import jit
- import tree_ir
- BINARY_INTRINSICS = {
- 'value_eq' : '==',
- 'value_neq' : '!=',
- 'bool_and' : 'and',
- 'bool_or' : 'or',
- 'integer_addition' : '+',
- 'integer_subtraction' : '-',
- 'integer_multiplication' : '*',
- 'integer_division' : '/',
- 'integer_gt' : '>',
- 'integer_gte' : '>=',
- 'integer_lt' : '<',
- 'integer_lte' : '<=',
- 'float_addition' : '+',
- 'float_subtraction' : '-',
- 'float_multiplication' : '*',
- 'float_division' : '/',
- 'float_gt' : '>',
- 'float_gte' : '>=',
- 'float_lt' : '<',
- 'float_lte' : '<='
- }
- MISC_INTRINSICS = {
- 'element_eq' : (
- lambda lhs, rhs:
- tree_ir.CreateNodeWithValueInstruction(
- tree_ir.BinaryInstruction(lhs, '==', rhs))),
- 'element_neq' : (
- lambda lhs, rhs:
- tree_ir.CreateNodeWithValueInstruction(
- tree_ir.BinaryInstruction(lhs, '!=', rhs)))
- }
- def register_intrinsics(target_jit):
- """Registers all intrinsics in the module with the given JIT."""
- for (key, value) in BINARY_INTRINSICS.items():
- target_jit.register_binary_intrinsic(key, value)
- for (key, value) in MISC_INTRINSICS.items():
- target_jit.register_intrinsic(key, value)
|