mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-07-21 12:45:41 +00:00
Switch target to 64bit and enable the zbb feature (#120)
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
/// The LLVM framework version.
|
||||
pub const LLVM_VERSION: semver::Version = semver::Version::new(18, 1, 4);
|
||||
|
||||
/// The register width sized type
|
||||
/// The pointer width sized type.
|
||||
pub static XLEN: usize = revive_common::BIT_LENGTH_X32;
|
||||
|
||||
/// The heap memory pointer pointer global variable name.
|
||||
|
||||
@@ -165,8 +165,9 @@ where
|
||||
|
||||
fn link_immutable_data(&self, contract_path: &str) -> anyhow::Result<()> {
|
||||
let size = self.solidity().immutables_size() as u32;
|
||||
let exports = revive_runtime_api::immutable_data::module(self.llvm(), size);
|
||||
self.module.link_in_module(exports).map_err(|error| {
|
||||
let immutables = revive_runtime_api::immutable_data::module(self.llvm(), size);
|
||||
|
||||
self.module.link_in_module(immutables).map_err(|error| {
|
||||
anyhow::anyhow!(
|
||||
"The contract `{}` immutable data module linking error: {}",
|
||||
contract_path,
|
||||
@@ -202,6 +203,16 @@ where
|
||||
);
|
||||
}
|
||||
|
||||
/// Configure the revive datalayout.
|
||||
fn set_data_layout(
|
||||
llvm: &'ctx inkwell::context::Context,
|
||||
module: &inkwell::module::Module<'ctx>,
|
||||
) {
|
||||
let source_module = revive_stdlib::module(llvm, "revive_stdlib").unwrap();
|
||||
let data_layout = source_module.get_data_layout();
|
||||
module.set_data_layout(&data_layout);
|
||||
}
|
||||
|
||||
/// Initializes a new LLVM context.
|
||||
pub fn new(
|
||||
llvm: &'ctx inkwell::context::Context,
|
||||
@@ -211,6 +222,7 @@ where
|
||||
include_metadata_hash: bool,
|
||||
debug_config: DebugConfig,
|
||||
) -> Self {
|
||||
Self::set_data_layout(llvm, &module);
|
||||
Self::link_stdlib_module(llvm, &module);
|
||||
Self::link_polkavm_imports(llvm, &module);
|
||||
Self::set_polkavm_stack_size(llvm, &module, Self::POLKAVM_STACK_SIZE);
|
||||
@@ -261,7 +273,7 @@ where
|
||||
self.link_immutable_data(contract_path)?;
|
||||
|
||||
let target_machine = TargetMachine::new(Target::PVM, self.optimizer.settings())?;
|
||||
target_machine.set_target_data(self.module());
|
||||
self.module().set_triple(&target_machine.get_triple());
|
||||
|
||||
self.debug_config
|
||||
.dump_llvm_ir_unoptimized(contract_path, self.module())?;
|
||||
|
||||
@@ -90,7 +90,7 @@ where
|
||||
let is_success = context.builder().build_int_compare(
|
||||
inkwell::IntPredicate::EQ,
|
||||
success,
|
||||
context.xlen_type().const_zero(),
|
||||
context.integer_const(revive_common::BIT_LENGTH_X64, 0),
|
||||
"is_success",
|
||||
)?;
|
||||
|
||||
@@ -139,8 +139,12 @@ where
|
||||
let arguments = &[
|
||||
flags.as_basic_value_enum(),
|
||||
address_pointer.value.as_basic_value_enum(),
|
||||
context.integer_const(64, 0).as_basic_value_enum(),
|
||||
context.integer_const(64, 0).as_basic_value_enum(),
|
||||
context
|
||||
.integer_const(revive_common::BIT_LENGTH_X64, 0)
|
||||
.as_basic_value_enum(),
|
||||
context
|
||||
.integer_const(revive_common::BIT_LENGTH_X64, 0)
|
||||
.as_basic_value_enum(),
|
||||
context.sentinel_pointer().value.as_basic_value_enum(),
|
||||
input_pointer.value.as_basic_value_enum(),
|
||||
input_length.as_basic_value_enum(),
|
||||
@@ -168,7 +172,7 @@ where
|
||||
let is_success = context.builder().build_int_compare(
|
||||
inkwell::IntPredicate::EQ,
|
||||
success,
|
||||
context.xlen_type().const_zero(),
|
||||
context.integer_const(revive_common::BIT_LENGTH_X64, 0),
|
||||
"is_success",
|
||||
)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user