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"
39 #include "lp_bld_blend.h"
43 lp_build_logicop(LLVMBuilderRef builder
,
44 unsigned logicop_func
,
51 type
= LLVMTypeOf(src
);
53 switch (logicop_func
) {
54 case PIPE_LOGICOP_CLEAR
:
55 res
= LLVMConstNull(type
);
57 case PIPE_LOGICOP_NOR
:
58 res
= LLVMBuildNot(builder
, LLVMBuildOr(builder
, src
, dst
, ""), "");
60 case PIPE_LOGICOP_AND_INVERTED
:
61 res
= LLVMBuildAnd(builder
, LLVMBuildNot(builder
, src
, ""), dst
, "");
63 case PIPE_LOGICOP_COPY_INVERTED
:
64 res
= LLVMBuildNot(builder
, src
, "");
66 case PIPE_LOGICOP_AND_REVERSE
:
67 res
= LLVMBuildAnd(builder
, src
, LLVMBuildNot(builder
, dst
, ""), "");
69 case PIPE_LOGICOP_INVERT
:
70 res
= LLVMBuildNot(builder
, dst
, "");
72 case PIPE_LOGICOP_XOR
:
73 res
= LLVMBuildXor(builder
, src
, dst
, "");
75 case PIPE_LOGICOP_NAND
:
76 res
= LLVMBuildNot(builder
, LLVMBuildAnd(builder
, src
, dst
, ""), "");
78 case PIPE_LOGICOP_AND
:
79 res
= LLVMBuildAnd(builder
, src
, dst
, "");
81 case PIPE_LOGICOP_EQUIV
:
82 res
= LLVMBuildNot(builder
, LLVMBuildXor(builder
, src
, dst
, ""), "");
84 case PIPE_LOGICOP_NOOP
:
87 case PIPE_LOGICOP_OR_INVERTED
:
88 res
= LLVMBuildOr(builder
, LLVMBuildNot(builder
, src
, ""), dst
, "");
90 case PIPE_LOGICOP_COPY
:
93 case PIPE_LOGICOP_OR_REVERSE
:
94 res
= LLVMBuildOr(builder
, src
, LLVMBuildNot(builder
, dst
, ""), "");
97 res
= LLVMBuildOr(builder
, src
, dst
, "");
99 case PIPE_LOGICOP_SET
:
100 res
= LLVMConstAllOnes(type
);