1 /* 2 * Copyright 2017 Intel Corporation 3 * 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: 10 * 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 13 * Software. 14 * 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 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 */ 23 24 #ifndef BRW_REG_TYPE_H 25 #define BRW_REG_TYPE_H 26 27 #include <stdbool.h> 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 #ifdef HAVE_FUNC_ATTRIBUTE_PURE 34 #define ATTRIBUTE_PURE __attribute__((__pure__)) 35 #else 36 #define ATTRIBUTE_PURE 37 #endif 38 39 enum brw_reg_file; 40 struct gen_device_info; 41 42 /* 43 * The ordering has been chosen so that no enum value is the same as a 44 * compatible hardware encoding. 45 */ 46 enum PACKED brw_reg_type { 47 /** Floating-point types: @{ */ 48 BRW_REGISTER_TYPE_DF, 49 BRW_REGISTER_TYPE_F, 50 BRW_REGISTER_TYPE_HF, 51 BRW_REGISTER_TYPE_VF, 52 /** @} */ 53 54 /** Integer types: @{ */ 55 BRW_REGISTER_TYPE_Q, 56 BRW_REGISTER_TYPE_UQ, 57 BRW_REGISTER_TYPE_D, 58 BRW_REGISTER_TYPE_UD, 59 BRW_REGISTER_TYPE_W, 60 BRW_REGISTER_TYPE_UW, 61 BRW_REGISTER_TYPE_B, 62 BRW_REGISTER_TYPE_UB, 63 BRW_REGISTER_TYPE_V, 64 BRW_REGISTER_TYPE_UV, 65 /** @} */ 66 67 BRW_REGISTER_TYPE_LAST = BRW_REGISTER_TYPE_UV 68 }; 69 70 static inline bool 71 brw_reg_type_is_floating_point(enum brw_reg_type type) 72 { 73 switch (type) { 74 case BRW_REGISTER_TYPE_DF: 75 case BRW_REGISTER_TYPE_F: 76 case BRW_REGISTER_TYPE_HF: 77 return true; 78 default: 79 return false; 80 } 81 } 82 83 unsigned 84 brw_reg_type_to_hw_type(const struct gen_device_info *devinfo, 85 enum brw_reg_file file, enum brw_reg_type type); 86 87 enum brw_reg_type ATTRIBUTE_PURE 88 brw_hw_type_to_reg_type(const struct gen_device_info *devinfo, 89 enum brw_reg_file file, unsigned hw_type); 90 91 unsigned 92 brw_reg_type_to_a16_hw_3src_type(const struct gen_device_info *devinfo, 93 enum brw_reg_type type); 94 95 unsigned 96 brw_reg_type_to_a1_hw_3src_type(const struct gen_device_info *devinfo, 97 enum brw_reg_type type); 98 99 enum brw_reg_type 100 brw_a16_hw_3src_type_to_reg_type(const struct gen_device_info *devinfo, 101 unsigned hw_type); 102 103 enum brw_reg_type 104 brw_a1_hw_3src_type_to_reg_type(const struct gen_device_info *devinfo, 105 unsigned hw_type, unsigned exec_type); 106 107 unsigned 108 brw_reg_type_to_size(enum brw_reg_type type); 109 110 const char * 111 brw_reg_type_to_letters(enum brw_reg_type type); 112 113 #ifdef __cplusplus 114 } 115 #endif 116 117 #endif 118