github.com/apache/arrow/go/v14@v14.0.2/internal/utils/_lib/transpose_ints.c (about)

     1  // Licensed to the Apache Software Foundation (ASF) under one
     2  // or more contributor license agreements.  See the NOTICE file
     3  // distributed with this work for additional information
     4  // regarding copyright ownership.  The ASF licenses this file
     5  // to you under the Apache License, Version 2.0 (the
     6  // "License"); you may not use this file except in compliance
     7  // with the License.  You may obtain a copy of the License at
     8  //
     9  // http://www.apache.org/licenses/LICENSE-2.0
    10  //
    11  // Unless required by applicable law or agreed to in writing, software
    12  // distributed under the License is distributed on an "AS IS" BASIS,
    13  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  // See the License for the specific language governing permissions and
    15  // limitations under the License.
    16  
    17  #include <arch.h>
    18  #include <stdint.h>
    19  
    20  #define CREATE_TRANSPOSE(SRC, DEST) \
    21      void FULL_NAME(transpose_ ## SRC ## _ ## DEST)(const SRC ## _t* src, DEST ## _t* dest, int length, const int32_t* transpose_map) { \
    22          while (length >= 4) {                                       \
    23              dest[0] = (DEST ## _t)(transpose_map[src[0]]);          \
    24              dest[1] = (DEST ## _t)(transpose_map[src[1]]);          \
    25              dest[2] = (DEST ## _t)(transpose_map[src[2]]);          \
    26              dest[3] = (DEST ## _t)(transpose_map[src[3]]);          \
    27              length -= 4;                                            \
    28              src += 4;                                               \
    29              dest += 4;                                              \
    30          }                                                           \
    31          while (length > 0) {                                        \
    32              *dest++ = (DEST ## _t)(transpose_map[*src++]);          \
    33              --length;                                               \
    34          }                                                           \
    35      }
    36  
    37  #define CREATE_TRANSPOSE_ALL_DEST(DEST) \
    38      CREATE_TRANSPOSE(uint8, DEST)     \
    39      CREATE_TRANSPOSE(int8, DEST)      \
    40      CREATE_TRANSPOSE(uint16, DEST)    \
    41      CREATE_TRANSPOSE(int16, DEST)     \
    42      CREATE_TRANSPOSE(uint32, DEST)    \
    43      CREATE_TRANSPOSE(int32, DEST)     \
    44      CREATE_TRANSPOSE(uint64, DEST)    \
    45      CREATE_TRANSPOSE(int64, DEST)
    46  
    47  #define CREATE_TRANSPOSE_ALL()        \
    48      CREATE_TRANSPOSE_ALL_DEST(uint8)  \
    49      CREATE_TRANSPOSE_ALL_DEST(int8)   \
    50      CREATE_TRANSPOSE_ALL_DEST(uint16) \
    51      CREATE_TRANSPOSE_ALL_DEST(int16)  \
    52      CREATE_TRANSPOSE_ALL_DEST(uint32) \
    53      CREATE_TRANSPOSE_ALL_DEST(int32)  \
    54      CREATE_TRANSPOSE_ALL_DEST(uint64) \
    55      CREATE_TRANSPOSE_ALL_DEST(int64)
    56  
    57  CREATE_TRANSPOSE_ALL()