restructure integration tests
This commit is contained in:
77
rust_compiler/libs/integration_tests/src/bitwise_tests.rs
Normal file
77
rust_compiler/libs/integration_tests/src/bitwise_tests.rs
Normal file
@@ -0,0 +1,77 @@
|
||||
#[cfg(test)]
|
||||
mod bitwise_tests {
|
||||
use crate::common::compile_with_and_without_optimization;
|
||||
use indoc::indoc;
|
||||
|
||||
#[test]
|
||||
fn test_bitwise_operations() {
|
||||
let source = indoc! {"
|
||||
let a = 5;
|
||||
let b = 3;
|
||||
let and_result = a & b;
|
||||
let or_result = a | b;
|
||||
let xor_result = a ^ b;
|
||||
let not_result = ~a;
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bitwise_shifts() {
|
||||
let source = indoc! {"
|
||||
let x = 8;
|
||||
let left_shift = x << 2;
|
||||
let arithmetic_shift = x >> 1;
|
||||
let logical_shift = x >>> 1;
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bitwise_constant_folding() {
|
||||
let source = indoc! {"
|
||||
let packed = (1 << 16) & (255 << 8) & 2;
|
||||
let mask = 0xFF & 0x0F;
|
||||
let combined = (15 | 4096);
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bitwise_with_variables() {
|
||||
let source = indoc! {"
|
||||
fn pack_bits(high, low) {
|
||||
let packed = (high << 8) | low;
|
||||
return packed;
|
||||
}
|
||||
fn extract_bits(value) {
|
||||
let high = (value >> 8) & 0xFF;
|
||||
let low = value & 0xFF;
|
||||
return (high, low);
|
||||
}
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_complex_bit_manipulation() {
|
||||
let source = indoc! {"
|
||||
fn encode_flags(enabled, mode, priority) {
|
||||
let flag_byte = (enabled << 7) | (mode << 4) | priority;
|
||||
return flag_byte;
|
||||
}
|
||||
fn decode_flags(byte) {
|
||||
let enabled = (byte >> 7) & 1;
|
||||
let mode = (byte >> 4) & 0x7;
|
||||
let priority = byte & 0xF;
|
||||
return (enabled, mode, priority);
|
||||
}
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
46
rust_compiler/libs/integration_tests/src/common.rs
Normal file
46
rust_compiler/libs/integration_tests/src/common.rs
Normal file
@@ -0,0 +1,46 @@
|
||||
use compiler::Compiler;
|
||||
use parser::Parser;
|
||||
use tokenizer::Tokenizer;
|
||||
|
||||
/// Compile Slang source code and return both unoptimized and optimized output
|
||||
pub fn compile_with_and_without_optimization(source: &str) -> String {
|
||||
// Compile for unoptimized output
|
||||
let tokenizer = Tokenizer::from(source);
|
||||
let parser = Parser::new(tokenizer);
|
||||
let compiler = Compiler::new(parser, None);
|
||||
let result = compiler.compile();
|
||||
|
||||
// Get unoptimized output
|
||||
let mut unoptimized_writer = std::io::BufWriter::new(Vec::new());
|
||||
result
|
||||
.instructions
|
||||
.write(&mut unoptimized_writer)
|
||||
.expect("Failed to write unoptimized output");
|
||||
let unoptimized_bytes = unoptimized_writer
|
||||
.into_inner()
|
||||
.expect("Failed to get bytes");
|
||||
let unoptimized = String::from_utf8(unoptimized_bytes).expect("Invalid UTF-8");
|
||||
|
||||
// Compile again for optimized output
|
||||
let tokenizer2 = Tokenizer::from(source);
|
||||
let parser2 = Parser::new(tokenizer2);
|
||||
let compiler2 = Compiler::new(parser2, None);
|
||||
let result2 = compiler2.compile();
|
||||
|
||||
// Apply optimizations
|
||||
let optimized_instructions = optimizer::optimize(result2.instructions);
|
||||
|
||||
// Get optimized output
|
||||
let mut optimized_writer = std::io::BufWriter::new(Vec::new());
|
||||
optimized_instructions
|
||||
.write(&mut optimized_writer)
|
||||
.expect("Failed to write optimized output");
|
||||
let optimized_bytes = optimized_writer.into_inner().expect("Failed to get bytes");
|
||||
let optimized = String::from_utf8(optimized_bytes).expect("Invalid UTF-8");
|
||||
|
||||
// Combine both outputs with clear separators
|
||||
format!(
|
||||
"## Unoptimized Output\n\n{}\n## Optimized Output\n\n{}",
|
||||
unoptimized, optimized
|
||||
)
|
||||
}
|
||||
48
rust_compiler/libs/integration_tests/src/function_tests.rs
Normal file
48
rust_compiler/libs/integration_tests/src/function_tests.rs
Normal file
@@ -0,0 +1,48 @@
|
||||
#[cfg(test)]
|
||||
mod function_tests {
|
||||
use crate::common::compile_with_and_without_optimization;
|
||||
use indoc::indoc;
|
||||
|
||||
#[test]
|
||||
fn test_simple_leaf_function() {
|
||||
let source = "fn test() { let x = 10; }";
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_function_with_call() {
|
||||
let source = indoc! {"
|
||||
fn add(a, b) { return a + b; }
|
||||
fn main() { let x = add(5, 10); }
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_leaf_function_no_stack_frame() {
|
||||
let source = indoc! {"
|
||||
fn increment(x) {
|
||||
x = x + 1;
|
||||
}
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_nested_function_calls() {
|
||||
let source = indoc! {"
|
||||
fn add(a, b) { return a + b; }
|
||||
fn multiply(x, y) { return x * 2; }
|
||||
fn complex(a, b) {
|
||||
let sum = add(a, b);
|
||||
let doubled = multiply(sum, 2);
|
||||
return doubled;
|
||||
}
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
@@ -4,174 +4,20 @@
|
||||
//! and optimization passes work correctly together using snapshot testing.
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use compiler::Compiler;
|
||||
mod bitwise_tests;
|
||||
#[cfg(test)]
|
||||
mod common;
|
||||
#[cfg(test)]
|
||||
mod function_tests;
|
||||
#[cfg(test)]
|
||||
mod number_literal_tests;
|
||||
#[cfg(test)]
|
||||
mod optimization_tests;
|
||||
|
||||
#[cfg(test)]
|
||||
mod integration_tests {
|
||||
use crate::common::compile_with_and_without_optimization;
|
||||
use indoc::indoc;
|
||||
use parser::Parser;
|
||||
use tokenizer::Tokenizer;
|
||||
|
||||
/// Compile Slang source code and return both unoptimized and optimized output
|
||||
fn compile_with_and_without_optimization(source: &str) -> String {
|
||||
// Compile for unoptimized output
|
||||
let tokenizer = Tokenizer::from(source);
|
||||
let parser = Parser::new(tokenizer);
|
||||
let compiler = Compiler::new(parser, None);
|
||||
let result = compiler.compile();
|
||||
|
||||
// Get unoptimized output
|
||||
let mut unoptimized_writer = std::io::BufWriter::new(Vec::new());
|
||||
result
|
||||
.instructions
|
||||
.write(&mut unoptimized_writer)
|
||||
.expect("Failed to write unoptimized output");
|
||||
let unoptimized_bytes = unoptimized_writer
|
||||
.into_inner()
|
||||
.expect("Failed to get bytes");
|
||||
let unoptimized = String::from_utf8(unoptimized_bytes).expect("Invalid UTF-8");
|
||||
|
||||
// Compile again for optimized output
|
||||
let tokenizer2 = Tokenizer::from(source);
|
||||
let parser2 = Parser::new(tokenizer2);
|
||||
let compiler2 = Compiler::new(parser2, None);
|
||||
let result2 = compiler2.compile();
|
||||
|
||||
// Apply optimizations
|
||||
let optimized_instructions = optimizer::optimize(result2.instructions);
|
||||
|
||||
// Get optimized output
|
||||
let mut optimized_writer = std::io::BufWriter::new(Vec::new());
|
||||
optimized_instructions
|
||||
.write(&mut optimized_writer)
|
||||
.expect("Failed to write optimized output");
|
||||
let optimized_bytes = optimized_writer.into_inner().expect("Failed to get bytes");
|
||||
let optimized = String::from_utf8(optimized_bytes).expect("Invalid UTF-8");
|
||||
|
||||
// Combine both outputs with clear separators
|
||||
format!(
|
||||
"## Unoptimized Output\n\n{}\n## Optimized Output\n\n{}",
|
||||
unoptimized, optimized
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_simple_leaf_function() {
|
||||
let source = "fn test() { let x = 10; }";
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_function_with_call() {
|
||||
let source = indoc! {"
|
||||
fn add(a, b) { return a + b; }
|
||||
fn main() { let x = add(5, 10); }
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_constant_folding() {
|
||||
let source = "let x = 5 + 10;";
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_algebraic_simplification() {
|
||||
let source = "let x = 5; let y = x * 1;";
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_strength_reduction() {
|
||||
let source = "fn double(x) { return x * 2; }";
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dead_code_elimination() {
|
||||
let source = indoc! {"
|
||||
fn compute(x) {
|
||||
let unused = 20;
|
||||
return x + 1;
|
||||
}
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_peephole_comparison_fusion() {
|
||||
let source = indoc! {"
|
||||
fn compare(x, y) {
|
||||
if (x > y) {
|
||||
let z = 1;
|
||||
}
|
||||
}
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_select_optimization() {
|
||||
let source = indoc! {"
|
||||
fn ternary(cond) {
|
||||
let result = 0;
|
||||
if (cond) {
|
||||
result = 10;
|
||||
} else {
|
||||
result = 20;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_leaf_function_no_stack_frame() {
|
||||
let source = indoc! {"
|
||||
fn increment(x) {
|
||||
x = x + 1;
|
||||
}
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_complex_arithmetic() {
|
||||
let source = indoc! {"
|
||||
fn compute(a, b, c) {
|
||||
let x = a * 2;
|
||||
let y = b + 0;
|
||||
let z = c * 1;
|
||||
return x + y + z;
|
||||
}
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_nested_function_calls() {
|
||||
let source = indoc! {"
|
||||
fn add(a, b) { return a + b; }
|
||||
fn multiply(x, y) { return x * 2; }
|
||||
fn complex(a, b) {
|
||||
let sum = add(a, b);
|
||||
let doubled = multiply(sum, 2);
|
||||
return doubled;
|
||||
}
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_tuples() {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#[cfg(test)]
|
||||
mod number_literal_tests {
|
||||
use crate::common::compile_with_and_without_optimization;
|
||||
use indoc::indoc;
|
||||
|
||||
#[test]
|
||||
fn test_binary_literals() {
|
||||
let source = indoc! {"
|
||||
let binary = 0b1010_1100;
|
||||
let octal = 0o755;
|
||||
let hex_upper = 0xDEAD_BEEF;
|
||||
let hex_lower = 0xcafe;
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_number_literal_optimization() {
|
||||
let source = indoc! {"
|
||||
let decimal = 42_000;
|
||||
let negative_hex = -0xFF;
|
||||
let negative_binary = -0b1111_0000;
|
||||
let temp_c = 100c;
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
#[cfg(test)]
|
||||
mod optimization_tests {
|
||||
use crate::common::compile_with_and_without_optimization;
|
||||
use indoc::indoc;
|
||||
|
||||
#[test]
|
||||
fn test_constant_folding() {
|
||||
let source = "let x = 5 + 10;";
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_algebraic_simplification() {
|
||||
let source = "let x = 5; let y = x * 1;";
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_strength_reduction() {
|
||||
let source = "fn double(x) { return x * 2; }";
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dead_code_elimination() {
|
||||
let source = indoc! {"
|
||||
fn compute(x) {
|
||||
let unused = 20;
|
||||
return x + 1;
|
||||
}
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_peephole_comparison_fusion() {
|
||||
let source = indoc! {"
|
||||
fn compare(x, y) {
|
||||
if (x > y) {
|
||||
let z = 1;
|
||||
}
|
||||
}
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_select_optimization() {
|
||||
let source = indoc! {"
|
||||
fn ternary(cond) {
|
||||
let result = 0;
|
||||
if (cond) {
|
||||
result = 10;
|
||||
} else {
|
||||
result = 20;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_complex_arithmetic() {
|
||||
let source = indoc! {"
|
||||
fn compute(a, b, c) {
|
||||
let x = a * 2;
|
||||
let y = b + 0;
|
||||
let z = c * 1;
|
||||
return x + y + z;
|
||||
}
|
||||
"};
|
||||
let output = compile_with_and_without_optimization(source);
|
||||
insta::assert_snapshot!(output);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
source: libs/integration_tests/src/bitwise_tests.rs
|
||||
assertion_line: 40
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
|
||||
j main
|
||||
main:
|
||||
move r8 0
|
||||
move r9 15
|
||||
move r10 4111
|
||||
|
||||
## Optimized Output
|
||||
|
||||
move r8 0
|
||||
move r9 15
|
||||
move r10 4111
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
source: libs/integration_tests/src/bitwise_tests.rs
|
||||
assertion_line: 17
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
|
||||
j main
|
||||
main:
|
||||
move r8 5
|
||||
move r9 3
|
||||
and r1 r8 r9
|
||||
move r10 r1
|
||||
or r2 r8 r9
|
||||
move r11 r2
|
||||
xor r3 r8 r9
|
||||
move r12 r3
|
||||
not r4 r8
|
||||
move r13 r4
|
||||
|
||||
## Optimized Output
|
||||
|
||||
move r8 5
|
||||
move r9 3
|
||||
and r10 r8 r9
|
||||
or r11 r8 r9
|
||||
xor r12 r8 r9
|
||||
not r4 r8
|
||||
move r13 r4
|
||||
@@ -0,0 +1,26 @@
|
||||
---
|
||||
source: libs/integration_tests/src/bitwise_tests.rs
|
||||
assertion_line: 29
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
|
||||
j main
|
||||
main:
|
||||
move r8 8
|
||||
sll r1 r8 2
|
||||
move r9 r1
|
||||
sra r2 r8 1
|
||||
move r10 r2
|
||||
srl r3 r8 1
|
||||
move r11 r3
|
||||
|
||||
## Optimized Output
|
||||
|
||||
move r8 8
|
||||
sll r1 r8 2
|
||||
move r9 r1
|
||||
sra r2 r8 1
|
||||
move r10 r2
|
||||
srl r3 r8 1
|
||||
move r11 r3
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
source: libs/integration_tests/src/bitwise_tests.rs
|
||||
assertion_line: 57
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
|
||||
j main
|
||||
pack_bits:
|
||||
pop r8
|
||||
pop r9
|
||||
push sp
|
||||
push ra
|
||||
sll r1 r9 8
|
||||
or r2 r1 r8
|
||||
move r10 r2
|
||||
move r15 r10
|
||||
j __internal_L1
|
||||
__internal_L1:
|
||||
pop ra
|
||||
pop sp
|
||||
j ra
|
||||
extract_bits:
|
||||
pop r8
|
||||
push sp
|
||||
push ra
|
||||
sra r1 r8 8
|
||||
and r2 r1 255
|
||||
move r9 r2
|
||||
and r3 r8 255
|
||||
move r10 r3
|
||||
push r9
|
||||
push r10
|
||||
sub r0 sp 4
|
||||
get r0 db r0
|
||||
move r15 r0
|
||||
j __internal_L2
|
||||
__internal_L2:
|
||||
sub r0 sp 3
|
||||
get ra db r0
|
||||
j ra
|
||||
|
||||
## Optimized Output
|
||||
|
||||
j main
|
||||
pop r8
|
||||
pop r9
|
||||
push sp
|
||||
push ra
|
||||
sll r1 r9 8
|
||||
or r15 r1 r8
|
||||
pop ra
|
||||
pop sp
|
||||
j ra
|
||||
pop r8
|
||||
push sp
|
||||
push ra
|
||||
sra r1 r8 8
|
||||
and r9 r1 255
|
||||
and r10 r8 255
|
||||
push r9
|
||||
push r10
|
||||
sub r0 sp 4
|
||||
get r15 db r0
|
||||
sub r0 sp 3
|
||||
get ra db r0
|
||||
j ra
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
source: libs/integration_tests/src/bitwise_tests.rs
|
||||
assertion_line: 75
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
|
||||
j main
|
||||
encode_flags:
|
||||
pop r8
|
||||
pop r9
|
||||
pop r10
|
||||
push sp
|
||||
push ra
|
||||
sll r1 r10 7
|
||||
sll r2 r9 4
|
||||
or r3 r1 r2
|
||||
or r4 r3 r8
|
||||
move r11 r4
|
||||
move r15 r11
|
||||
j __internal_L1
|
||||
__internal_L1:
|
||||
pop ra
|
||||
pop sp
|
||||
j ra
|
||||
decode_flags:
|
||||
pop r8
|
||||
push sp
|
||||
push ra
|
||||
sra r1 r8 7
|
||||
and r2 r1 1
|
||||
move r9 r2
|
||||
sra r3 r8 4
|
||||
and r4 r3 7
|
||||
move r10 r4
|
||||
and r5 r8 15
|
||||
move r11 r5
|
||||
push r9
|
||||
push r10
|
||||
push r11
|
||||
sub r0 sp 5
|
||||
get r0 db r0
|
||||
move r15 r0
|
||||
j __internal_L2
|
||||
__internal_L2:
|
||||
sub r0 sp 4
|
||||
get ra db r0
|
||||
j ra
|
||||
|
||||
## Optimized Output
|
||||
|
||||
j main
|
||||
pop r8
|
||||
pop r9
|
||||
pop r10
|
||||
push sp
|
||||
push ra
|
||||
sll r1 r10 7
|
||||
sll r2 r9 4
|
||||
or r3 r1 r2
|
||||
or r15 r3 r8
|
||||
pop ra
|
||||
pop sp
|
||||
j ra
|
||||
pop r8
|
||||
push sp
|
||||
push ra
|
||||
sra r1 r8 7
|
||||
and r9 r1 1
|
||||
sra r3 r8 4
|
||||
and r10 r3 7
|
||||
and r11 r8 15
|
||||
push r9
|
||||
push r10
|
||||
push r11
|
||||
sub r0 sp 5
|
||||
get r15 db r0
|
||||
sub r0 sp 4
|
||||
get ra db r0
|
||||
j ra
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
source: libs/integration_tests/src/lib.rs
|
||||
assertion_line: 70
|
||||
source: libs/integration_tests/src/function_tests.rs
|
||||
assertion_line: 20
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
source: libs/integration_tests/src/lib.rs
|
||||
assertion_line: 144
|
||||
source: libs/integration_tests/src/function_tests.rs
|
||||
assertion_line: 31
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
source: libs/integration_tests/src/lib.rs
|
||||
assertion_line: 173
|
||||
source: libs/integration_tests/src/function_tests.rs
|
||||
assertion_line: 46
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
source: libs/integration_tests/src/lib.rs
|
||||
assertion_line: 60
|
||||
source: libs/integration_tests/src/function_tests.rs
|
||||
assertion_line: 10
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
@@ -0,0 +1,224 @@
|
||||
---
|
||||
source: libs/integration_tests/src/lib.rs
|
||||
assertion_line: 54
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
|
||||
j main
|
||||
waitForIdle:
|
||||
push sp
|
||||
push ra
|
||||
yield
|
||||
__internal_L2:
|
||||
l r1 d0 Idle
|
||||
seq r2 r1 0
|
||||
beqz r2 __internal_L3
|
||||
yield
|
||||
j __internal_L2
|
||||
__internal_L3:
|
||||
__internal_L1:
|
||||
pop ra
|
||||
pop sp
|
||||
j ra
|
||||
deposit:
|
||||
push sp
|
||||
push ra
|
||||
s d0 Setting 1
|
||||
jal waitForIdle
|
||||
move r1 r15
|
||||
s d0 Activate 1
|
||||
jal waitForIdle
|
||||
move r2 r15
|
||||
s d1 Open 0
|
||||
__internal_L4:
|
||||
pop ra
|
||||
pop sp
|
||||
j ra
|
||||
checkAndHarvest:
|
||||
pop r8
|
||||
push sp
|
||||
push ra
|
||||
sle r1 r8 1
|
||||
ls r15 d0 255 Seeding
|
||||
slt r2 r15 1
|
||||
or r3 r1 r2
|
||||
beqz r3 __internal_L6
|
||||
j __internal_L5
|
||||
__internal_L6:
|
||||
__internal_L7:
|
||||
ls r15 d0 255 Mature
|
||||
beqz r15 __internal_L8
|
||||
yield
|
||||
s d0 Activate 1
|
||||
j __internal_L7
|
||||
__internal_L8:
|
||||
ls r15 d0 255 Occupied
|
||||
move r9 r15
|
||||
s d0 Setting 1
|
||||
push r8
|
||||
push r9
|
||||
jal waitForIdle
|
||||
pop r9
|
||||
pop r8
|
||||
move r4 r15
|
||||
push r8
|
||||
push r9
|
||||
jal deposit
|
||||
pop r9
|
||||
pop r8
|
||||
move r5 r15
|
||||
beqz r9 __internal_L9
|
||||
push r8
|
||||
push r9
|
||||
jal deposit
|
||||
pop r9
|
||||
pop r8
|
||||
move r6 r15
|
||||
__internal_L9:
|
||||
s d0 Setting r8
|
||||
push r8
|
||||
push r9
|
||||
jal waitForIdle
|
||||
pop r9
|
||||
pop r8
|
||||
move r6 r15
|
||||
ls r15 d0 0 Occupied
|
||||
beqz r15 __internal_L10
|
||||
s d0 Activate 1
|
||||
__internal_L10:
|
||||
push r8
|
||||
push r9
|
||||
jal waitForIdle
|
||||
pop r9
|
||||
pop r8
|
||||
move r7 r15
|
||||
__internal_L5:
|
||||
pop ra
|
||||
pop sp
|
||||
j ra
|
||||
main:
|
||||
move r8 0
|
||||
__internal_L11:
|
||||
yield
|
||||
l r1 d0 Idle
|
||||
seq r2 r1 0
|
||||
beqz r2 __internal_L13
|
||||
j __internal_L11
|
||||
__internal_L13:
|
||||
add r3 r8 1
|
||||
sgt r4 r3 19
|
||||
add r5 r8 1
|
||||
select r6 r4 2 r5
|
||||
move r9 r6
|
||||
push r8
|
||||
push r9
|
||||
push r8
|
||||
jal checkAndHarvest
|
||||
pop r9
|
||||
pop r8
|
||||
move r7 r15
|
||||
s d0 Setting r9
|
||||
move r8 r9
|
||||
j __internal_L11
|
||||
__internal_L12:
|
||||
|
||||
## Optimized Output
|
||||
|
||||
j 77
|
||||
push sp
|
||||
push ra
|
||||
yield
|
||||
l r1 d0 Idle
|
||||
bne r1 0 8
|
||||
yield
|
||||
j 4
|
||||
pop ra
|
||||
pop sp
|
||||
j ra
|
||||
push sp
|
||||
push ra
|
||||
s d0 Setting 1
|
||||
jal 1
|
||||
move r1 r15
|
||||
s d0 Activate 1
|
||||
jal 1
|
||||
move r2 r15
|
||||
s d1 Open 0
|
||||
pop ra
|
||||
pop sp
|
||||
j ra
|
||||
pop r8
|
||||
push sp
|
||||
push ra
|
||||
sle r1 r8 1
|
||||
ls r15 d0 255 Seeding
|
||||
slt r2 r15 1
|
||||
or r3 r1 r2
|
||||
beqz r3 32
|
||||
j 74
|
||||
ls r15 d0 255 Mature
|
||||
beqz r15 37
|
||||
yield
|
||||
s d0 Activate 1
|
||||
j 32
|
||||
ls r9 d0 255 Occupied
|
||||
s d0 Setting 1
|
||||
push r8
|
||||
push r9
|
||||
jal 1
|
||||
pop r9
|
||||
pop r8
|
||||
move r4 r15
|
||||
push r8
|
||||
push r9
|
||||
jal 11
|
||||
pop r9
|
||||
pop r8
|
||||
move r5 r15
|
||||
beqz r9 58
|
||||
push r8
|
||||
push r9
|
||||
jal 11
|
||||
pop r9
|
||||
pop r8
|
||||
move r6 r15
|
||||
s d0 Setting r8
|
||||
push r8
|
||||
push r9
|
||||
jal 1
|
||||
pop r9
|
||||
pop r8
|
||||
move r6 r15
|
||||
ls r15 d0 0 Occupied
|
||||
beqz r15 68
|
||||
s d0 Activate 1
|
||||
push r8
|
||||
push r9
|
||||
jal 1
|
||||
pop r9
|
||||
pop r8
|
||||
move r7 r15
|
||||
pop ra
|
||||
pop sp
|
||||
j ra
|
||||
move r8 0
|
||||
yield
|
||||
l r1 d0 Idle
|
||||
bne r1 0 82
|
||||
j 78
|
||||
add r3 r8 1
|
||||
sgt r4 r3 19
|
||||
add r5 r8 1
|
||||
select r6 r4 2 r5
|
||||
move r9 r6
|
||||
push r8
|
||||
push r9
|
||||
push r8
|
||||
jal 23
|
||||
pop r9
|
||||
pop r8
|
||||
move r7 r15
|
||||
s d0 Setting r9
|
||||
move r8 r9
|
||||
j 78
|
||||
@@ -0,0 +1,112 @@
|
||||
---
|
||||
source: libs/integration_tests/src/lib.rs
|
||||
assertion_line: 61
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
|
||||
j main
|
||||
main:
|
||||
s d2 Mode 1
|
||||
s d2 On 0
|
||||
move r8 0
|
||||
move r9 0
|
||||
__internal_L1:
|
||||
yield
|
||||
l r1 d0 Reagents
|
||||
move r10 r1
|
||||
sge r2 r10 100
|
||||
sge r3 r9 2
|
||||
or r4 r2 r3
|
||||
beqz r4 __internal_L3
|
||||
move r8 1
|
||||
__internal_L3:
|
||||
slt r5 r10 100
|
||||
ls r15 d0 0 Occupied
|
||||
seq r6 r15 0
|
||||
and r7 r5 r6
|
||||
add r1 r9 1
|
||||
select r2 r7 r1 0
|
||||
move r9 r2
|
||||
l r3 d0 Rpm
|
||||
slt r4 r3 1
|
||||
and r5 r8 r4
|
||||
beqz r5 __internal_L4
|
||||
s d0 Open 1
|
||||
seq r6 r10 0
|
||||
ls r15 d0 0 Occupied
|
||||
and r7 r6 r15
|
||||
seq r1 r7 0
|
||||
move r8 r1
|
||||
__internal_L4:
|
||||
seq r6 r8 0
|
||||
s d0 On r6
|
||||
ls r15 d1 0 Quantity
|
||||
move r11 r15
|
||||
l r7 d3 Pressure
|
||||
sgt r1 r7 200
|
||||
beqz r1 __internal_L5
|
||||
j __internal_L1
|
||||
__internal_L5:
|
||||
sgt r2 r11 0
|
||||
s d1 On r2
|
||||
sgt r3 r11 0
|
||||
s d1 Activate r3
|
||||
l r4 d3 Pressure
|
||||
sgt r5 r4 0
|
||||
l r6 d1 Activate
|
||||
or r7 r5 r6
|
||||
s d2 On r7
|
||||
l r1 d1 Activate
|
||||
s db Setting r1
|
||||
j __internal_L1
|
||||
__internal_L2:
|
||||
|
||||
## Optimized Output
|
||||
|
||||
s d2 Mode 1
|
||||
s d2 On 0
|
||||
move r8 0
|
||||
move r9 0
|
||||
yield
|
||||
l r10 d0 Reagents
|
||||
sge r2 r10 100
|
||||
sge r3 r9 2
|
||||
or r4 r2 r3
|
||||
beqz r4 11
|
||||
move r8 1
|
||||
slt r5 r10 100
|
||||
ls r15 d0 0 Occupied
|
||||
seq r6 r15 0
|
||||
and r7 r5 r6
|
||||
add r1 r9 1
|
||||
select r2 r7 r1 0
|
||||
move r9 r2
|
||||
l r3 d0 Rpm
|
||||
slt r4 r3 1
|
||||
and r5 r8 r4
|
||||
beqz r5 27
|
||||
s d0 Open 1
|
||||
seq r6 r10 0
|
||||
ls r15 d0 0 Occupied
|
||||
and r7 r6 r15
|
||||
seq r8 r7 0
|
||||
seq r6 r8 0
|
||||
s d0 On r6
|
||||
ls r15 d1 0 Quantity
|
||||
move r11 r15
|
||||
l r7 d3 Pressure
|
||||
ble r7 200 34
|
||||
j 4
|
||||
sgt r2 r11 0
|
||||
s d1 On r2
|
||||
sgt r3 r11 0
|
||||
s d1 Activate r3
|
||||
l r4 d3 Pressure
|
||||
sgt r5 r4 0
|
||||
l r6 d1 Activate
|
||||
or r7 r5 r6
|
||||
s d2 On r7
|
||||
l r1 d1 Activate
|
||||
s db Setting r1
|
||||
j 4
|
||||
@@ -0,0 +1,93 @@
|
||||
---
|
||||
source: libs/integration_tests/src/lib.rs
|
||||
assertion_line: 47
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
|
||||
j main
|
||||
getSomethingElse:
|
||||
pop r8
|
||||
push sp
|
||||
push ra
|
||||
add r1 r8 1
|
||||
move r15 r1
|
||||
j __internal_L1
|
||||
__internal_L1:
|
||||
pop ra
|
||||
pop sp
|
||||
j ra
|
||||
getSensorData:
|
||||
push sp
|
||||
push ra
|
||||
l r1 d0 Vertical
|
||||
push r1
|
||||
l r2 d0 Horizontal
|
||||
push r2
|
||||
push 3
|
||||
jal getSomethingElse
|
||||
move r3 r15
|
||||
push r3
|
||||
sub r0 sp 5
|
||||
get r0 db r0
|
||||
move r15 r0
|
||||
j __internal_L2
|
||||
__internal_L2:
|
||||
sub r0 sp 4
|
||||
get ra db r0
|
||||
j ra
|
||||
main:
|
||||
__internal_L3:
|
||||
yield
|
||||
jal getSensorData
|
||||
pop r0
|
||||
pop r9
|
||||
pop r8
|
||||
move sp r15
|
||||
jal getSensorData
|
||||
pop r0
|
||||
pop r0
|
||||
pop r9
|
||||
move sp r15
|
||||
s db Setting r9
|
||||
j __internal_L3
|
||||
__internal_L4:
|
||||
|
||||
## Optimized Output
|
||||
|
||||
j 23
|
||||
pop r8
|
||||
push sp
|
||||
push ra
|
||||
add r15 r8 1
|
||||
pop ra
|
||||
pop sp
|
||||
j ra
|
||||
push sp
|
||||
push ra
|
||||
l r1 d0 Vertical
|
||||
push r1
|
||||
l r2 d0 Horizontal
|
||||
push r2
|
||||
push 3
|
||||
jal 1
|
||||
move r3 r15
|
||||
push r3
|
||||
sub r0 sp 5
|
||||
get r15 db r0
|
||||
sub r0 sp 4
|
||||
get ra db r0
|
||||
j ra
|
||||
yield
|
||||
jal 8
|
||||
pop r0
|
||||
pop r9
|
||||
pop r8
|
||||
move sp r15
|
||||
jal 8
|
||||
pop r0
|
||||
pop r0
|
||||
pop r9
|
||||
move sp r15
|
||||
s db Setting r9
|
||||
j 23
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
source: libs/integration_tests/src/number_literal_tests.rs
|
||||
assertion_line: 15
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
|
||||
j main
|
||||
main:
|
||||
move r8 172
|
||||
move r9 493
|
||||
move r10 3735928559
|
||||
move r11 51966
|
||||
|
||||
## Optimized Output
|
||||
|
||||
move r8 172
|
||||
move r9 493
|
||||
move r10 3735928559
|
||||
move r11 51966
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
source: libs/integration_tests/src/number_literal_tests.rs
|
||||
assertion_line: 27
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
|
||||
j main
|
||||
main:
|
||||
move r8 42000
|
||||
move r9 -255
|
||||
move r10 -240
|
||||
move r11 373.15
|
||||
|
||||
## Optimized Output
|
||||
|
||||
move r8 42000
|
||||
move r9 -255
|
||||
move r10 -240
|
||||
move r11 373.15
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
source: libs/integration_tests/src/lib.rs
|
||||
source: libs/integration_tests/src/optimization_tests.rs
|
||||
assertion_line: 17
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
source: libs/integration_tests/src/lib.rs
|
||||
assertion_line: 158
|
||||
source: libs/integration_tests/src/optimization_tests.rs
|
||||
assertion_line: 80
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
source: libs/integration_tests/src/lib.rs
|
||||
source: libs/integration_tests/src/optimization_tests.rs
|
||||
assertion_line: 10
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
source: libs/integration_tests/src/lib.rs
|
||||
assertion_line: 103
|
||||
source: libs/integration_tests/src/optimization_tests.rs
|
||||
assertion_line: 36
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
source: libs/integration_tests/src/lib.rs
|
||||
assertion_line: 116
|
||||
source: libs/integration_tests/src/optimization_tests.rs
|
||||
assertion_line: 49
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
source: libs/integration_tests/src/lib.rs
|
||||
assertion_line: 133
|
||||
source: libs/integration_tests/src/optimization_tests.rs
|
||||
assertion_line: 66
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
source: libs/integration_tests/src/lib.rs
|
||||
assertion_line: 91
|
||||
source: libs/integration_tests/src/optimization_tests.rs
|
||||
assertion_line: 24
|
||||
expression: output
|
||||
---
|
||||
## Unoptimized Output
|
||||
Reference in New Issue
Block a user