From 40cc0837cfa82cd74daf631a46d01d4c544b1277 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Wed, 25 May 2022 18:34:57 -0700 Subject: Actually inline load_fast/store_fast for clang/ARM --- riscv/common.h | 2 ++ riscv/mmu.h | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/riscv/common.h b/riscv/common.h index 002a83f..7d37001 100644 --- a/riscv/common.h +++ b/riscv/common.h @@ -8,11 +8,13 @@ # define unlikely(x) __builtin_expect(x, 0) # define NOINLINE __attribute__ ((noinline)) # define NORETURN __attribute__ ((noreturn)) +# define ALWAYS_INLINE __attribute__ ((always_inline)) #else # define likely(x) (x) # define unlikely(x) (x) # define NOINLINE # define NORETURN +# define ALWAYS_INLINE #endif #endif diff --git a/riscv/mmu.h b/riscv/mmu.h index 06122c4..7c44c1e 100644 --- a/riscv/mmu.h +++ b/riscv/mmu.h @@ -84,7 +84,7 @@ public: #endif template - inline T load_fast(reg_t addr, bool require_alignment = false) { + ALWAYS_INLINE T load_fast(reg_t addr, bool require_alignment = false) { const size_t size = sizeof(T); const reg_t vpn = addr >> PGSHIFT; const bool normal_tlb_hit = likely(tlb_load_tag[vpn % TLB_ENTRIES] == vpn); @@ -123,7 +123,7 @@ public: // template for functions that load an aligned value from memory #define load_func(type, prefix, xlate_flags) \ - inline type##_t prefix##_##type(reg_t addr, bool require_alignment = false) { \ + ALWAYS_INLINE type##_t prefix##_##type(reg_t addr, bool require_alignment = false) { \ return load_fast(addr, require_alignment); \ } @@ -161,7 +161,7 @@ public: #endif template - inline void store_fast(reg_t addr, T val, bool actually_store=true, bool require_alignment=false) { + ALWAYS_INLINE void store_fast(reg_t addr, T val, bool actually_store=true, bool require_alignment=false) { const size_t size = sizeof(T); const reg_t vpn = addr >> PGSHIFT; const bool misaligned = unlikely((addr & (size-1)) != 0); @@ -197,7 +197,7 @@ public: // template for functions that store an aligned value to memory #define store_func(type, prefix, xlate_flags) \ - void prefix##_##type(reg_t addr, type##_t val, bool actually_store=true, bool require_alignment=false) { \ + ALWAYS_INLINE void prefix##_##type(reg_t addr, type##_t val, bool actually_store=true, bool require_alignment=false) { \ store_fast(addr, val, actually_store, require_alignment); \ } -- cgit v1.1