Skip to content

improve dev builds #324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/generate/peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ pub fn render(

impl #name_pc {
/// Returns a pointer to the register block
pub fn ptr() -> *const #base::RegisterBlock {
#[inline(always)]
pub const fn ptr() -> *const #base::RegisterBlock {
#address as *const _
}
}
Expand Down
46 changes: 23 additions & 23 deletions src/generate/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn render(
if access == Access::ReadWrite {
reg_impl_items.push(quote! {
/// Modifies the contents of the register
#[inline]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W
Expand All @@ -56,7 +56,7 @@ pub fn render(
if access == Access::ReadOnly || access == Access::ReadWrite {
reg_impl_items.push(quote! {
/// Reads the contents of the register
#[inline]
#[inline(always)]
pub fn read(&self) -> R {
R { bits: self.register.get() }
}
Expand All @@ -71,7 +71,7 @@ pub fn render(

r_impl_items.push(quote! {
/// Value of the register as raw bits
#[inline]
#[inline(always)]
pub fn bits(&self) -> #rty {
self.bits
}
Expand All @@ -81,7 +81,7 @@ pub fn render(
if access == Access::WriteOnly || access == Access::ReadWrite {
reg_impl_items.push(quote! {
/// Writes to the register
#[inline]
#[inline(always)]
pub fn write<F>(&self, f: F)
where
F: FnOnce(&mut W) -> &mut W
Expand All @@ -105,20 +105,20 @@ pub fn render(

reg_impl_items.push(quote! {
/// Reset value of the register
#[inline]
#[inline(always)]
pub const fn reset_value() -> #rty {
#rv
}
/// Writes the reset value to the register
#[inline]
#[inline(always)]
pub fn reset(&self) {
self.register.set(Self::reset_value())
}
});

w_impl_items.push(quote! {
/// Writes raw bits to the register
#[inline]
#[inline(always)]
pub #unsafety fn bits(&mut self, bits: #rty) -> &mut Self {
self.bits = bits;
self
Expand Down Expand Up @@ -365,7 +365,7 @@ pub fn fields(
let sc = &f.sc;
r_impl_items.push(quote! {
#[doc = #description]
#[inline]
#[inline(always)]
pub fn #sc(&self) -> #pc_r {
#pc_r::_from( #value )
}
Expand Down Expand Up @@ -421,13 +421,13 @@ pub fn fields(
if f.width == 1 {
enum_items.push(quote! {
/// Returns `true` if the bit is clear (0)
#[inline]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.#bits()
}

/// Returns `true` if the bit is set (1)
#[inline]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.#bits()
}
Expand All @@ -436,7 +436,7 @@ pub fn fields(

enum_items.push(quote! {
/// Value of the field as raw bits
#[inline]
#[inline(always)]
pub fn #bits(&self) -> #fty {
match *self {
#(#arms),*
Expand Down Expand Up @@ -469,7 +469,7 @@ pub fn fields(
enum_items.push(quote! {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline]
#[inline(always)]
pub fn _from(value: #fty) -> #pc_r {
match value {
#(#arms),*,
Expand All @@ -490,7 +490,7 @@ pub fn fields(
let doc = format!("Checks if the value of the field is `{}`", pc);
enum_items.push(quote! {
#[doc = #doc]
#[inline]
#[inline(always)]
pub fn #is_variant(&self) -> bool {
*self == #pc_r::#pc
}
Expand All @@ -509,7 +509,7 @@ pub fn fields(
let sc = &f.sc;
r_impl_items.push(quote! {
#[doc = #description]
#[inline]
#[inline(always)]
pub fn #sc(&self) -> #pc_r {
let bits = #value;
#pc_r { bits }
Expand All @@ -519,7 +519,7 @@ pub fn fields(
let mut pc_r_impl_items = vec![
quote! {
/// Value of the field as raw bits
#[inline]
#[inline(always)]
pub fn #bits(&self) -> #fty {
self.bits
}
Expand All @@ -529,13 +529,13 @@ pub fn fields(
if f.width == 1 {
pc_r_impl_items.push(quote! {
/// Returns `true` if the bit is clear (0)
#[inline]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.#bits()
}

/// Returns `true` if the bit is set (1)
#[inline]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.#bits()
}
Expand Down Expand Up @@ -690,7 +690,7 @@ pub fn fields(
impl #pc_w {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline]
#[inline(always)]
pub fn _bits(&self) -> #fty {
match *self {
#(#arms),*
Expand All @@ -702,7 +702,7 @@ pub fn fields(

proxy_items.push(quote! {
/// Writes `variant` to the field
#[inline]
#[inline(always)]
pub fn variant(self, variant: #pc_w) -> &'a mut W {
#unsafety {
self.#bits(variant._bits())
Expand All @@ -718,15 +718,15 @@ pub fn fields(
if let Some(enum_) = base_pc_w.as_ref() {
proxy_items.push(quote! {
#[doc = #doc]
#[inline]
#[inline(always)]
pub fn #sc(self) -> &'a mut W {
self.variant(#enum_::#pc)
}
});
} else {
proxy_items.push(quote! {
#[doc = #doc]
#[inline]
#[inline(always)]
pub fn #sc(self) -> &'a mut W {
self.variant(#pc_w::#pc)
}
Expand All @@ -751,7 +751,7 @@ pub fn fields(

proxy_items.push(quote! {
/// Writes raw bits to the field
#[inline]
#[inline(always)]
pub #unsafety fn #bits(self, value: #fty) -> &'a mut W {
self.w.bits &= !(#mask << #offset);
self.w.bits |= ((value as #rty) & #mask) << #offset;
Expand All @@ -775,7 +775,7 @@ pub fn fields(
let sc = &f.sc;
w_impl_items.push(quote! {
#[doc = #description]
#[inline]
#[inline(always)]
pub fn #sc(&mut self) -> #_pc_w {
#_pc_w { w: self }
}
Expand Down