[libc-commits] [PATCH] D128335: [libc][mem*] Introduce Algorithms for new mem framework

Guillaume Chatelet via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Jun 27 07:46:37 PDT 2022


gchatelet added inline comments.


================
Comment at: libc/src/string/memory_utils/algorithm.h:118
+template <typename SizedOp> struct HeadTail {
+  template <typename DstAddrT, typename SrcAddrT>
+  static inline void copy(DstAddrT dst, SrcAddrT src, size_t runtime_size) {
----------------
courbet wrote:
> courbet wrote:
> > gchatelet wrote:
> > > courbet wrote:
> > > > maybe: 
> > > > 
> > > > ```
> > > > static_assert(SizedOp::SIZE >0);
> > > > ```
> > > > 
> > > > to fail explicitly if `SizedOp` is not a statically sized operation.
> > > By definition `SizedOp` **is** a statically sized operation 
> > That's what I want to check :) 
> > 
> > I think that you essentially have two kinds of operations:
> >  - What I was calling "statically sized operations": `_1`, `_2`, ..., ``.
> >  - 
> > 
> > Maybe a better name would be "Composite operations" for the later and "Elementary operations" for the former.
> > 
> > My point is that I think some operations only take elementary operations, for example, this does not really make sense:
> > 
> > `HeadTail<Loop<_16>>`
> > 
> > We might even want `static constexpr  bool IS_ELEMENTARY = true`, or something like this.
> > 
> > WDYT ?
> > 
> > 
> > 
> Actually an elementary `SizedOp` is an instance of `SizeOp<BackendT, Size>`. So we could have a `IsElementaryOp<SizedOpT>` that checks that.
> 
I went with the static constexpr bool member variable as it's simpler. It's hackable from the outside but this is not a concern here, actually it's fine to use a different type as long as it duck types.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128335/new/

https://reviews.llvm.org/D128335



More information about the libc-commits mailing list