本文整理汇总了Python中optimizer.Optimizer.add_input方法的典型用法代码示例。如果您正苦于以下问题:Python Optimizer.add_input方法的具体用法?Python Optimizer.add_input怎么用?Python Optimizer.add_input使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类optimizer.Optimizer
的用法示例。
在下文中一共展示了Optimizer.add_input方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cant_fold
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import add_input [as 别名]
def test_cant_fold(self):
opt = Optimizer([ConstantFold])
i0 = opt.add_input(Types.INT)
opt.add_operation(Types.INT, Operations.INT_ADD,
[i0, opt.new_constant_int(1)]
)
ops = opt.build_operations()
assert len(ops) == 1
示例2: test_inputs
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import add_input [as 别名]
def test_inputs(self):
opt = Optimizer()
res = opt.add_input(Types.INT)
opt.add_operation(Types.VOID, Operations.FINISH, [res])
ops = opt.build_operations()
assert len(ops) == 1
assert ops[0].op == Operations.FINISH
assert ops[0].getarglist() == [res]
示例3: test_known_guard_true
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import add_input [as 别名]
def test_known_guard_true(self):
opt = Optimizer([GuardPropagation])
i0 = opt.add_input(Types.INT)
opt.add_operation(Types.VOID, Operations.GUARD_TRUE, [i0])
opt.add_operation(Types.VOID, Operations.GUARD_TRUE, [i0])
ops = opt.build_operations()
assert len(ops) == 1
assert opt.getvalue(i0).getint() == 1
示例4: test_guard_false
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import add_input [as 别名]
def test_guard_false(self):
opt = Optimizer([ConstantFold, GuardPropagation])
i0 = opt.add_input(Types.INT)
opt.add_operation(Types.VOID, Operations.GUARD_FALSE, [i0])
opt.add_operation(Types.INT, Operations.INT_EQ, [i0, opt.new_constant_int(1)])
ops = opt.build_operations()
assert len(ops) == 1
assert opt.getvalue(i0).getint() == 0
示例5: test_setfield
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import add_input [as 别名]
def test_setfield(self, cpu):
opt = Optimizer([Virtualize])
i0 = opt.add_input(Types.INT)
struct_descr = cpu.new_struct()
field_descr = cpu.new_field(struct_descr)
p0 = opt.add_operation(Types.REF, Operations.NEW, [], descr=struct_descr)
opt.add_operation(Types.VOID, Operations.SETFIELD, [p0, i0], descr=field_descr)
ops = opt.build_operations()
assert len(ops) == 0
示例6: test_lt
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import add_input [as 别名]
def test_lt(self):
opt = Optimizer([IntBounds, GuardPropagation])
i0 = opt.add_input(Types.INT)
i1 = opt.add_operation(Types.INT, Operations.INT_LT,
[i0, opt.new_constant_int(10)],
)
opt.add_operation(Types.VOID, Operations.GUARD_TRUE, [i1])
opt.add_operation(Types.INT, Operations.INT_LT, [i0, opt.new_constant_int(15)])
ops = opt.build_operations()
assert len(ops) == 2
示例7: test_lt_reverse
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import add_input [as 别名]
def test_lt_reverse(self):
opt = Optimizer([IntBounds, GuardPropagation])
i0 = opt.add_input(Types.INT)
i1 = opt.add_operation(Types.INT, Operations.INT_GT,
[i0, opt.new_constant_int(5)]
)
opt.add_operation(Types.VOID, Operations.GUARD_TRUE, [i1])
i2 = opt.add_operation(Types.INT, Operations.INT_LT,
[i0, opt.new_constant_int(3)]
)
opt.add_operation(Types.VOID, Operations.GUARD_FALSE, [i2])
ops = opt.build_operations()
assert len(ops) == 2
assert opt.getvalue(i2).getint() == 0
示例8: test_multiple_setfields
# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import add_input [as 别名]
def test_multiple_setfields(self, cpu):
opt = Optimizer([Virtualize])
struct_descr = cpu.new_struct()
field_descr1 = cpu.new_field(struct_descr)
field_descr2 = cpu.new_field(struct_descr)
i0 = opt.add_input(Types.INT)
i1 = opt.add_input(Types.INT)
p0 = opt.add_operation(Types.REF, Operations.NEW, [], descr=struct_descr)
opt.add_operation(Types.VOID, Operations.SETFIELD, [p0, i0], descr=field_descr1)
opt.add_operation(Types.VOID, Operations.SETFIELD, [p0, i1], descr=field_descr2)
i2 = opt.add_operation(Types.INT, Operations.GETFIELD, [p0], descr=field_descr1)
i3 = opt.add_operation(Types.INT, Operations.GETFIELD, [p0], descr=field_descr2)
ops = opt.build_operations()
assert len(ops) == 0
assert opt.getvalue(i2) is i0
assert opt.getvalue(i3) is i1