remove extensions crate

Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
xermicus
2024-06-18 16:08:35 +02:00
parent 0d39b289cb
commit a4c4ad55dc
5 changed files with 0 additions and 108 deletions
Generated
-7
View File
@@ -1718,13 +1718,6 @@ dependencies = [
"primitive-types",
]
[[package]]
name = "revive-extensions"
version = "0.1.0"
dependencies = [
"inkwell",
]
[[package]]
name = "revive-integration"
version = "0.1.0"
-9
View File
@@ -1,9 +0,0 @@
[package]
name = "revive-extensions"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
inkwell = { workspace = true, features = ["target-riscv", "no-libffi-linking", "llvm18-0"] }
-13
View File
@@ -1,13 +0,0 @@
target datalayout = "e-m:e-p:32:32-i64:64-n32-S128"
target triple = "riscv32-unknown-unknown-elf"
define dso_local noundef i256 @__bswap(i256 noundef %0) local_unnamed_addr #0 {
%2 = tail call i256 @llvm.bswap.i256(i256 %0)
ret i256 %2
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i256 @llvm.bswap.i256(i256) #1
attributes #0 = { alwaysinline mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
-40
View File
@@ -1,40 +0,0 @@
use std::{env, fs, path::Path, process::Command};
fn compile(source_path: &str, output_path: &str) {
let output = Command::new("llc")
.args([
"-O3",
"-filetype=asm",
"-mattr=+zbb,+e",
source_path,
"-o",
output_path,
])
.output()
.expect("should be able to invoke llc");
assert!(
output.status.success(),
"failed to compile {}: {:?}",
source_path,
output
);
}
fn main() {
let in_file = "bswap.ll";
let out_file = "bswap.s";
let out_dir = env::var_os("OUT_DIR").expect("env should have $OUT_DIR");
let out_path = Path::new(&out_dir).join(out_file);
compile(
in_file,
out_path.to_str().expect("$OUT_DIR should be UTF-8"),
);
let src_path = Path::new(&out_dir).join("bswap.rs");
let src = format!("pub static ASSEMBLY: &str = include_str!(\"{out_file}\");");
fs::write(src_path, src).expect("should be able to write in $OUT_DIR");
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=bswap.ll");
}
-39
View File
@@ -1,39 +0,0 @@
//! Custom RISC-V extension in PolkaVM that are partially supported.
//! We use inline assembly to emit partially supported instructions.
use inkwell::{context::Context, module::Module, support::LLVMString};
include!(concat!(env!("OUT_DIR"), "/bswap.rs"));
/// Returns a LLVM module containing a `__bswap` function, which
/// - Takes a `i256` value argument
/// - Byte swaps it using `rev8` from the `zbb` extension
/// - Returns the `i256` value
/// Returns `Error` if the module fails to validate, which should never happen.
pub fn module<'context>(
context: &'context Context,
module_name: &str,
) -> Result<Module<'context>, LLVMString> {
let module = context.create_module(module_name);
module.set_inline_assembly(ASSEMBLY);
module.verify()?;
Ok(module)
}
#[cfg(test)]
mod tests {
#[test]
fn assembly_contains_rev8_instruction() {
assert!(crate::ASSEMBLY.contains("rev8"));
}
#[test]
fn module_is_valid() {
inkwell::targets::Target::initialize_riscv(&Default::default());
let context = inkwell::context::Context::create();
assert!(crate::module(&context, "polkavm_bswap").is_ok());
}
}