Skip to content

Commit

Permalink
Small refactor with BlockExt (#939)
Browse files Browse the repository at this point in the history
* extend blockext

* arugment -> arg

* extui

* extsi

* shrui ext

* shrui

* shli

* cmpi

* fix

* mul addi

* muli

* addi

* check

* trunci

* trunci
  • Loading branch information
edg-l authored Nov 25, 2024
1 parent 075b9ac commit 2b945fc
Show file tree
Hide file tree
Showing 47 changed files with 1,123 additions and 1,928 deletions.
2 changes: 1 addition & 1 deletion src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ fn compile_func(
block.append_operation(llvm::store(
context,
ptr,
pre_entry_block.argument(0)?.into(),
pre_entry_block.arg(0)?,
location,
LoadStoreOptions::new().align(Some(IntegerAttribute::new(
IntegerType::new(context, 64).into(),
Expand Down
351 changes: 107 additions & 244 deletions src/libfuncs/array.rs

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions src/libfuncs/bitwise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ pub fn build<'ctx, 'this>(
_metadata: &mut MetadataStorage,
_info: &SignatureOnlyConcreteLibfunc,
) -> Result<()> {
let bitwise =
super::increment_builtin_counter(context, entry, location, entry.argument(0)?.into())?;
let bitwise = super::increment_builtin_counter(context, entry, location, entry.arg(0)?)?;

let lhs = entry.argument(1)?.into();
let rhs = entry.argument(2)?.into();
let lhs = entry.arg(1)?;
let rhs = entry.arg(2)?;

let logical_and = entry.append_op_result(arith::andi(lhs, rhs, location))?;
let logical_xor = entry.append_op_result(arith::xori(lhs, rhs, location))?;
Expand Down
10 changes: 5 additions & 5 deletions src/libfuncs/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ fn build_bool_binary<'ctx, 'this>(
.trailing_zeros();
let tag_ty = IntegerType::new(context, tag_bits).into();

let lhs = entry.argument(0)?.into();
let rhs = entry.argument(1)?.into();
let lhs = entry.arg(0)?;
let rhs = entry.arg(1)?;

let lhs_tag = entry.extract_value(context, location, lhs, tag_ty, 0)?;

Expand Down Expand Up @@ -149,7 +149,7 @@ pub fn build_bool_not<'ctx, 'this>(
.trailing_zeros();
let tag_ty = IntegerType::new(context, tag_bits).into();

let value = entry.argument(0)?.into();
let value = entry.arg(0)?;
let tag_value = entry.extract_value(context, location, value, tag_ty, 0)?;

let const_1 = entry.const_int_from_type(context, location, 1, tag_ty)?;
Expand Down Expand Up @@ -199,10 +199,10 @@ pub fn build_bool_to_felt252<'ctx, 'this>(
.trailing_zeros();
let tag_ty = IntegerType::new(context, tag_bits).into();

let value = entry.argument(0)?.into();
let value = entry.arg(0)?;
let tag_value = entry.extract_value(context, location, value, tag_ty, 0)?;

let result = entry.append_op_result(arith::extui(tag_value, felt252_ty, location))?;
let result = entry.extui(tag_value, felt252_ty, location)?;

entry.append_operation(helper.br(0, &[result], location));
Ok(())
Expand Down
Loading

0 comments on commit 2b945fc

Please sign in to comment.