Skip to content

Commit 9fd5cd1

Browse files
committed
Fixed tests and examples from ownership change
1 parent 4f264fd commit 9fd5cd1

File tree

8 files changed

+37
-37
lines changed

8 files changed

+37
-37
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ fn jit_compile_sum(
106106
let y = function.get_nth_param(1)?.into_int_value();
107107
let z = function.get_nth_param(2)?.into_int_value();
108108

109-
let sum = builder.build_int_add(&x, &y, "sum");
110-
let sum = builder.build_int_add(&sum, &z, "sum");
109+
let sum = builder.build_int_add(x, y, "sum");
110+
let sum = builder.build_int_add(sum, z, "sum");
111111

112112
builder.build_return(Some(&sum));
113113

examples/jit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ fn jit_compile_sum(
3232
let y = function.get_nth_param(1)?.into_int_value();
3333
let z = function.get_nth_param(2)?.into_int_value();
3434

35-
let sum = builder.build_int_add(&x, &y, "sum");
36-
let sum = builder.build_int_add(&sum, &z, "sum");
35+
let sum = builder.build_int_add(x, y, "sum");
36+
let sum = builder.build_int_add(sum, z, "sum");
3737

3838
builder.build_return(Some(&sum));
3939

examples/kaleidoscope/main.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -941,19 +941,19 @@ impl<'a> Compiler<'a> {
941941
let rhs = self.compile_expr(right)?;
942942

943943
match op {
944-
'+' => Ok(self.builder.build_float_add(&lhs, &rhs, "tmpadd")),
945-
'-' => Ok(self.builder.build_float_sub(&lhs, &rhs, "tmpsub")),
946-
'*' => Ok(self.builder.build_float_mul(&lhs, &rhs, "tmpmul")),
947-
'/' => Ok(self.builder.build_float_div(&lhs, &rhs, "tmpdiv")),
944+
'+' => Ok(self.builder.build_float_add(lhs, rhs, "tmpadd")),
945+
'-' => Ok(self.builder.build_float_sub(lhs, rhs, "tmpsub")),
946+
'*' => Ok(self.builder.build_float_mul(lhs, rhs, "tmpmul")),
947+
'/' => Ok(self.builder.build_float_div(lhs, rhs, "tmpdiv")),
948948
'<' => Ok({
949-
let cmp = self.builder.build_float_compare(FloatPredicate::ULT, &lhs, &rhs, "tmpcmp");
949+
let cmp = self.builder.build_float_compare(FloatPredicate::ULT, lhs, rhs, "tmpcmp");
950950

951-
self.builder.build_unsigned_int_to_float(&cmp, &self.context.f64_type(), "tmpbool")
951+
self.builder.build_unsigned_int_to_float(cmp, self.context.f64_type(), "tmpbool")
952952
}),
953953
'>' => Ok({
954-
let cmp = self.builder.build_float_compare(FloatPredicate::ULT, &rhs, &lhs, "tmpcmp");
954+
let cmp = self.builder.build_float_compare(FloatPredicate::ULT, rhs, lhs, "tmpcmp");
955955

956-
self.builder.build_unsigned_int_to_float(&cmp, &self.context.f64_type(), "tmpbool")
956+
self.builder.build_unsigned_int_to_float(cmp, self.context.f64_type(), "tmpbool")
957957
}),
958958

959959
custom => {
@@ -1002,7 +1002,7 @@ impl<'a> Compiler<'a> {
10021002

10031003
// create condition by comparing without 0.0 and returning an int
10041004
let cond = self.compile_expr(cond)?;
1005-
let cond = self.builder.build_float_compare(FloatPredicate::ONE, &cond, &zero_const, "ifcond");
1005+
let cond = self.builder.build_float_compare(FloatPredicate::ONE, cond, zero_const, "ifcond");
10061006

10071007
// build branch
10081008
let then_bb = self.context.append_basic_block(&parent, "then");
@@ -1069,11 +1069,11 @@ impl<'a> Compiler<'a> {
10691069
let end_cond = self.compile_expr(end)?;
10701070

10711071
let curr_var = self.builder.build_load(&start_alloca, var_name);
1072-
let next_var = self.builder.build_float_add(curr_var.as_float_value(), &step, "nextvar");
1072+
let next_var = self.builder.build_float_add(curr_var.into_float_value(), step, "nextvar");
10731073

10741074
self.builder.build_store(&start_alloca, &next_var);
10751075

1076-
let end_cond = self.builder.build_float_compare(FloatPredicate::ONE, &end_cond, &self.context.f64_type().const_float(0.0), "loopcond");
1076+
let end_cond = self.builder.build_float_compare(FloatPredicate::ONE, end_cond, self.context.f64_type().const_float(0.0), "loopcond");
10771077
let after_bb = self.context.append_basic_block(&parent, "afterloop");
10781078

10791079
self.builder.build_conditional_branch(&end_cond, &loop_bb, &after_bb);

src/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ impl Builder {
594594
///
595595
/// builder.position_at_end(&entry_block);
596596
///
597-
/// let shift = builder.build_left_shift(&value, &n, "left_shift"); // value << n
597+
/// let shift = builder.build_left_shift(value, n, "left_shift"); // value << n
598598
///
599599
/// builder.build_return(Some(&shift));
600600
/// ```
@@ -663,7 +663,7 @@ impl Builder {
663663
///
664664
/// // Whether or not your right shift is sign extended (true) or logical (false) depends
665665
/// // on the boolean input parameter:
666-
/// let shift = builder.build_right_shift(&value, &n, false, "right_shift"); // value >> n
666+
/// let shift = builder.build_right_shift(value, n, false, "right_shift"); // value >> n
667667
///
668668
/// builder.build_return(Some(&shift));
669669
/// ```

tests/test_builder.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn test_null_checked_ptr_ops() {
6868

6969
let ptr = function.get_first_param().unwrap().into_pointer_value();
7070

71-
let is_null = builder.build_is_null(&ptr, "is_null");
71+
let is_null = builder.build_is_null(ptr, "is_null");
7272

7373
let ret_0 = function.append_basic_block("ret_0");
7474
let ret_idx = function.append_basic_block("ret_idx");
@@ -82,9 +82,9 @@ fn test_null_checked_ptr_ops() {
8282

8383
// FIXME: This might not work if compiled on non 64bit devices. Ideally we'd
8484
// be able to create pointer sized ints easily
85-
let ptr_as_int = builder.build_ptr_to_int(&ptr, &i64_type, "ptr_as_int");
86-
let new_ptr_as_int = builder.build_int_add(&ptr_as_int, &one, "add");
87-
let new_ptr = builder.build_int_to_ptr(&new_ptr_as_int, &i8_ptr_type, "int_as_ptr");
85+
let ptr_as_int = builder.build_ptr_to_int(ptr, i64_type, "ptr_as_int");
86+
let new_ptr_as_int = builder.build_int_add(ptr_as_int, one, "add");
87+
let new_ptr = builder.build_int_to_ptr(new_ptr_as_int, i8_ptr_type, "int_as_ptr");
8888
let index1 = builder.build_load(&new_ptr, "deref");
8989

9090
builder.build_return(Some(&index1));
@@ -105,7 +105,7 @@ fn test_null_checked_ptr_ops() {
105105

106106
let ptr = function.get_first_param().unwrap().into_pointer_value();
107107

108-
let is_not_null = builder.build_is_not_null(&ptr, "is_not_null");
108+
let is_not_null = builder.build_is_not_null(ptr, "is_not_null");
109109

110110
let ret_idx = function.append_basic_block("ret_idx");
111111
let ret_0 = function.append_basic_block("ret_0");
@@ -119,9 +119,9 @@ fn test_null_checked_ptr_ops() {
119119

120120
// FIXME: This might not work if compiled on non 64bit devices. Ideally we'd
121121
// be able to create pointer sized ints easily
122-
let ptr_as_int = builder.build_ptr_to_int(&ptr, &i64_type, "ptr_as_int");
123-
let new_ptr_as_int = builder.build_int_add(&ptr_as_int, &one, "add");
124-
let new_ptr = builder.build_int_to_ptr(&new_ptr_as_int, &i8_ptr_type, "int_as_ptr");
122+
let ptr_as_int = builder.build_ptr_to_int(ptr, i64_type, "ptr_as_int");
123+
let new_ptr_as_int = builder.build_int_add(ptr_as_int, one, "add");
124+
let new_ptr = builder.build_int_to_ptr(new_ptr_as_int, i8_ptr_type, "int_as_ptr");
125125
let index1 = builder.build_load(&new_ptr, "deref");
126126

127127
builder.build_return(Some(&index1));
@@ -167,7 +167,7 @@ fn test_binary_ops() {
167167
let left = fn_value.get_first_param().unwrap().into_int_value();
168168
let right = fn_value.get_last_param().unwrap().into_int_value();
169169

170-
let and = builder.build_and(&left, &right, "and_op");
170+
let and = builder.build_and(left, right, "and_op");
171171

172172
builder.build_return(Some(&and));
173173

@@ -184,7 +184,7 @@ fn test_binary_ops() {
184184
let left = fn_value.get_first_param().unwrap().into_int_value();
185185
let right = fn_value.get_last_param().unwrap().into_int_value();
186186

187-
let or = builder.build_or(&left, &right, "or_op");
187+
let or = builder.build_or(left, right, "or_op");
188188

189189
builder.build_return(Some(&or));
190190

@@ -201,7 +201,7 @@ fn test_binary_ops() {
201201
let left = fn_value.get_first_param().unwrap().into_int_value();
202202
let right = fn_value.get_last_param().unwrap().into_int_value();
203203

204-
let xor = builder.build_xor(&left, &right, "xor_op");
204+
let xor = builder.build_xor(left, right, "xor_op");
205205

206206
builder.build_return(Some(&xor));
207207

@@ -274,7 +274,7 @@ fn test_switch() {
274274

275275
builder.position_at_end(&else_);
276276

277-
let double = builder.build_int_mul(&value, &i8_two, "double");
277+
let double = builder.build_int_mul(value, i8_two, "double");
278278

279279
builder.build_return(Some(&double));
280280

@@ -312,7 +312,7 @@ fn test_bit_shifts() {
312312

313313
builder.position_at_end(&entry);
314314

315-
let shift = builder.build_left_shift(&value, &bits, "shl");
315+
let shift = builder.build_left_shift(value, bits, "shl");
316316

317317
builder.build_return(Some(&shift));
318318

@@ -328,7 +328,7 @@ fn test_bit_shifts() {
328328

329329
builder.position_at_end(&entry);
330330

331-
let shift = builder.build_right_shift(&value, &bits, false, "shr");
331+
let shift = builder.build_right_shift(value, bits, false, "shr");
332332

333333
builder.build_return(Some(&shift));
334334

@@ -344,7 +344,7 @@ fn test_bit_shifts() {
344344

345345
builder.position_at_end(&entry);
346346

347-
let shift = builder.build_right_shift(&value, &bits, true, "shr");
347+
let shift = builder.build_right_shift(value, bits, true, "shr");
348348

349349
builder.build_return(Some(&shift));
350350

tests/test_execution_engine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn test_jit_execution_engine() {
8181
builder.position_at_end(&check_argc);
8282

8383
let eq = IntPredicate::EQ;
84-
let argc_check = builder.build_int_compare(eq, &main_argc, &three_i32, "argc_cmp");
84+
let argc_check = builder.build_int_compare(eq, main_argc, three_i32, "argc_cmp");
8585

8686
builder.build_conditional_branch(&argc_check, &check_arg3, &error1);
8787

tests/test_tari_example.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ fn test_tari_example() {
2626
let y = function.get_nth_param(1).unwrap().into_int_value();
2727
let z = function.get_nth_param(2).unwrap().into_int_value();
2828

29-
let sum = builder.build_int_add(&x, &y, "sum");
30-
let sum = builder.build_int_add(&sum, &z, "sum");
29+
let sum = builder.build_int_add(x, y, "sum");
30+
let sum = builder.build_int_add(sum, z, "sum");
3131

3232
builder.build_return(Some(&sum));
3333

tests/test_values.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ fn test_instructions() {
4646
let f32_val = f32_type.const_float(::std::f64::consts::PI);
4747

4848
let store_instruction = builder.build_store(&arg1, &f32_val);
49-
let ptr_val = builder.build_ptr_to_int(&arg1, &i64_type, "ptr_val");
50-
let ptr = builder.build_int_to_ptr(&ptr_val, &f32_ptr_type, "ptr");
49+
let ptr_val = builder.build_ptr_to_int(arg1, i64_type, "ptr_val");
50+
let ptr = builder.build_int_to_ptr(ptr_val, f32_ptr_type, "ptr");
5151
let free_instruction = builder.build_free(&arg1);
5252
let return_instruction = builder.build_return(None);
5353

0 commit comments

Comments
 (0)