本文整理汇总了Python中pykit.ir.Builder.gen_call_external方法的典型用法代码示例。如果您正苦于以下问题:Python Builder.gen_call_external方法的具体用法?Python Builder.gen_call_external怎么用?Python Builder.gen_call_external使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pykit.ir.Builder
的用法示例。
在下文中一共展示了Builder.gen_call_external方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RuntimeLowering
# 需要导入模块: from pykit.ir import Builder [as 别名]
# 或者: from pykit.ir.Builder import gen_call_external [as 别名]
class RuntimeLowering(object):
"""
Lower assembly Operations into runtime calls, e.g.
Op("thread_start") -> Op("call", "thread_start", [])
"""
def __init__(self, func):
self.mod = func.module
self.builder = Builder(func)
self.func = func
def lower_ops_into_runtime(self, names, insert_decl=False):
"""Lower all ops listed in `names` into runtime calls"""
names = set(names)
for op in self.func.ops:
if op.opcode in names:
self.lower_into_runtime(op, insert_decl)
def lower_into_runtime(self, op, insert_decl=False):
"""
Lower op into a runtime call.
:param decl: Whether to insert an external declaration if not present
"""
_verify_args(op)
if insert_decl and not self.mod.get_global(op.opcode):
signature = types.Function(op.type, [arg.type for arg in op.args])
self.mod.add_global(GlobalValue(op.opcode, signature, external=True))
call = self.builder.gen_call_external(op.opcode, op.args, op.result)
op.replace(call)
示例2: LowerConversions
# 需要导入模块: from pykit.ir import Builder [as 别名]
# 或者: from pykit.ir.Builder import gen_call_external [as 别名]
class LowerConversions(object):
def __init__(self, func, conversion_table):
self.conversion_table = conversion_table
self.builder = Builder(func)
def op_convert(self, op):
arg = op.args[0]
if (op.type, arg.type) in self.conversion_table:
funcname = self.conversion_table[op.type, arg.type]
return self.builder.gen_call_external(funcname, [arg])