custom ir

Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
Cyrill Leutwiler
2024-02-02 09:10:03 +01:00
parent 7a094f17c0
commit d238d8f39e
48 changed files with 4399 additions and 603 deletions
+4 -1
View File
@@ -8,4 +8,7 @@ edition = "2021"
[dependencies]
hex = { workspace = true }
evmil = { workspace = true }
revive-ir = { path = "../ir" }
revive-ir = { path = "../ir" }
revive-codegen = { path = "../codegen" }
revive-target-polkavm = { path = "../target-polkavm" }
+13 -2
View File
@@ -1,10 +1,21 @@
use evmil::bytecode::Disassemble;
use revive_ir::cfg::{BasicBlockFormatOption, Program};
use revive_ir::cfg::BasicBlockFormatOption;
use revive_target_polkavm::PolkaVm;
fn main() {
let hexcode = std::fs::read_to_string(std::env::args().nth(1).unwrap()).unwrap();
let bytecode = hex::decode(hexcode.trim()).unwrap();
let instructions = bytecode.disassemble();
Program::new(instructions).dot(BasicBlockFormatOption::ByteCode);
let mut ir = revive_ir::cfg::Program::new(&instructions);
ir.optimize();
ir.dot(BasicBlockFormatOption::Ir);
let target = PolkaVm::default();
let program = revive_codegen::program::Program::new(&target).unwrap();
program.emit(ir);
let artifact = program.compile_and_link();
std::fs::write("/tmp/out.pvm", artifact).unwrap();
}