Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
FractalFir committed Feb 16, 2025
1 parent fa34609 commit 25c6f80
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 820 deletions.
5 changes: 0 additions & 5 deletions src/alloc_erorr_hook.rs

This file was deleted.

19 changes: 18 additions & 1 deletion src/assembly.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pub use crate::fn_ctx::MethodCompileCtx;
use crate::{
basic_block::handler_for_block,
cil::span_source_info,
codegen_error::{CodegenError, MethodCodegenError},
r#type::get_type,
rustc_middle::dep_graph::DepContext,
Expand Down Expand Up @@ -866,3 +865,21 @@ pub fn add_const_value(asm: &mut cilly::v2::Assembly, bytes: u128) -> StaticFiel

field_desc
}


pub(crate) fn span_source_info(tcx: TyCtxt, span: rustc_span::Span) -> CILRoot {
let (file, lstart, cstart, lend, mut cend) = tcx.sess.source_map().span_to_location_info(span);
let file = file.map_or(String::new(), |file| {
file.name
.display(rustc_span::FileNameDisplayPreference::Local)
.to_string()
});
if cstart >= cend {
cend = cstart + 1;
}
CILRoot::source_info(
&file,
(lstart as u64)..(lend as u64),
(cstart as u64)..(cend as u64),
)
}
Empty file removed src/builtin/atomic.rs
Empty file.
1 change: 0 additions & 1 deletion src/builtin/casts.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/builtin/mod.rs

This file was deleted.

36 changes: 0 additions & 36 deletions src/builtin/panic_location.rs

This file was deleted.

Empty file removed src/builtin/select.rs
Empty file.
19 changes: 0 additions & 19 deletions src/cil/mod.rs

This file was deleted.

15 changes: 8 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ extern crate rustc_symbol_mangling;
extern crate rustc_target;
extern crate rustc_ty_utils;
extern crate stable_mir;
/// Used for handling OOM in compiler
mod alloc_erorr_hook;


// Modules
/// Code handling the creation of aggreate values (Arrays, enums,structs,tuples,etc.)
Expand All @@ -108,8 +107,7 @@ pub mod assembly;
pub mod basic_block;
/// Code handling binary operations
mod binop;
/// Implementation of key external functions(eg. libc) necesary for propely running a Rust executable
pub mod builtin;

mod call_info;
/// Code hansling rust `as` casts.
mod casts;
Expand Down Expand Up @@ -146,8 +144,6 @@ mod rvalue;
pub mod statement;
/// Converts a terminator of a basic block into CIL ops.
mod terminator;
/// Code handling transmutes.
mod transmute;
/// Code related to types.
pub mod r#type;

Expand Down Expand Up @@ -341,7 +337,12 @@ impl ArchiveBuilderBuilder for RlibArchiveBuilder {
#[no_mangle]
/// Entrypoint of the codegen. This function starts the backend up, and returns a reference to it to rustc.
pub extern "Rust" fn __rustc_codegen_backend() -> Box<dyn CodegenBackend> {
std::alloc::set_alloc_error_hook(alloc_erorr_hook::custom_alloc_error_hook);
std::alloc::set_alloc_error_hook(custom_alloc_error_hook);
Box::new(MyBackend)
}
pub use cilly::{DATA_PTR, ENUM_TAG, METADATA};
use std::alloc::Layout;

pub fn custom_alloc_error_hook(layout: Layout) {
panic!("memory allocation of {} bytes failed", layout.size());
}
Empty file removed src/libc.rs
Empty file.
155 changes: 0 additions & 155 deletions src/liblets/panic_info.rs

This file was deleted.

Loading

0 comments on commit 25c6f80

Please sign in to comment.