Skip to content

Commit 1c5917b

Browse files
committed
WIP: fix endianness of non-native 128-bit integers
1 parent 9b4c701 commit 1c5917b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/int.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use gccjit::{ComparisonOp, FunctionType, RValue, ToRValue, Type, UnaryOp, Binary
88
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
99
use rustc_codegen_ssa::traits::{BackendTypes, BaseTypeMethods, BuilderMethods, OverflowOp};
1010
use rustc_middle::ty::Ty;
11+
use rustc_target::abi::Endian;
1112

1213
use crate::builder::ToGccComp;
1314
use crate::{builder::Builder, common::{SignType, TypeReflection}, context::CodegenCx};
@@ -792,10 +793,16 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
792793
}
793794

794795
fn from_low_high(&self, typ: Type<'gcc>, low: i64, high: i64) -> RValue<'gcc> {
796+
let (first, last) =
797+
match self.sess().target.options.endian {
798+
Endian::Little => (low, high),
799+
Endian::Big => (high, low),
800+
};
801+
795802
let native_int_type = typ.dyncast_array().expect("get element type");
796803
let values = [
797-
self.context.new_rvalue_from_long(native_int_type, low),
798-
self.context.new_rvalue_from_long(native_int_type, high),
804+
self.context.new_rvalue_from_long(native_int_type, first),
805+
self.context.new_rvalue_from_long(native_int_type, last),
799806
];
800807
self.context.new_array_constructor(None, typ, &values)
801808
}

tests/lang_tests_common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub fn main_inner(profile: Profile) {
7474
}
7575
// Test command 2: run `tempdir/x`.
7676
let vm_parent_dir = "/home/bouanto/Ordinateur/VirtualMachines";
77-
let vm_dir = "debian-m68k-root-img/";
77+
let vm_dir = "debian-m68k-root/";
7878
let exe_filename = exe.file_name().unwrap();
7979
let vm_exe_path = PathBuf::from(vm_parent_dir).join(vm_dir).join("home").join(exe_filename);
8080
// FIXME: panicking here makes the test pass.

0 commit comments

Comments
 (0)