Skip to main content

revmc_codegen/
lib.rs

1#![allow(clippy::needless_doctest_main)]
2#![doc = include_str!("../README.md")]
3#![cfg_attr(not(test), warn(unused_extern_crates))]
4#![cfg_attr(docsrs, feature(doc_cfg))]
5
6#[macro_use]
7extern crate tracing;
8
9use revmc_backend::{eyre, *};
10use revmc_context::*;
11
12mod bytecode;
13pub use bytecode::*;
14
15mod compiler;
16pub use compiler::{CompileTimings, EvmCompiler, EvmCompilerInput};
17
18mod linker;
19pub use linker::{Linker, shared_library_path};
20
21/// Generic `revm` JIT EVM from `revmc-context`.
22pub mod simple_revm_evm {
23    pub use revmc_context::JitEvm;
24}
25
26/// ABI version of compiled artifacts. Bump when the calling convention changes.
27pub const ABI_VERSION: u32 = 0;
28
29/// Internal tests and testing utilities. Not public API.
30#[cfg(any(test, feature = "__fuzzing"))]
31pub mod tests;
32
33type FxHashMap<K, V> = alloy_primitives::map::HashMap<K, V, alloy_primitives::map::FxBuildHasher>;
34
35/// Enable for `cargo asm -p revmc --lib`.
36#[cfg(any())]
37pub fn generate_all_assembly() -> EvmCompiler<revmc_llvm::EvmLlvmBackend> {
38    let mut compiler = EvmCompiler::new_llvm(false).unwrap();
39    let _ = compiler.jit(None, &[], revm_primitives::hardfork::SpecId::ARROW_GLACIER).unwrap();
40    unsafe { compiler.clear().unwrap() };
41    compiler
42}