Make it possible to define data alignment
This commit is contained in:
@@ -185,6 +185,7 @@ pub struct DataDeclaration {
|
||||
pub name: String,
|
||||
pub linkage: Linkage,
|
||||
pub writable: bool,
|
||||
pub align: Option<u8>,
|
||||
}
|
||||
|
||||
/// A data object belonging to a `Module`.
|
||||
@@ -438,6 +439,7 @@ where
|
||||
name: &str,
|
||||
linkage: Linkage,
|
||||
writable: bool,
|
||||
align: Option<u8>, // An alignment bigger than 128 is unlikely
|
||||
) -> ModuleResult<DataId> {
|
||||
// TODO: Can we avoid allocating names so often?
|
||||
use super::hash_map::Entry::*;
|
||||
@@ -447,7 +449,7 @@ where
|
||||
let existing = &mut self.contents.data_objects[id];
|
||||
existing.merge(linkage, writable);
|
||||
self.backend
|
||||
.declare_data(name, existing.decl.linkage, existing.decl.writable);
|
||||
.declare_data(name, existing.decl.linkage, existing.decl.writable, existing.decl.align);
|
||||
Ok(id)
|
||||
}
|
||||
|
||||
@@ -461,11 +463,12 @@ where
|
||||
name: name.to_owned(),
|
||||
linkage,
|
||||
writable,
|
||||
align,
|
||||
},
|
||||
compiled: None,
|
||||
});
|
||||
entry.insert(FuncOrDataId::Data(id));
|
||||
self.backend.declare_data(name, linkage, writable);
|
||||
self.backend.declare_data(name, linkage, writable, align);
|
||||
Ok(id)
|
||||
}
|
||||
}
|
||||
@@ -563,6 +566,7 @@ where
|
||||
Some(self.backend.define_data(
|
||||
&info.decl.name,
|
||||
info.decl.writable,
|
||||
info.decl.align,
|
||||
data_ctx,
|
||||
&ModuleNamespace::<B> {
|
||||
contents: &self.contents,
|
||||
|
||||
Reference in New Issue
Block a user