mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-25 02:27:58 +00:00
use opaque pointer types everywhere
Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
@@ -46,11 +46,10 @@ impl<'ctx> Intrinsics<'ctx> {
|
||||
) -> Self {
|
||||
let void_type = llvm.void_type();
|
||||
let bool_type = llvm.bool_type();
|
||||
let byte_type = llvm.custom_width_int_type(revive_common::BIT_LENGTH_BYTE as u32);
|
||||
let field_type = llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32);
|
||||
let _stack_field_pointer_type = field_type.ptr_type(AddressSpace::Stack.into());
|
||||
let heap_field_pointer_type = byte_type.ptr_type(AddressSpace::Heap.into());
|
||||
let generic_byte_pointer_type = byte_type.ptr_type(AddressSpace::Generic.into());
|
||||
let _stack_field_pointer_type = llvm.ptr_type(AddressSpace::Stack.into());
|
||||
let heap_field_pointer_type = llvm.ptr_type(AddressSpace::Heap.into());
|
||||
let generic_byte_pointer_type = llvm.ptr_type(AddressSpace::Generic.into());
|
||||
|
||||
let trap = Self::declare(
|
||||
llvm,
|
||||
@@ -130,20 +129,16 @@ impl<'ctx> Intrinsics<'ctx> {
|
||||
|
||||
match name {
|
||||
name if name == Self::FUNCTION_MEMORY_COPY => vec![
|
||||
field_type
|
||||
.ptr_type(AddressSpace::Heap.into())
|
||||
llvm.ptr_type(AddressSpace::Heap.into())
|
||||
.as_basic_type_enum(),
|
||||
field_type
|
||||
.ptr_type(AddressSpace::Heap.into())
|
||||
llvm.ptr_type(AddressSpace::Heap.into())
|
||||
.as_basic_type_enum(),
|
||||
field_type.as_basic_type_enum(),
|
||||
],
|
||||
name if name == Self::FUNCTION_MEMORY_COPY_FROM_GENERIC => vec![
|
||||
field_type
|
||||
.ptr_type(AddressSpace::Heap.into())
|
||||
llvm.ptr_type(AddressSpace::Heap.into())
|
||||
.as_basic_type_enum(),
|
||||
field_type
|
||||
.ptr_type(AddressSpace::Generic.into())
|
||||
llvm.ptr_type(AddressSpace::Generic.into())
|
||||
.as_basic_type_enum(),
|
||||
field_type.as_basic_type_enum(),
|
||||
],
|
||||
|
||||
@@ -186,8 +186,7 @@ impl<'ctx> LLVMRuntime<'ctx> {
|
||||
Self::FUNCTION_CXA_THROW,
|
||||
llvm.void_type().fn_type(
|
||||
vec![
|
||||
llvm.i8_type()
|
||||
.ptr_type(AddressSpace::Stack.into())
|
||||
llvm.ptr_type(AddressSpace::Stack.into())
|
||||
.as_basic_type_enum()
|
||||
.into();
|
||||
3
|
||||
@@ -432,8 +431,7 @@ impl<'ctx> LLVMRuntime<'ctx> {
|
||||
Self::FUNCTION_MSTORE8,
|
||||
llvm.void_type().fn_type(
|
||||
vec![
|
||||
llvm.custom_width_int_type(revive_common::BIT_LENGTH_BYTE as u32)
|
||||
.ptr_type(AddressSpace::Heap.into())
|
||||
llvm.ptr_type(AddressSpace::Heap.into())
|
||||
.as_basic_type_enum()
|
||||
.into(),
|
||||
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
|
||||
@@ -463,8 +461,7 @@ impl<'ctx> LLVMRuntime<'ctx> {
|
||||
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
|
||||
.fn_type(
|
||||
vec![
|
||||
llvm.custom_width_int_type(revive_common::BIT_LENGTH_BYTE as u32)
|
||||
.ptr_type(AddressSpace::Heap.into())
|
||||
llvm.ptr_type(AddressSpace::Heap.into())
|
||||
.as_basic_type_enum()
|
||||
.into(),
|
||||
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
|
||||
@@ -503,8 +500,7 @@ impl<'ctx> LLVMRuntime<'ctx> {
|
||||
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
|
||||
.as_basic_type_enum()
|
||||
.into(),
|
||||
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
|
||||
.ptr_type(AddressSpace::Stack.into())
|
||||
llvm.ptr_type(AddressSpace::Stack.into())
|
||||
.as_basic_type_enum()
|
||||
.into(),
|
||||
]
|
||||
@@ -537,8 +533,7 @@ impl<'ctx> LLVMRuntime<'ctx> {
|
||||
);
|
||||
|
||||
let mut external_call_arguments_by_ref: Vec<inkwell::types::BasicMetadataTypeEnum> = vec![
|
||||
llvm.custom_width_int_type(revive_common::BIT_LENGTH_BYTE as u32)
|
||||
.ptr_type(AddressSpace::Generic.into())
|
||||
llvm.ptr_type(AddressSpace::Generic.into())
|
||||
.as_basic_type_enum()
|
||||
.into(),
|
||||
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
|
||||
@@ -563,8 +558,7 @@ impl<'ctx> LLVMRuntime<'ctx> {
|
||||
let external_call_result_type = llvm
|
||||
.struct_type(
|
||||
&[
|
||||
llvm.custom_width_int_type(revive_common::BIT_LENGTH_BYTE as u32)
|
||||
.ptr_type(AddressSpace::Generic.into())
|
||||
llvm.ptr_type(AddressSpace::Generic.into())
|
||||
.as_basic_type_enum(),
|
||||
llvm.bool_type().as_basic_type_enum(),
|
||||
],
|
||||
|
||||
@@ -197,7 +197,7 @@ where
|
||||
context.build_store(result_pointer, context.field_const(0))?;
|
||||
let deployer_call_result_type = context.structure_type(&[
|
||||
context
|
||||
.byte_type()
|
||||
.llvm()
|
||||
.ptr_type(AddressSpace::Generic.into())
|
||||
.as_basic_type_enum(),
|
||||
context.bool_type().as_basic_type_enum(),
|
||||
@@ -266,7 +266,7 @@ where
|
||||
.const_zero(),
|
||||
],
|
||||
context
|
||||
.byte_type()
|
||||
.llvm()
|
||||
.ptr_type(AddressSpace::Generic.into())
|
||||
.as_basic_type_enum(),
|
||||
"deployer_call_result_abi_data_pointer",
|
||||
|
||||
@@ -44,7 +44,7 @@ impl Entry {
|
||||
|
||||
context.set_global(
|
||||
crate::eravm::GLOBAL_HEAP_MEMORY_POINTER,
|
||||
context.byte_type().ptr_type(AddressSpace::Generic.into()),
|
||||
context.llvm().ptr_type(AddressSpace::Generic.into()),
|
||||
AddressSpace::Stack,
|
||||
context.xlen_type().get_undef(),
|
||||
);
|
||||
@@ -145,7 +145,7 @@ impl Entry {
|
||||
input_pointer,
|
||||
&[calldata_size_casted],
|
||||
context
|
||||
.byte_type()
|
||||
.llvm()
|
||||
.ptr_type(AddressSpace::Generic.into())
|
||||
.as_basic_type_enum(),
|
||||
"return_data_abi_initializer",
|
||||
|
||||
@@ -990,7 +990,7 @@ where
|
||||
|
||||
self.set_basic_block(catch_block);
|
||||
let landing_pad_type = self.structure_type(&[
|
||||
self.byte_type()
|
||||
self.llvm()
|
||||
.ptr_type(AddressSpace::Stack.into())
|
||||
.as_basic_type_enum(),
|
||||
self.integer_type(revive_common::BIT_LENGTH_X32)
|
||||
@@ -1001,7 +1001,7 @@ where
|
||||
landing_pad_type,
|
||||
self.llvm_runtime.personality.value,
|
||||
&[self
|
||||
.byte_type()
|
||||
.llvm()
|
||||
.ptr_type(AddressSpace::Stack.into())
|
||||
.const_zero()
|
||||
.as_basic_value_enum()],
|
||||
@@ -1272,7 +1272,7 @@ where
|
||||
let return_is_nil = self.builder().build_int_compare(
|
||||
inkwell::IntPredicate::EQ,
|
||||
end_of_memory,
|
||||
self.byte_type().ptr_type(Default::default()).const_null(),
|
||||
self.llvm().ptr_type(Default::default()).const_null(),
|
||||
"compare_end_of_memory_nil",
|
||||
)?;
|
||||
|
||||
@@ -1350,7 +1350,7 @@ where
|
||||
pub fn write_abi_pointer(&mut self, pointer: Pointer<'ctx>, global_name: &str) {
|
||||
self.set_global(
|
||||
global_name,
|
||||
self.byte_type().ptr_type(AddressSpace::Generic.into()),
|
||||
self.llvm().ptr_type(AddressSpace::Generic.into()),
|
||||
AddressSpace::Stack,
|
||||
pointer.value,
|
||||
);
|
||||
@@ -1528,11 +1528,8 @@ where
|
||||
.void_type()
|
||||
.fn_type(argument_types.as_slice(), false),
|
||||
1 => self.field_type().fn_type(argument_types.as_slice(), false),
|
||||
size if is_near_call_abi && self.is_system_mode() => {
|
||||
let return_types: Vec<_> = vec![self.field_type().as_basic_type_enum(); size];
|
||||
let return_type = self
|
||||
.structure_type(return_types.as_slice())
|
||||
.ptr_type(AddressSpace::Stack.into());
|
||||
_size if is_near_call_abi && self.is_system_mode() => {
|
||||
let return_type = self.llvm().ptr_type(AddressSpace::Stack.into());
|
||||
argument_types.insert(0, return_type.as_basic_type_enum().into());
|
||||
return_type.fn_type(argument_types.as_slice(), false)
|
||||
}
|
||||
|
||||
@@ -81,11 +81,7 @@ impl<'ctx> Pointer<'ctx> {
|
||||
let offset = context.safe_truncate_int_to_i32(offset).unwrap();
|
||||
let value = context
|
||||
.builder
|
||||
.build_int_to_ptr(
|
||||
offset,
|
||||
context.byte_type().ptr_type(address_space.into()),
|
||||
name,
|
||||
)
|
||||
.build_int_to_ptr(offset, context.llvm().ptr_type(address_space.into()), name)
|
||||
.unwrap();
|
||||
Self::new(r#type, address_space, value)
|
||||
}
|
||||
@@ -115,7 +111,7 @@ impl<'ctx> Pointer<'ctx> {
|
||||
{
|
||||
let value = context.builder().build_address_space_cast(
|
||||
self.value,
|
||||
self.r#type.ptr_type(address_space.into()),
|
||||
context.llvm().ptr_type(address_space.into()),
|
||||
name,
|
||||
)?;
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ where
|
||||
context.build_call(
|
||||
context.llvm_runtime().cxa_throw,
|
||||
&[context
|
||||
.byte_type()
|
||||
.llvm()
|
||||
.ptr_type(AddressSpace::Stack.into())
|
||||
.get_undef()
|
||||
.as_basic_value_enum(); 3],
|
||||
|
||||
Reference in New Issue
Block a user