1 /**************************************************************************
3 * Copyright 2009 VMware, Inc.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
31 * Blend LLVM IR generation -- logic ops.
33 * @author Jose Fonseca <jfonseca@vmware.com>
37 #include "pipe/p_state.h"
38 #include "util/u_debug.h"
40 #include "lp_bld_blend.h"
44 lp_build_logicop(LLVMBuilderRef builder,
45 unsigned logicop_func,
52 type = LLVMTypeOf(src);
54 switch (logicop_func) {
55 case PIPE_LOGICOP_CLEAR:
56 res = LLVMConstNull(type);
58 case PIPE_LOGICOP_NOR:
59 res = LLVMBuildNot(builder, LLVMBuildOr(builder, src, dst, ""), "");
61 case PIPE_LOGICOP_AND_INVERTED:
62 res = LLVMBuildAnd(builder, LLVMBuildNot(builder, src, ""), dst, "");
64 case PIPE_LOGICOP_COPY_INVERTED:
65 res = LLVMBuildNot(builder, src, "");
67 case PIPE_LOGICOP_AND_REVERSE:
68 res = LLVMBuildAnd(builder, src, LLVMBuildNot(builder, dst, ""), "");
70 case PIPE_LOGICOP_INVERT:
71 res = LLVMBuildNot(builder, dst, "");
73 case PIPE_LOGICOP_XOR:
74 res = LLVMBuildXor(builder, src, dst, "");
76 case PIPE_LOGICOP_NAND:
77 res = LLVMBuildNot(builder, LLVMBuildAnd(builder, src, dst, ""), "");
79 case PIPE_LOGICOP_AND:
80 res = LLVMBuildAnd(builder, src, dst, "");
82 case PIPE_LOGICOP_EQUIV:
83 res = LLVMBuildNot(builder, LLVMBuildXor(builder, src, dst, ""), "");
85 case PIPE_LOGICOP_NOOP:
88 case PIPE_LOGICOP_OR_INVERTED:
89 res = LLVMBuildOr(builder, LLVMBuildNot(builder, src, ""), dst, "");
91 case PIPE_LOGICOP_COPY:
94 case PIPE_LOGICOP_OR_REVERSE:
95 res = LLVMBuildOr(builder, src, LLVMBuildNot(builder, dst, ""), "");
98 res = LLVMBuildOr(builder, src, dst, "");
100 case PIPE_LOGICOP_SET:
101 res = LLVMConstAllOnes(type);