Skip to content

Commit 5fc589a

Browse files
committed
remove alignment
1 parent 3327303 commit 5fc589a

File tree

4 files changed

+2
-79
lines changed

4 files changed

+2
-79
lines changed

src/codegen/debug.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,6 @@ impl<'ink> DebugBuilder<'ink> {
300300
let type_info = dt.get_type_information();
301301
// let alignment = type_info.get_alignment(index);
302302
let size = type_info.get_size(index).unwrap();
303-
// TODO: alignment
304-
// running_offset = running_offset.align_to(alignment);
305303

306304
types.push(
307305
self.debug_info
@@ -311,8 +309,6 @@ impl<'ink> DebugBuilder<'ink> {
311309
file,
312310
location.get_line_plus_one() as u32,
313311
size.bits().into(),
314-
// TODO: alignment
315-
// alignment.bits(),
316312
0, // no alignment for now
317313
running_offset.bits().into(),
318314
DIFlags::PUBLIC,
@@ -323,19 +319,14 @@ impl<'ink> DebugBuilder<'ink> {
323319
running_offset += size;
324320
}
325321

326-
// TODO: alignment
327-
// let struct_dt = index.get_type_information_or_void(name);
328-
329322
//Create a struct type
330323
let struct_type = self.debug_info.create_struct_type(
331324
file.as_debug_info_scope(),
332325
name,
333326
file,
334327
location.get_line_plus_one() as u32,
335328
running_offset.bits().into(),
336-
// TODO: alignment
337329
0, // no alignment for now
338-
// struct_dt.get_alignment(index).bits(),
339330
DIFlags::PUBLIC,
340331
None,
341332
types.as_slice(),
@@ -464,9 +455,7 @@ impl<'ink> DebugBuilder<'ink> {
464455
file,
465456
location.get_line_plus_one() as u32,
466457
file.as_debug_info_scope(),
467-
// TODO: alignment
468458
0, // no alignment for now
469-
// inner_dt.get_type_information().get_alignment(index).bits(),
470459
);
471460
self.register_concrete_type(name, DebugType::Derived(typedef));
472461

@@ -550,11 +539,6 @@ impl<'ink> DebugBuilder<'ink> {
550539
.iter()
551540
.filter(|it| it.is_local() || it.is_temp() || it.is_return())
552541
{
553-
// TODO: alignment
554-
// let var_type = index
555-
// .find_effective_type_by_name(variable.get_type_name())
556-
// .expect("Type should exist at this stage");
557-
// let alignment = var_type.get_type_information().get_alignment(index).bits();
558542
self.register_local_variable(variable, 0, func);
559543
}
560544

@@ -648,8 +632,6 @@ impl<'ink> Debug<'ink> for DebugBuilder<'ink> {
648632
if !self.types.contains_key(&name.to_lowercase()) {
649633
let type_info = datatype.get_type_information();
650634
let size = type_info.get_size(index).unwrap();
651-
// TODO: alignment
652-
// let alignment = type_info.get_alignment(index);
653635
let location = &datatype.location;
654636
match type_info {
655637
DataTypeInformation::Struct { members, .. } => {
@@ -681,8 +663,6 @@ impl<'ink> Debug<'ink> for DebugBuilder<'ink> {
681663
let length = string_size
682664
.as_int_value(index)
683665
.map_err(|err| Diagnostic::codegen_error(err, SourceLocation::undefined()))?;
684-
// TODO: alignment
685-
// TODO does this break strings?
686666
self.create_string_type(name, length, *encoding, size, Bytes::new(0), index)
687667
}
688668
DataTypeInformation::Alias { name, referenced_type }

src/datalayout.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,7 @@ mod tests {
185185
);
186186

187187
let struct_type = index.get_effective_type_by_name("MyStruct").unwrap().get_type_information();
188-
// And the struct size takes the alignment into account
188+
// The size is 120 bytes and the struct is not aligned
189189
assert_eq!(struct_type.get_size(&index).unwrap().bits(), 120);
190-
// TODO: alignment
191-
// assert_eq!(struct_type.get_alignment(&index), Bytes::new(8)) //Struct alignment is 64 by default
192190
}
193191
}

src/index/tests/index_tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2273,7 +2273,6 @@ fn pou_with_two_types_not_considered_recursive() {
22732273
);
22742274

22752275
let pou_type = index.find_pou_type("p").unwrap();
2276-
// TODO: why not 64 bytes?
22772276
assert_eq!(pou_type.get_type_information().get_size(&index).unwrap().bits(), 64);
22782277
}
22792278

src/typesystem.rs

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -645,10 +645,7 @@ impl DataTypeInformation {
645645
.try_fold(MemoryLocation::new(0), |prev, it| {
646646
let type_info: &DataTypeInformation = index.get_type_information_or_void(it);
647647
let size = type_info.get_size_recursive(index, seen)?.value();
648-
// TODO: alignment
649-
// let after_align = prev.align_to(type_info.get_alignment(index)).value();
650-
let res = prev.value() + size;
651-
Ok(MemoryLocation::new(res))
648+
Ok(MemoryLocation::new(prev.value() + size))
652649
})
653650
.map(Into::into),
654651
DataTypeInformation::Array { inner_type_name, dimensions, .. } => {
@@ -684,57 +681,6 @@ impl DataTypeInformation {
684681
}
685682
}
686683

687-
// TODO: alignment
688-
// pub fn get_alignment(&self, index: &Index) -> Bytes {
689-
// if true {
690-
// return Bytes::new(0);
691-
// }
692-
// if self.get_size(index).unwrap_or_default().value() == 0 {
693-
// return Bytes::new(0);
694-
// }
695-
//
696-
// let type_layout = index.get_type_layout();
697-
// match self {
698-
// DataTypeInformation::Array { inner_type_name, .. } => {
699-
// index.get_type_information_or_void(inner_type_name).get_alignment(index)
700-
// }
701-
// DataTypeInformation::Struct { .. } => type_layout.aggregate,
702-
// DataTypeInformation::String { encoding, .. } => match encoding {
703-
// StringEncoding::Utf8 => Bytes::new(1),
704-
// StringEncoding::Utf16 => Bytes::new(2),
705-
// },
706-
// DataTypeInformation::Pointer { .. } => type_layout.p64,
707-
// DataTypeInformation::Integer { size, semantic_size, .. } => {
708-
// if let Some(1) = semantic_size {
709-
// type_layout.i1
710-
// } else {
711-
// match size {
712-
// 8 => type_layout.i8,
713-
// 16 => type_layout.i16,
714-
// 32 => type_layout.i32,
715-
// 64 => type_layout.i64,
716-
// _ => type_layout.p64,
717-
// }
718-
// }
719-
// }
720-
// DataTypeInformation::Enum { referenced_type, .. } => {
721-
// index.get_type_information_or_void(referenced_type).get_alignment(index)
722-
// }
723-
// DataTypeInformation::Float { size, .. } => match size {
724-
// 32 => type_layout.f32,
725-
// 64 => type_layout.f64,
726-
// _ => type_layout.p64,
727-
// },
728-
// DataTypeInformation::SubRange { referenced_type, .. } => {
729-
// index.get_type_information_or_void(referenced_type).get_alignment(index)
730-
// }
731-
// DataTypeInformation::Alias { referenced_type, .. } => {
732-
// index.get_type_information_or_void(referenced_type).get_alignment(index)
733-
// }
734-
// _ => type_layout.i8,
735-
// }
736-
// }
737-
//
738684
pub fn get_inner_array_type_name(&self) -> Option<&str> {
739685
match self {
740686
DataTypeInformation::Array { inner_type_name, .. } => Some(inner_type_name),

0 commit comments

Comments
 (0)