s/field/word

Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
xermicus
2024-05-07 13:37:17 +02:00
parent 9f8a8a782d
commit c0dd845b39
48 changed files with 291 additions and 282 deletions
@@ -145,12 +145,12 @@ where
let field_pointer = context.build_gep(
tuple_pointer,
&[
context.field_const(0),
context.word_const(0),
context
.integer_type(revive_common::BIT_LENGTH_X32)
.const_int(index as u64, false),
],
context.field_type().as_basic_type_enum(),
context.word_type().as_basic_type_enum(),
format!("assignment_binding_{index}_gep_pointer").as_str(),
);
@@ -263,7 +263,7 @@ impl FunctionCall {
revive_llvm_context::polkavm_evm_comparison::compare(
context,
arguments[0].into_int_value(),
context.field_const(0),
context.word_const(0),
inkwell::IntPredicate::EQ,
)
.map(Some)
@@ -312,7 +312,7 @@ impl FunctionCall {
revive_llvm_context::polkavm_evm_bitwise::xor(
context,
arguments[0].into_int_value(),
context.field_type().const_all_ones(),
context.word_type().const_all_ones(),
)
.map(Some)
}
@@ -512,7 +512,7 @@ impl FunctionCall {
let offset = context.solidity_mut().allocate_immutable(key.as_str());
let index = context.field_const(offset as u64);
let index = context.word_const(offset as u64);
let value = arguments[2].value.into_int_value();
revive_llvm_context::polkavm_evm_immutable::store(context, index, value)
.map(|_| None)
@@ -526,7 +526,7 @@ impl FunctionCall {
.ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))?
{
revive_llvm_context::PolkaVMCodeType::Deploy => {
Ok(Some(context.field_const(0).as_basic_value_enum()))
Ok(Some(context.word_const(0).as_basic_value_enum()))
}
revive_llvm_context::PolkaVMCodeType::Runtime => {
revive_llvm_context::polkavm_evm_calldata::load(
@@ -543,7 +543,7 @@ impl FunctionCall {
.ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))?
{
revive_llvm_context::PolkaVMCodeType::Deploy => {
Ok(Some(context.field_const(0).as_basic_value_enum()))
Ok(Some(context.word_const(0).as_basic_value_enum()))
}
revive_llvm_context::PolkaVMCodeType::Runtime => {
revive_llvm_context::polkavm_evm_calldata::size(context).map(Some)
@@ -877,8 +877,8 @@ impl FunctionCall {
let arguments = self.pop_arguments_llvm::<D, 3>(context)?;
let offset = context.builder().build_int_add(
arguments[0].into_int_value(),
context.field_const(
(revive_common::BYTE_LENGTH_X32 + revive_common::BYTE_LENGTH_FIELD) as u64,
context.word_const(
(revive_common::BYTE_LENGTH_X32 + revive_common::BYTE_LENGTH_WORD) as u64,
),
"datacopy_contract_hash_offset",
)?;
@@ -138,8 +138,7 @@ impl Literal {
let mut hex_string = if inner.is_hexadecimal {
string.clone()
} else {
let mut hex_string =
String::with_capacity(revive_common::BYTE_LENGTH_FIELD * 2);
let mut hex_string = String::with_capacity(revive_common::BYTE_LENGTH_WORD * 2);
let mut index = 0;
loop {
if index >= string.len() {
@@ -200,16 +199,16 @@ impl Literal {
hex_string
};
if hex_string.len() > revive_common::BYTE_LENGTH_FIELD * 2 {
if hex_string.len() > revive_common::BYTE_LENGTH_WORD * 2 {
return Ok(revive_llvm_context::PolkaVMArgument::new_with_original(
r#type.const_zero().as_basic_value_enum(),
string,
));
}
if hex_string.len() < revive_common::BYTE_LENGTH_FIELD * 2 {
if hex_string.len() < revive_common::BYTE_LENGTH_WORD * 2 {
hex_string.push_str(
"0".repeat((revive_common::BYTE_LENGTH_FIELD * 2) - hex_string.len())
"0".repeat((revive_common::BYTE_LENGTH_WORD * 2) - hex_string.len())
.as_str(),
);
}
@@ -82,13 +82,13 @@ where
.into_int_value();
let condition = context.builder().build_int_z_extend_or_bit_cast(
condition,
context.field_type(),
context.word_type(),
"for_condition_extended",
)?;
let condition = context.builder().build_int_compare(
inkwell::IntPredicate::NE,
condition,
context.field_const(0),
context.word_const(0),
"for_condition_compared",
)?;
context.build_conditional_branch(condition, body_block, join_block)?;
@@ -285,12 +285,12 @@ where
let pointer = context.build_gep(
pointer,
&[
context.field_const(0),
context.word_const(0),
context
.integer_type(revive_common::BIT_LENGTH_X32)
.const_int(index as u64, false),
],
context.field_type(),
context.word_type(),
format!("return_{index}_gep_pointer").as_str(),
);
context.build_store(pointer, r#type.const_zero())?;
@@ -61,13 +61,13 @@ where
.into_int_value();
let condition = context.builder().build_int_z_extend_or_bit_cast(
condition,
context.field_type(),
context.word_type(),
"if_condition_extended",
)?;
let condition = context.builder().build_int_compare(
inkwell::IntPredicate::NE,
condition,
context.field_const(0),
context.word_const(0),
"if_condition_compared",
)?;
let main_block = context.append_basic_block("if_main");
@@ -185,7 +185,7 @@ where
let pointer = context.build_gep(
pointer,
&[
context.field_const(0),
context.word_const(0),
context
.integer_type(revive_common::BIT_LENGTH_X32)
.const_int(index as u64, false),
+2 -2
View File
@@ -26,7 +26,7 @@ pub enum Type {
impl Default for Type {
fn default() -> Self {
Self::UInt(revive_common::BIT_LENGTH_FIELD)
Self::UInt(revive_common::BIT_LENGTH_WORD)
}
}
@@ -73,7 +73,7 @@ impl Type {
Self::Bool => context.integer_type(revive_common::BIT_LENGTH_BOOLEAN),
Self::Int(bitlength) => context.integer_type(bitlength),
Self::UInt(bitlength) => context.integer_type(bitlength),
Self::Custom(_) => context.field_type(),
Self::Custom(_) => context.word_type(),
}
}
}