2 * Copyright (C) 2019 Collabora, Ltd.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 #include "midgard_ops.h"
27 /* Lowers the invert field on instructions to a dedicated inot (inor)
28 * instruction instead, as invert is not always supported natively by the
32 midgard_lower_invert(compiler_context
*ctx
, midgard_block
*block
)
34 mir_foreach_instr_in_block_safe(block
, ins
) {
35 if (ins
->type
!= TAG_ALU_4
) continue;
36 if (!ins
->invert
) continue;
38 unsigned temp
= make_compiler_temp(ctx
);
40 midgard_instruction
not = {
46 .dest
= ins
->ssa_args
.dest
,
47 .inline_constant
= true
50 .op
= midgard_alu_op_inor
,
52 .reg_mode
= midgard_reg_mode_32
,
53 .dest_override
= midgard_dest_override_none
,
54 .outmod
= midgard_outmod_int_wrap
,
55 .src1
= vector_alu_srco_unsigned(blank_alu_src
),
56 .src2
= vector_alu_srco_unsigned(zero_alu_src
)
60 ins
->ssa_args
.dest
= temp
;
62 mir_insert_instruction_before(mir_next_op(ins
), not);