"Fossies" - the Fresh Open Source Software Archive

Member "mesa-20.1.8/src/gallium/drivers/llvmpipe/lp_bld_blend_logicop.c" (16 Sep 2020, 3390 Bytes) of package /linux/misc/mesa-20.1.8.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "lp_bld_blend_logicop.c" see the Fossies "Dox" file reference documentation.

    1 /**************************************************************************
    2  *
    3  * Copyright 2009 VMware, Inc.
    4  * All Rights Reserved.
    5  *
    6  * Permission is hereby granted, free of charge, to any person obtaining a
    7  * copy of this software and associated documentation files (the
    8  * "Software"), to deal in the Software without restriction, including
    9  * without limitation the rights to use, copy, modify, merge, publish,
   10  * distribute, sub license, and/or sell copies of the Software, and to
   11  * permit persons to whom the Software is furnished to do so, subject to
   12  * the following conditions:
   13  *
   14  * The above copyright notice and this permission notice (including the
   15  * next paragraph) shall be included in all copies or substantial portions
   16  * of the Software.
   17  *
   18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
   19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
   21  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
   22  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
   23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
   24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   25  *
   26  **************************************************************************/
   27 
   28 
   29 /**
   30  * @file
   31  * Blend LLVM IR generation -- logic ops.
   32  *
   33  * @author Jose Fonseca <jfonseca@vmware.com>
   34  */
   35 
   36 
   37 #include "pipe/p_state.h"
   38 #include "util/u_debug.h"
   39 
   40 #include "lp_bld_blend.h"
   41 
   42 
   43 LLVMValueRef
   44 lp_build_logicop(LLVMBuilderRef builder,
   45                  unsigned logicop_func,
   46                  LLVMValueRef src,
   47                  LLVMValueRef dst)
   48 {
   49    LLVMTypeRef type;
   50    LLVMValueRef res;
   51 
   52    type = LLVMTypeOf(src);
   53 
   54    switch (logicop_func) {
   55    case PIPE_LOGICOP_CLEAR:
   56       res = LLVMConstNull(type);
   57       break;
   58    case PIPE_LOGICOP_NOR:
   59       res = LLVMBuildNot(builder, LLVMBuildOr(builder, src, dst, ""), "");
   60       break;
   61    case PIPE_LOGICOP_AND_INVERTED:
   62       res = LLVMBuildAnd(builder, LLVMBuildNot(builder, src, ""), dst, "");
   63       break;
   64    case PIPE_LOGICOP_COPY_INVERTED:
   65       res = LLVMBuildNot(builder, src, "");
   66       break;
   67    case PIPE_LOGICOP_AND_REVERSE:
   68       res = LLVMBuildAnd(builder, src, LLVMBuildNot(builder, dst, ""), "");
   69       break;
   70    case PIPE_LOGICOP_INVERT:
   71       res = LLVMBuildNot(builder, dst, "");
   72       break;
   73    case PIPE_LOGICOP_XOR:
   74       res = LLVMBuildXor(builder, src, dst, "");
   75       break;
   76    case PIPE_LOGICOP_NAND:
   77       res = LLVMBuildNot(builder, LLVMBuildAnd(builder, src, dst, ""), "");
   78       break;
   79    case PIPE_LOGICOP_AND:
   80       res = LLVMBuildAnd(builder, src, dst, "");
   81       break;
   82    case PIPE_LOGICOP_EQUIV:
   83       res = LLVMBuildNot(builder, LLVMBuildXor(builder, src, dst, ""), "");
   84       break;
   85    case PIPE_LOGICOP_NOOP:
   86       res = dst;
   87       break;
   88    case PIPE_LOGICOP_OR_INVERTED:
   89       res = LLVMBuildOr(builder, LLVMBuildNot(builder, src, ""), dst, "");
   90       break;
   91    case PIPE_LOGICOP_COPY:
   92       res = src;
   93       break;
   94    case PIPE_LOGICOP_OR_REVERSE:
   95       res = LLVMBuildOr(builder, src, LLVMBuildNot(builder, dst, ""), "");
   96       break;
   97    case PIPE_LOGICOP_OR:
   98       res = LLVMBuildOr(builder, src, dst, "");
   99       break;
  100    case PIPE_LOGICOP_SET:
  101       res = LLVMConstAllOnes(type);
  102       break;
  103    default:
  104       assert(0);
  105       res = src;
  106    }
  107 
  108    return res;
  109 }