Update to work with latest llvmlite, which needs LLVM 3.6

This commit is contained in:
Eli Bendersky 2015-07-15 05:48:21 -07:00
commit 54d82e9f37
5 changed files with 21 additions and 21 deletions

View file

@ -36,7 +36,7 @@ unit tests that check a variety of cases.
Version of LLVM, Python and llvmlite
------------------------------------
I tested with Python 3.4, LLVM 3.5 and top-of-tree ``llvmlite``.
Last tested with Python 3.4, LLVM 3.6 and top-of-tree ``llvmlite``.
Testing
-------

View file

@ -385,7 +385,7 @@ class LLVMCodeGenerator(object):
return getattr(self, method)(node)
def _codegen_NumberExprAST(self, node):
return self.builder.constant(ir.DoubleType(), float(node.val))
return ir.Constant(ir.DoubleType(), float(node.val))
def _codegen_VariableExprAST(self, node):
return self.func_symtab[node.name]

View file

@ -474,7 +474,7 @@ class LLVMCodeGenerator(object):
return getattr(self, method)(node)
def _codegen_NumberExprAST(self, node):
return self.builder.constant(ir.DoubleType(), float(node.val))
return ir.Constant(ir.DoubleType(), float(node.val))
def _codegen_VariableExprAST(self, node):
return self.func_symtab[node.name]
@ -499,7 +499,7 @@ class LLVMCodeGenerator(object):
# Emit comparison value
cond_val = self._codegen(node.cond_expr)
cmp = self.builder.fcmp_ordered(
'!=', cond_val, self.builder.constant(ir.DoubleType(), 0.0))
'!=', cond_val, ir.Constant(ir.DoubleType(), 0.0))
# Create basic blocks to express the control flow, with a conditional
# branch to either then_bb or else_bb depending on cmp. else_bb and
@ -574,7 +574,7 @@ class LLVMCodeGenerator(object):
body_val = self._codegen(node.body)
if node.step_expr is None:
stepval = self.builder.constant(ir.DoubleType(), 1.0)
stepval = ir.Constant(ir.DoubleType(), 1.0)
else:
stepval = self._codegen(node.step_expr)
nextvar = self.builder.fadd(phi, stepval, 'nextvar')
@ -582,7 +582,7 @@ class LLVMCodeGenerator(object):
# Compute the end condition
endcond = self._codegen(node.end_expr)
cmp = self.builder.fcmp_ordered(
'!=', endcond, self.builder.constant(ir.DoubleType(), 0.0),
'!=', endcond, ir.Constant(ir.DoubleType(), 0.0),
'loopcond')
# Create the 'after loop' block and insert it
@ -606,7 +606,7 @@ class LLVMCodeGenerator(object):
self.func_symtab[node.id_name] = oldval
# The 'for' expression always returns 0
return self.builder.constant(ir.DoubleType(), 0.0)
return ir.Constant(ir.DoubleType(), 0.0)
def _codegen_CallExprAST(self, node):
callee_func = self.module.globals.get(node.callee, None)
@ -746,7 +746,7 @@ class KaleidoscopeEvaluator(object):
irbuilder = ir.IRBuilder(putchard.append_basic_block('entry'))
ival = irbuilder.fptoui(putchard.args[0], ir.IntType(32), 'intcast')
irbuilder.call(putchar, [ival])
irbuilder.ret(irbuilder.constant(ir.DoubleType(), 0))
irbuilder.ret(ir.Constant(ir.DoubleType(), 0))
#---- Some unit tests ----#

View file

