Skip to content

Commit 284d262

Browse files
Merge #324
324: improve dev builds r=ryankurte a=therealprof This PR basically reverts #141 and plays with inline markers for some large dev build binary size gains Co-authored-by: Daniel Egger <[email protected]>
2 parents 749c751 + 3d101f9 commit 284d262

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

src/generate/peripheral.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ pub fn render(
5454

5555
impl #name_pc {
5656
/// Returns a pointer to the register block
57-
pub fn ptr() -> *const #base::RegisterBlock {
57+
#[inline(always)]
58+
pub const fn ptr() -> *const #base::RegisterBlock {
5859
#address as *const _
5960
}
6061
}

src/generate/register.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn render(
4545
if access == Access::ReadWrite || access == Access::ReadWriteOnce {
4646
reg_impl_items.push(quote! {
4747
/// Modifies the contents of the register
48-
#[inline]
48+
#[inline(always)]
4949
pub fn modify<F>(&self, f: F)
5050
where
5151
for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W
@@ -59,7 +59,7 @@ pub fn render(
5959
if can_read {
6060
reg_impl_items.push(quote! {
6161
/// Reads the contents of the register
62-
#[inline]
62+
#[inline(always)]
6363
pub fn read(&self) -> R {
6464
R { bits: self.register.get() }
6565
}
@@ -74,7 +74,7 @@ pub fn render(
7474

7575
r_impl_items.push(quote! {
7676
/// Value of the register as raw bits
77-
#[inline]
77+
#[inline(always)]
7878
pub fn bits(&self) -> #rty {
7979
self.bits
8080
}
@@ -84,7 +84,7 @@ pub fn render(
8484
if can_write {
8585
reg_impl_items.push(quote! {
8686
/// Writes to the register
87-
#[inline]
87+
#[inline(always)]
8888
pub fn write<F>(&self, f: F)
8989
where
9090
F: FnOnce(&mut W) -> &mut W
@@ -108,20 +108,20 @@ pub fn render(
108108

109109
reg_impl_items.push(quote! {
110110
/// Reset value of the register
111-
#[inline]
111+
#[inline(always)]
112112
pub const fn reset_value() -> #rty {
113113
#rv
114114
}
115115
/// Writes the reset value to the register
116-
#[inline]
116+
#[inline(always)]
117117
pub fn reset(&self) {
118118
self.register.set(Self::reset_value())
119119
}
120120
});
121121

122122
w_impl_items.push(quote! {
123123
/// Writes raw bits to the register
124-
#[inline]
124+
#[inline(always)]
125125
pub #unsafety fn bits(&mut self, bits: #rty) -> &mut Self {
126126
self.bits = bits;
127127
self
@@ -368,7 +368,7 @@ pub fn fields(
368368
let sc = &f.sc;
369369
r_impl_items.push(quote! {
370370
#[doc = #description]
371-
#[inline]
371+
#[inline(always)]
372372
pub fn #sc(&self) -> #pc_r {
373373
#pc_r::_from( #value )
374374
}
@@ -424,13 +424,13 @@ pub fn fields(
424424
if f.width == 1 {
425425
enum_items.push(quote! {
426426
/// Returns `true` if the bit is clear (0)
427-
#[inline]
427+
#[inline(always)]
428428
pub fn bit_is_clear(&self) -> bool {
429429
!self.#bits()
430430
}
431431

432432
/// Returns `true` if the bit is set (1)
433-
#[inline]
433+
#[inline(always)]
434434
pub fn bit_is_set(&self) -> bool {
435435
self.#bits()
436436
}
@@ -439,7 +439,7 @@ pub fn fields(
439439

440440
enum_items.push(quote! {
441441
/// Value of the field as raw bits
442-
#[inline]
442+
#[inline(always)]
443443
pub fn #bits(&self) -> #fty {
444444
match *self {
445445
#(#arms),*
@@ -472,7 +472,7 @@ pub fn fields(
472472
enum_items.push(quote! {
473473
#[allow(missing_docs)]
474474
#[doc(hidden)]
475-
#[inline]
475+
#[inline(always)]
476476
pub fn _from(value: #fty) -> #pc_r {
477477
match value {
478478
#(#arms),*,
@@ -493,7 +493,7 @@ pub fn fields(
493493
let doc = format!("Checks if the value of the field is `{}`", pc);
494494
enum_items.push(quote! {
495495
#[doc = #doc]
496-
#[inline]
496+
#[inline(always)]
497497
pub fn #is_variant(&self) -> bool {
498498
*self == #pc_r::#pc
499499
}
@@ -512,7 +512,7 @@ pub fn fields(
512512
let sc = &f.sc;
513513
r_impl_items.push(quote! {
514514
#[doc = #description]
515-
#[inline]
515+
#[inline(always)]
516516
pub fn #sc(&self) -> #pc_r {
517517
let bits = #value;
518518
#pc_r { bits }
@@ -522,7 +522,7 @@ pub fn fields(
522522
let mut pc_r_impl_items = vec![
523523
quote! {
524524
/// Value of the field as raw bits
525-
#[inline]
525+
#[inline(always)]
526526
pub fn #bits(&self) -> #fty {
527527
self.bits
528528
}
@@ -532,13 +532,13 @@ pub fn fields(
532532
if f.width == 1 {
533533
pc_r_impl_items.push(quote! {
534534
/// Returns `true` if the bit is clear (0)
535-
#[inline]
535+
#[inline(always)]
536536
pub fn bit_is_clear(&self) -> bool {
537537
!self.#bits()
538538
}
539539

540540
/// Returns `true` if the bit is set (1)
541-
#[inline]
541+
#[inline(always)]
542542
pub fn bit_is_set(&self) -> bool {
543543
self.#bits()
544544
}
@@ -693,7 +693,7 @@ pub fn fields(
693693
impl #pc_w {
694694
#[allow(missing_docs)]
695695
#[doc(hidden)]
696-
#[inline]
696+
#[inline(always)]
697697
pub fn _bits(&self) -> #fty {
698698
match *self {
699699
#(#arms),*
@@ -705,7 +705,7 @@ pub fn fields(
705705

706706
proxy_items.push(quote! {
707707
/// Writes `variant` to the field
708-
#[inline]
708+
#[inline(always)]
709709
pub fn variant(self, variant: #pc_w) -> &'a mut W {
710710
#unsafety {
711711
self.#bits(variant._bits())
@@ -721,15 +721,15 @@ pub fn fields(
721721
if let Some(enum_) = base_pc_w.as_ref() {
722722
proxy_items.push(quote! {
723723
#[doc = #doc]
724-
#[inline]
724+
#[inline(always)]
725725
pub fn #sc(self) -> &'a mut W {
726726
self.variant(#enum_::#pc)
727727
}
728728
});
729729
} else {
730730
proxy_items.push(quote! {
731731
#[doc = #doc]
732-
#[inline]
732+
#[inline(always)]
733733
pub fn #sc(self) -> &'a mut W {
734734
self.variant(#pc_w::#pc)
735735
}
@@ -754,7 +754,7 @@ pub fn fields(
754754

755755
proxy_items.push(quote! {
756756
/// Writes raw bits to the field
757-
#[inline]
757+
#[inline(always)]
758758
pub #unsafety fn #bits(self, value: #fty) -> &'a mut W {
759759
self.w.bits &= !(#mask << #offset);
760760
self.w.bits |= ((value as #rty) & #mask) << #offset;
@@ -778,7 +778,7 @@ pub fn fields(
778778
let sc = &f.sc;
779779
w_impl_items.push(quote! {
780780
#[doc = #description]
781-
#[inline]
781+
#[inline(always)]
782782
pub fn #sc(&mut self) -> #_pc_w {
783783
#_pc_w { w: self }
784784
}

0 commit comments

Comments
 (0)