mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-11 05:34:11 +03:00
Refactor for faster Rust compile times
This commit is contained in:
parent
c7459e9888
commit
07b3c74713
@ -116,6 +116,13 @@ impl From<&StoredValue> for CodeGenNumType {
|
||||
}
|
||||
}
|
||||
|
||||
fn integer_symbol_is_signed(backend: &WasmBackend<'_>, symbol: Symbol) -> bool {
|
||||
return match backend.storage.symbol_layouts[&symbol] {
|
||||
Layout::Builtin(Builtin::Int(int_width)) => int_width.is_signed(),
|
||||
x => internal_error!("Expected integer, found {:?}", x),
|
||||
};
|
||||
}
|
||||
|
||||
pub struct LowLevelCall<'a> {
|
||||
pub lowlevel: LowLevel,
|
||||
pub arguments: &'a [Symbol],
|
||||
@ -180,16 +187,6 @@ impl<'a> LowLevelCall<'a> {
|
||||
use CodeGenNumType::*;
|
||||
use LowLevel::*;
|
||||
|
||||
fn integer_symbol_is_signed(backend: &WasmBackend<'_>, symbol: Symbol) -> bool {
|
||||
return match backend.storage.symbol_layouts[&symbol] {
|
||||
Layout::Builtin(Builtin::Int(int_width)) => match int_width {
|
||||
IntWidth::U8 | IntWidth::U16 | IntWidth::U32 | IntWidth::U64 | IntWidth::U128 => false,
|
||||
IntWidth::I8 | IntWidth::I16 | IntWidth::I32 | IntWidth::I64 | IntWidth::I128 => true,
|
||||
},
|
||||
_ => internal_error!("Expected integer, found {:?}", symbol),
|
||||
};
|
||||
}
|
||||
|
||||
let panic_ret_type = || {
|
||||
internal_error!(
|
||||
"Invalid return layout for {:?}: {:?}",
|
||||
@ -387,15 +384,19 @@ impl<'a> LowLevelCall<'a> {
|
||||
NumGt => {
|
||||
self.load_args(backend);
|
||||
match CodeGenNumType::for_symbol(backend, self.arguments[0]) {
|
||||
I32 => if integer_symbol_is_signed(backend, self.arguments[0]) {
|
||||
backend.code_builder.i32_gt_s()
|
||||
} else {
|
||||
backend.code_builder.i32_gt_u()
|
||||
I32 => {
|
||||
if integer_symbol_is_signed(backend, self.arguments[0]) {
|
||||
backend.code_builder.i32_gt_s()
|
||||
} else {
|
||||
backend.code_builder.i32_gt_u()
|
||||
}
|
||||
}
|
||||
I64 => if integer_symbol_is_signed(backend, self.arguments[0]) {
|
||||
backend.code_builder.i64_gt_s()
|
||||
} else {
|
||||
backend.code_builder.i64_gt_u()
|
||||
I64 => {
|
||||
if integer_symbol_is_signed(backend, self.arguments[0]) {
|
||||
backend.code_builder.i64_gt_s()
|
||||
} else {
|
||||
backend.code_builder.i64_gt_u()
|
||||
}
|
||||
}
|
||||
F32 => backend.code_builder.f32_gt(),
|
||||
F64 => backend.code_builder.f64_gt(),
|
||||
@ -405,15 +406,19 @@ impl<'a> LowLevelCall<'a> {
|
||||
NumGte => {
|
||||
self.load_args(backend);
|
||||
match CodeGenNumType::for_symbol(backend, self.arguments[0]) {
|
||||
I32 => if integer_symbol_is_signed(backend, self.arguments[0]) {
|
||||
backend.code_builder.i32_ge_s()
|
||||
} else {
|
||||
backend.code_builder.i32_ge_u()
|
||||
I32 => {
|
||||
if integer_symbol_is_signed(backend, self.arguments[0]) {
|
||||
backend.code_builder.i32_ge_s()
|
||||
} else {
|
||||
backend.code_builder.i32_ge_u()
|
||||
}
|
||||
}
|
||||
I64 => if integer_symbol_is_signed(backend, self.arguments[0]) {
|
||||
backend.code_builder.i64_ge_s()
|
||||
} else {
|
||||
backend.code_builder.i64_ge_u()
|
||||
I64 => {
|
||||
if integer_symbol_is_signed(backend, self.arguments[0]) {
|
||||
backend.code_builder.i64_ge_s()
|
||||
} else {
|
||||
backend.code_builder.i64_ge_u()
|
||||
}
|
||||
}
|
||||
F32 => backend.code_builder.f32_ge(),
|
||||
F64 => backend.code_builder.f64_ge(),
|
||||
@ -423,15 +428,19 @@ impl<'a> LowLevelCall<'a> {
|
||||
NumLt => {
|
||||
self.load_args(backend);
|
||||
match CodeGenNumType::for_symbol(backend, self.arguments[0]) {
|
||||
I32 => if integer_symbol_is_signed(backend, self.arguments[0]) {
|
||||
backend.code_builder.i32_lt_s()
|
||||
} else {
|
||||
backend.code_builder.i32_lt_u()
|
||||
I32 => {
|
||||
if integer_symbol_is_signed(backend, self.arguments[0]) {
|
||||
backend.code_builder.i32_lt_s()
|
||||
} else {
|
||||
backend.code_builder.i32_lt_u()
|
||||
}
|
||||
}
|
||||
I64 => if integer_symbol_is_signed(backend, self.arguments[0]) {
|
||||
backend.code_builder.i64_lt_s()
|
||||
} else {
|
||||
backend.code_builder.i64_lt_u()
|
||||
I64 => {
|
||||
if integer_symbol_is_signed(backend, self.arguments[0]) {
|
||||
backend.code_builder.i64_lt_s()
|
||||
} else {
|
||||
backend.code_builder.i64_lt_u()
|
||||
}
|
||||
}
|
||||
F32 => backend.code_builder.f32_lt(),
|
||||
F64 => backend.code_builder.f64_lt(),
|
||||
@ -441,15 +450,19 @@ impl<'a> LowLevelCall<'a> {
|
||||
NumLte => {
|
||||
self.load_args(backend);
|
||||
match CodeGenNumType::for_symbol(backend, self.arguments[0]) {
|
||||
I32 => if integer_symbol_is_signed(backend, self.arguments[0]) {
|
||||
backend.code_builder.i32_le_s()
|
||||
} else {
|
||||
backend.code_builder.i32_le_u()
|
||||
I32 => {
|
||||
if integer_symbol_is_signed(backend, self.arguments[0]) {
|
||||
backend.code_builder.i32_le_s()
|
||||
} else {
|
||||
backend.code_builder.i32_le_u()
|
||||
}
|
||||
}
|
||||
I64 => if integer_symbol_is_signed(backend, self.arguments[0]) {
|
||||
backend.code_builder.i64_le_s()
|
||||
} else {
|
||||
backend.code_builder.i64_le_u()
|
||||
I64 => {
|
||||
if integer_symbol_is_signed(backend, self.arguments[0]) {
|
||||
backend.code_builder.i64_le_s()
|
||||
} else {
|
||||
backend.code_builder.i64_le_u()
|
||||
}
|
||||
}
|
||||
F32 => backend.code_builder.f32_le(),
|
||||
F64 => backend.code_builder.f64_le(),
|
||||
|
Loading…
Reference in New Issue
Block a user