enable some utf8 conversion tests

This commit is contained in:
Folkert 2023-02-12 14:04:54 +01:00
parent aa113f169c
commit 4e38a4ce32
No known key found for this signature in database
GPG Key ID: 1F17F6FFD112B97C
3 changed files with 38 additions and 8 deletions

View File

@ -490,6 +490,24 @@ impl X64_64SystemVStoreArgs {
sym,
lambda_set.runtime_representation(),
),
Layout::Struct { .. } => {
// for now, just also store this on the stack
let (base_offset, size) = storage_manager.stack_offset_and_size(&sym);
debug_assert_eq!(base_offset % 8, 0);
for i in (0..size as i32).step_by(8) {
X86_64Assembler::mov_reg64_base32(
buf,
Self::GENERAL_RETURN_REGS[0],
base_offset + i,
);
X86_64Assembler::mov_stack32_reg64(
buf,
self.tmp_stack_offset + i,
Self::GENERAL_RETURN_REGS[0],
);
}
self.tmp_stack_offset += size as i32;
}
_ => {
todo!("calling with arg type, {:?}", layout_interner.dbg(other));
}
@ -589,6 +607,11 @@ impl X64_64SystemVLoadArgs {
sym,
lambda_set.runtime_representation(),
),
Layout::Struct { .. } => {
// for now, just also store this on the stack
storage_manager.complex_stack_arg(&sym, self.argument_offset, stack_size);
self.argument_offset += stack_size as i32;
}
_ => {
dbg!(other, layout_interner.get(other));
todo!("Loading args with layout {:?}", layout_interner.dbg(other));

View File

@ -868,6 +868,13 @@ trait Backend<'a> {
arg_layouts,
ret_layout,
),
LowLevel::StrToUtf8 => self.build_fn_call(
sym,
bitcode::STR_TO_UTF8.to_string(),
args,
arg_layouts,
ret_layout,
),
LowLevel::StrCountUtf8Bytes => self.build_fn_call(
sym,
bitcode::STR_COUNT_UTF8_BYTES.to_string(),

View File

@ -891,7 +891,7 @@ fn str_join_comma_single() {
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_to_utf8() {
assert_evals_to!(
r#"Str.toUtf8 "hello""#,
@ -909,7 +909,7 @@ fn str_to_utf8() {
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_from_utf8_range() {
assert_evals_to!(
indoc!(
@ -926,7 +926,7 @@ fn str_from_utf8_range() {
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_from_utf8_range_slice() {
assert_evals_to!(
indoc!(
@ -943,7 +943,7 @@ fn str_from_utf8_range_slice() {
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_from_utf8_range_slice_not_end() {
assert_evals_to!(
indoc!(
@ -960,7 +960,7 @@ fn str_from_utf8_range_slice_not_end() {
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_from_utf8_range_order_does_not_matter() {
assert_evals_to!(
indoc!(
@ -977,7 +977,7 @@ fn str_from_utf8_range_order_does_not_matter() {
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_from_utf8_range_out_of_bounds_start_value() {
assert_evals_to!(
indoc!(
@ -995,7 +995,7 @@ fn str_from_utf8_range_out_of_bounds_start_value() {
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_from_utf8_range_count_too_high() {
assert_evals_to!(
indoc!(
@ -1013,7 +1013,7 @@ fn str_from_utf8_range_count_too_high() {
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
fn str_from_utf8_range_count_too_high_for_start() {
assert_evals_to!(
indoc!(