~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/gallium/auxiliary/gallivm/lp_bld_type.c

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
 * XXX: I'm not sure if it wouldn't be easier/efficient to just recreate the
82
82
 * type and check for identity.
83
83
 */
84
 
boolean
 
84
bool
85
85
lp_check_elem_type(struct lp_type type, LLVMTypeRef elem_type)
86
86
{
87
87
   assert(elem_type);
88
88
   if (!elem_type)
89
 
      return FALSE;
 
89
      return false;
90
90
 
91
91
   const LLVMTypeKind elem_kind = LLVMGetTypeKind(elem_type);
92
92
 
96
96
         if (elem_kind != (lp_has_fp16()
97
97
                           ? LLVMHalfTypeKind : LLVMIntegerTypeKind)) {
98
98
            debug_printf("%s:%d: type is not 16 bits\n", __FILE__, __LINE__);
99
 
            return FALSE;
 
99
            return false;
100
100
         }
101
101
         break;
102
102
      case 32:
103
103
         if (elem_kind != LLVMFloatTypeKind) {
104
104
            debug_printf("%s:%d: type is not float\n", __FILE__, __LINE__);
105
 
            return FALSE;
 
105
            return false;
106
106
         }
107
107
         break;
108
108
      case 64:
109
109
         if (elem_kind != LLVMDoubleTypeKind) {
110
110
            debug_printf("%s:%d: type is not double\n", __FILE__, __LINE__);
111
 
            return FALSE;
 
111
            return false;
112
112
         }
113
113
         break;
114
114
      default:
115
115
         assert(0);
116
 
         return FALSE;
 
116
         return false;
117
117
      }
118
118
   }
119
119
   else {
120
120
      if (elem_kind != LLVMIntegerTypeKind) {
121
121
         debug_printf("%s:%d: element is not integer\n", __FILE__, __LINE__);
122
 
         return FALSE;
 
122
         return false;
123
123
      }
124
124
 
125
125
      if (LLVMGetIntTypeWidth(elem_type) != type.width) {
126
126
         debug_printf("%s:%d: type width mismatch %d != %d\n",
127
127
                      __FILE__, __LINE__,
128
128
                      LLVMGetIntTypeWidth(elem_type), type.width);
129
 
         return FALSE;
 
129
         return false;
130
130
      }
131
131
   }
132
132
 
133
 
   return TRUE;
 
133
   return true;
134
134
}
135
135
 
136
136
 
137
 
boolean
 
137
bool
138
138
lp_check_vec_type(struct lp_type type, LLVMTypeRef vec_type)
139
139
{
140
140
   assert(vec_type);
141
141
   if (!vec_type)
142
 
      return FALSE;
 
142
      return false;
143
143
 
144
144
   if (type.length == 1)
145
145
      return lp_check_elem_type(type, vec_type);
146
146
 
147
147
   if (LLVMGetTypeKind(vec_type) != LLVMVectorTypeKind) {
148
148
      printf("%s:%d: kind is not vector\n", __FILE__, __LINE__);
149
 
      return FALSE;
 
149
      return false;
150
150
   }
151
151
 
152
152
   if (LLVMGetVectorSize(vec_type) != type.length) {
153
153
      printf("%s:%d: vector size mismatch %d != expected %d\n", __FILE__, __LINE__,
154
154
             LLVMGetVectorSize(vec_type), type.length);
155
 
      return FALSE;
 
155
      return false;
156
156
   }
157
157
 
158
158
   LLVMTypeRef elem_type = LLVMGetElementType(vec_type);
161
161
}
162
162
 
163
163
 
164
 
boolean
 
164
bool
165
165
lp_check_value(struct lp_type type, LLVMValueRef val)
166
166
{
167
167
   assert(val);
168
168
   if (!val)
169
 
      return FALSE;
 
169
      return false;
170
170
 
171
171
   LLVMTypeRef vec_type = LLVMTypeOf(val);
172
172