Path: blob/21.2-virgl/src/gallium/drivers/llvmpipe/lp_bld_blend_logicop.c
4570 views
/**************************************************************************1*2* Copyright 2009 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/262728/**29* @file30* Blend LLVM IR generation -- logic ops.31*32* @author Jose Fonseca <[email protected]>33*/343536#include "pipe/p_state.h"37#include "util/u_debug.h"3839#include "lp_bld_blend.h"404142LLVMValueRef43lp_build_logicop(LLVMBuilderRef builder,44unsigned logicop_func,45LLVMValueRef src,46LLVMValueRef dst)47{48LLVMTypeRef type;49LLVMValueRef res;5051type = LLVMTypeOf(src);5253switch (logicop_func) {54case PIPE_LOGICOP_CLEAR:55res = LLVMConstNull(type);56break;57case PIPE_LOGICOP_NOR:58res = LLVMBuildNot(builder, LLVMBuildOr(builder, src, dst, ""), "");59break;60case PIPE_LOGICOP_AND_INVERTED:61res = LLVMBuildAnd(builder, LLVMBuildNot(builder, src, ""), dst, "");62break;63case PIPE_LOGICOP_COPY_INVERTED:64res = LLVMBuildNot(builder, src, "");65break;66case PIPE_LOGICOP_AND_REVERSE:67res = LLVMBuildAnd(builder, src, LLVMBuildNot(builder, dst, ""), "");68break;69case PIPE_LOGICOP_INVERT:70res = LLVMBuildNot(builder, dst, "");71break;72case PIPE_LOGICOP_XOR:73res = LLVMBuildXor(builder, src, dst, "");74break;75case PIPE_LOGICOP_NAND:76res = LLVMBuildNot(builder, LLVMBuildAnd(builder, src, dst, ""), "");77break;78case PIPE_LOGICOP_AND:79res = LLVMBuildAnd(builder, src, dst, "");80break;81case PIPE_LOGICOP_EQUIV:82res = LLVMBuildNot(builder, LLVMBuildXor(builder, src, dst, ""), "");83break;84case PIPE_LOGICOP_NOOP:85res = dst;86break;87case PIPE_LOGICOP_OR_INVERTED:88res = LLVMBuildOr(builder, LLVMBuildNot(builder, src, ""), dst, "");89break;90case PIPE_LOGICOP_COPY:91res = src;92break;93case PIPE_LOGICOP_OR_REVERSE:94res = LLVMBuildOr(builder, src, LLVMBuildNot(builder, dst, ""), "");95break;96case PIPE_LOGICOP_OR:97res = LLVMBuildOr(builder, src, dst, "");98break;99case PIPE_LOGICOP_SET:100res = LLVMConstAllOnes(type);101break;102default:103assert(0);104res = src;105}106107return res;108}109110111