From 54d82e9f3725fed51c45a0109f7b0ea15b2cec67 Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Wed, 15 Jul 2015 05:48:21 -0700 Subject: [PATCH] Update to work with latest llvmlite, which needs LLVM 3.6 --- README.rst | 2 +- chapter3and4.py | 2 +- chapter5.py | 12 ++++++------ chapter6.py | 12 ++++++------ chapter7.py | 14 +++++++------- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.rst b/README.rst index aacb8f4..cf6cd1d 100644 --- a/README.rst +++ b/README.rst @@ -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 ------- diff --git a/chapter3and4.py b/chapter3and4.py index f426400..a5e483f 100644 --- a/chapter3and4.py +++ b/chapter3and4.py @@ -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] diff --git a/chapter5.py b/chapter5.py index 360d747..740af9c 100644 --- a/chapter5.py +++ b/chapter5.py @@ -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 ----# diff --git a/chapter6.py b/chapter6.py index 4036745..da36cff 100644 --- a/chapter6.py +++ b/chapter6.py @@ -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 ----# diff --git a/chapter7.py b/chapter7.py index 90e40e5..3e353bc 100644 --- a/chapter7.py +++ b/chapter7.py @@ -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 ----#