Path: blob/21.2-virgl/src/panfrost/midgard/midgard_ops.h
4564 views
/* Copyright (c) 2018-2019 Alyssa Rosenzweig ([email protected])1* Copyright (C) 2019-2020 Collabora, Ltd.2*3* Permission is hereby granted, free of charge, to any person obtaining a copy4* of this software and associated documentation files (the "Software"), to deal5* in the Software without restriction, including without limitation the rights6* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell7* copies of the Software, and to permit persons to whom the Software is8* furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice shall be included in11* all copies or substantial portions of the Software.12*13* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE16* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER17* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,18* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN19* THE SOFTWARE.20*/2122#ifndef __MIDGARD_OPS23#define __MIDGARD_OPS2425#include "helpers.h"2627/* Forward declare */2829extern struct mir_op_props alu_opcode_props[256];30extern struct mir_ldst_op_props load_store_opcode_props[256];31extern struct mir_tex_op_props tex_opcode_props[16];32extern struct mir_tag_props midgard_tag_props[16];3334#define OP_IS_ATOMIC(op) (load_store_opcode_props[op].props & LDST_ATOMIC)35#define OP_USES_ATTRIB(op) (load_store_opcode_props[op].props & LDST_ATTRIB)36#define OP_IS_STORE(op) (load_store_opcode_props[op].props & LDST_STORE)37#define OP_HAS_ADDRESS(op) (load_store_opcode_props[op].props & LDST_ADDRESS)3839/* Is this opcode that of an integer (regardless of signedness)? Instruction40* names authoritatively determine types */4142static inline bool43midgard_is_integer_op(int op)44{45return (op >= 0x40 && op <= 0x7E) || (op >= 0xA0 && op <= 0xC1);46}4748static inline bool49midgard_is_unsigned_op(int op)50{51assert(midgard_is_integer_op(op));5253switch (op) {54case midgard_alu_op_uaddsat:55case midgard_alu_op_usubsat:56case midgard_alu_op_uwmul:57case midgard_alu_op_umin:58case midgard_alu_op_umax:59case midgard_alu_op_uavg:60case midgard_alu_op_uravg:61case midgard_alu_op_ushlsat:62case midgard_alu_op_uabsdiff:63case midgard_alu_op_ult:64case midgard_alu_op_ule:65case midgard_alu_op_uball_lt:66case midgard_alu_op_uball_lte:67case midgard_alu_op_ubany_lt:68case midgard_alu_op_ubany_lte:69case midgard_alu_op_u2f_rte:70case midgard_alu_op_u2f_rtz:71case midgard_alu_op_u2f_rtn:72case midgard_alu_op_u2f_rtp:73return true;74default:75return false;76}77}7879/* Does this opcode *write* an integer? Same as is_integer_op, unless it's a80* conversion between int<->float in which case we do the opposite */8182static inline bool83midgard_is_integer_out_op(int op)84{85bool is_int = midgard_is_integer_op(op);86bool is_conversion = alu_opcode_props[op].props & OP_TYPE_CONVERT;8788return is_int ^ is_conversion;89}9091/* Determines effective writemask, taking quirks and expansion into account */9293static inline unsigned94effective_writemask(midgard_alu_op op, unsigned existing_mask)95{96/* Channel count is off-by-one to fit in two-bits (0 channel makes no97* sense) */9899unsigned channel_count = GET_CHANNEL_COUNT(alu_opcode_props[op].props);100101/* If there is a fixed channel count, construct the appropriate mask */102103if (channel_count)104return (1 << channel_count) - 1;105106return existing_mask;107};108109#endif110111112