Skip to content

Commit

Permalink
cleaning up super instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwparas committed Feb 19, 2024
1 parent cd3d3a8 commit 75a739a
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 135 deletions.
8 changes: 6 additions & 2 deletions crates/steel-core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ fn main() {
use std::path::Path;

let out_dir = env::var_os("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("generated.rs");
// let dest_path = Path::new(&out_dir).join("generated.rs");

fs::write(dest_path, steel_gen::permutations::code_gen()).unwrap();
// fs::write(dest_path, steel_gen::permutations::code_gen()).unwrap();

let dest_path = Path::new(&out_dir).join("dynamic.rs");

fs::write(dest_path, steel_gen::generate_opcode_map()).unwrap();

println!("cargo:rerun-if-changed=build.rs");
}
Expand Down
13 changes: 9 additions & 4 deletions crates/steel-core/src/compiler/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use log::{debug, log_enabled};

use super::{compiler::DebruijnIndicesInterner, map::SymbolMap};

const _TILE_SUPER_INSTRUCTIONS: bool = false;
const TILE_SUPER_INSTRUCTIONS: bool = true;

pub fn number_literal_to_steel(n: &NumberLiteral) -> Result<SteelVal> {
// real_to_steel does some cloning of bignums. It may be possible to optimize this away.
Expand Down Expand Up @@ -505,7 +505,7 @@ pub const fn sequence_to_opcode(pattern: &[(OpCode, usize)]) -> &'static [steel_
}
}

pub fn tile_super_instructions(_instructions: &mut [Instruction]) {
pub fn tile_super_instructions(instructions: &mut [Instruction]) {
#[cfg(feature = "dynamic")]
{
pub fn tile<const N: usize>(instructions: &mut [Instruction]) {
Expand Down Expand Up @@ -535,7 +535,10 @@ pub fn tile_super_instructions(_instructions: &mut [Instruction]) {
steel_gen::Pattern::from_opcodes_with_buffer(&buffer, &mut pattern_buffer);

if crate::steel_vm::vm::pattern_exists(&pattern_buffer) {
log::debug!(target: "super-instructions", "Applying tiling for: {:?}", op_code);
// log::debug!(target: "super-instructions", "Applying tiling for: {:?}", op_code);

// println!("Applying tiling for: {:?}", op_code);
// println!("{:?}", pattern_buffer);

instructions[i].op_code = op_code;

Expand All @@ -551,7 +554,9 @@ pub fn tile_super_instructions(_instructions: &mut [Instruction]) {

// Super instruction tiling here!

if _TILE_SUPER_INSTRUCTIONS {
if TILE_SUPER_INSTRUCTIONS {
tile::<11>(instructions);
tile::<10>(instructions);
tile::<9>(instructions);
tile::<8>(instructions);
tile::<7>(instructions);
Expand Down
Loading

0 comments on commit 75a739a

Please sign in to comment.