@ -555,7 +555,7 @@ class LLVMCodeGenerator(object):
return getattr(self, method)(node)
def _codegen_NumberExprAST(self, node):
return self.builder.constant(ir.DoubleType(), float(node.val))
return ir.Constant(ir.DoubleType(), float(node.val))
def _codegen_VariableExprAST(self, node):
return self.func_symtab[node.name]
@ -588,7 +588,7 @@ class LLVMCodeGenerator(object):
# Emit comparison value
cond_val = self._codegen(node.cond_expr)
cmp = self.builder.fcmp_ordered(
'!=', cond_val, self.builder.constant(ir.DoubleType(), 0.0))
'!=', cond_val, ir.Constant(ir.DoubleType(), 0.0))
# Create basic blocks to express the control flow, with a conditional
# branch to either then_bb or else_bb depending on cmp. else_bb and
@ -666,7 +666,7 @@ class LLVMCodeGenerator(object):
body_val = self._codegen(node.body)
if node.step_expr is None:
stepval = self.builder.constant(ir.DoubleType(), 1.0)
stepval = ir.Constant(ir.DoubleType(), 1.0)
else:
stepval = self._codegen(node.step_expr)
nextvar = self.builder.fadd(phi, stepval, 'nextvar')
@ -674,7 +674,7 @@ class LLVMCodeGenerator(object):
# Compute the end condition
endcond = self._codegen(node.end_expr)
cmp = self.builder.fcmp_ordered(
'!=', endcond, self.builder.constant(ir.DoubleType(), 0.0),
'!=', endcond, ir.Constant(ir.DoubleType(), 0.0),
'loopcond')
# Create the 'after loop' block and insert it
@ -698,7 +698,7 @@ class LLVMCodeGenerator(object):
self.func_symtab[node.id_name] = oldval
# The 'for' expression always returns 0
return self.builder.constant(ir.DoubleType(), 0.0)
return ir.Constant(ir.DoubleType(), 0.0)
def _codegen_CallExprAST(self, node):
callee_func = self.module.get_global(node.callee)
@ -839,7 +839,7 @@ class KaleidoscopeEvaluator(object):
irbuilder = ir.IRBuilder(putchard.append_basic_block('entry'))
ival = irbuilder.fptoui(putchard.args[0], ir.IntType(32), 'intcast')
irbuilder.call(putchar, [ival])
irbuilder.ret(irbuilder.constant(ir.DoubleType(), 0))
irbuilder.ret(ir.Constant(ir.DoubleType(), 0))
#---- Some unit tests ----#

View file

@ -617,7 +617,7 @@ class LLVMCodeGenerator(object):
return getattr(self, method)(node)
def _codegen_NumberExprAST(self, node):
return self.builder.constant(ir.DoubleType(), float(node.val))
return ir.Constant(ir.DoubleType(), float(node.val))
def _codegen_VariableExprAST(self, node):
var_addr = self.func_symtab[node.name]
@ -661,7 +661,7 @@ class LLVMCodeGenerator(object):
# Emit comparison value
cond_val = self._codegen(node.cond_expr)
cmp = self.builder.fcmp_ordered(
'!=', cond_val, self.builder.constant(ir.DoubleType(), 0.0))
'!=', cond_val, ir.Constant(ir.DoubleType(), 0.0))
# Create basic blocks to express the control flow, with a conditional
# branch to either then_bb or else_bb depending on cmp. else_bb and
@ -748,11 +748,11 @@ class LLVMCodeGenerator(object):
# Compute the end condition
endcond = self._codegen(node.end_expr)
cmp = self.builder.fcmp_ordered(
'!=', endcond, self.builder.constant(ir.DoubleType(), 0.0),
'!=', endcond, ir.Constant(ir.DoubleType(), 0.0),
'loopcond')
if node.step_expr is None:
stepval = self.builder.constant(ir.DoubleType(), 1.0)
stepval = ir.Constant(ir.DoubleType(), 1.0)
else:
stepval = self._codegen(node.step_expr)
cur_var = self.builder.load(var_addr, node.id_name)
@ -775,7 +775,7 @@ class LLVMCodeGenerator(object):
del self.func_symtab[node.id_name]
# The 'for' expression always returns 0
return self.builder.constant(ir.DoubleType(), 0.0)
return ir.Constant(ir.DoubleType(), 0.0)
def _codegen_VarExprAST(self, node):
old_bindings = []
@ -786,7 +786,7 @@ class LLVMCodeGenerator(object):
if init is not None:
init_val = self._codegen(init)
else:
init_val = self.builder.constant(ir.DoubleType(), 0.0)
init_val = ir.Constant(ir.DoubleType(), 0.0)
# Create an alloca for the induction var and store the init value to
# it. Save and restore location of our builder because
@ -956,7 +956,7 @@ class KaleidoscopeEvaluator(object):
irbuilder = ir.IRBuilder(putchard.append_basic_block('entry'))
ival = irbuilder.fptoui(putchard.args[0], ir.IntType(32), 'intcast')
irbuilder.call(putchar, [ival])
irbuilder.ret(irbuilder.constant(ir.DoubleType(), 0))
irbuilder.ret(ir.Constant(ir.DoubleType(), 0))
#---- Some unit tests ----#