bi_builder.h revision 96c5ddc4
1/* 2 * Copyright (C) 2020 Collabora, Ltd. 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 FROM, 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 * SOFTWARE. 22 */ 23 24/* Autogenerated file, do not edit */ 25 26 27#ifndef _BI_BUILDER_H_ 28#define _BI_BUILDER_H_ 29 30#include "compiler.h" 31 32 33 34static inline 35bi_instr * bi_acmpstore_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 36{ 37 bi_instr *I = rzalloc(b->shader, bi_instr); 38 I->op = BI_OPCODE_ACMPSTORE_I32; 39 I->src[0] = src0; 40 I->src[1] = src1; 41 I->src[2] = src2; 42 I->seg = seg; 43 bi_builder_insert(&b->cursor, I); 44 return I; 45} 46 47 48static inline 49bi_instr * bi_acmpstore_i64(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 50{ 51 bi_instr *I = rzalloc(b->shader, bi_instr); 52 I->op = BI_OPCODE_ACMPSTORE_I64; 53 I->src[0] = src0; 54 I->src[1] = src1; 55 I->src[2] = src2; 56 I->seg = seg; 57 bi_builder_insert(&b->cursor, I); 58 return I; 59} 60 61 62static inline 63bi_instr * bi_acmpstore(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 64{ 65 if (bitsize == 32) 66 return (bi_acmpstore_i32(b, src0, src1, src2, seg)); 67 else if (bitsize == 64) 68 return (bi_acmpstore_i64(b, src0, src1, src2, seg)); 69 else 70 unreachable("Invalid parameters for ACMPSTORE"); 71} 72 73static inline 74bi_instr * bi_acmpxchg_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 75{ 76 bi_instr *I = rzalloc(b->shader, bi_instr); 77 I->op = BI_OPCODE_ACMPXCHG_I32; 78 I->dest[0] = dest0; 79 I->src[0] = src0; 80 I->src[1] = src1; 81 I->src[2] = src2; 82 I->seg = seg; 83 bi_builder_insert(&b->cursor, I); 84 return I; 85} 86 87static inline 88bi_index bi_acmpxchg_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 89{ 90 return (bi_acmpxchg_i32_to(b, bi_temp(b->shader), src0, src1, src2, seg))->dest[0]; 91} 92 93 94static inline 95bi_instr * bi_acmpxchg_i64_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 96{ 97 bi_instr *I = rzalloc(b->shader, bi_instr); 98 I->op = BI_OPCODE_ACMPXCHG_I64; 99 I->dest[0] = dest0; 100 I->src[0] = src0; 101 I->src[1] = src1; 102 I->src[2] = src2; 103 I->seg = seg; 104 bi_builder_insert(&b->cursor, I); 105 return I; 106} 107 108static inline 109bi_index bi_acmpxchg_i64(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 110{ 111 return (bi_acmpxchg_i64_to(b, bi_temp(b->shader), src0, src1, src2, seg))->dest[0]; 112} 113 114 115static inline 116bi_instr * bi_acmpxchg_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 117{ 118 if (bitsize == 32) 119 return (bi_acmpxchg_i32_to(b, dest0, src0, src1, src2, seg)); 120 else if (bitsize == 64) 121 return (bi_acmpxchg_i64_to(b, dest0, src0, src1, src2, seg)); 122 else 123 unreachable("Invalid parameters for ACMPXCHG"); 124} 125 126static inline 127bi_index bi_acmpxchg(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 128{ 129 if (bitsize == 32) 130 return (bi_acmpxchg_i32_to(b, bi_temp(b->shader), src0, src1, src2, seg))->dest[0]; 131 else if (bitsize == 64) 132 return (bi_acmpxchg_i64_to(b, bi_temp(b->shader), src0, src1, src2, seg))->dest[0]; 133 else 134 unreachable("Invalid parameters for ACMPXCHG"); 135} 136 137static inline 138bi_instr * bi_arshift_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 139{ 140 bi_instr *I = rzalloc(b->shader, bi_instr); 141 I->op = BI_OPCODE_ARSHIFT_I32; 142 I->dest[0] = dest0; 143 I->src[0] = src0; 144 I->src[1] = src1; 145 I->src[2] = src2; 146 bi_builder_insert(&b->cursor, I); 147 return I; 148} 149 150static inline 151bi_index bi_arshift_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 152{ 153 return (bi_arshift_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 154} 155 156 157static inline 158bi_instr * bi_arshift_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 159{ 160 bi_instr *I = rzalloc(b->shader, bi_instr); 161 I->op = BI_OPCODE_ARSHIFT_V2I16; 162 I->dest[0] = dest0; 163 I->src[0] = src0; 164 I->src[1] = src1; 165 I->src[2] = src2; 166 bi_builder_insert(&b->cursor, I); 167 return I; 168} 169 170static inline 171bi_index bi_arshift_v2i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 172{ 173 return (bi_arshift_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 174} 175 176 177static inline 178bi_instr * bi_arshift_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 179{ 180 bi_instr *I = rzalloc(b->shader, bi_instr); 181 I->op = BI_OPCODE_ARSHIFT_V4I8; 182 I->dest[0] = dest0; 183 I->src[0] = src0; 184 I->src[1] = src1; 185 I->src[2] = src2; 186 bi_builder_insert(&b->cursor, I); 187 return I; 188} 189 190static inline 191bi_index bi_arshift_v4i8(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 192{ 193 return (bi_arshift_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 194} 195 196 197static inline 198bi_instr * bi_arshift_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 199{ 200 if (bitsize == 32) 201 return (bi_arshift_i32_to(b, dest0, src0, src1, src2)); 202 else if (bitsize == 16) 203 return (bi_arshift_v2i16_to(b, dest0, src0, src1, src2)); 204 else if (bitsize == 8) 205 return (bi_arshift_v4i8_to(b, dest0, src0, src1, src2)); 206 else 207 unreachable("Invalid parameters for ARSHIFT"); 208} 209 210static inline 211bi_index bi_arshift(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2) 212{ 213 if (bitsize == 32) 214 return (bi_arshift_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 215 else if (bitsize == 16) 216 return (bi_arshift_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 217 else if (bitsize == 8) 218 return (bi_arshift_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 219 else 220 unreachable("Invalid parameters for ARSHIFT"); 221} 222 223static inline 224bi_instr * bi_arshift_double_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bool bytes2, bool result_word) 225{ 226 bi_instr *I = rzalloc(b->shader, bi_instr); 227 I->op = BI_OPCODE_ARSHIFT_DOUBLE_I32; 228 I->dest[0] = dest0; 229 I->src[0] = src0; 230 I->src[1] = src1; 231 I->src[2] = src2; 232 I->bytes2 = bytes2; 233 I->result_word = result_word; 234 bi_builder_insert(&b->cursor, I); 235 return I; 236} 237 238static inline 239bi_index bi_arshift_double_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bool bytes2, bool result_word) 240{ 241 return (bi_arshift_double_i32_to(b, bi_temp(b->shader), src0, src1, src2, bytes2, result_word))->dest[0]; 242} 243 244 245static inline 246bi_instr * bi_atest_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1) 247{ 248 bi_instr *I = rzalloc(b->shader, bi_instr); 249 I->op = BI_OPCODE_ATEST; 250 I->dest[0] = dest0; 251 I->src[0] = src0; 252 I->src[1] = src1; 253 bi_builder_insert(&b->cursor, I); 254 return I; 255} 256 257static inline 258bi_index bi_atest(bi_builder *b, bi_index src0, bi_index src1) 259{ 260 return (bi_atest_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 261} 262 263 264static inline 265bi_instr * bi_atom_c_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_atom_opc atom_opc) 266{ 267 bi_instr *I = rzalloc(b->shader, bi_instr); 268 I->op = BI_OPCODE_ATOM_C_I32; 269 I->src[0] = src0; 270 I->src[1] = src1; 271 I->src[2] = src2; 272 I->atom_opc = atom_opc; 273 bi_builder_insert(&b->cursor, I); 274 return I; 275} 276 277 278static inline 279bi_instr * bi_atom_c_i64(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_atom_opc atom_opc) 280{ 281 bi_instr *I = rzalloc(b->shader, bi_instr); 282 I->op = BI_OPCODE_ATOM_C_I64; 283 I->src[0] = src0; 284 I->src[1] = src1; 285 I->src[2] = src2; 286 I->atom_opc = atom_opc; 287 bi_builder_insert(&b->cursor, I); 288 return I; 289} 290 291 292static inline 293bi_instr * bi_atom_c(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2, enum bi_atom_opc atom_opc) 294{ 295 if (bitsize == 32) 296 return (bi_atom_c_i32(b, src0, src1, src2, atom_opc)); 297 else if (bitsize == 64) 298 return (bi_atom_c_i64(b, src0, src1, src2, atom_opc)); 299 else 300 unreachable("Invalid parameters for ATOM_C"); 301} 302 303static inline 304bi_instr * bi_atom_c1_i32(bi_builder *b, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc) 305{ 306 bi_instr *I = rzalloc(b->shader, bi_instr); 307 I->op = BI_OPCODE_ATOM_C1_I32; 308 I->src[0] = src0; 309 I->src[1] = src1; 310 I->atom_opc = atom_opc; 311 bi_builder_insert(&b->cursor, I); 312 return I; 313} 314 315 316static inline 317bi_instr * bi_atom_c1_i64(bi_builder *b, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc) 318{ 319 bi_instr *I = rzalloc(b->shader, bi_instr); 320 I->op = BI_OPCODE_ATOM_C1_I64; 321 I->src[0] = src0; 322 I->src[1] = src1; 323 I->atom_opc = atom_opc; 324 bi_builder_insert(&b->cursor, I); 325 return I; 326} 327 328 329static inline 330bi_instr * bi_atom_c1(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc) 331{ 332 if (bitsize == 32) 333 return (bi_atom_c1_i32(b, src0, src1, atom_opc)); 334 else if (bitsize == 64) 335 return (bi_atom_c1_i64(b, src0, src1, atom_opc)); 336 else 337 unreachable("Invalid parameters for ATOM_C1"); 338} 339 340static inline 341bi_instr * bi_atom_c1_return_i32(bi_builder *b, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc) 342{ 343 bi_instr *I = rzalloc(b->shader, bi_instr); 344 I->op = BI_OPCODE_ATOM_C1_RETURN_I32; 345 I->src[0] = src0; 346 I->src[1] = src1; 347 I->atom_opc = atom_opc; 348 bi_builder_insert(&b->cursor, I); 349 return I; 350} 351 352 353static inline 354bi_instr * bi_atom_c1_return_i64(bi_builder *b, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc) 355{ 356 bi_instr *I = rzalloc(b->shader, bi_instr); 357 I->op = BI_OPCODE_ATOM_C1_RETURN_I64; 358 I->src[0] = src0; 359 I->src[1] = src1; 360 I->atom_opc = atom_opc; 361 bi_builder_insert(&b->cursor, I); 362 return I; 363} 364 365 366static inline 367bi_instr * bi_atom_c1_return(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc) 368{ 369 if (bitsize == 32) 370 return (bi_atom_c1_return_i32(b, src0, src1, atom_opc)); 371 else if (bitsize == 64) 372 return (bi_atom_c1_return_i64(b, src0, src1, atom_opc)); 373 else 374 unreachable("Invalid parameters for ATOM_C1_RETURN"); 375} 376 377static inline 378bi_instr * bi_atom_cx_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bi_index src3, uint32_t sr_count) 379{ 380 bi_instr *I = rzalloc(b->shader, bi_instr); 381 I->op = BI_OPCODE_ATOM_CX; 382 I->dest[0] = dest0; 383 I->src[0] = src0; 384 I->src[1] = src1; 385 I->src[2] = src2; 386 I->src[3] = src3; 387 I->sr_count = sr_count; 388 bi_builder_insert(&b->cursor, I); 389 return I; 390} 391 392static inline 393bi_index bi_atom_cx(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, uint32_t sr_count) 394{ 395 return (bi_atom_cx_to(b, bi_temp(b->shader), src0, src1, src2, src3, sr_count))->dest[0]; 396} 397 398 399static inline 400bi_instr * bi_atom_c_return_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_atom_opc atom_opc) 401{ 402 bi_instr *I = rzalloc(b->shader, bi_instr); 403 I->op = BI_OPCODE_ATOM_C_RETURN_I32; 404 I->src[0] = src0; 405 I->src[1] = src1; 406 I->src[2] = src2; 407 I->atom_opc = atom_opc; 408 bi_builder_insert(&b->cursor, I); 409 return I; 410} 411 412 413static inline 414bi_instr * bi_atom_c_return_i64(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_atom_opc atom_opc) 415{ 416 bi_instr *I = rzalloc(b->shader, bi_instr); 417 I->op = BI_OPCODE_ATOM_C_RETURN_I64; 418 I->src[0] = src0; 419 I->src[1] = src1; 420 I->src[2] = src2; 421 I->atom_opc = atom_opc; 422 bi_builder_insert(&b->cursor, I); 423 return I; 424} 425 426 427static inline 428bi_instr * bi_atom_c_return(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2, enum bi_atom_opc atom_opc) 429{ 430 if (bitsize == 32) 431 return (bi_atom_c_return_i32(b, src0, src1, src2, atom_opc)); 432 else if (bitsize == 64) 433 return (bi_atom_c_return_i64(b, src0, src1, src2, atom_opc)); 434 else 435 unreachable("Invalid parameters for ATOM_C_RETURN"); 436} 437 438static inline 439bi_instr * bi_atom_post_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc) 440{ 441 bi_instr *I = rzalloc(b->shader, bi_instr); 442 I->op = BI_OPCODE_ATOM_POST_I32; 443 I->dest[0] = dest0; 444 I->src[0] = src0; 445 I->src[1] = src1; 446 I->atom_opc = atom_opc; 447 bi_builder_insert(&b->cursor, I); 448 return I; 449} 450 451static inline 452bi_index bi_atom_post_i32(bi_builder *b, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc) 453{ 454 return (bi_atom_post_i32_to(b, bi_temp(b->shader), src0, src1, atom_opc))->dest[0]; 455} 456 457 458static inline 459bi_instr * bi_atom_post_i64_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc) 460{ 461 bi_instr *I = rzalloc(b->shader, bi_instr); 462 I->op = BI_OPCODE_ATOM_POST_I64; 463 I->dest[0] = dest0; 464 I->src[0] = src0; 465 I->src[1] = src1; 466 I->atom_opc = atom_opc; 467 bi_builder_insert(&b->cursor, I); 468 return I; 469} 470 471static inline 472bi_index bi_atom_post_i64(bi_builder *b, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc) 473{ 474 return (bi_atom_post_i64_to(b, bi_temp(b->shader), src0, src1, atom_opc))->dest[0]; 475} 476 477 478static inline 479bi_instr * bi_atom_post_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc) 480{ 481 if (bitsize == 32) 482 return (bi_atom_post_i32_to(b, dest0, src0, src1, atom_opc)); 483 else if (bitsize == 64) 484 return (bi_atom_post_i64_to(b, dest0, src0, src1, atom_opc)); 485 else 486 unreachable("Invalid parameters for ATOM_POST"); 487} 488 489static inline 490bi_index bi_atom_post(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc) 491{ 492 if (bitsize == 32) 493 return (bi_atom_post_i32_to(b, bi_temp(b->shader), src0, src1, atom_opc))->dest[0]; 494 else if (bitsize == 64) 495 return (bi_atom_post_i64_to(b, bi_temp(b->shader), src0, src1, atom_opc))->dest[0]; 496 else 497 unreachable("Invalid parameters for ATOM_POST"); 498} 499 500static inline 501bi_instr * bi_atom_pre_i64_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_atom_opc atom_opc) 502{ 503 bi_instr *I = rzalloc(b->shader, bi_instr); 504 I->op = BI_OPCODE_ATOM_PRE_I64; 505 I->dest[0] = dest0; 506 I->src[0] = src0; 507 I->src[1] = src1; 508 I->src[2] = src2; 509 I->atom_opc = atom_opc; 510 bi_builder_insert(&b->cursor, I); 511 return I; 512} 513 514static inline 515bi_index bi_atom_pre_i64(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_atom_opc atom_opc) 516{ 517 return (bi_atom_pre_i64_to(b, bi_temp(b->shader), src0, src1, src2, atom_opc))->dest[0]; 518} 519 520 521static inline 522bi_instr * bi_axchg_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 523{ 524 bi_instr *I = rzalloc(b->shader, bi_instr); 525 I->op = BI_OPCODE_AXCHG_I32; 526 I->dest[0] = dest0; 527 I->src[0] = src0; 528 I->src[1] = src1; 529 I->src[2] = src2; 530 I->seg = seg; 531 bi_builder_insert(&b->cursor, I); 532 return I; 533} 534 535static inline 536bi_index bi_axchg_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 537{ 538 return (bi_axchg_i32_to(b, bi_temp(b->shader), src0, src1, src2, seg))->dest[0]; 539} 540 541 542static inline 543bi_instr * bi_axchg_i64_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 544{ 545 bi_instr *I = rzalloc(b->shader, bi_instr); 546 I->op = BI_OPCODE_AXCHG_I64; 547 I->dest[0] = dest0; 548 I->src[0] = src0; 549 I->src[1] = src1; 550 I->src[2] = src2; 551 I->seg = seg; 552 bi_builder_insert(&b->cursor, I); 553 return I; 554} 555 556static inline 557bi_index bi_axchg_i64(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 558{ 559 return (bi_axchg_i64_to(b, bi_temp(b->shader), src0, src1, src2, seg))->dest[0]; 560} 561 562 563static inline 564bi_instr * bi_axchg_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 565{ 566 if (bitsize == 32) 567 return (bi_axchg_i32_to(b, dest0, src0, src1, src2, seg)); 568 else if (bitsize == 64) 569 return (bi_axchg_i64_to(b, dest0, src0, src1, src2, seg)); 570 else 571 unreachable("Invalid parameters for AXCHG"); 572} 573 574static inline 575bi_index bi_axchg(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 576{ 577 if (bitsize == 32) 578 return (bi_axchg_i32_to(b, bi_temp(b->shader), src0, src1, src2, seg))->dest[0]; 579 else if (bitsize == 64) 580 return (bi_axchg_i64_to(b, bi_temp(b->shader), src0, src1, src2, seg))->dest[0]; 581 else 582 unreachable("Invalid parameters for AXCHG"); 583} 584 585static inline 586bi_instr * bi_barrier(bi_builder *b) 587{ 588 bi_instr *I = rzalloc(b->shader, bi_instr); 589 I->op = BI_OPCODE_BARRIER; 590 bi_builder_insert(&b->cursor, I); 591 return I; 592} 593 594 595static inline 596bi_instr * bi_bitrev_i32_to(bi_builder *b, bi_index dest0, bi_index src0) 597{ 598 bi_instr *I = rzalloc(b->shader, bi_instr); 599 I->op = BI_OPCODE_BITREV_I32; 600 I->dest[0] = dest0; 601 I->src[0] = src0; 602 bi_builder_insert(&b->cursor, I); 603 return I; 604} 605 606static inline 607bi_index bi_bitrev_i32(bi_builder *b, bi_index src0) 608{ 609 return (bi_bitrev_i32_to(b, bi_temp(b->shader), src0))->dest[0]; 610} 611 612 613static inline 614bi_instr * bi_blend_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bi_index src3, uint32_t sr_count) 615{ 616 bi_instr *I = rzalloc(b->shader, bi_instr); 617 I->op = BI_OPCODE_BLEND; 618 I->dest[0] = dest0; 619 I->src[0] = src0; 620 I->src[1] = src1; 621 I->src[2] = src2; 622 I->src[3] = src3; 623 I->sr_count = sr_count; 624 bi_builder_insert(&b->cursor, I); 625 return I; 626} 627 628static inline 629bi_index bi_blend(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, uint32_t sr_count) 630{ 631 return (bi_blend_to(b, bi_temp(b->shader), src0, src1, src2, src3, sr_count))->dest[0]; 632} 633 634 635static inline 636bi_instr * bi_branch_f16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_cmpf cmpf) 637{ 638 bi_instr *I = rzalloc(b->shader, bi_instr); 639 I->op = BI_OPCODE_BRANCH_F16; 640 I->src[0] = src0; 641 I->src[1] = src1; 642 I->src[2] = src2; 643 I->cmpf = cmpf; 644 bi_builder_insert(&b->cursor, I); 645 return I; 646} 647 648 649static inline 650bi_instr * bi_branch_f32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_cmpf cmpf) 651{ 652 bi_instr *I = rzalloc(b->shader, bi_instr); 653 I->op = BI_OPCODE_BRANCH_F32; 654 I->src[0] = src0; 655 I->src[1] = src1; 656 I->src[2] = src2; 657 I->cmpf = cmpf; 658 bi_builder_insert(&b->cursor, I); 659 return I; 660} 661 662 663static inline 664bi_instr * bi_branch_i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_cmpf cmpf) 665{ 666 bi_instr *I = rzalloc(b->shader, bi_instr); 667 I->op = BI_OPCODE_BRANCH_I16; 668 I->src[0] = src0; 669 I->src[1] = src1; 670 I->src[2] = src2; 671 I->cmpf = cmpf; 672 bi_builder_insert(&b->cursor, I); 673 return I; 674} 675 676 677static inline 678bi_instr * bi_branch_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_cmpf cmpf) 679{ 680 bi_instr *I = rzalloc(b->shader, bi_instr); 681 I->op = BI_OPCODE_BRANCH_I32; 682 I->src[0] = src0; 683 I->src[1] = src1; 684 I->src[2] = src2; 685 I->cmpf = cmpf; 686 bi_builder_insert(&b->cursor, I); 687 return I; 688} 689 690 691static inline 692bi_instr * bi_branch_s16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_cmpf cmpf) 693{ 694 bi_instr *I = rzalloc(b->shader, bi_instr); 695 I->op = BI_OPCODE_BRANCH_S16; 696 I->src[0] = src0; 697 I->src[1] = src1; 698 I->src[2] = src2; 699 I->cmpf = cmpf; 700 bi_builder_insert(&b->cursor, I); 701 return I; 702} 703 704 705static inline 706bi_instr * bi_branch_s32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_cmpf cmpf) 707{ 708 bi_instr *I = rzalloc(b->shader, bi_instr); 709 I->op = BI_OPCODE_BRANCH_S32; 710 I->src[0] = src0; 711 I->src[1] = src1; 712 I->src[2] = src2; 713 I->cmpf = cmpf; 714 bi_builder_insert(&b->cursor, I); 715 return I; 716} 717 718 719static inline 720bi_instr * bi_branch_u16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_cmpf cmpf) 721{ 722 bi_instr *I = rzalloc(b->shader, bi_instr); 723 I->op = BI_OPCODE_BRANCH_U16; 724 I->src[0] = src0; 725 I->src[1] = src1; 726 I->src[2] = src2; 727 I->cmpf = cmpf; 728 bi_builder_insert(&b->cursor, I); 729 return I; 730} 731 732 733static inline 734bi_instr * bi_branch_u32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_cmpf cmpf) 735{ 736 bi_instr *I = rzalloc(b->shader, bi_instr); 737 I->op = BI_OPCODE_BRANCH_U32; 738 I->src[0] = src0; 739 I->src[1] = src1; 740 I->src[2] = src2; 741 I->cmpf = cmpf; 742 bi_builder_insert(&b->cursor, I); 743 return I; 744} 745 746 747static inline 748bi_instr * bi_branch(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2, enum bi_cmpf cmpf) 749{ 750 if ((type == nir_type_float) && bitsize == 16 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_NE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 751 return (bi_branch_f16(b, src0, src1, src2, cmpf)); 752 else if ((type == nir_type_float) && bitsize == 32 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_NE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 753 return (bi_branch_f32(b, src0, src1, src2, cmpf)); 754 else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE)) 755 return (bi_branch_i16(b, src0, src1, src2, cmpf)); 756 else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE)) 757 return (bi_branch_i32(b, src0, src1, src2, cmpf)); 758 else if ((type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 759 return (bi_branch_s16(b, src0, src1, src2, cmpf)); 760 else if ((type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 761 return (bi_branch_s32(b, src0, src1, src2, cmpf)); 762 else if ((type == nir_type_uint) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 763 return (bi_branch_u16(b, src0, src1, src2, cmpf)); 764 else if ((type == nir_type_uint) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 765 return (bi_branch_u32(b, src0, src1, src2, cmpf)); 766 else 767 unreachable("Invalid parameters for BRANCH"); 768} 769 770static inline 771bi_instr * bi_branchc_i16(bi_builder *b, bi_index src0, bi_index src1, bool combine) 772{ 773 bi_instr *I = rzalloc(b->shader, bi_instr); 774 I->op = BI_OPCODE_BRANCHC_I16; 775 I->src[0] = src0; 776 I->src[1] = src1; 777 I->combine = combine; 778 bi_builder_insert(&b->cursor, I); 779 return I; 780} 781 782 783static inline 784bi_instr * bi_branchc_i32(bi_builder *b, bi_index src0, bi_index src1, bool combine) 785{ 786 bi_instr *I = rzalloc(b->shader, bi_instr); 787 I->op = BI_OPCODE_BRANCHC_I32; 788 I->src[0] = src0; 789 I->src[1] = src1; 790 I->combine = combine; 791 bi_builder_insert(&b->cursor, I); 792 return I; 793} 794 795 796static inline 797bi_instr * bi_branchc(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bool combine) 798{ 799 if (bitsize == 16) 800 return (bi_branchc_i16(b, src0, src1, combine)); 801 else if (bitsize == 32) 802 return (bi_branchc_i32(b, src0, src1, combine)); 803 else 804 unreachable("Invalid parameters for BRANCHC"); 805} 806 807static inline 808bi_instr * bi_branchz_f16(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf) 809{ 810 bi_instr *I = rzalloc(b->shader, bi_instr); 811 I->op = BI_OPCODE_BRANCHZ_F16; 812 I->src[0] = src0; 813 I->src[1] = src1; 814 I->cmpf = cmpf; 815 bi_builder_insert(&b->cursor, I); 816 return I; 817} 818 819 820static inline 821bi_instr * bi_branchz_f32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf) 822{ 823 bi_instr *I = rzalloc(b->shader, bi_instr); 824 I->op = BI_OPCODE_BRANCHZ_F32; 825 I->src[0] = src0; 826 I->src[1] = src1; 827 I->cmpf = cmpf; 828 bi_builder_insert(&b->cursor, I); 829 return I; 830} 831 832 833static inline 834bi_instr * bi_branchz_i16(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf) 835{ 836 bi_instr *I = rzalloc(b->shader, bi_instr); 837 I->op = BI_OPCODE_BRANCHZ_I16; 838 I->src[0] = src0; 839 I->src[1] = src1; 840 I->cmpf = cmpf; 841 bi_builder_insert(&b->cursor, I); 842 return I; 843} 844 845 846static inline 847bi_instr * bi_branchz_i32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf) 848{ 849 bi_instr *I = rzalloc(b->shader, bi_instr); 850 I->op = BI_OPCODE_BRANCHZ_I32; 851 I->src[0] = src0; 852 I->src[1] = src1; 853 I->cmpf = cmpf; 854 bi_builder_insert(&b->cursor, I); 855 return I; 856} 857 858 859static inline 860bi_instr * bi_branchz_s16(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf) 861{ 862 bi_instr *I = rzalloc(b->shader, bi_instr); 863 I->op = BI_OPCODE_BRANCHZ_S16; 864 I->src[0] = src0; 865 I->src[1] = src1; 866 I->cmpf = cmpf; 867 bi_builder_insert(&b->cursor, I); 868 return I; 869} 870 871 872static inline 873bi_instr * bi_branchz_s32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf) 874{ 875 bi_instr *I = rzalloc(b->shader, bi_instr); 876 I->op = BI_OPCODE_BRANCHZ_S32; 877 I->src[0] = src0; 878 I->src[1] = src1; 879 I->cmpf = cmpf; 880 bi_builder_insert(&b->cursor, I); 881 return I; 882} 883 884 885static inline 886bi_instr * bi_branchz_u16(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf) 887{ 888 bi_instr *I = rzalloc(b->shader, bi_instr); 889 I->op = BI_OPCODE_BRANCHZ_U16; 890 I->src[0] = src0; 891 I->src[1] = src1; 892 I->cmpf = cmpf; 893 bi_builder_insert(&b->cursor, I); 894 return I; 895} 896 897 898static inline 899bi_instr * bi_branchz_u32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf) 900{ 901 bi_instr *I = rzalloc(b->shader, bi_instr); 902 I->op = BI_OPCODE_BRANCHZ_U32; 903 I->src[0] = src0; 904 I->src[1] = src1; 905 I->cmpf = cmpf; 906 bi_builder_insert(&b->cursor, I); 907 return I; 908} 909 910 911static inline 912bi_instr * bi_branchz(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index src0, bi_index src1, enum bi_cmpf cmpf) 913{ 914 if ((type == nir_type_float) && bitsize == 16 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_NE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 915 return (bi_branchz_f16(b, src0, src1, cmpf)); 916 else if ((type == nir_type_float) && bitsize == 32 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_NE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 917 return (bi_branchz_f32(b, src0, src1, cmpf)); 918 else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE)) 919 return (bi_branchz_i16(b, src0, src1, cmpf)); 920 else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE)) 921 return (bi_branchz_i32(b, src0, src1, cmpf)); 922 else if ((type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 923 return (bi_branchz_s16(b, src0, src1, cmpf)); 924 else if ((type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 925 return (bi_branchz_s32(b, src0, src1, cmpf)); 926 else if ((type == nir_type_uint) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 927 return (bi_branchz_u16(b, src0, src1, cmpf)); 928 else if ((type == nir_type_uint) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 929 return (bi_branchz_u32(b, src0, src1, cmpf)); 930 else 931 unreachable("Invalid parameters for BRANCHZ"); 932} 933 934static inline 935bi_instr * bi_branch_diverg(bi_builder *b, bi_index src0) 936{ 937 bi_instr *I = rzalloc(b->shader, bi_instr); 938 I->op = BI_OPCODE_BRANCH_DIVERG; 939 I->src[0] = src0; 940 bi_builder_insert(&b->cursor, I); 941 return I; 942} 943 944 945static inline 946bi_instr * bi_branch_lowbits_f32(bi_builder *b, bi_index src0, bi_index src1) 947{ 948 bi_instr *I = rzalloc(b->shader, bi_instr); 949 I->op = BI_OPCODE_BRANCH_LOWBITS_F32; 950 I->src[0] = src0; 951 I->src[1] = src1; 952 bi_builder_insert(&b->cursor, I); 953 return I; 954} 955 956 957static inline 958bi_instr * bi_branch_no_diverg(bi_builder *b, bi_index src0) 959{ 960 bi_instr *I = rzalloc(b->shader, bi_instr); 961 I->op = BI_OPCODE_BRANCH_NO_DIVERG; 962 I->src[0] = src0; 963 bi_builder_insert(&b->cursor, I); 964 return I; 965} 966 967 968static inline 969bi_instr * bi_clper_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_inactive_result inactive_result, enum bi_lane_op lane_op, enum bi_subgroup subgroup) 970{ 971 bi_instr *I = rzalloc(b->shader, bi_instr); 972 I->op = BI_OPCODE_CLPER_I32; 973 I->dest[0] = dest0; 974 I->src[0] = src0; 975 I->src[1] = src1; 976 I->lane_op = lane_op; 977 I->subgroup = subgroup; 978 I->inactive_result = inactive_result; 979 bi_builder_insert(&b->cursor, I); 980 return I; 981} 982 983static inline 984bi_index bi_clper_i32(bi_builder *b, bi_index src0, bi_index src1, enum bi_inactive_result inactive_result, enum bi_lane_op lane_op, enum bi_subgroup subgroup) 985{ 986 return (bi_clper_i32_to(b, bi_temp(b->shader), src0, src1, inactive_result, lane_op, subgroup))->dest[0]; 987} 988 989 990static inline 991bi_instr * bi_clper_v6_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1) 992{ 993 bi_instr *I = rzalloc(b->shader, bi_instr); 994 I->op = BI_OPCODE_CLPER_V6_I32; 995 I->dest[0] = dest0; 996 I->src[0] = src0; 997 I->src[1] = src1; 998 bi_builder_insert(&b->cursor, I); 999 return I; 1000} 1001 1002static inline 1003bi_index bi_clper_v6_i32(bi_builder *b, bi_index src0, bi_index src1) 1004{ 1005 return (bi_clper_v6_i32_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 1006} 1007 1008 1009static inline 1010bi_instr * bi_clz_u32_to(bi_builder *b, bi_index dest0, bi_index src0, bool mask) 1011{ 1012 bi_instr *I = rzalloc(b->shader, bi_instr); 1013 I->op = BI_OPCODE_CLZ_U32; 1014 I->dest[0] = dest0; 1015 I->src[0] = src0; 1016 I->mask = mask; 1017 bi_builder_insert(&b->cursor, I); 1018 return I; 1019} 1020 1021static inline 1022bi_index bi_clz_u32(bi_builder *b, bi_index src0, bool mask) 1023{ 1024 return (bi_clz_u32_to(b, bi_temp(b->shader), src0, mask))->dest[0]; 1025} 1026 1027 1028static inline 1029bi_instr * bi_clz_v2u16_to(bi_builder *b, bi_index dest0, bi_index src0, bool mask) 1030{ 1031 bi_instr *I = rzalloc(b->shader, bi_instr); 1032 I->op = BI_OPCODE_CLZ_V2U16; 1033 I->dest[0] = dest0; 1034 I->src[0] = src0; 1035 I->mask = mask; 1036 bi_builder_insert(&b->cursor, I); 1037 return I; 1038} 1039 1040static inline 1041bi_index bi_clz_v2u16(bi_builder *b, bi_index src0, bool mask) 1042{ 1043 return (bi_clz_v2u16_to(b, bi_temp(b->shader), src0, mask))->dest[0]; 1044} 1045 1046 1047static inline 1048bi_instr * bi_clz_v4u8_to(bi_builder *b, bi_index dest0, bi_index src0, bool mask) 1049{ 1050 bi_instr *I = rzalloc(b->shader, bi_instr); 1051 I->op = BI_OPCODE_CLZ_V4U8; 1052 I->dest[0] = dest0; 1053 I->src[0] = src0; 1054 I->mask = mask; 1055 bi_builder_insert(&b->cursor, I); 1056 return I; 1057} 1058 1059static inline 1060bi_index bi_clz_v4u8(bi_builder *b, bi_index src0, bool mask) 1061{ 1062 return (bi_clz_v4u8_to(b, bi_temp(b->shader), src0, mask))->dest[0]; 1063} 1064 1065 1066static inline 1067bi_instr * bi_clz_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bool mask) 1068{ 1069 if (bitsize == 32) 1070 return (bi_clz_u32_to(b, dest0, src0, mask)); 1071 else if (bitsize == 16) 1072 return (bi_clz_v2u16_to(b, dest0, src0, mask)); 1073 else if (bitsize == 8) 1074 return (bi_clz_v4u8_to(b, dest0, src0, mask)); 1075 else 1076 unreachable("Invalid parameters for CLZ"); 1077} 1078 1079static inline 1080bi_index bi_clz(bi_builder *b, unsigned bitsize, bi_index src0, bool mask) 1081{ 1082 if (bitsize == 32) 1083 return (bi_clz_u32_to(b, bi_temp(b->shader), src0, mask))->dest[0]; 1084 else if (bitsize == 16) 1085 return (bi_clz_v2u16_to(b, bi_temp(b->shader), src0, mask))->dest[0]; 1086 else if (bitsize == 8) 1087 return (bi_clz_v4u8_to(b, bi_temp(b->shader), src0, mask))->dest[0]; 1088 else 1089 unreachable("Invalid parameters for CLZ"); 1090} 1091 1092static inline 1093bi_instr * bi_csel_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf) 1094{ 1095 bi_instr *I = rzalloc(b->shader, bi_instr); 1096 I->op = BI_OPCODE_CSEL_F32; 1097 I->dest[0] = dest0; 1098 I->src[0] = src0; 1099 I->src[1] = src1; 1100 I->src[2] = src2; 1101 I->src[3] = src3; 1102 I->cmpf = cmpf; 1103 bi_builder_insert(&b->cursor, I); 1104 return I; 1105} 1106 1107static inline 1108bi_index bi_csel_f32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf) 1109{ 1110 return (bi_csel_f32_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0]; 1111} 1112 1113 1114static inline 1115bi_instr * bi_csel_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf) 1116{ 1117 bi_instr *I = rzalloc(b->shader, bi_instr); 1118 I->op = BI_OPCODE_CSEL_I32; 1119 I->dest[0] = dest0; 1120 I->src[0] = src0; 1121 I->src[1] = src1; 1122 I->src[2] = src2; 1123 I->src[3] = src3; 1124 I->cmpf = cmpf; 1125 bi_builder_insert(&b->cursor, I); 1126 return I; 1127} 1128 1129static inline 1130bi_index bi_csel_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf) 1131{ 1132 return (bi_csel_i32_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0]; 1133} 1134 1135 1136static inline 1137bi_instr * bi_csel_s32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf) 1138{ 1139 bi_instr *I = rzalloc(b->shader, bi_instr); 1140 I->op = BI_OPCODE_CSEL_S32; 1141 I->dest[0] = dest0; 1142 I->src[0] = src0; 1143 I->src[1] = src1; 1144 I->src[2] = src2; 1145 I->src[3] = src3; 1146 I->cmpf = cmpf; 1147 bi_builder_insert(&b->cursor, I); 1148 return I; 1149} 1150 1151static inline 1152bi_index bi_csel_s32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf) 1153{ 1154 return (bi_csel_s32_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0]; 1155} 1156 1157 1158static inline 1159bi_instr * bi_csel_u32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf) 1160{ 1161 bi_instr *I = rzalloc(b->shader, bi_instr); 1162 I->op = BI_OPCODE_CSEL_U32; 1163 I->dest[0] = dest0; 1164 I->src[0] = src0; 1165 I->src[1] = src1; 1166 I->src[2] = src2; 1167 I->src[3] = src3; 1168 I->cmpf = cmpf; 1169 bi_builder_insert(&b->cursor, I); 1170 return I; 1171} 1172 1173static inline 1174bi_index bi_csel_u32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf) 1175{ 1176 return (bi_csel_u32_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0]; 1177} 1178 1179 1180static inline 1181bi_instr * bi_csel_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf) 1182{ 1183 bi_instr *I = rzalloc(b->shader, bi_instr); 1184 I->op = BI_OPCODE_CSEL_V2F16; 1185 I->dest[0] = dest0; 1186 I->src[0] = src0; 1187 I->src[1] = src1; 1188 I->src[2] = src2; 1189 I->src[3] = src3; 1190 I->cmpf = cmpf; 1191 bi_builder_insert(&b->cursor, I); 1192 return I; 1193} 1194 1195static inline 1196bi_index bi_csel_v2f16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf) 1197{ 1198 return (bi_csel_v2f16_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0]; 1199} 1200 1201 1202static inline 1203bi_instr * bi_csel_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf) 1204{ 1205 bi_instr *I = rzalloc(b->shader, bi_instr); 1206 I->op = BI_OPCODE_CSEL_V2I16; 1207 I->dest[0] = dest0; 1208 I->src[0] = src0; 1209 I->src[1] = src1; 1210 I->src[2] = src2; 1211 I->src[3] = src3; 1212 I->cmpf = cmpf; 1213 bi_builder_insert(&b->cursor, I); 1214 return I; 1215} 1216 1217static inline 1218bi_index bi_csel_v2i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf) 1219{ 1220 return (bi_csel_v2i16_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0]; 1221} 1222 1223 1224static inline 1225bi_instr * bi_csel_v2s16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf) 1226{ 1227 bi_instr *I = rzalloc(b->shader, bi_instr); 1228 I->op = BI_OPCODE_CSEL_V2S16; 1229 I->dest[0] = dest0; 1230 I->src[0] = src0; 1231 I->src[1] = src1; 1232 I->src[2] = src2; 1233 I->src[3] = src3; 1234 I->cmpf = cmpf; 1235 bi_builder_insert(&b->cursor, I); 1236 return I; 1237} 1238 1239static inline 1240bi_index bi_csel_v2s16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf) 1241{ 1242 return (bi_csel_v2s16_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0]; 1243} 1244 1245 1246static inline 1247bi_instr * bi_csel_v2u16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf) 1248{ 1249 bi_instr *I = rzalloc(b->shader, bi_instr); 1250 I->op = BI_OPCODE_CSEL_V2U16; 1251 I->dest[0] = dest0; 1252 I->src[0] = src0; 1253 I->src[1] = src1; 1254 I->src[2] = src2; 1255 I->src[3] = src3; 1256 I->cmpf = cmpf; 1257 bi_builder_insert(&b->cursor, I); 1258 return I; 1259} 1260 1261static inline 1262bi_index bi_csel_v2u16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf) 1263{ 1264 return (bi_csel_v2u16_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0]; 1265} 1266 1267 1268static inline 1269bi_instr * bi_csel_to(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf) 1270{ 1271 if ((type == nir_type_float) && bitsize == 32 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_NE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 1272 return (bi_csel_f32_to(b, dest0, src0, src1, src2, src3, cmpf)); 1273 else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE)) 1274 return (bi_csel_i32_to(b, dest0, src0, src1, src2, src3, cmpf)); 1275 else if ((type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 1276 return (bi_csel_s32_to(b, dest0, src0, src1, src2, src3, cmpf)); 1277 else if ((type == nir_type_uint) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 1278 return (bi_csel_u32_to(b, dest0, src0, src1, src2, src3, cmpf)); 1279 else if ((type == nir_type_float) && bitsize == 16 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_NE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 1280 return (bi_csel_v2f16_to(b, dest0, src0, src1, src2, src3, cmpf)); 1281 else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE)) 1282 return (bi_csel_v2i16_to(b, dest0, src0, src1, src2, src3, cmpf)); 1283 else if ((type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 1284 return (bi_csel_v2s16_to(b, dest0, src0, src1, src2, src3, cmpf)); 1285 else if ((type == nir_type_uint) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 1286 return (bi_csel_v2u16_to(b, dest0, src0, src1, src2, src3, cmpf)); 1287 else 1288 unreachable("Invalid parameters for CSEL"); 1289} 1290 1291static inline 1292bi_index bi_csel(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf) 1293{ 1294 if ((type == nir_type_float) && bitsize == 32 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_NE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 1295 return (bi_csel_f32_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0]; 1296 else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE)) 1297 return (bi_csel_i32_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0]; 1298 else if ((type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 1299 return (bi_csel_s32_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0]; 1300 else if ((type == nir_type_uint) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 1301 return (bi_csel_u32_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0]; 1302 else if ((type == nir_type_float) && bitsize == 16 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_NE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 1303 return (bi_csel_v2f16_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0]; 1304 else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE)) 1305 return (bi_csel_v2i16_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0]; 1306 else if ((type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 1307 return (bi_csel_v2s16_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0]; 1308 else if ((type == nir_type_uint) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 1309 return (bi_csel_v2u16_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0]; 1310 else 1311 unreachable("Invalid parameters for CSEL"); 1312} 1313 1314static inline 1315bi_instr * bi_cubeface_to(bi_builder *b, bi_index dest0, bi_index dest1, bi_index src0, bi_index src1, bi_index src2) 1316{ 1317 bi_instr *I = rzalloc(b->shader, bi_instr); 1318 I->op = BI_OPCODE_CUBEFACE; 1319 I->dest[0] = dest0; 1320 I->dest[1] = dest1; 1321 I->src[0] = src0; 1322 I->src[1] = src1; 1323 I->src[2] = src2; 1324 bi_builder_insert(&b->cursor, I); 1325 return I; 1326} 1327 1328 1329static inline 1330bi_instr * bi_cubeface1_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 1331{ 1332 bi_instr *I = rzalloc(b->shader, bi_instr); 1333 I->op = BI_OPCODE_CUBEFACE1; 1334 I->dest[0] = dest0; 1335 I->src[0] = src0; 1336 I->src[1] = src1; 1337 I->src[2] = src2; 1338 bi_builder_insert(&b->cursor, I); 1339 return I; 1340} 1341 1342static inline 1343bi_index bi_cubeface1(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 1344{ 1345 return (bi_cubeface1_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 1346} 1347 1348 1349static inline 1350bi_instr * bi_cubeface2_to(bi_builder *b, bi_index dest0, bi_index src0) 1351{ 1352 bi_instr *I = rzalloc(b->shader, bi_instr); 1353 I->op = BI_OPCODE_CUBEFACE2; 1354 I->dest[0] = dest0; 1355 I->src[0] = src0; 1356 bi_builder_insert(&b->cursor, I); 1357 return I; 1358} 1359 1360static inline 1361bi_index bi_cubeface2(bi_builder *b, bi_index src0) 1362{ 1363 return (bi_cubeface2_to(b, bi_temp(b->shader), src0))->dest[0]; 1364} 1365 1366 1367static inline 1368bi_instr * bi_cube_ssel_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 1369{ 1370 bi_instr *I = rzalloc(b->shader, bi_instr); 1371 I->op = BI_OPCODE_CUBE_SSEL; 1372 I->dest[0] = dest0; 1373 I->src[0] = src0; 1374 I->src[1] = src1; 1375 I->src[2] = src2; 1376 bi_builder_insert(&b->cursor, I); 1377 return I; 1378} 1379 1380static inline 1381bi_index bi_cube_ssel(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 1382{ 1383 return (bi_cube_ssel_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 1384} 1385 1386 1387static inline 1388bi_instr * bi_cube_tsel_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 1389{ 1390 bi_instr *I = rzalloc(b->shader, bi_instr); 1391 I->op = BI_OPCODE_CUBE_TSEL; 1392 I->dest[0] = dest0; 1393 I->src[0] = src0; 1394 I->src[1] = src1; 1395 I->src[2] = src2; 1396 bi_builder_insert(&b->cursor, I); 1397 return I; 1398} 1399 1400static inline 1401bi_index bi_cube_tsel(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 1402{ 1403 return (bi_cube_tsel_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 1404} 1405 1406 1407static inline 1408bi_instr * bi_discard_b32(bi_builder *b, bi_index src0) 1409{ 1410 bi_instr *I = rzalloc(b->shader, bi_instr); 1411 I->op = BI_OPCODE_DISCARD_B32; 1412 I->src[0] = src0; 1413 bi_builder_insert(&b->cursor, I); 1414 return I; 1415} 1416 1417 1418static inline 1419bi_instr * bi_discard_f32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf) 1420{ 1421 bi_instr *I = rzalloc(b->shader, bi_instr); 1422 I->op = BI_OPCODE_DISCARD_F32; 1423 I->src[0] = src0; 1424 I->src[1] = src1; 1425 I->cmpf = cmpf; 1426 bi_builder_insert(&b->cursor, I); 1427 return I; 1428} 1429 1430 1431static inline 1432bi_instr * bi_dtsel_imm_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_table table) 1433{ 1434 bi_instr *I = rzalloc(b->shader, bi_instr); 1435 I->op = BI_OPCODE_DTSEL_IMM; 1436 I->dest[0] = dest0; 1437 I->src[0] = src0; 1438 I->table = table; 1439 bi_builder_insert(&b->cursor, I); 1440 return I; 1441} 1442 1443static inline 1444bi_index bi_dtsel_imm(bi_builder *b, bi_index src0, enum bi_table table) 1445{ 1446 return (bi_dtsel_imm_to(b, bi_temp(b->shader), src0, table))->dest[0]; 1447} 1448 1449 1450static inline 1451bi_instr * bi_f16_to_f32_to(bi_builder *b, bi_index dest0, bi_index src0) 1452{ 1453 bi_instr *I = rzalloc(b->shader, bi_instr); 1454 I->op = BI_OPCODE_F16_TO_F32; 1455 I->dest[0] = dest0; 1456 I->src[0] = src0; 1457 bi_builder_insert(&b->cursor, I); 1458 return I; 1459} 1460 1461static inline 1462bi_index bi_f16_to_f32(bi_builder *b, bi_index src0) 1463{ 1464 return (bi_f16_to_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 1465} 1466 1467 1468static inline 1469bi_instr * bi_f16_to_s32_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round) 1470{ 1471 bi_instr *I = rzalloc(b->shader, bi_instr); 1472 I->op = BI_OPCODE_F16_TO_S32; 1473 I->dest[0] = dest0; 1474 I->src[0] = src0; 1475 I->round = round; 1476 bi_builder_insert(&b->cursor, I); 1477 return I; 1478} 1479 1480static inline 1481bi_index bi_f16_to_s32(bi_builder *b, bi_index src0, enum bi_round round) 1482{ 1483 return (bi_f16_to_s32_to(b, bi_temp(b->shader), src0, round))->dest[0]; 1484} 1485 1486 1487static inline 1488bi_instr * bi_f16_to_u32_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round) 1489{ 1490 bi_instr *I = rzalloc(b->shader, bi_instr); 1491 I->op = BI_OPCODE_F16_TO_U32; 1492 I->dest[0] = dest0; 1493 I->src[0] = src0; 1494 I->round = round; 1495 bi_builder_insert(&b->cursor, I); 1496 return I; 1497} 1498 1499static inline 1500bi_index bi_f16_to_u32(bi_builder *b, bi_index src0, enum bi_round round) 1501{ 1502 return (bi_f16_to_u32_to(b, bi_temp(b->shader), src0, round))->dest[0]; 1503} 1504 1505 1506static inline 1507bi_instr * bi_f32_to_s32_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round) 1508{ 1509 bi_instr *I = rzalloc(b->shader, bi_instr); 1510 I->op = BI_OPCODE_F32_TO_S32; 1511 I->dest[0] = dest0; 1512 I->src[0] = src0; 1513 I->round = round; 1514 bi_builder_insert(&b->cursor, I); 1515 return I; 1516} 1517 1518static inline 1519bi_index bi_f32_to_s32(bi_builder *b, bi_index src0, enum bi_round round) 1520{ 1521 return (bi_f32_to_s32_to(b, bi_temp(b->shader), src0, round))->dest[0]; 1522} 1523 1524 1525static inline 1526bi_instr * bi_f32_to_u32_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round) 1527{ 1528 bi_instr *I = rzalloc(b->shader, bi_instr); 1529 I->op = BI_OPCODE_F32_TO_U32; 1530 I->dest[0] = dest0; 1531 I->src[0] = src0; 1532 I->round = round; 1533 bi_builder_insert(&b->cursor, I); 1534 return I; 1535} 1536 1537static inline 1538bi_index bi_f32_to_u32(bi_builder *b, bi_index src0, enum bi_round round) 1539{ 1540 return (bi_f32_to_u32_to(b, bi_temp(b->shader), src0, round))->dest[0]; 1541} 1542 1543 1544static inline 1545bi_instr * bi_fabsneg_f32_to(bi_builder *b, bi_index dest0, bi_index src0) 1546{ 1547 bi_instr *I = rzalloc(b->shader, bi_instr); 1548 I->op = BI_OPCODE_FABSNEG_F32; 1549 I->dest[0] = dest0; 1550 I->src[0] = src0; 1551 bi_builder_insert(&b->cursor, I); 1552 return I; 1553} 1554 1555static inline 1556bi_index bi_fabsneg_f32(bi_builder *b, bi_index src0) 1557{ 1558 return (bi_fabsneg_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 1559} 1560 1561 1562static inline 1563bi_instr * bi_fabsneg_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0) 1564{ 1565 bi_instr *I = rzalloc(b->shader, bi_instr); 1566 I->op = BI_OPCODE_FABSNEG_V2F16; 1567 I->dest[0] = dest0; 1568 I->src[0] = src0; 1569 bi_builder_insert(&b->cursor, I); 1570 return I; 1571} 1572 1573static inline 1574bi_index bi_fabsneg_v2f16(bi_builder *b, bi_index src0) 1575{ 1576 return (bi_fabsneg_v2f16_to(b, bi_temp(b->shader), src0))->dest[0]; 1577} 1578 1579 1580static inline 1581bi_instr * bi_fabsneg_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0) 1582{ 1583 if (bitsize == 32) 1584 return (bi_fabsneg_f32_to(b, dest0, src0)); 1585 else if (bitsize == 16) 1586 return (bi_fabsneg_v2f16_to(b, dest0, src0)); 1587 else 1588 unreachable("Invalid parameters for FABSNEG"); 1589} 1590 1591static inline 1592bi_index bi_fabsneg(bi_builder *b, unsigned bitsize, bi_index src0) 1593{ 1594 if (bitsize == 32) 1595 return (bi_fabsneg_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 1596 else if (bitsize == 16) 1597 return (bi_fabsneg_v2f16_to(b, bi_temp(b->shader), src0))->dest[0]; 1598 else 1599 unreachable("Invalid parameters for FABSNEG"); 1600} 1601 1602static inline 1603bi_instr * bi_fadd_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round) 1604{ 1605 bi_instr *I = rzalloc(b->shader, bi_instr); 1606 I->op = BI_OPCODE_FADD_F32; 1607 I->dest[0] = dest0; 1608 I->src[0] = src0; 1609 I->src[1] = src1; 1610 I->round = round; 1611 bi_builder_insert(&b->cursor, I); 1612 return I; 1613} 1614 1615static inline 1616bi_index bi_fadd_f32(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round) 1617{ 1618 return (bi_fadd_f32_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 1619} 1620 1621 1622static inline 1623bi_instr * bi_fadd_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round) 1624{ 1625 bi_instr *I = rzalloc(b->shader, bi_instr); 1626 I->op = BI_OPCODE_FADD_V2F16; 1627 I->dest[0] = dest0; 1628 I->src[0] = src0; 1629 I->src[1] = src1; 1630 I->round = round; 1631 bi_builder_insert(&b->cursor, I); 1632 return I; 1633} 1634 1635static inline 1636bi_index bi_fadd_v2f16(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round) 1637{ 1638 return (bi_fadd_v2f16_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 1639} 1640 1641 1642static inline 1643bi_instr * bi_fadd_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round) 1644{ 1645 if (bitsize == 32) 1646 return (bi_fadd_f32_to(b, dest0, src0, src1, round)); 1647 else if (bitsize == 16) 1648 return (bi_fadd_v2f16_to(b, dest0, src0, src1, round)); 1649 else 1650 unreachable("Invalid parameters for FADD"); 1651} 1652 1653static inline 1654bi_index bi_fadd(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, enum bi_round round) 1655{ 1656 if (bitsize == 32) 1657 return (bi_fadd_f32_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 1658 else if (bitsize == 16) 1659 return (bi_fadd_v2f16_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 1660 else 1661 unreachable("Invalid parameters for FADD"); 1662} 1663 1664static inline 1665bi_instr * bi_fadd_imm_f32_to(bi_builder *b, bi_index dest0, bi_index src0, uint32_t index) 1666{ 1667 bi_instr *I = rzalloc(b->shader, bi_instr); 1668 I->op = BI_OPCODE_FADD_IMM_F32; 1669 I->dest[0] = dest0; 1670 I->src[0] = src0; 1671 I->index = index; 1672 bi_builder_insert(&b->cursor, I); 1673 return I; 1674} 1675 1676static inline 1677bi_index bi_fadd_imm_f32(bi_builder *b, bi_index src0, uint32_t index) 1678{ 1679 return (bi_fadd_imm_f32_to(b, bi_temp(b->shader), src0, index))->dest[0]; 1680} 1681 1682 1683static inline 1684bi_instr * bi_fadd_imm_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, uint32_t index) 1685{ 1686 bi_instr *I = rzalloc(b->shader, bi_instr); 1687 I->op = BI_OPCODE_FADD_IMM_V2F16; 1688 I->dest[0] = dest0; 1689 I->src[0] = src0; 1690 I->index = index; 1691 bi_builder_insert(&b->cursor, I); 1692 return I; 1693} 1694 1695static inline 1696bi_index bi_fadd_imm_v2f16(bi_builder *b, bi_index src0, uint32_t index) 1697{ 1698 return (bi_fadd_imm_v2f16_to(b, bi_temp(b->shader), src0, index))->dest[0]; 1699} 1700 1701 1702static inline 1703bi_instr * bi_fadd_imm_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, uint32_t index) 1704{ 1705 if (bitsize == 32) 1706 return (bi_fadd_imm_f32_to(b, dest0, src0, index)); 1707 else if (bitsize == 16) 1708 return (bi_fadd_imm_v2f16_to(b, dest0, src0, index)); 1709 else 1710 unreachable("Invalid parameters for FADD_IMM"); 1711} 1712 1713static inline 1714bi_index bi_fadd_imm(bi_builder *b, unsigned bitsize, bi_index src0, uint32_t index) 1715{ 1716 if (bitsize == 32) 1717 return (bi_fadd_imm_f32_to(b, bi_temp(b->shader), src0, index))->dest[0]; 1718 else if (bitsize == 16) 1719 return (bi_fadd_imm_v2f16_to(b, bi_temp(b->shader), src0, index))->dest[0]; 1720 else 1721 unreachable("Invalid parameters for FADD_IMM"); 1722} 1723 1724static inline 1725bi_instr * bi_fadd_lscale_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1) 1726{ 1727 bi_instr *I = rzalloc(b->shader, bi_instr); 1728 I->op = BI_OPCODE_FADD_LSCALE_F32; 1729 I->dest[0] = dest0; 1730 I->src[0] = src0; 1731 I->src[1] = src1; 1732 bi_builder_insert(&b->cursor, I); 1733 return I; 1734} 1735 1736static inline 1737bi_index bi_fadd_lscale_f32(bi_builder *b, bi_index src0, bi_index src1) 1738{ 1739 return (bi_fadd_lscale_f32_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 1740} 1741 1742 1743static inline 1744bi_instr * bi_fadd_rscale_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_round round, enum bi_special special) 1745{ 1746 bi_instr *I = rzalloc(b->shader, bi_instr); 1747 I->op = BI_OPCODE_FADD_RSCALE_F32; 1748 I->dest[0] = dest0; 1749 I->src[0] = src0; 1750 I->src[1] = src1; 1751 I->src[2] = src2; 1752 I->special = special; 1753 I->round = round; 1754 bi_builder_insert(&b->cursor, I); 1755 return I; 1756} 1757 1758static inline 1759bi_index bi_fadd_rscale_f32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_round round, enum bi_special special) 1760{ 1761 return (bi_fadd_rscale_f32_to(b, bi_temp(b->shader), src0, src1, src2, round, special))->dest[0]; 1762} 1763 1764 1765static inline 1766bi_instr * bi_fclamp_f32_to(bi_builder *b, bi_index dest0, bi_index src0) 1767{ 1768 bi_instr *I = rzalloc(b->shader, bi_instr); 1769 I->op = BI_OPCODE_FCLAMP_F32; 1770 I->dest[0] = dest0; 1771 I->src[0] = src0; 1772 bi_builder_insert(&b->cursor, I); 1773 return I; 1774} 1775 1776static inline 1777bi_index bi_fclamp_f32(bi_builder *b, bi_index src0) 1778{ 1779 return (bi_fclamp_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 1780} 1781 1782 1783static inline 1784bi_instr * bi_fclamp_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0) 1785{ 1786 bi_instr *I = rzalloc(b->shader, bi_instr); 1787 I->op = BI_OPCODE_FCLAMP_V2F16; 1788 I->dest[0] = dest0; 1789 I->src[0] = src0; 1790 bi_builder_insert(&b->cursor, I); 1791 return I; 1792} 1793 1794static inline 1795bi_index bi_fclamp_v2f16(bi_builder *b, bi_index src0) 1796{ 1797 return (bi_fclamp_v2f16_to(b, bi_temp(b->shader), src0))->dest[0]; 1798} 1799 1800 1801static inline 1802bi_instr * bi_fclamp_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0) 1803{ 1804 if (bitsize == 32) 1805 return (bi_fclamp_f32_to(b, dest0, src0)); 1806 else if (bitsize == 16) 1807 return (bi_fclamp_v2f16_to(b, dest0, src0)); 1808 else 1809 unreachable("Invalid parameters for FCLAMP"); 1810} 1811 1812static inline 1813bi_index bi_fclamp(bi_builder *b, unsigned bitsize, bi_index src0) 1814{ 1815 if (bitsize == 32) 1816 return (bi_fclamp_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 1817 else if (bitsize == 16) 1818 return (bi_fclamp_v2f16_to(b, bi_temp(b->shader), src0))->dest[0]; 1819 else 1820 unreachable("Invalid parameters for FCLAMP"); 1821} 1822 1823static inline 1824bi_instr * bi_fcmp_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 1825{ 1826 bi_instr *I = rzalloc(b->shader, bi_instr); 1827 I->op = BI_OPCODE_FCMP_F32; 1828 I->dest[0] = dest0; 1829 I->src[0] = src0; 1830 I->src[1] = src1; 1831 I->cmpf = cmpf; 1832 I->result_type = result_type; 1833 bi_builder_insert(&b->cursor, I); 1834 return I; 1835} 1836 1837static inline 1838bi_index bi_fcmp_f32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 1839{ 1840 return (bi_fcmp_f32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 1841} 1842 1843 1844static inline 1845bi_instr * bi_fcmp_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 1846{ 1847 bi_instr *I = rzalloc(b->shader, bi_instr); 1848 I->op = BI_OPCODE_FCMP_V2F16; 1849 I->dest[0] = dest0; 1850 I->src[0] = src0; 1851 I->src[1] = src1; 1852 I->cmpf = cmpf; 1853 I->result_type = result_type; 1854 bi_builder_insert(&b->cursor, I); 1855 return I; 1856} 1857 1858static inline 1859bi_index bi_fcmp_v2f16(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 1860{ 1861 return (bi_fcmp_v2f16_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 1862} 1863 1864 1865static inline 1866bi_instr * bi_fcmp_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 1867{ 1868 if (bitsize == 32 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_NE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE || cmpf == BI_CMPF_GTLT || cmpf == BI_CMPF_TOTAL || cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_NE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE || cmpf == BI_CMPF_GTLT || cmpf == BI_CMPF_TOTAL)) 1869 return (bi_fcmp_f32_to(b, dest0, src0, src1, cmpf, result_type)); 1870 else if (bitsize == 16 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_NE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE || cmpf == BI_CMPF_GTLT || cmpf == BI_CMPF_TOTAL || cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_NE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE || cmpf == BI_CMPF_GTLT || cmpf == BI_CMPF_TOTAL)) 1871 return (bi_fcmp_v2f16_to(b, dest0, src0, src1, cmpf, result_type)); 1872 else 1873 unreachable("Invalid parameters for FCMP"); 1874} 1875 1876static inline 1877bi_index bi_fcmp(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 1878{ 1879 if (bitsize == 32 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_NE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE || cmpf == BI_CMPF_GTLT || cmpf == BI_CMPF_TOTAL || cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_NE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE || cmpf == BI_CMPF_GTLT || cmpf == BI_CMPF_TOTAL)) 1880 return (bi_fcmp_f32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 1881 else if (bitsize == 16 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_NE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE || cmpf == BI_CMPF_GTLT || cmpf == BI_CMPF_TOTAL || cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_NE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE || cmpf == BI_CMPF_GTLT || cmpf == BI_CMPF_TOTAL)) 1882 return (bi_fcmp_v2f16_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 1883 else 1884 unreachable("Invalid parameters for FCMP"); 1885} 1886 1887static inline 1888bi_instr * bi_fcos_table_u6_to(bi_builder *b, bi_index dest0, bi_index src0, bool offset) 1889{ 1890 bi_instr *I = rzalloc(b->shader, bi_instr); 1891 I->op = BI_OPCODE_FCOS_TABLE_U6; 1892 I->dest[0] = dest0; 1893 I->src[0] = src0; 1894 I->offset = offset; 1895 bi_builder_insert(&b->cursor, I); 1896 return I; 1897} 1898 1899static inline 1900bi_index bi_fcos_table_u6(bi_builder *b, bi_index src0, bool offset) 1901{ 1902 return (bi_fcos_table_u6_to(b, bi_temp(b->shader), src0, offset))->dest[0]; 1903} 1904 1905 1906static inline 1907bi_instr * bi_fexp_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1) 1908{ 1909 bi_instr *I = rzalloc(b->shader, bi_instr); 1910 I->op = BI_OPCODE_FEXP_F32; 1911 I->dest[0] = dest0; 1912 I->src[0] = src0; 1913 I->src[1] = src1; 1914 bi_builder_insert(&b->cursor, I); 1915 return I; 1916} 1917 1918static inline 1919bi_index bi_fexp_f32(bi_builder *b, bi_index src0, bi_index src1) 1920{ 1921 return (bi_fexp_f32_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 1922} 1923 1924 1925static inline 1926bi_instr * bi_fexp_table_u4_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_adj adj) 1927{ 1928 bi_instr *I = rzalloc(b->shader, bi_instr); 1929 I->op = BI_OPCODE_FEXP_TABLE_U4; 1930 I->dest[0] = dest0; 1931 I->src[0] = src0; 1932 I->adj = adj; 1933 bi_builder_insert(&b->cursor, I); 1934 return I; 1935} 1936 1937static inline 1938bi_index bi_fexp_table_u4(bi_builder *b, bi_index src0, enum bi_adj adj) 1939{ 1940 return (bi_fexp_table_u4_to(b, bi_temp(b->shader), src0, adj))->dest[0]; 1941} 1942 1943 1944static inline 1945bi_instr * bi_flogd_f32_to(bi_builder *b, bi_index dest0, bi_index src0) 1946{ 1947 bi_instr *I = rzalloc(b->shader, bi_instr); 1948 I->op = BI_OPCODE_FLOGD_F32; 1949 I->dest[0] = dest0; 1950 I->src[0] = src0; 1951 bi_builder_insert(&b->cursor, I); 1952 return I; 1953} 1954 1955static inline 1956bi_index bi_flogd_f32(bi_builder *b, bi_index src0) 1957{ 1958 return (bi_flogd_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 1959} 1960 1961 1962static inline 1963bi_instr * bi_flog_table_f32_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_mode mode, enum bi_precision precision) 1964{ 1965 bi_instr *I = rzalloc(b->shader, bi_instr); 1966 I->op = BI_OPCODE_FLOG_TABLE_F32; 1967 I->dest[0] = dest0; 1968 I->src[0] = src0; 1969 I->mode = mode; 1970 I->precision = precision; 1971 bi_builder_insert(&b->cursor, I); 1972 return I; 1973} 1974 1975static inline 1976bi_index bi_flog_table_f32(bi_builder *b, bi_index src0, enum bi_mode mode, enum bi_precision precision) 1977{ 1978 return (bi_flog_table_f32_to(b, bi_temp(b->shader), src0, mode, precision))->dest[0]; 1979} 1980 1981 1982static inline 1983bi_instr * bi_flshift_double_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bool bytes2) 1984{ 1985 bi_instr *I = rzalloc(b->shader, bi_instr); 1986 I->op = BI_OPCODE_FLSHIFT_DOUBLE_I32; 1987 I->dest[0] = dest0; 1988 I->src[0] = src0; 1989 I->src[1] = src1; 1990 I->src[2] = src2; 1991 I->bytes2 = bytes2; 1992 bi_builder_insert(&b->cursor, I); 1993 return I; 1994} 1995 1996static inline 1997bi_index bi_flshift_double_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bool bytes2) 1998{ 1999 return (bi_flshift_double_i32_to(b, bi_temp(b->shader), src0, src1, src2, bytes2))->dest[0]; 2000} 2001 2002 2003static inline 2004bi_instr * bi_fma_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_round round) 2005{ 2006 bi_instr *I = rzalloc(b->shader, bi_instr); 2007 I->op = BI_OPCODE_FMA_F32; 2008 I->dest[0] = dest0; 2009 I->src[0] = src0; 2010 I->src[1] = src1; 2011 I->src[2] = src2; 2012 I->round = round; 2013 bi_builder_insert(&b->cursor, I); 2014 return I; 2015} 2016 2017static inline 2018bi_index bi_fma_f32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_round round) 2019{ 2020 return (bi_fma_f32_to(b, bi_temp(b->shader), src0, src1, src2, round))->dest[0]; 2021} 2022 2023 2024static inline 2025bi_instr * bi_fma_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_round round) 2026{ 2027 bi_instr *I = rzalloc(b->shader, bi_instr); 2028 I->op = BI_OPCODE_FMA_V2F16; 2029 I->dest[0] = dest0; 2030 I->src[0] = src0; 2031 I->src[1] = src1; 2032 I->src[2] = src2; 2033 I->round = round; 2034 bi_builder_insert(&b->cursor, I); 2035 return I; 2036} 2037 2038static inline 2039bi_index bi_fma_v2f16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_round round) 2040{ 2041 return (bi_fma_v2f16_to(b, bi_temp(b->shader), src0, src1, src2, round))->dest[0]; 2042} 2043 2044 2045static inline 2046bi_instr * bi_fma_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_round round) 2047{ 2048 if (bitsize == 32) 2049 return (bi_fma_f32_to(b, dest0, src0, src1, src2, round)); 2050 else if (bitsize == 16) 2051 return (bi_fma_v2f16_to(b, dest0, src0, src1, src2, round)); 2052 else 2053 unreachable("Invalid parameters for FMA"); 2054} 2055 2056static inline 2057bi_index bi_fma(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2, enum bi_round round) 2058{ 2059 if (bitsize == 32) 2060 return (bi_fma_f32_to(b, bi_temp(b->shader), src0, src1, src2, round))->dest[0]; 2061 else if (bitsize == 16) 2062 return (bi_fma_v2f16_to(b, bi_temp(b->shader), src0, src1, src2, round))->dest[0]; 2063 else 2064 unreachable("Invalid parameters for FMA"); 2065} 2066 2067static inline 2068bi_instr * bi_fmax_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1) 2069{ 2070 bi_instr *I = rzalloc(b->shader, bi_instr); 2071 I->op = BI_OPCODE_FMAX_F32; 2072 I->dest[0] = dest0; 2073 I->src[0] = src0; 2074 I->src[1] = src1; 2075 bi_builder_insert(&b->cursor, I); 2076 return I; 2077} 2078 2079static inline 2080bi_index bi_fmax_f32(bi_builder *b, bi_index src0, bi_index src1) 2081{ 2082 return (bi_fmax_f32_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 2083} 2084 2085 2086static inline 2087bi_instr * bi_fmax_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1) 2088{ 2089 bi_instr *I = rzalloc(b->shader, bi_instr); 2090 I->op = BI_OPCODE_FMAX_V2F16; 2091 I->dest[0] = dest0; 2092 I->src[0] = src0; 2093 I->src[1] = src1; 2094 bi_builder_insert(&b->cursor, I); 2095 return I; 2096} 2097 2098static inline 2099bi_index bi_fmax_v2f16(bi_builder *b, bi_index src0, bi_index src1) 2100{ 2101 return (bi_fmax_v2f16_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 2102} 2103 2104 2105static inline 2106bi_instr * bi_fmax_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1) 2107{ 2108 if (bitsize == 32) 2109 return (bi_fmax_f32_to(b, dest0, src0, src1)); 2110 else if (bitsize == 16) 2111 return (bi_fmax_v2f16_to(b, dest0, src0, src1)); 2112 else 2113 unreachable("Invalid parameters for FMAX"); 2114} 2115 2116static inline 2117bi_index bi_fmax(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1) 2118{ 2119 if (bitsize == 32) 2120 return (bi_fmax_f32_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 2121 else if (bitsize == 16) 2122 return (bi_fmax_v2f16_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 2123 else 2124 unreachable("Invalid parameters for FMAX"); 2125} 2126 2127static inline 2128bi_instr * bi_fma_rscale_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_round round, enum bi_special special) 2129{ 2130 bi_instr *I = rzalloc(b->shader, bi_instr); 2131 I->op = BI_OPCODE_FMA_RSCALE_F32; 2132 I->dest[0] = dest0; 2133 I->src[0] = src0; 2134 I->src[1] = src1; 2135 I->src[2] = src2; 2136 I->src[3] = src3; 2137 I->round = round; 2138 I->special = special; 2139 bi_builder_insert(&b->cursor, I); 2140 return I; 2141} 2142 2143static inline 2144bi_index bi_fma_rscale_f32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_round round, enum bi_special special) 2145{ 2146 return (bi_fma_rscale_f32_to(b, bi_temp(b->shader), src0, src1, src2, src3, round, special))->dest[0]; 2147} 2148 2149 2150static inline 2151bi_instr * bi_fma_rscale_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_round round, enum bi_special special) 2152{ 2153 bi_instr *I = rzalloc(b->shader, bi_instr); 2154 I->op = BI_OPCODE_FMA_RSCALE_V2F16; 2155 I->dest[0] = dest0; 2156 I->src[0] = src0; 2157 I->src[1] = src1; 2158 I->src[2] = src2; 2159 I->src[3] = src3; 2160 I->round = round; 2161 I->special = special; 2162 bi_builder_insert(&b->cursor, I); 2163 return I; 2164} 2165 2166static inline 2167bi_index bi_fma_rscale_v2f16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_round round, enum bi_special special) 2168{ 2169 return (bi_fma_rscale_v2f16_to(b, bi_temp(b->shader), src0, src1, src2, src3, round, special))->dest[0]; 2170} 2171 2172 2173static inline 2174bi_instr * bi_fma_rscale_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_round round, enum bi_special special) 2175{ 2176 if (bitsize == 32) 2177 return (bi_fma_rscale_f32_to(b, dest0, src0, src1, src2, src3, round, special)); 2178 else if (bitsize == 16) 2179 return (bi_fma_rscale_v2f16_to(b, dest0, src0, src1, src2, src3, round, special)); 2180 else 2181 unreachable("Invalid parameters for FMA_RSCALE"); 2182} 2183 2184static inline 2185bi_index bi_fma_rscale(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_round round, enum bi_special special) 2186{ 2187 if (bitsize == 32) 2188 return (bi_fma_rscale_f32_to(b, bi_temp(b->shader), src0, src1, src2, src3, round, special))->dest[0]; 2189 else if (bitsize == 16) 2190 return (bi_fma_rscale_v2f16_to(b, bi_temp(b->shader), src0, src1, src2, src3, round, special))->dest[0]; 2191 else 2192 unreachable("Invalid parameters for FMA_RSCALE"); 2193} 2194 2195static inline 2196bi_instr * bi_fmin_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1) 2197{ 2198 bi_instr *I = rzalloc(b->shader, bi_instr); 2199 I->op = BI_OPCODE_FMIN_F32; 2200 I->dest[0] = dest0; 2201 I->src[0] = src0; 2202 I->src[1] = src1; 2203 bi_builder_insert(&b->cursor, I); 2204 return I; 2205} 2206 2207static inline 2208bi_index bi_fmin_f32(bi_builder *b, bi_index src0, bi_index src1) 2209{ 2210 return (bi_fmin_f32_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 2211} 2212 2213 2214static inline 2215bi_instr * bi_fmin_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1) 2216{ 2217 bi_instr *I = rzalloc(b->shader, bi_instr); 2218 I->op = BI_OPCODE_FMIN_V2F16; 2219 I->dest[0] = dest0; 2220 I->src[0] = src0; 2221 I->src[1] = src1; 2222 bi_builder_insert(&b->cursor, I); 2223 return I; 2224} 2225 2226static inline 2227bi_index bi_fmin_v2f16(bi_builder *b, bi_index src0, bi_index src1) 2228{ 2229 return (bi_fmin_v2f16_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 2230} 2231 2232 2233static inline 2234bi_instr * bi_fmin_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1) 2235{ 2236 if (bitsize == 32) 2237 return (bi_fmin_f32_to(b, dest0, src0, src1)); 2238 else if (bitsize == 16) 2239 return (bi_fmin_v2f16_to(b, dest0, src0, src1)); 2240 else 2241 unreachable("Invalid parameters for FMIN"); 2242} 2243 2244static inline 2245bi_index bi_fmin(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1) 2246{ 2247 if (bitsize == 32) 2248 return (bi_fmin_f32_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 2249 else if (bitsize == 16) 2250 return (bi_fmin_v2f16_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 2251 else 2252 unreachable("Invalid parameters for FMIN"); 2253} 2254 2255static inline 2256bi_instr * bi_fmul_cslice_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1) 2257{ 2258 bi_instr *I = rzalloc(b->shader, bi_instr); 2259 I->op = BI_OPCODE_FMUL_CSLICE; 2260 I->dest[0] = dest0; 2261 I->src[0] = src0; 2262 I->src[1] = src1; 2263 bi_builder_insert(&b->cursor, I); 2264 return I; 2265} 2266 2267static inline 2268bi_index bi_fmul_cslice(bi_builder *b, bi_index src0, bi_index src1) 2269{ 2270 return (bi_fmul_cslice_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 2271} 2272 2273 2274static inline 2275bi_instr * bi_fmul_slice_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1) 2276{ 2277 bi_instr *I = rzalloc(b->shader, bi_instr); 2278 I->op = BI_OPCODE_FMUL_SLICE_F32; 2279 I->dest[0] = dest0; 2280 I->src[0] = src0; 2281 I->src[1] = src1; 2282 bi_builder_insert(&b->cursor, I); 2283 return I; 2284} 2285 2286static inline 2287bi_index bi_fmul_slice_f32(bi_builder *b, bi_index src0, bi_index src1) 2288{ 2289 return (bi_fmul_slice_f32_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 2290} 2291 2292 2293static inline 2294bi_instr * bi_fpclass_f16_to(bi_builder *b, bi_index dest0, bi_index src0) 2295{ 2296 bi_instr *I = rzalloc(b->shader, bi_instr); 2297 I->op = BI_OPCODE_FPCLASS_F16; 2298 I->dest[0] = dest0; 2299 I->src[0] = src0; 2300 bi_builder_insert(&b->cursor, I); 2301 return I; 2302} 2303 2304static inline 2305bi_index bi_fpclass_f16(bi_builder *b, bi_index src0) 2306{ 2307 return (bi_fpclass_f16_to(b, bi_temp(b->shader), src0))->dest[0]; 2308} 2309 2310 2311static inline 2312bi_instr * bi_fpclass_f32_to(bi_builder *b, bi_index dest0, bi_index src0) 2313{ 2314 bi_instr *I = rzalloc(b->shader, bi_instr); 2315 I->op = BI_OPCODE_FPCLASS_F32; 2316 I->dest[0] = dest0; 2317 I->src[0] = src0; 2318 bi_builder_insert(&b->cursor, I); 2319 return I; 2320} 2321 2322static inline 2323bi_index bi_fpclass_f32(bi_builder *b, bi_index src0) 2324{ 2325 return (bi_fpclass_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 2326} 2327 2328 2329static inline 2330bi_instr * bi_fpclass_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0) 2331{ 2332 if (bitsize == 16) 2333 return (bi_fpclass_f16_to(b, dest0, src0)); 2334 else if (bitsize == 32) 2335 return (bi_fpclass_f32_to(b, dest0, src0)); 2336 else 2337 unreachable("Invalid parameters for FPCLASS"); 2338} 2339 2340static inline 2341bi_index bi_fpclass(bi_builder *b, unsigned bitsize, bi_index src0) 2342{ 2343 if (bitsize == 16) 2344 return (bi_fpclass_f16_to(b, bi_temp(b->shader), src0))->dest[0]; 2345 else if (bitsize == 32) 2346 return (bi_fpclass_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 2347 else 2348 unreachable("Invalid parameters for FPCLASS"); 2349} 2350 2351static inline 2352bi_instr * bi_fpow_sc_apply_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1) 2353{ 2354 bi_instr *I = rzalloc(b->shader, bi_instr); 2355 I->op = BI_OPCODE_FPOW_SC_APPLY; 2356 I->dest[0] = dest0; 2357 I->src[0] = src0; 2358 I->src[1] = src1; 2359 bi_builder_insert(&b->cursor, I); 2360 return I; 2361} 2362 2363static inline 2364bi_index bi_fpow_sc_apply(bi_builder *b, bi_index src0, bi_index src1) 2365{ 2366 return (bi_fpow_sc_apply_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 2367} 2368 2369 2370static inline 2371bi_instr * bi_fpow_sc_det_f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_func func) 2372{ 2373 bi_instr *I = rzalloc(b->shader, bi_instr); 2374 I->op = BI_OPCODE_FPOW_SC_DET_F16; 2375 I->dest[0] = dest0; 2376 I->src[0] = src0; 2377 I->src[1] = src1; 2378 I->func = func; 2379 bi_builder_insert(&b->cursor, I); 2380 return I; 2381} 2382 2383static inline 2384bi_index bi_fpow_sc_det_f16(bi_builder *b, bi_index src0, bi_index src1, enum bi_func func) 2385{ 2386 return (bi_fpow_sc_det_f16_to(b, bi_temp(b->shader), src0, src1, func))->dest[0]; 2387} 2388 2389 2390static inline 2391bi_instr * bi_fpow_sc_det_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_func func) 2392{ 2393 bi_instr *I = rzalloc(b->shader, bi_instr); 2394 I->op = BI_OPCODE_FPOW_SC_DET_F32; 2395 I->dest[0] = dest0; 2396 I->src[0] = src0; 2397 I->src[1] = src1; 2398 I->func = func; 2399 bi_builder_insert(&b->cursor, I); 2400 return I; 2401} 2402 2403static inline 2404bi_index bi_fpow_sc_det_f32(bi_builder *b, bi_index src0, bi_index src1, enum bi_func func) 2405{ 2406 return (bi_fpow_sc_det_f32_to(b, bi_temp(b->shader), src0, src1, func))->dest[0]; 2407} 2408 2409 2410static inline 2411bi_instr * bi_fpow_sc_det_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, enum bi_func func) 2412{ 2413 if (bitsize == 16) 2414 return (bi_fpow_sc_det_f16_to(b, dest0, src0, src1, func)); 2415 else if (bitsize == 32) 2416 return (bi_fpow_sc_det_f32_to(b, dest0, src0, src1, func)); 2417 else 2418 unreachable("Invalid parameters for FPOW_SC_DET"); 2419} 2420 2421static inline 2422bi_index bi_fpow_sc_det(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, enum bi_func func) 2423{ 2424 if (bitsize == 16) 2425 return (bi_fpow_sc_det_f16_to(b, bi_temp(b->shader), src0, src1, func))->dest[0]; 2426 else if (bitsize == 32) 2427 return (bi_fpow_sc_det_f32_to(b, bi_temp(b->shader), src0, src1, func))->dest[0]; 2428 else 2429 unreachable("Invalid parameters for FPOW_SC_DET"); 2430} 2431 2432static inline 2433bi_instr * bi_frcp_f16_to(bi_builder *b, bi_index dest0, bi_index src0) 2434{ 2435 bi_instr *I = rzalloc(b->shader, bi_instr); 2436 I->op = BI_OPCODE_FRCP_F16; 2437 I->dest[0] = dest0; 2438 I->src[0] = src0; 2439 bi_builder_insert(&b->cursor, I); 2440 return I; 2441} 2442 2443static inline 2444bi_index bi_frcp_f16(bi_builder *b, bi_index src0) 2445{ 2446 return (bi_frcp_f16_to(b, bi_temp(b->shader), src0))->dest[0]; 2447} 2448 2449 2450static inline 2451bi_instr * bi_frcp_f32_to(bi_builder *b, bi_index dest0, bi_index src0) 2452{ 2453 bi_instr *I = rzalloc(b->shader, bi_instr); 2454 I->op = BI_OPCODE_FRCP_F32; 2455 I->dest[0] = dest0; 2456 I->src[0] = src0; 2457 bi_builder_insert(&b->cursor, I); 2458 return I; 2459} 2460 2461static inline 2462bi_index bi_frcp_f32(bi_builder *b, bi_index src0) 2463{ 2464 return (bi_frcp_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 2465} 2466 2467 2468static inline 2469bi_instr * bi_frcp_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0) 2470{ 2471 if (bitsize == 16) 2472 return (bi_frcp_f16_to(b, dest0, src0)); 2473 else if (bitsize == 32) 2474 return (bi_frcp_f32_to(b, dest0, src0)); 2475 else 2476 unreachable("Invalid parameters for FRCP"); 2477} 2478 2479static inline 2480bi_index bi_frcp(bi_builder *b, unsigned bitsize, bi_index src0) 2481{ 2482 if (bitsize == 16) 2483 return (bi_frcp_f16_to(b, bi_temp(b->shader), src0))->dest[0]; 2484 else if (bitsize == 32) 2485 return (bi_frcp_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 2486 else 2487 unreachable("Invalid parameters for FRCP"); 2488} 2489 2490static inline 2491bi_instr * bi_frcp_approx_f32_to(bi_builder *b, bi_index dest0, bi_index src0) 2492{ 2493 bi_instr *I = rzalloc(b->shader, bi_instr); 2494 I->op = BI_OPCODE_FRCP_APPROX_F32; 2495 I->dest[0] = dest0; 2496 I->src[0] = src0; 2497 bi_builder_insert(&b->cursor, I); 2498 return I; 2499} 2500 2501static inline 2502bi_index bi_frcp_approx_f32(bi_builder *b, bi_index src0) 2503{ 2504 return (bi_frcp_approx_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 2505} 2506 2507 2508static inline 2509bi_instr * bi_frexpe_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bool log, bool sqrt) 2510{ 2511 bi_instr *I = rzalloc(b->shader, bi_instr); 2512 I->op = BI_OPCODE_FREXPE_F32; 2513 I->dest[0] = dest0; 2514 I->src[0] = src0; 2515 I->sqrt = sqrt; 2516 I->log = log; 2517 bi_builder_insert(&b->cursor, I); 2518 return I; 2519} 2520 2521static inline 2522bi_index bi_frexpe_f32(bi_builder *b, bi_index src0, bool log, bool sqrt) 2523{ 2524 return (bi_frexpe_f32_to(b, bi_temp(b->shader), src0, log, sqrt))->dest[0]; 2525} 2526 2527 2528static inline 2529bi_instr * bi_frexpe_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bool log, bool sqrt) 2530{ 2531 bi_instr *I = rzalloc(b->shader, bi_instr); 2532 I->op = BI_OPCODE_FREXPE_V2F16; 2533 I->dest[0] = dest0; 2534 I->src[0] = src0; 2535 I->sqrt = sqrt; 2536 I->log = log; 2537 bi_builder_insert(&b->cursor, I); 2538 return I; 2539} 2540 2541static inline 2542bi_index bi_frexpe_v2f16(bi_builder *b, bi_index src0, bool log, bool sqrt) 2543{ 2544 return (bi_frexpe_v2f16_to(b, bi_temp(b->shader), src0, log, sqrt))->dest[0]; 2545} 2546 2547 2548static inline 2549bi_instr * bi_frexpe_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bool log, bool sqrt) 2550{ 2551 if (bitsize == 32) 2552 return (bi_frexpe_f32_to(b, dest0, src0, log, sqrt)); 2553 else if (bitsize == 16) 2554 return (bi_frexpe_v2f16_to(b, dest0, src0, log, sqrt)); 2555 else 2556 unreachable("Invalid parameters for FREXPE"); 2557} 2558 2559static inline 2560bi_index bi_frexpe(bi_builder *b, unsigned bitsize, bi_index src0, bool log, bool sqrt) 2561{ 2562 if (bitsize == 32) 2563 return (bi_frexpe_f32_to(b, bi_temp(b->shader), src0, log, sqrt))->dest[0]; 2564 else if (bitsize == 16) 2565 return (bi_frexpe_v2f16_to(b, bi_temp(b->shader), src0, log, sqrt))->dest[0]; 2566 else 2567 unreachable("Invalid parameters for FREXPE"); 2568} 2569 2570static inline 2571bi_instr * bi_frexpm_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bool log, bool sqrt) 2572{ 2573 bi_instr *I = rzalloc(b->shader, bi_instr); 2574 I->op = BI_OPCODE_FREXPM_F32; 2575 I->dest[0] = dest0; 2576 I->src[0] = src0; 2577 I->sqrt = sqrt; 2578 I->log = log; 2579 bi_builder_insert(&b->cursor, I); 2580 return I; 2581} 2582 2583static inline 2584bi_index bi_frexpm_f32(bi_builder *b, bi_index src0, bool log, bool sqrt) 2585{ 2586 return (bi_frexpm_f32_to(b, bi_temp(b->shader), src0, log, sqrt))->dest[0]; 2587} 2588 2589 2590static inline 2591bi_instr * bi_frexpm_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bool log, bool sqrt) 2592{ 2593 bi_instr *I = rzalloc(b->shader, bi_instr); 2594 I->op = BI_OPCODE_FREXPM_V2F16; 2595 I->dest[0] = dest0; 2596 I->src[0] = src0; 2597 I->sqrt = sqrt; 2598 I->log = log; 2599 bi_builder_insert(&b->cursor, I); 2600 return I; 2601} 2602 2603static inline 2604bi_index bi_frexpm_v2f16(bi_builder *b, bi_index src0, bool log, bool sqrt) 2605{ 2606 return (bi_frexpm_v2f16_to(b, bi_temp(b->shader), src0, log, sqrt))->dest[0]; 2607} 2608 2609 2610static inline 2611bi_instr * bi_frexpm_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bool log, bool sqrt) 2612{ 2613 if (bitsize == 32) 2614 return (bi_frexpm_f32_to(b, dest0, src0, log, sqrt)); 2615 else if (bitsize == 16) 2616 return (bi_frexpm_v2f16_to(b, dest0, src0, log, sqrt)); 2617 else 2618 unreachable("Invalid parameters for FREXPM"); 2619} 2620 2621static inline 2622bi_index bi_frexpm(bi_builder *b, unsigned bitsize, bi_index src0, bool log, bool sqrt) 2623{ 2624 if (bitsize == 32) 2625 return (bi_frexpm_f32_to(b, bi_temp(b->shader), src0, log, sqrt))->dest[0]; 2626 else if (bitsize == 16) 2627 return (bi_frexpm_v2f16_to(b, bi_temp(b->shader), src0, log, sqrt))->dest[0]; 2628 else 2629 unreachable("Invalid parameters for FREXPM"); 2630} 2631 2632static inline 2633bi_instr * bi_fround_f32_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round) 2634{ 2635 bi_instr *I = rzalloc(b->shader, bi_instr); 2636 I->op = BI_OPCODE_FROUND_F32; 2637 I->dest[0] = dest0; 2638 I->src[0] = src0; 2639 I->round = round; 2640 bi_builder_insert(&b->cursor, I); 2641 return I; 2642} 2643 2644static inline 2645bi_index bi_fround_f32(bi_builder *b, bi_index src0, enum bi_round round) 2646{ 2647 return (bi_fround_f32_to(b, bi_temp(b->shader), src0, round))->dest[0]; 2648} 2649 2650 2651static inline 2652bi_instr * bi_fround_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round) 2653{ 2654 bi_instr *I = rzalloc(b->shader, bi_instr); 2655 I->op = BI_OPCODE_FROUND_V2F16; 2656 I->dest[0] = dest0; 2657 I->src[0] = src0; 2658 I->round = round; 2659 bi_builder_insert(&b->cursor, I); 2660 return I; 2661} 2662 2663static inline 2664bi_index bi_fround_v2f16(bi_builder *b, bi_index src0, enum bi_round round) 2665{ 2666 return (bi_fround_v2f16_to(b, bi_temp(b->shader), src0, round))->dest[0]; 2667} 2668 2669 2670static inline 2671bi_instr * bi_fround_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, enum bi_round round) 2672{ 2673 if (bitsize == 32) 2674 return (bi_fround_f32_to(b, dest0, src0, round)); 2675 else if (bitsize == 16) 2676 return (bi_fround_v2f16_to(b, dest0, src0, round)); 2677 else 2678 unreachable("Invalid parameters for FROUND"); 2679} 2680 2681static inline 2682bi_index bi_fround(bi_builder *b, unsigned bitsize, bi_index src0, enum bi_round round) 2683{ 2684 if (bitsize == 32) 2685 return (bi_fround_f32_to(b, bi_temp(b->shader), src0, round))->dest[0]; 2686 else if (bitsize == 16) 2687 return (bi_fround_v2f16_to(b, bi_temp(b->shader), src0, round))->dest[0]; 2688 else 2689 unreachable("Invalid parameters for FROUND"); 2690} 2691 2692static inline 2693bi_instr * bi_frscale_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1) 2694{ 2695 bi_instr *I = rzalloc(b->shader, bi_instr); 2696 I->op = BI_OPCODE_FRSCALE_F32; 2697 I->dest[0] = dest0; 2698 I->src[0] = src0; 2699 I->src[1] = src1; 2700 bi_builder_insert(&b->cursor, I); 2701 return I; 2702} 2703 2704static inline 2705bi_index bi_frscale_f32(bi_builder *b, bi_index src0, bi_index src1) 2706{ 2707 return (bi_frscale_f32_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 2708} 2709 2710 2711static inline 2712bi_instr * bi_frscale_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1) 2713{ 2714 bi_instr *I = rzalloc(b->shader, bi_instr); 2715 I->op = BI_OPCODE_FRSCALE_V2F16; 2716 I->dest[0] = dest0; 2717 I->src[0] = src0; 2718 I->src[1] = src1; 2719 bi_builder_insert(&b->cursor, I); 2720 return I; 2721} 2722 2723static inline 2724bi_index bi_frscale_v2f16(bi_builder *b, bi_index src0, bi_index src1) 2725{ 2726 return (bi_frscale_v2f16_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 2727} 2728 2729 2730static inline 2731bi_instr * bi_frscale_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1) 2732{ 2733 if (bitsize == 32) 2734 return (bi_frscale_f32_to(b, dest0, src0, src1)); 2735 else if (bitsize == 16) 2736 return (bi_frscale_v2f16_to(b, dest0, src0, src1)); 2737 else 2738 unreachable("Invalid parameters for FRSCALE"); 2739} 2740 2741static inline 2742bi_index bi_frscale(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1) 2743{ 2744 if (bitsize == 32) 2745 return (bi_frscale_f32_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 2746 else if (bitsize == 16) 2747 return (bi_frscale_v2f16_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 2748 else 2749 unreachable("Invalid parameters for FRSCALE"); 2750} 2751 2752static inline 2753bi_instr * bi_frshift_double_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bool bytes2) 2754{ 2755 bi_instr *I = rzalloc(b->shader, bi_instr); 2756 I->op = BI_OPCODE_FRSHIFT_DOUBLE_I32; 2757 I->dest[0] = dest0; 2758 I->src[0] = src0; 2759 I->src[1] = src1; 2760 I->src[2] = src2; 2761 I->bytes2 = bytes2; 2762 bi_builder_insert(&b->cursor, I); 2763 return I; 2764} 2765 2766static inline 2767bi_index bi_frshift_double_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bool bytes2) 2768{ 2769 return (bi_frshift_double_i32_to(b, bi_temp(b->shader), src0, src1, src2, bytes2))->dest[0]; 2770} 2771 2772 2773static inline 2774bi_instr * bi_frsq_f16_to(bi_builder *b, bi_index dest0, bi_index src0) 2775{ 2776 bi_instr *I = rzalloc(b->shader, bi_instr); 2777 I->op = BI_OPCODE_FRSQ_F16; 2778 I->dest[0] = dest0; 2779 I->src[0] = src0; 2780 bi_builder_insert(&b->cursor, I); 2781 return I; 2782} 2783 2784static inline 2785bi_index bi_frsq_f16(bi_builder *b, bi_index src0) 2786{ 2787 return (bi_frsq_f16_to(b, bi_temp(b->shader), src0))->dest[0]; 2788} 2789 2790 2791static inline 2792bi_instr * bi_frsq_f32_to(bi_builder *b, bi_index dest0, bi_index src0) 2793{ 2794 bi_instr *I = rzalloc(b->shader, bi_instr); 2795 I->op = BI_OPCODE_FRSQ_F32; 2796 I->dest[0] = dest0; 2797 I->src[0] = src0; 2798 bi_builder_insert(&b->cursor, I); 2799 return I; 2800} 2801 2802static inline 2803bi_index bi_frsq_f32(bi_builder *b, bi_index src0) 2804{ 2805 return (bi_frsq_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 2806} 2807 2808 2809static inline 2810bi_instr * bi_frsq_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0) 2811{ 2812 if (bitsize == 16) 2813 return (bi_frsq_f16_to(b, dest0, src0)); 2814 else if (bitsize == 32) 2815 return (bi_frsq_f32_to(b, dest0, src0)); 2816 else 2817 unreachable("Invalid parameters for FRSQ"); 2818} 2819 2820static inline 2821bi_index bi_frsq(bi_builder *b, unsigned bitsize, bi_index src0) 2822{ 2823 if (bitsize == 16) 2824 return (bi_frsq_f16_to(b, bi_temp(b->shader), src0))->dest[0]; 2825 else if (bitsize == 32) 2826 return (bi_frsq_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 2827 else 2828 unreachable("Invalid parameters for FRSQ"); 2829} 2830 2831static inline 2832bi_instr * bi_frsq_approx_f32_to(bi_builder *b, bi_index dest0, bi_index src0) 2833{ 2834 bi_instr *I = rzalloc(b->shader, bi_instr); 2835 I->op = BI_OPCODE_FRSQ_APPROX_F32; 2836 I->dest[0] = dest0; 2837 I->src[0] = src0; 2838 bi_builder_insert(&b->cursor, I); 2839 return I; 2840} 2841 2842static inline 2843bi_index bi_frsq_approx_f32(bi_builder *b, bi_index src0) 2844{ 2845 return (bi_frsq_approx_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 2846} 2847 2848 2849static inline 2850bi_instr * bi_fsincos_offset_u6_to(bi_builder *b, bi_index dest0, bi_index src0, bool scale) 2851{ 2852 bi_instr *I = rzalloc(b->shader, bi_instr); 2853 I->op = BI_OPCODE_FSINCOS_OFFSET_U6; 2854 I->dest[0] = dest0; 2855 I->src[0] = src0; 2856 I->scale = scale; 2857 bi_builder_insert(&b->cursor, I); 2858 return I; 2859} 2860 2861static inline 2862bi_index bi_fsincos_offset_u6(bi_builder *b, bi_index src0, bool scale) 2863{ 2864 return (bi_fsincos_offset_u6_to(b, bi_temp(b->shader), src0, scale))->dest[0]; 2865} 2866 2867 2868static inline 2869bi_instr * bi_fsin_table_u6_to(bi_builder *b, bi_index dest0, bi_index src0, bool offset) 2870{ 2871 bi_instr *I = rzalloc(b->shader, bi_instr); 2872 I->op = BI_OPCODE_FSIN_TABLE_U6; 2873 I->dest[0] = dest0; 2874 I->src[0] = src0; 2875 I->offset = offset; 2876 bi_builder_insert(&b->cursor, I); 2877 return I; 2878} 2879 2880static inline 2881bi_index bi_fsin_table_u6(bi_builder *b, bi_index src0, bool offset) 2882{ 2883 return (bi_fsin_table_u6_to(b, bi_temp(b->shader), src0, offset))->dest[0]; 2884} 2885 2886 2887static inline 2888bi_instr * bi_hadd_s32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round) 2889{ 2890 bi_instr *I = rzalloc(b->shader, bi_instr); 2891 I->op = BI_OPCODE_HADD_S32; 2892 I->dest[0] = dest0; 2893 I->src[0] = src0; 2894 I->src[1] = src1; 2895 I->round = round; 2896 bi_builder_insert(&b->cursor, I); 2897 return I; 2898} 2899 2900static inline 2901bi_index bi_hadd_s32(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round) 2902{ 2903 return (bi_hadd_s32_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 2904} 2905 2906 2907static inline 2908bi_instr * bi_hadd_u32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round) 2909{ 2910 bi_instr *I = rzalloc(b->shader, bi_instr); 2911 I->op = BI_OPCODE_HADD_U32; 2912 I->dest[0] = dest0; 2913 I->src[0] = src0; 2914 I->src[1] = src1; 2915 I->round = round; 2916 bi_builder_insert(&b->cursor, I); 2917 return I; 2918} 2919 2920static inline 2921bi_index bi_hadd_u32(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round) 2922{ 2923 return (bi_hadd_u32_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 2924} 2925 2926 2927static inline 2928bi_instr * bi_hadd_v2s16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round) 2929{ 2930 bi_instr *I = rzalloc(b->shader, bi_instr); 2931 I->op = BI_OPCODE_HADD_V2S16; 2932 I->dest[0] = dest0; 2933 I->src[0] = src0; 2934 I->src[1] = src1; 2935 I->round = round; 2936 bi_builder_insert(&b->cursor, I); 2937 return I; 2938} 2939 2940static inline 2941bi_index bi_hadd_v2s16(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round) 2942{ 2943 return (bi_hadd_v2s16_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 2944} 2945 2946 2947static inline 2948bi_instr * bi_hadd_v2u16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round) 2949{ 2950 bi_instr *I = rzalloc(b->shader, bi_instr); 2951 I->op = BI_OPCODE_HADD_V2U16; 2952 I->dest[0] = dest0; 2953 I->src[0] = src0; 2954 I->src[1] = src1; 2955 I->round = round; 2956 bi_builder_insert(&b->cursor, I); 2957 return I; 2958} 2959 2960static inline 2961bi_index bi_hadd_v2u16(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round) 2962{ 2963 return (bi_hadd_v2u16_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 2964} 2965 2966 2967static inline 2968bi_instr * bi_hadd_v4s8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round) 2969{ 2970 bi_instr *I = rzalloc(b->shader, bi_instr); 2971 I->op = BI_OPCODE_HADD_V4S8; 2972 I->dest[0] = dest0; 2973 I->src[0] = src0; 2974 I->src[1] = src1; 2975 I->round = round; 2976 bi_builder_insert(&b->cursor, I); 2977 return I; 2978} 2979 2980static inline 2981bi_index bi_hadd_v4s8(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round) 2982{ 2983 return (bi_hadd_v4s8_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 2984} 2985 2986 2987static inline 2988bi_instr * bi_hadd_v4u8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round) 2989{ 2990 bi_instr *I = rzalloc(b->shader, bi_instr); 2991 I->op = BI_OPCODE_HADD_V4U8; 2992 I->dest[0] = dest0; 2993 I->src[0] = src0; 2994 I->src[1] = src1; 2995 I->round = round; 2996 bi_builder_insert(&b->cursor, I); 2997 return I; 2998} 2999 3000static inline 3001bi_index bi_hadd_v4u8(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round) 3002{ 3003 return (bi_hadd_v4u8_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 3004} 3005 3006 3007static inline 3008bi_instr * bi_hadd_to(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round) 3009{ 3010 if ((type == nir_type_int) && bitsize == 32) 3011 return (bi_hadd_s32_to(b, dest0, src0, src1, round)); 3012 else if ((type == nir_type_uint) && bitsize == 32) 3013 return (bi_hadd_u32_to(b, dest0, src0, src1, round)); 3014 else if ((type == nir_type_int) && bitsize == 16) 3015 return (bi_hadd_v2s16_to(b, dest0, src0, src1, round)); 3016 else if ((type == nir_type_uint) && bitsize == 16) 3017 return (bi_hadd_v2u16_to(b, dest0, src0, src1, round)); 3018 else if ((type == nir_type_int) && bitsize == 8) 3019 return (bi_hadd_v4s8_to(b, dest0, src0, src1, round)); 3020 else if ((type == nir_type_uint) && bitsize == 8) 3021 return (bi_hadd_v4u8_to(b, dest0, src0, src1, round)); 3022 else 3023 unreachable("Invalid parameters for HADD"); 3024} 3025 3026static inline 3027bi_index bi_hadd(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index src0, bi_index src1, enum bi_round round) 3028{ 3029 if ((type == nir_type_int) && bitsize == 32) 3030 return (bi_hadd_s32_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 3031 else if ((type == nir_type_uint) && bitsize == 32) 3032 return (bi_hadd_u32_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 3033 else if ((type == nir_type_int) && bitsize == 16) 3034 return (bi_hadd_v2s16_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 3035 else if ((type == nir_type_uint) && bitsize == 16) 3036 return (bi_hadd_v2u16_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 3037 else if ((type == nir_type_int) && bitsize == 8) 3038 return (bi_hadd_v4s8_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 3039 else if ((type == nir_type_uint) && bitsize == 8) 3040 return (bi_hadd_v4u8_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 3041 else 3042 unreachable("Invalid parameters for HADD"); 3043} 3044 3045static inline 3046bi_instr * bi_iabs_s32_to(bi_builder *b, bi_index dest0, bi_index src0) 3047{ 3048 bi_instr *I = rzalloc(b->shader, bi_instr); 3049 I->op = BI_OPCODE_IABS_S32; 3050 I->dest[0] = dest0; 3051 I->src[0] = src0; 3052 bi_builder_insert(&b->cursor, I); 3053 return I; 3054} 3055 3056static inline 3057bi_index bi_iabs_s32(bi_builder *b, bi_index src0) 3058{ 3059 return (bi_iabs_s32_to(b, bi_temp(b->shader), src0))->dest[0]; 3060} 3061 3062 3063static inline 3064bi_instr * bi_iabs_v2s16_to(bi_builder *b, bi_index dest0, bi_index src0) 3065{ 3066 bi_instr *I = rzalloc(b->shader, bi_instr); 3067 I->op = BI_OPCODE_IABS_V2S16; 3068 I->dest[0] = dest0; 3069 I->src[0] = src0; 3070 bi_builder_insert(&b->cursor, I); 3071 return I; 3072} 3073 3074static inline 3075bi_index bi_iabs_v2s16(bi_builder *b, bi_index src0) 3076{ 3077 return (bi_iabs_v2s16_to(b, bi_temp(b->shader), src0))->dest[0]; 3078} 3079 3080 3081static inline 3082bi_instr * bi_iabs_v4s8_to(bi_builder *b, bi_index dest0, bi_index src0) 3083{ 3084 bi_instr *I = rzalloc(b->shader, bi_instr); 3085 I->op = BI_OPCODE_IABS_V4S8; 3086 I->dest[0] = dest0; 3087 I->src[0] = src0; 3088 bi_builder_insert(&b->cursor, I); 3089 return I; 3090} 3091 3092static inline 3093bi_index bi_iabs_v4s8(bi_builder *b, bi_index src0) 3094{ 3095 return (bi_iabs_v4s8_to(b, bi_temp(b->shader), src0))->dest[0]; 3096} 3097 3098 3099static inline 3100bi_instr * bi_iabs_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0) 3101{ 3102 if (bitsize == 32) 3103 return (bi_iabs_s32_to(b, dest0, src0)); 3104 else if (bitsize == 16) 3105 return (bi_iabs_v2s16_to(b, dest0, src0)); 3106 else if (bitsize == 8) 3107 return (bi_iabs_v4s8_to(b, dest0, src0)); 3108 else 3109 unreachable("Invalid parameters for IABS"); 3110} 3111 3112static inline 3113bi_index bi_iabs(bi_builder *b, unsigned bitsize, bi_index src0) 3114{ 3115 if (bitsize == 32) 3116 return (bi_iabs_s32_to(b, bi_temp(b->shader), src0))->dest[0]; 3117 else if (bitsize == 16) 3118 return (bi_iabs_v2s16_to(b, bi_temp(b->shader), src0))->dest[0]; 3119 else if (bitsize == 8) 3120 return (bi_iabs_v4s8_to(b, bi_temp(b->shader), src0))->dest[0]; 3121 else 3122 unreachable("Invalid parameters for IABS"); 3123} 3124 3125static inline 3126bi_instr * bi_iadd_s32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate) 3127{ 3128 bi_instr *I = rzalloc(b->shader, bi_instr); 3129 I->op = BI_OPCODE_IADD_S32; 3130 I->dest[0] = dest0; 3131 I->src[0] = src0; 3132 I->src[1] = src1; 3133 I->saturate = saturate; 3134 bi_builder_insert(&b->cursor, I); 3135 return I; 3136} 3137 3138static inline 3139bi_index bi_iadd_s32(bi_builder *b, bi_index src0, bi_index src1, bool saturate) 3140{ 3141 return (bi_iadd_s32_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 3142} 3143 3144 3145static inline 3146bi_instr * bi_iadd_u32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate) 3147{ 3148 bi_instr *I = rzalloc(b->shader, bi_instr); 3149 I->op = BI_OPCODE_IADD_U32; 3150 I->dest[0] = dest0; 3151 I->src[0] = src0; 3152 I->src[1] = src1; 3153 I->saturate = saturate; 3154 bi_builder_insert(&b->cursor, I); 3155 return I; 3156} 3157 3158static inline 3159bi_index bi_iadd_u32(bi_builder *b, bi_index src0, bi_index src1, bool saturate) 3160{ 3161 return (bi_iadd_u32_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 3162} 3163 3164 3165static inline 3166bi_instr * bi_iadd_v2s16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate) 3167{ 3168 bi_instr *I = rzalloc(b->shader, bi_instr); 3169 I->op = BI_OPCODE_IADD_V2S16; 3170 I->dest[0] = dest0; 3171 I->src[0] = src0; 3172 I->src[1] = src1; 3173 I->saturate = saturate; 3174 bi_builder_insert(&b->cursor, I); 3175 return I; 3176} 3177 3178static inline 3179bi_index bi_iadd_v2s16(bi_builder *b, bi_index src0, bi_index src1, bool saturate) 3180{ 3181 return (bi_iadd_v2s16_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 3182} 3183 3184 3185static inline 3186bi_instr * bi_iadd_v2u16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate) 3187{ 3188 bi_instr *I = rzalloc(b->shader, bi_instr); 3189 I->op = BI_OPCODE_IADD_V2U16; 3190 I->dest[0] = dest0; 3191 I->src[0] = src0; 3192 I->src[1] = src1; 3193 I->saturate = saturate; 3194 bi_builder_insert(&b->cursor, I); 3195 return I; 3196} 3197 3198static inline 3199bi_index bi_iadd_v2u16(bi_builder *b, bi_index src0, bi_index src1, bool saturate) 3200{ 3201 return (bi_iadd_v2u16_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 3202} 3203 3204 3205static inline 3206bi_instr * bi_iadd_v4s8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate) 3207{ 3208 bi_instr *I = rzalloc(b->shader, bi_instr); 3209 I->op = BI_OPCODE_IADD_V4S8; 3210 I->dest[0] = dest0; 3211 I->src[0] = src0; 3212 I->src[1] = src1; 3213 I->saturate = saturate; 3214 bi_builder_insert(&b->cursor, I); 3215 return I; 3216} 3217 3218static inline 3219bi_index bi_iadd_v4s8(bi_builder *b, bi_index src0, bi_index src1, bool saturate) 3220{ 3221 return (bi_iadd_v4s8_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 3222} 3223 3224 3225static inline 3226bi_instr * bi_iadd_v4u8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate) 3227{ 3228 bi_instr *I = rzalloc(b->shader, bi_instr); 3229 I->op = BI_OPCODE_IADD_V4U8; 3230 I->dest[0] = dest0; 3231 I->src[0] = src0; 3232 I->src[1] = src1; 3233 I->saturate = saturate; 3234 bi_builder_insert(&b->cursor, I); 3235 return I; 3236} 3237 3238static inline 3239bi_index bi_iadd_v4u8(bi_builder *b, bi_index src0, bi_index src1, bool saturate) 3240{ 3241 return (bi_iadd_v4u8_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 3242} 3243 3244 3245static inline 3246bi_instr * bi_iadd_to(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bool saturate) 3247{ 3248 if ((type == nir_type_int) && bitsize == 32) 3249 return (bi_iadd_s32_to(b, dest0, src0, src1, saturate)); 3250 else if ((type == nir_type_uint) && bitsize == 32) 3251 return (bi_iadd_u32_to(b, dest0, src0, src1, saturate)); 3252 else if ((type == nir_type_int) && bitsize == 16) 3253 return (bi_iadd_v2s16_to(b, dest0, src0, src1, saturate)); 3254 else if ((type == nir_type_uint) && bitsize == 16) 3255 return (bi_iadd_v2u16_to(b, dest0, src0, src1, saturate)); 3256 else if ((type == nir_type_int) && bitsize == 8) 3257 return (bi_iadd_v4s8_to(b, dest0, src0, src1, saturate)); 3258 else if ((type == nir_type_uint) && bitsize == 8) 3259 return (bi_iadd_v4u8_to(b, dest0, src0, src1, saturate)); 3260 else 3261 unreachable("Invalid parameters for IADD"); 3262} 3263 3264static inline 3265bi_index bi_iadd(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index src0, bi_index src1, bool saturate) 3266{ 3267 if ((type == nir_type_int) && bitsize == 32) 3268 return (bi_iadd_s32_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 3269 else if ((type == nir_type_uint) && bitsize == 32) 3270 return (bi_iadd_u32_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 3271 else if ((type == nir_type_int) && bitsize == 16) 3272 return (bi_iadd_v2s16_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 3273 else if ((type == nir_type_uint) && bitsize == 16) 3274 return (bi_iadd_v2u16_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 3275 else if ((type == nir_type_int) && bitsize == 8) 3276 return (bi_iadd_v4s8_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 3277 else if ((type == nir_type_uint) && bitsize == 8) 3278 return (bi_iadd_v4u8_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 3279 else 3280 unreachable("Invalid parameters for IADD"); 3281} 3282 3283static inline 3284bi_instr * bi_iaddc_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 3285{ 3286 bi_instr *I = rzalloc(b->shader, bi_instr); 3287 I->op = BI_OPCODE_IADDC_I32; 3288 I->dest[0] = dest0; 3289 I->src[0] = src0; 3290 I->src[1] = src1; 3291 I->src[2] = src2; 3292 bi_builder_insert(&b->cursor, I); 3293 return I; 3294} 3295 3296static inline 3297bi_index bi_iaddc_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 3298{ 3299 return (bi_iaddc_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 3300} 3301 3302 3303static inline 3304bi_instr * bi_iadd_imm_i32_to(bi_builder *b, bi_index dest0, bi_index src0, uint32_t index) 3305{ 3306 bi_instr *I = rzalloc(b->shader, bi_instr); 3307 I->op = BI_OPCODE_IADD_IMM_I32; 3308 I->dest[0] = dest0; 3309 I->src[0] = src0; 3310 I->index = index; 3311 bi_builder_insert(&b->cursor, I); 3312 return I; 3313} 3314 3315static inline 3316bi_index bi_iadd_imm_i32(bi_builder *b, bi_index src0, uint32_t index) 3317{ 3318 return (bi_iadd_imm_i32_to(b, bi_temp(b->shader), src0, index))->dest[0]; 3319} 3320 3321 3322static inline 3323bi_instr * bi_iadd_imm_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, uint32_t index) 3324{ 3325 bi_instr *I = rzalloc(b->shader, bi_instr); 3326 I->op = BI_OPCODE_IADD_IMM_V2I16; 3327 I->dest[0] = dest0; 3328 I->src[0] = src0; 3329 I->index = index; 3330 bi_builder_insert(&b->cursor, I); 3331 return I; 3332} 3333 3334static inline 3335bi_index bi_iadd_imm_v2i16(bi_builder *b, bi_index src0, uint32_t index) 3336{ 3337 return (bi_iadd_imm_v2i16_to(b, bi_temp(b->shader), src0, index))->dest[0]; 3338} 3339 3340 3341static inline 3342bi_instr * bi_iadd_imm_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, uint32_t index) 3343{ 3344 bi_instr *I = rzalloc(b->shader, bi_instr); 3345 I->op = BI_OPCODE_IADD_IMM_V4I8; 3346 I->dest[0] = dest0; 3347 I->src[0] = src0; 3348 I->index = index; 3349 bi_builder_insert(&b->cursor, I); 3350 return I; 3351} 3352 3353static inline 3354bi_index bi_iadd_imm_v4i8(bi_builder *b, bi_index src0, uint32_t index) 3355{ 3356 return (bi_iadd_imm_v4i8_to(b, bi_temp(b->shader), src0, index))->dest[0]; 3357} 3358 3359 3360static inline 3361bi_instr * bi_iadd_imm_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, uint32_t index) 3362{ 3363 if (bitsize == 32) 3364 return (bi_iadd_imm_i32_to(b, dest0, src0, index)); 3365 else if (bitsize == 16) 3366 return (bi_iadd_imm_v2i16_to(b, dest0, src0, index)); 3367 else if (bitsize == 8) 3368 return (bi_iadd_imm_v4i8_to(b, dest0, src0, index)); 3369 else 3370 unreachable("Invalid parameters for IADD_IMM"); 3371} 3372 3373static inline 3374bi_index bi_iadd_imm(bi_builder *b, unsigned bitsize, bi_index src0, uint32_t index) 3375{ 3376 if (bitsize == 32) 3377 return (bi_iadd_imm_i32_to(b, bi_temp(b->shader), src0, index))->dest[0]; 3378 else if (bitsize == 16) 3379 return (bi_iadd_imm_v2i16_to(b, bi_temp(b->shader), src0, index))->dest[0]; 3380 else if (bitsize == 8) 3381 return (bi_iadd_imm_v4i8_to(b, bi_temp(b->shader), src0, index))->dest[0]; 3382 else 3383 unreachable("Invalid parameters for IADD_IMM"); 3384} 3385 3386static inline 3387bi_instr * bi_icmp_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3388{ 3389 bi_instr *I = rzalloc(b->shader, bi_instr); 3390 I->op = BI_OPCODE_ICMP_I32; 3391 I->dest[0] = dest0; 3392 I->src[0] = src0; 3393 I->src[1] = src1; 3394 I->result_type = result_type; 3395 I->cmpf = cmpf; 3396 bi_builder_insert(&b->cursor, I); 3397 return I; 3398} 3399 3400static inline 3401bi_index bi_icmp_i32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3402{ 3403 return (bi_icmp_i32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3404} 3405 3406 3407static inline 3408bi_instr * bi_icmp_s32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3409{ 3410 bi_instr *I = rzalloc(b->shader, bi_instr); 3411 I->op = BI_OPCODE_ICMP_S32; 3412 I->dest[0] = dest0; 3413 I->src[0] = src0; 3414 I->src[1] = src1; 3415 I->result_type = result_type; 3416 I->cmpf = cmpf; 3417 bi_builder_insert(&b->cursor, I); 3418 return I; 3419} 3420 3421static inline 3422bi_index bi_icmp_s32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3423{ 3424 return (bi_icmp_s32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3425} 3426 3427 3428static inline 3429bi_instr * bi_icmp_u32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3430{ 3431 bi_instr *I = rzalloc(b->shader, bi_instr); 3432 I->op = BI_OPCODE_ICMP_U32; 3433 I->dest[0] = dest0; 3434 I->src[0] = src0; 3435 I->src[1] = src1; 3436 I->result_type = result_type; 3437 I->cmpf = cmpf; 3438 bi_builder_insert(&b->cursor, I); 3439 return I; 3440} 3441 3442static inline 3443bi_index bi_icmp_u32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3444{ 3445 return (bi_icmp_u32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3446} 3447 3448 3449static inline 3450bi_instr * bi_icmp_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3451{ 3452 bi_instr *I = rzalloc(b->shader, bi_instr); 3453 I->op = BI_OPCODE_ICMP_V2I16; 3454 I->dest[0] = dest0; 3455 I->src[0] = src0; 3456 I->src[1] = src1; 3457 I->result_type = result_type; 3458 I->cmpf = cmpf; 3459 bi_builder_insert(&b->cursor, I); 3460 return I; 3461} 3462 3463static inline 3464bi_index bi_icmp_v2i16(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3465{ 3466 return (bi_icmp_v2i16_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3467} 3468 3469 3470static inline 3471bi_instr * bi_icmp_v2s16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3472{ 3473 bi_instr *I = rzalloc(b->shader, bi_instr); 3474 I->op = BI_OPCODE_ICMP_V2S16; 3475 I->dest[0] = dest0; 3476 I->src[0] = src0; 3477 I->src[1] = src1; 3478 I->result_type = result_type; 3479 I->cmpf = cmpf; 3480 bi_builder_insert(&b->cursor, I); 3481 return I; 3482} 3483 3484static inline 3485bi_index bi_icmp_v2s16(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3486{ 3487 return (bi_icmp_v2s16_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3488} 3489 3490 3491static inline 3492bi_instr * bi_icmp_v2u16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3493{ 3494 bi_instr *I = rzalloc(b->shader, bi_instr); 3495 I->op = BI_OPCODE_ICMP_V2U16; 3496 I->dest[0] = dest0; 3497 I->src[0] = src0; 3498 I->src[1] = src1; 3499 I->result_type = result_type; 3500 I->cmpf = cmpf; 3501 bi_builder_insert(&b->cursor, I); 3502 return I; 3503} 3504 3505static inline 3506bi_index bi_icmp_v2u16(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3507{ 3508 return (bi_icmp_v2u16_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3509} 3510 3511 3512static inline 3513bi_instr * bi_icmp_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3514{ 3515 bi_instr *I = rzalloc(b->shader, bi_instr); 3516 I->op = BI_OPCODE_ICMP_V4I8; 3517 I->dest[0] = dest0; 3518 I->src[0] = src0; 3519 I->src[1] = src1; 3520 I->result_type = result_type; 3521 I->cmpf = cmpf; 3522 bi_builder_insert(&b->cursor, I); 3523 return I; 3524} 3525 3526static inline 3527bi_index bi_icmp_v4i8(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3528{ 3529 return (bi_icmp_v4i8_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3530} 3531 3532 3533static inline 3534bi_instr * bi_icmp_v4s8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3535{ 3536 bi_instr *I = rzalloc(b->shader, bi_instr); 3537 I->op = BI_OPCODE_ICMP_V4S8; 3538 I->dest[0] = dest0; 3539 I->src[0] = src0; 3540 I->src[1] = src1; 3541 I->result_type = result_type; 3542 I->cmpf = cmpf; 3543 bi_builder_insert(&b->cursor, I); 3544 return I; 3545} 3546 3547static inline 3548bi_index bi_icmp_v4s8(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3549{ 3550 return (bi_icmp_v4s8_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3551} 3552 3553 3554static inline 3555bi_instr * bi_icmp_v4u8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3556{ 3557 bi_instr *I = rzalloc(b->shader, bi_instr); 3558 I->op = BI_OPCODE_ICMP_V4U8; 3559 I->dest[0] = dest0; 3560 I->src[0] = src0; 3561 I->src[1] = src1; 3562 I->result_type = result_type; 3563 I->cmpf = cmpf; 3564 bi_builder_insert(&b->cursor, I); 3565 return I; 3566} 3567 3568static inline 3569bi_index bi_icmp_v4u8(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3570{ 3571 return (bi_icmp_v4u8_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3572} 3573 3574 3575static inline 3576bi_instr * bi_icmp_to(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3577{ 3578 if ((type == nir_type_uint || type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE)) 3579 return (bi_icmp_i32_to(b, dest0, src0, src1, cmpf, result_type)); 3580 else if ((type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 3581 return (bi_icmp_s32_to(b, dest0, src0, src1, cmpf, result_type)); 3582 else if ((type == nir_type_uint) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 3583 return (bi_icmp_u32_to(b, dest0, src0, src1, cmpf, result_type)); 3584 else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE)) 3585 return (bi_icmp_v2i16_to(b, dest0, src0, src1, cmpf, result_type)); 3586 else if ((type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 3587 return (bi_icmp_v2s16_to(b, dest0, src0, src1, cmpf, result_type)); 3588 else if ((type == nir_type_uint) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 3589 return (bi_icmp_v2u16_to(b, dest0, src0, src1, cmpf, result_type)); 3590 else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 8 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE)) 3591 return (bi_icmp_v4i8_to(b, dest0, src0, src1, cmpf, result_type)); 3592 else if ((type == nir_type_int) && bitsize == 8 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 3593 return (bi_icmp_v4s8_to(b, dest0, src0, src1, cmpf, result_type)); 3594 else if ((type == nir_type_uint) && bitsize == 8 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 3595 return (bi_icmp_v4u8_to(b, dest0, src0, src1, cmpf, result_type)); 3596 else 3597 unreachable("Invalid parameters for ICMP"); 3598} 3599 3600static inline 3601bi_index bi_icmp(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3602{ 3603 if ((type == nir_type_uint || type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE)) 3604 return (bi_icmp_i32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3605 else if ((type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 3606 return (bi_icmp_s32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3607 else if ((type == nir_type_uint) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 3608 return (bi_icmp_u32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3609 else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE)) 3610 return (bi_icmp_v2i16_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3611 else if ((type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 3612 return (bi_icmp_v2s16_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3613 else if ((type == nir_type_uint) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 3614 return (bi_icmp_v2u16_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3615 else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 8 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE)) 3616 return (bi_icmp_v4i8_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3617 else if ((type == nir_type_int) && bitsize == 8 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 3618 return (bi_icmp_v4s8_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3619 else if ((type == nir_type_uint) && bitsize == 8 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE)) 3620 return (bi_icmp_v4u8_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3621 else 3622 unreachable("Invalid parameters for ICMP"); 3623} 3624 3625static inline 3626bi_instr * bi_icmpf_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 3627{ 3628 bi_instr *I = rzalloc(b->shader, bi_instr); 3629 I->op = BI_OPCODE_ICMPF_I32; 3630 I->dest[0] = dest0; 3631 I->src[0] = src0; 3632 I->src[1] = src1; 3633 I->src[2] = src2; 3634 bi_builder_insert(&b->cursor, I); 3635 return I; 3636} 3637 3638static inline 3639bi_index bi_icmpf_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 3640{ 3641 return (bi_icmpf_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 3642} 3643 3644 3645static inline 3646bi_instr * bi_icmpi_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3647{ 3648 bi_instr *I = rzalloc(b->shader, bi_instr); 3649 I->op = BI_OPCODE_ICMPI_I32; 3650 I->dest[0] = dest0; 3651 I->src[0] = src0; 3652 I->src[1] = src1; 3653 I->result_type = result_type; 3654 I->cmpf = cmpf; 3655 bi_builder_insert(&b->cursor, I); 3656 return I; 3657} 3658 3659static inline 3660bi_index bi_icmpi_i32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3661{ 3662 return (bi_icmpi_i32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3663} 3664 3665 3666static inline 3667bi_instr * bi_icmpi_s32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3668{ 3669 bi_instr *I = rzalloc(b->shader, bi_instr); 3670 I->op = BI_OPCODE_ICMPI_S32; 3671 I->dest[0] = dest0; 3672 I->src[0] = src0; 3673 I->src[1] = src1; 3674 I->result_type = result_type; 3675 I->cmpf = cmpf; 3676 bi_builder_insert(&b->cursor, I); 3677 return I; 3678} 3679 3680static inline 3681bi_index bi_icmpi_s32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3682{ 3683 return (bi_icmpi_s32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3684} 3685 3686 3687static inline 3688bi_instr * bi_icmpi_u32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3689{ 3690 bi_instr *I = rzalloc(b->shader, bi_instr); 3691 I->op = BI_OPCODE_ICMPI_U32; 3692 I->dest[0] = dest0; 3693 I->src[0] = src0; 3694 I->src[1] = src1; 3695 I->result_type = result_type; 3696 I->cmpf = cmpf; 3697 bi_builder_insert(&b->cursor, I); 3698 return I; 3699} 3700 3701static inline 3702bi_index bi_icmpi_u32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3703{ 3704 return (bi_icmpi_u32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3705} 3706 3707 3708static inline 3709bi_instr * bi_icmpi_to(bi_builder *b, nir_alu_type type, bi_index dest0, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3710{ 3711 if ((type == nir_type_uint || type == nir_type_int) && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE)) 3712 return (bi_icmpi_i32_to(b, dest0, src0, src1, cmpf, result_type)); 3713 else if ((type == nir_type_int) && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE)) 3714 return (bi_icmpi_s32_to(b, dest0, src0, src1, cmpf, result_type)); 3715 else if ((type == nir_type_uint) && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE)) 3716 return (bi_icmpi_u32_to(b, dest0, src0, src1, cmpf, result_type)); 3717 else 3718 unreachable("Invalid parameters for ICMPI"); 3719} 3720 3721static inline 3722bi_index bi_icmpi(bi_builder *b, nir_alu_type type, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type) 3723{ 3724 if ((type == nir_type_uint || type == nir_type_int) && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE)) 3725 return (bi_icmpi_i32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3726 else if ((type == nir_type_int) && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE)) 3727 return (bi_icmpi_s32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3728 else if ((type == nir_type_uint) && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE)) 3729 return (bi_icmpi_u32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0]; 3730 else 3731 unreachable("Invalid parameters for ICMPI"); 3732} 3733 3734static inline 3735bi_instr * bi_icmpm_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 3736{ 3737 bi_instr *I = rzalloc(b->shader, bi_instr); 3738 I->op = BI_OPCODE_ICMPM_I32; 3739 I->dest[0] = dest0; 3740 I->src[0] = src0; 3741 I->src[1] = src1; 3742 I->src[2] = src2; 3743 bi_builder_insert(&b->cursor, I); 3744 return I; 3745} 3746 3747static inline 3748bi_index bi_icmpm_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 3749{ 3750 return (bi_icmpm_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 3751} 3752 3753 3754static inline 3755bi_instr * bi_idp_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1) 3756{ 3757 bi_instr *I = rzalloc(b->shader, bi_instr); 3758 I->op = BI_OPCODE_IDP_V4I8; 3759 I->dest[0] = dest0; 3760 I->src[0] = src0; 3761 I->src[1] = src1; 3762 bi_builder_insert(&b->cursor, I); 3763 return I; 3764} 3765 3766static inline 3767bi_index bi_idp_v4i8(bi_builder *b, bi_index src0, bi_index src1) 3768{ 3769 return (bi_idp_v4i8_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 3770} 3771 3772 3773static inline 3774bi_instr * bi_ilogb_f32_to(bi_builder *b, bi_index dest0, bi_index src0) 3775{ 3776 bi_instr *I = rzalloc(b->shader, bi_instr); 3777 I->op = BI_OPCODE_ILOGB_F32; 3778 I->dest[0] = dest0; 3779 I->src[0] = src0; 3780 bi_builder_insert(&b->cursor, I); 3781 return I; 3782} 3783 3784static inline 3785bi_index bi_ilogb_f32(bi_builder *b, bi_index src0) 3786{ 3787 return (bi_ilogb_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 3788} 3789 3790 3791static inline 3792bi_instr * bi_ilogb_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0) 3793{ 3794 bi_instr *I = rzalloc(b->shader, bi_instr); 3795 I->op = BI_OPCODE_ILOGB_V2F16; 3796 I->dest[0] = dest0; 3797 I->src[0] = src0; 3798 bi_builder_insert(&b->cursor, I); 3799 return I; 3800} 3801 3802static inline 3803bi_index bi_ilogb_v2f16(bi_builder *b, bi_index src0) 3804{ 3805 return (bi_ilogb_v2f16_to(b, bi_temp(b->shader), src0))->dest[0]; 3806} 3807 3808 3809static inline 3810bi_instr * bi_ilogb_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0) 3811{ 3812 if (bitsize == 32) 3813 return (bi_ilogb_f32_to(b, dest0, src0)); 3814 else if (bitsize == 16) 3815 return (bi_ilogb_v2f16_to(b, dest0, src0)); 3816 else 3817 unreachable("Invalid parameters for ILOGB"); 3818} 3819 3820static inline 3821bi_index bi_ilogb(bi_builder *b, unsigned bitsize, bi_index src0) 3822{ 3823 if (bitsize == 32) 3824 return (bi_ilogb_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 3825 else if (bitsize == 16) 3826 return (bi_ilogb_v2f16_to(b, bi_temp(b->shader), src0))->dest[0]; 3827 else 3828 unreachable("Invalid parameters for ILOGB"); 3829} 3830 3831static inline 3832bi_instr * bi_imov_fma_to(bi_builder *b, bi_index dest0, bool threads) 3833{ 3834 bi_instr *I = rzalloc(b->shader, bi_instr); 3835 I->op = BI_OPCODE_IMOV_FMA; 3836 I->dest[0] = dest0; 3837 I->threads = threads; 3838 bi_builder_insert(&b->cursor, I); 3839 return I; 3840} 3841 3842static inline 3843bi_index bi_imov_fma(bi_builder *b, bool threads) 3844{ 3845 return (bi_imov_fma_to(b, bi_temp(b->shader), threads))->dest[0]; 3846} 3847 3848 3849static inline 3850bi_instr * bi_imul_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1) 3851{ 3852 bi_instr *I = rzalloc(b->shader, bi_instr); 3853 I->op = BI_OPCODE_IMUL_I32; 3854 I->dest[0] = dest0; 3855 I->src[0] = src0; 3856 I->src[1] = src1; 3857 bi_builder_insert(&b->cursor, I); 3858 return I; 3859} 3860 3861static inline 3862bi_index bi_imul_i32(bi_builder *b, bi_index src0, bi_index src1) 3863{ 3864 return (bi_imul_i32_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 3865} 3866 3867 3868static inline 3869bi_instr * bi_imul_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1) 3870{ 3871 bi_instr *I = rzalloc(b->shader, bi_instr); 3872 I->op = BI_OPCODE_IMUL_V2I16; 3873 I->dest[0] = dest0; 3874 I->src[0] = src0; 3875 I->src[1] = src1; 3876 bi_builder_insert(&b->cursor, I); 3877 return I; 3878} 3879 3880static inline 3881bi_index bi_imul_v2i16(bi_builder *b, bi_index src0, bi_index src1) 3882{ 3883 return (bi_imul_v2i16_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 3884} 3885 3886 3887static inline 3888bi_instr * bi_imul_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1) 3889{ 3890 bi_instr *I = rzalloc(b->shader, bi_instr); 3891 I->op = BI_OPCODE_IMUL_V4I8; 3892 I->dest[0] = dest0; 3893 I->src[0] = src0; 3894 I->src[1] = src1; 3895 bi_builder_insert(&b->cursor, I); 3896 return I; 3897} 3898 3899static inline 3900bi_index bi_imul_v4i8(bi_builder *b, bi_index src0, bi_index src1) 3901{ 3902 return (bi_imul_v4i8_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 3903} 3904 3905 3906static inline 3907bi_instr * bi_imul_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1) 3908{ 3909 if (bitsize == 32) 3910 return (bi_imul_i32_to(b, dest0, src0, src1)); 3911 else if (bitsize == 16) 3912 return (bi_imul_v2i16_to(b, dest0, src0, src1)); 3913 else if (bitsize == 8) 3914 return (bi_imul_v4i8_to(b, dest0, src0, src1)); 3915 else 3916 unreachable("Invalid parameters for IMUL"); 3917} 3918 3919static inline 3920bi_index bi_imul(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1) 3921{ 3922 if (bitsize == 32) 3923 return (bi_imul_i32_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 3924 else if (bitsize == 16) 3925 return (bi_imul_v2i16_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 3926 else if (bitsize == 8) 3927 return (bi_imul_v4i8_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 3928 else 3929 unreachable("Invalid parameters for IMUL"); 3930} 3931 3932static inline 3933bi_instr * bi_imuld_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool threads) 3934{ 3935 bi_instr *I = rzalloc(b->shader, bi_instr); 3936 I->op = BI_OPCODE_IMULD; 3937 I->dest[0] = dest0; 3938 I->src[0] = src0; 3939 I->src[1] = src1; 3940 I->threads = threads; 3941 bi_builder_insert(&b->cursor, I); 3942 return I; 3943} 3944 3945static inline 3946bi_index bi_imuld(bi_builder *b, bi_index src0, bi_index src1, bool threads) 3947{ 3948 return (bi_imuld_to(b, bi_temp(b->shader), src0, src1, threads))->dest[0]; 3949} 3950 3951 3952static inline 3953bi_instr * bi_isub_s32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate) 3954{ 3955 bi_instr *I = rzalloc(b->shader, bi_instr); 3956 I->op = BI_OPCODE_ISUB_S32; 3957 I->dest[0] = dest0; 3958 I->src[0] = src0; 3959 I->src[1] = src1; 3960 I->saturate = saturate; 3961 bi_builder_insert(&b->cursor, I); 3962 return I; 3963} 3964 3965static inline 3966bi_index bi_isub_s32(bi_builder *b, bi_index src0, bi_index src1, bool saturate) 3967{ 3968 return (bi_isub_s32_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 3969} 3970 3971 3972static inline 3973bi_instr * bi_isub_u32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate) 3974{ 3975 bi_instr *I = rzalloc(b->shader, bi_instr); 3976 I->op = BI_OPCODE_ISUB_U32; 3977 I->dest[0] = dest0; 3978 I->src[0] = src0; 3979 I->src[1] = src1; 3980 I->saturate = saturate; 3981 bi_builder_insert(&b->cursor, I); 3982 return I; 3983} 3984 3985static inline 3986bi_index bi_isub_u32(bi_builder *b, bi_index src0, bi_index src1, bool saturate) 3987{ 3988 return (bi_isub_u32_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 3989} 3990 3991 3992static inline 3993bi_instr * bi_isub_v2s16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate) 3994{ 3995 bi_instr *I = rzalloc(b->shader, bi_instr); 3996 I->op = BI_OPCODE_ISUB_V2S16; 3997 I->dest[0] = dest0; 3998 I->src[0] = src0; 3999 I->src[1] = src1; 4000 I->saturate = saturate; 4001 bi_builder_insert(&b->cursor, I); 4002 return I; 4003} 4004 4005static inline 4006bi_index bi_isub_v2s16(bi_builder *b, bi_index src0, bi_index src1, bool saturate) 4007{ 4008 return (bi_isub_v2s16_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 4009} 4010 4011 4012static inline 4013bi_instr * bi_isub_v2u16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate) 4014{ 4015 bi_instr *I = rzalloc(b->shader, bi_instr); 4016 I->op = BI_OPCODE_ISUB_V2U16; 4017 I->dest[0] = dest0; 4018 I->src[0] = src0; 4019 I->src[1] = src1; 4020 I->saturate = saturate; 4021 bi_builder_insert(&b->cursor, I); 4022 return I; 4023} 4024 4025static inline 4026bi_index bi_isub_v2u16(bi_builder *b, bi_index src0, bi_index src1, bool saturate) 4027{ 4028 return (bi_isub_v2u16_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 4029} 4030 4031 4032static inline 4033bi_instr * bi_isub_v4s8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate) 4034{ 4035 bi_instr *I = rzalloc(b->shader, bi_instr); 4036 I->op = BI_OPCODE_ISUB_V4S8; 4037 I->dest[0] = dest0; 4038 I->src[0] = src0; 4039 I->src[1] = src1; 4040 I->saturate = saturate; 4041 bi_builder_insert(&b->cursor, I); 4042 return I; 4043} 4044 4045static inline 4046bi_index bi_isub_v4s8(bi_builder *b, bi_index src0, bi_index src1, bool saturate) 4047{ 4048 return (bi_isub_v4s8_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 4049} 4050 4051 4052static inline 4053bi_instr * bi_isub_v4u8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate) 4054{ 4055 bi_instr *I = rzalloc(b->shader, bi_instr); 4056 I->op = BI_OPCODE_ISUB_V4U8; 4057 I->dest[0] = dest0; 4058 I->src[0] = src0; 4059 I->src[1] = src1; 4060 I->saturate = saturate; 4061 bi_builder_insert(&b->cursor, I); 4062 return I; 4063} 4064 4065static inline 4066bi_index bi_isub_v4u8(bi_builder *b, bi_index src0, bi_index src1, bool saturate) 4067{ 4068 return (bi_isub_v4u8_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 4069} 4070 4071 4072static inline 4073bi_instr * bi_isub_to(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bool saturate) 4074{ 4075 if ((type == nir_type_int) && bitsize == 32) 4076 return (bi_isub_s32_to(b, dest0, src0, src1, saturate)); 4077 else if ((type == nir_type_uint) && bitsize == 32) 4078 return (bi_isub_u32_to(b, dest0, src0, src1, saturate)); 4079 else if ((type == nir_type_int) && bitsize == 16) 4080 return (bi_isub_v2s16_to(b, dest0, src0, src1, saturate)); 4081 else if ((type == nir_type_uint) && bitsize == 16) 4082 return (bi_isub_v2u16_to(b, dest0, src0, src1, saturate)); 4083 else if ((type == nir_type_int) && bitsize == 8) 4084 return (bi_isub_v4s8_to(b, dest0, src0, src1, saturate)); 4085 else if ((type == nir_type_uint) && bitsize == 8) 4086 return (bi_isub_v4u8_to(b, dest0, src0, src1, saturate)); 4087 else 4088 unreachable("Invalid parameters for ISUB"); 4089} 4090 4091static inline 4092bi_index bi_isub(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index src0, bi_index src1, bool saturate) 4093{ 4094 if ((type == nir_type_int) && bitsize == 32) 4095 return (bi_isub_s32_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 4096 else if ((type == nir_type_uint) && bitsize == 32) 4097 return (bi_isub_u32_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 4098 else if ((type == nir_type_int) && bitsize == 16) 4099 return (bi_isub_v2s16_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 4100 else if ((type == nir_type_uint) && bitsize == 16) 4101 return (bi_isub_v2u16_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 4102 else if ((type == nir_type_int) && bitsize == 8) 4103 return (bi_isub_v4s8_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 4104 else if ((type == nir_type_uint) && bitsize == 8) 4105 return (bi_isub_v4u8_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0]; 4106 else 4107 unreachable("Invalid parameters for ISUB"); 4108} 4109 4110static inline 4111bi_instr * bi_isubb_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 4112{ 4113 bi_instr *I = rzalloc(b->shader, bi_instr); 4114 I->op = BI_OPCODE_ISUBB_I32; 4115 I->dest[0] = dest0; 4116 I->src[0] = src0; 4117 I->src[1] = src1; 4118 I->src[2] = src2; 4119 bi_builder_insert(&b->cursor, I); 4120 return I; 4121} 4122 4123static inline 4124bi_index bi_isubb_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 4125{ 4126 return (bi_isubb_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 4127} 4128 4129 4130static inline 4131bi_instr * bi_jump(bi_builder *b, bi_index src0) 4132{ 4133 bi_instr *I = rzalloc(b->shader, bi_instr); 4134 I->op = BI_OPCODE_JUMP; 4135 I->src[0] = src0; 4136 bi_builder_insert(&b->cursor, I); 4137 return I; 4138} 4139 4140 4141static inline 4142bi_instr * bi_jump_ex_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_stack_mode stack_mode, bool test_mode) 4143{ 4144 bi_instr *I = rzalloc(b->shader, bi_instr); 4145 I->op = BI_OPCODE_JUMP_EX; 4146 I->dest[0] = dest0; 4147 I->src[0] = src0; 4148 I->src[1] = src1; 4149 I->src[2] = src2; 4150 I->test_mode = test_mode; 4151 I->stack_mode = stack_mode; 4152 bi_builder_insert(&b->cursor, I); 4153 return I; 4154} 4155 4156static inline 4157bi_index bi_jump_ex(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_stack_mode stack_mode, bool test_mode) 4158{ 4159 return (bi_jump_ex_to(b, bi_temp(b->shader), src0, src1, src2, stack_mode, test_mode))->dest[0]; 4160} 4161 4162 4163static inline 4164bi_instr * bi_ldexp_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round) 4165{ 4166 bi_instr *I = rzalloc(b->shader, bi_instr); 4167 I->op = BI_OPCODE_LDEXP_F32; 4168 I->dest[0] = dest0; 4169 I->src[0] = src0; 4170 I->src[1] = src1; 4171 I->round = round; 4172 bi_builder_insert(&b->cursor, I); 4173 return I; 4174} 4175 4176static inline 4177bi_index bi_ldexp_f32(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round) 4178{ 4179 return (bi_ldexp_f32_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 4180} 4181 4182 4183static inline 4184bi_instr * bi_ldexp_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round) 4185{ 4186 bi_instr *I = rzalloc(b->shader, bi_instr); 4187 I->op = BI_OPCODE_LDEXP_V2F16; 4188 I->dest[0] = dest0; 4189 I->src[0] = src0; 4190 I->src[1] = src1; 4191 I->round = round; 4192 bi_builder_insert(&b->cursor, I); 4193 return I; 4194} 4195 4196static inline 4197bi_index bi_ldexp_v2f16(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round) 4198{ 4199 return (bi_ldexp_v2f16_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 4200} 4201 4202 4203static inline 4204bi_instr * bi_ldexp_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round) 4205{ 4206 if (bitsize == 32) 4207 return (bi_ldexp_f32_to(b, dest0, src0, src1, round)); 4208 else if (bitsize == 16) 4209 return (bi_ldexp_v2f16_to(b, dest0, src0, src1, round)); 4210 else 4211 unreachable("Invalid parameters for LDEXP"); 4212} 4213 4214static inline 4215bi_index bi_ldexp(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, enum bi_round round) 4216{ 4217 if (bitsize == 32) 4218 return (bi_ldexp_f32_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 4219 else if (bitsize == 16) 4220 return (bi_ldexp_v2f16_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 4221 else 4222 unreachable("Invalid parameters for LDEXP"); 4223} 4224 4225static inline 4226bi_instr * bi_ld_attr_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_register_format register_format, enum bi_vecsize vecsize) 4227{ 4228 bi_instr *I = rzalloc(b->shader, bi_instr); 4229 I->op = BI_OPCODE_LD_ATTR; 4230 I->dest[0] = dest0; 4231 I->src[0] = src0; 4232 I->src[1] = src1; 4233 I->src[2] = src2; 4234 I->register_format = register_format; 4235 I->vecsize = vecsize; 4236 bi_builder_insert(&b->cursor, I); 4237 return I; 4238} 4239 4240static inline 4241bi_index bi_ld_attr(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_register_format register_format, enum bi_vecsize vecsize) 4242{ 4243 return (bi_ld_attr_to(b, bi_temp(b->shader), src0, src1, src2, register_format, vecsize))->dest[0]; 4244} 4245 4246 4247static inline 4248bi_instr * bi_ld_attr_imm_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_register_format register_format, enum bi_vecsize vecsize, uint32_t attribute_index) 4249{ 4250 bi_instr *I = rzalloc(b->shader, bi_instr); 4251 I->op = BI_OPCODE_LD_ATTR_IMM; 4252 I->dest[0] = dest0; 4253 I->src[0] = src0; 4254 I->src[1] = src1; 4255 I->register_format = register_format; 4256 I->vecsize = vecsize; 4257 I->attribute_index = attribute_index; 4258 bi_builder_insert(&b->cursor, I); 4259 return I; 4260} 4261 4262static inline 4263bi_index bi_ld_attr_imm(bi_builder *b, bi_index src0, bi_index src1, enum bi_register_format register_format, enum bi_vecsize vecsize, uint32_t attribute_index) 4264{ 4265 return (bi_ld_attr_imm_to(b, bi_temp(b->shader), src0, src1, register_format, vecsize, attribute_index))->dest[0]; 4266} 4267 4268 4269static inline 4270bi_instr * bi_ld_attr_tex_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_register_format register_format, enum bi_vecsize vecsize) 4271{ 4272 bi_instr *I = rzalloc(b->shader, bi_instr); 4273 I->op = BI_OPCODE_LD_ATTR_TEX; 4274 I->dest[0] = dest0; 4275 I->src[0] = src0; 4276 I->src[1] = src1; 4277 I->src[2] = src2; 4278 I->register_format = register_format; 4279 I->vecsize = vecsize; 4280 bi_builder_insert(&b->cursor, I); 4281 return I; 4282} 4283 4284static inline 4285bi_index bi_ld_attr_tex(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_register_format register_format, enum bi_vecsize vecsize) 4286{ 4287 return (bi_ld_attr_tex_to(b, bi_temp(b->shader), src0, src1, src2, register_format, vecsize))->dest[0]; 4288} 4289 4290 4291static inline 4292bi_instr * bi_ld_cvt_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_register_format register_format, enum bi_vecsize vecsize) 4293{ 4294 bi_instr *I = rzalloc(b->shader, bi_instr); 4295 I->op = BI_OPCODE_LD_CVT; 4296 I->dest[0] = dest0; 4297 I->src[0] = src0; 4298 I->src[1] = src1; 4299 I->src[2] = src2; 4300 I->register_format = register_format; 4301 I->vecsize = vecsize; 4302 bi_builder_insert(&b->cursor, I); 4303 return I; 4304} 4305 4306static inline 4307bi_index bi_ld_cvt(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_register_format register_format, enum bi_vecsize vecsize) 4308{ 4309 return (bi_ld_cvt_to(b, bi_temp(b->shader), src0, src1, src2, register_format, vecsize))->dest[0]; 4310} 4311 4312 4313static inline 4314bi_instr * bi_ld_gclk_u64_to(bi_builder *b, bi_index dest0, enum bi_source source) 4315{ 4316 bi_instr *I = rzalloc(b->shader, bi_instr); 4317 I->op = BI_OPCODE_LD_GCLK_U64; 4318 I->dest[0] = dest0; 4319 I->source = source; 4320 bi_builder_insert(&b->cursor, I); 4321 return I; 4322} 4323 4324static inline 4325bi_index bi_ld_gclk_u64(bi_builder *b, enum bi_source source) 4326{ 4327 return (bi_ld_gclk_u64_to(b, bi_temp(b->shader), source))->dest[0]; 4328} 4329 4330 4331static inline 4332bi_instr * bi_ld_tile_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_vecsize vecsize) 4333{ 4334 bi_instr *I = rzalloc(b->shader, bi_instr); 4335 I->op = BI_OPCODE_LD_TILE; 4336 I->dest[0] = dest0; 4337 I->src[0] = src0; 4338 I->src[1] = src1; 4339 I->src[2] = src2; 4340 I->vecsize = vecsize; 4341 bi_builder_insert(&b->cursor, I); 4342 return I; 4343} 4344 4345static inline 4346bi_index bi_ld_tile(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_vecsize vecsize) 4347{ 4348 return (bi_ld_tile_to(b, bi_temp(b->shader), src0, src1, src2, vecsize))->dest[0]; 4349} 4350 4351 4352static inline 4353bi_instr * bi_ld_var_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_register_format register_format, enum bi_sample sample, enum bi_update update, enum bi_vecsize vecsize) 4354{ 4355 bi_instr *I = rzalloc(b->shader, bi_instr); 4356 I->op = BI_OPCODE_LD_VAR; 4357 I->dest[0] = dest0; 4358 I->src[0] = src0; 4359 I->src[1] = src1; 4360 I->vecsize = vecsize; 4361 I->update = update; 4362 I->register_format = register_format; 4363 I->sample = sample; 4364 bi_builder_insert(&b->cursor, I); 4365 return I; 4366} 4367 4368static inline 4369bi_index bi_ld_var(bi_builder *b, bi_index src0, bi_index src1, enum bi_register_format register_format, enum bi_sample sample, enum bi_update update, enum bi_vecsize vecsize) 4370{ 4371 return (bi_ld_var_to(b, bi_temp(b->shader), src0, src1, register_format, sample, update, vecsize))->dest[0]; 4372} 4373 4374 4375static inline 4376bi_instr * bi_ld_var_flat_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_function function, enum bi_register_format register_format, enum bi_vecsize vecsize) 4377{ 4378 bi_instr *I = rzalloc(b->shader, bi_instr); 4379 I->op = BI_OPCODE_LD_VAR_FLAT; 4380 I->dest[0] = dest0; 4381 I->src[0] = src0; 4382 I->vecsize = vecsize; 4383 I->register_format = register_format; 4384 I->function = function; 4385 bi_builder_insert(&b->cursor, I); 4386 return I; 4387} 4388 4389static inline 4390bi_index bi_ld_var_flat(bi_builder *b, bi_index src0, enum bi_function function, enum bi_register_format register_format, enum bi_vecsize vecsize) 4391{ 4392 return (bi_ld_var_flat_to(b, bi_temp(b->shader), src0, function, register_format, vecsize))->dest[0]; 4393} 4394 4395 4396static inline 4397bi_instr * bi_ld_var_flat_imm_to(bi_builder *b, bi_index dest0, enum bi_function function, enum bi_register_format register_format, enum bi_vecsize vecsize, uint32_t index) 4398{ 4399 bi_instr *I = rzalloc(b->shader, bi_instr); 4400 I->op = BI_OPCODE_LD_VAR_FLAT_IMM; 4401 I->dest[0] = dest0; 4402 I->vecsize = vecsize; 4403 I->register_format = register_format; 4404 I->function = function; 4405 I->index = index; 4406 bi_builder_insert(&b->cursor, I); 4407 return I; 4408} 4409 4410static inline 4411bi_index bi_ld_var_flat_imm(bi_builder *b, enum bi_function function, enum bi_register_format register_format, enum bi_vecsize vecsize, uint32_t index) 4412{ 4413 return (bi_ld_var_flat_imm_to(b, bi_temp(b->shader), function, register_format, vecsize, index))->dest[0]; 4414} 4415 4416 4417static inline 4418bi_instr * bi_ld_var_imm_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_register_format register_format, enum bi_sample sample, enum bi_update update, enum bi_vecsize vecsize, uint32_t index) 4419{ 4420 bi_instr *I = rzalloc(b->shader, bi_instr); 4421 I->op = BI_OPCODE_LD_VAR_IMM; 4422 I->dest[0] = dest0; 4423 I->src[0] = src0; 4424 I->vecsize = vecsize; 4425 I->update = update; 4426 I->register_format = register_format; 4427 I->sample = sample; 4428 I->index = index; 4429 bi_builder_insert(&b->cursor, I); 4430 return I; 4431} 4432 4433static inline 4434bi_index bi_ld_var_imm(bi_builder *b, bi_index src0, enum bi_register_format register_format, enum bi_sample sample, enum bi_update update, enum bi_vecsize vecsize, uint32_t index) 4435{ 4436 return (bi_ld_var_imm_to(b, bi_temp(b->shader), src0, register_format, sample, update, vecsize, index))->dest[0]; 4437} 4438 4439 4440static inline 4441bi_instr * bi_ld_var_special_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_register_format register_format, enum bi_sample sample, enum bi_update update, enum bi_varying_name varying_name, enum bi_vecsize vecsize) 4442{ 4443 bi_instr *I = rzalloc(b->shader, bi_instr); 4444 I->op = BI_OPCODE_LD_VAR_SPECIAL; 4445 I->dest[0] = dest0; 4446 I->src[0] = src0; 4447 I->varying_name = varying_name; 4448 I->vecsize = vecsize; 4449 I->update = update; 4450 I->register_format = register_format; 4451 I->sample = sample; 4452 bi_builder_insert(&b->cursor, I); 4453 return I; 4454} 4455 4456static inline 4457bi_index bi_ld_var_special(bi_builder *b, bi_index src0, enum bi_register_format register_format, enum bi_sample sample, enum bi_update update, enum bi_varying_name varying_name, enum bi_vecsize vecsize) 4458{ 4459 return (bi_ld_var_special_to(b, bi_temp(b->shader), src0, register_format, sample, update, varying_name, vecsize))->dest[0]; 4460} 4461 4462 4463static inline 4464bi_instr * bi_lea_attr_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_register_format register_format) 4465{ 4466 bi_instr *I = rzalloc(b->shader, bi_instr); 4467 I->op = BI_OPCODE_LEA_ATTR; 4468 I->dest[0] = dest0; 4469 I->src[0] = src0; 4470 I->src[1] = src1; 4471 I->src[2] = src2; 4472 I->register_format = register_format; 4473 bi_builder_insert(&b->cursor, I); 4474 return I; 4475} 4476 4477static inline 4478bi_index bi_lea_attr(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_register_format register_format) 4479{ 4480 return (bi_lea_attr_to(b, bi_temp(b->shader), src0, src1, src2, register_format))->dest[0]; 4481} 4482 4483 4484static inline 4485bi_instr * bi_lea_attr_imm_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_register_format register_format, uint32_t attribute_index) 4486{ 4487 bi_instr *I = rzalloc(b->shader, bi_instr); 4488 I->op = BI_OPCODE_LEA_ATTR_IMM; 4489 I->dest[0] = dest0; 4490 I->src[0] = src0; 4491 I->src[1] = src1; 4492 I->register_format = register_format; 4493 I->attribute_index = attribute_index; 4494 bi_builder_insert(&b->cursor, I); 4495 return I; 4496} 4497 4498static inline 4499bi_index bi_lea_attr_imm(bi_builder *b, bi_index src0, bi_index src1, enum bi_register_format register_format, uint32_t attribute_index) 4500{ 4501 return (bi_lea_attr_imm_to(b, bi_temp(b->shader), src0, src1, register_format, attribute_index))->dest[0]; 4502} 4503 4504 4505static inline 4506bi_instr * bi_lea_attr_tex_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_register_format register_format) 4507{ 4508 bi_instr *I = rzalloc(b->shader, bi_instr); 4509 I->op = BI_OPCODE_LEA_ATTR_TEX; 4510 I->dest[0] = dest0; 4511 I->src[0] = src0; 4512 I->src[1] = src1; 4513 I->src[2] = src2; 4514 I->register_format = register_format; 4515 bi_builder_insert(&b->cursor, I); 4516 return I; 4517} 4518 4519static inline 4520bi_index bi_lea_attr_tex(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_register_format register_format) 4521{ 4522 return (bi_lea_attr_tex_to(b, bi_temp(b->shader), src0, src1, src2, register_format))->dest[0]; 4523} 4524 4525 4526static inline 4527bi_instr * bi_lea_tex_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bool format) 4528{ 4529 bi_instr *I = rzalloc(b->shader, bi_instr); 4530 I->op = BI_OPCODE_LEA_TEX; 4531 I->dest[0] = dest0; 4532 I->src[0] = src0; 4533 I->src[1] = src1; 4534 I->src[2] = src2; 4535 I->format = format; 4536 bi_builder_insert(&b->cursor, I); 4537 return I; 4538} 4539 4540static inline 4541bi_index bi_lea_tex(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bool format) 4542{ 4543 return (bi_lea_tex_to(b, bi_temp(b->shader), src0, src1, src2, format))->dest[0]; 4544} 4545 4546 4547static inline 4548bi_instr * bi_lea_tex_imm_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool format, uint32_t texture_index) 4549{ 4550 bi_instr *I = rzalloc(b->shader, bi_instr); 4551 I->op = BI_OPCODE_LEA_TEX_IMM; 4552 I->dest[0] = dest0; 4553 I->src[0] = src0; 4554 I->src[1] = src1; 4555 I->format = format; 4556 I->texture_index = texture_index; 4557 bi_builder_insert(&b->cursor, I); 4558 return I; 4559} 4560 4561static inline 4562bi_index bi_lea_tex_imm(bi_builder *b, bi_index src0, bi_index src1, bool format, uint32_t texture_index) 4563{ 4564 return (bi_lea_tex_imm_to(b, bi_temp(b->shader), src0, src1, format, texture_index))->dest[0]; 4565} 4566 4567 4568static inline 4569bi_instr * bi_load_i128_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_seg seg) 4570{ 4571 bi_instr *I = rzalloc(b->shader, bi_instr); 4572 I->op = BI_OPCODE_LOAD_I128; 4573 I->dest[0] = dest0; 4574 I->src[0] = src0; 4575 I->src[1] = src1; 4576 I->seg = seg; 4577 bi_builder_insert(&b->cursor, I); 4578 return I; 4579} 4580 4581static inline 4582bi_index bi_load_i128(bi_builder *b, bi_index src0, bi_index src1, enum bi_seg seg) 4583{ 4584 return (bi_load_i128_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0]; 4585} 4586 4587 4588static inline 4589bi_instr * bi_load_i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_seg seg) 4590{ 4591 bi_instr *I = rzalloc(b->shader, bi_instr); 4592 I->op = BI_OPCODE_LOAD_I16; 4593 I->dest[0] = dest0; 4594 I->src[0] = src0; 4595 I->src[1] = src1; 4596 I->seg = seg; 4597 I->extend = BI_EXTEND_ZEXT; 4598 bi_builder_insert(&b->cursor, I); 4599 return I; 4600} 4601 4602static inline 4603bi_index bi_load_i16(bi_builder *b, bi_index src0, bi_index src1, enum bi_seg seg) 4604{ 4605 return (bi_load_i16_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0]; 4606} 4607 4608 4609static inline 4610bi_instr * bi_load_i24_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_seg seg) 4611{ 4612 bi_instr *I = rzalloc(b->shader, bi_instr); 4613 I->op = BI_OPCODE_LOAD_I24; 4614 I->dest[0] = dest0; 4615 I->src[0] = src0; 4616 I->src[1] = src1; 4617 I->seg = seg; 4618 I->extend = BI_EXTEND_ZEXT; 4619 bi_builder_insert(&b->cursor, I); 4620 return I; 4621} 4622 4623static inline 4624bi_index bi_load_i24(bi_builder *b, bi_index src0, bi_index src1, enum bi_seg seg) 4625{ 4626 return (bi_load_i24_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0]; 4627} 4628 4629 4630static inline 4631bi_instr * bi_load_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_seg seg) 4632{ 4633 bi_instr *I = rzalloc(b->shader, bi_instr); 4634 I->op = BI_OPCODE_LOAD_I32; 4635 I->dest[0] = dest0; 4636 I->src[0] = src0; 4637 I->src[1] = src1; 4638 I->seg = seg; 4639 bi_builder_insert(&b->cursor, I); 4640 return I; 4641} 4642 4643static inline 4644bi_index bi_load_i32(bi_builder *b, bi_index src0, bi_index src1, enum bi_seg seg) 4645{ 4646 return (bi_load_i32_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0]; 4647} 4648 4649 4650static inline 4651bi_instr * bi_load_i48_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_seg seg) 4652{ 4653 bi_instr *I = rzalloc(b->shader, bi_instr); 4654 I->op = BI_OPCODE_LOAD_I48; 4655 I->dest[0] = dest0; 4656 I->src[0] = src0; 4657 I->src[1] = src1; 4658 I->seg = seg; 4659 bi_builder_insert(&b->cursor, I); 4660 return I; 4661} 4662 4663static inline 4664bi_index bi_load_i48(bi_builder *b, bi_index src0, bi_index src1, enum bi_seg seg) 4665{ 4666 return (bi_load_i48_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0]; 4667} 4668 4669 4670static inline 4671bi_instr * bi_load_i64_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_seg seg) 4672{ 4673 bi_instr *I = rzalloc(b->shader, bi_instr); 4674 I->op = BI_OPCODE_LOAD_I64; 4675 I->dest[0] = dest0; 4676 I->src[0] = src0; 4677 I->src[1] = src1; 4678 I->seg = seg; 4679 bi_builder_insert(&b->cursor, I); 4680 return I; 4681} 4682 4683static inline 4684bi_index bi_load_i64(bi_builder *b, bi_index src0, bi_index src1, enum bi_seg seg) 4685{ 4686 return (bi_load_i64_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0]; 4687} 4688 4689 4690static inline 4691bi_instr * bi_load_i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_seg seg) 4692{ 4693 bi_instr *I = rzalloc(b->shader, bi_instr); 4694 I->op = BI_OPCODE_LOAD_I8; 4695 I->dest[0] = dest0; 4696 I->src[0] = src0; 4697 I->src[1] = src1; 4698 I->seg = seg; 4699 I->extend = BI_EXTEND_ZEXT; 4700 bi_builder_insert(&b->cursor, I); 4701 return I; 4702} 4703 4704static inline 4705bi_index bi_load_i8(bi_builder *b, bi_index src0, bi_index src1, enum bi_seg seg) 4706{ 4707 return (bi_load_i8_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0]; 4708} 4709 4710 4711static inline 4712bi_instr * bi_load_i96_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_seg seg) 4713{ 4714 bi_instr *I = rzalloc(b->shader, bi_instr); 4715 I->op = BI_OPCODE_LOAD_I96; 4716 I->dest[0] = dest0; 4717 I->src[0] = src0; 4718 I->src[1] = src1; 4719 I->seg = seg; 4720 bi_builder_insert(&b->cursor, I); 4721 return I; 4722} 4723 4724static inline 4725bi_index bi_load_i96(bi_builder *b, bi_index src0, bi_index src1, enum bi_seg seg) 4726{ 4727 return (bi_load_i96_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0]; 4728} 4729 4730 4731static inline 4732bi_instr * bi_load_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, enum bi_seg seg) 4733{ 4734 if (bitsize == 128) 4735 return (bi_load_i128_to(b, dest0, src0, src1, seg)); 4736 else if (bitsize == 16) 4737 return (bi_load_i16_to(b, dest0, src0, src1, seg)); 4738 else if (bitsize == 24) 4739 return (bi_load_i24_to(b, dest0, src0, src1, seg)); 4740 else if (bitsize == 32) 4741 return (bi_load_i32_to(b, dest0, src0, src1, seg)); 4742 else if (bitsize == 48) 4743 return (bi_load_i48_to(b, dest0, src0, src1, seg)); 4744 else if (bitsize == 64) 4745 return (bi_load_i64_to(b, dest0, src0, src1, seg)); 4746 else if (bitsize == 8) 4747 return (bi_load_i8_to(b, dest0, src0, src1, seg)); 4748 else if (bitsize == 96) 4749 return (bi_load_i96_to(b, dest0, src0, src1, seg)); 4750 else 4751 unreachable("Invalid parameters for LOAD"); 4752} 4753 4754static inline 4755bi_index bi_load(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, enum bi_seg seg) 4756{ 4757 if (bitsize == 128) 4758 return (bi_load_i128_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0]; 4759 else if (bitsize == 16) 4760 return (bi_load_i16_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0]; 4761 else if (bitsize == 24) 4762 return (bi_load_i24_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0]; 4763 else if (bitsize == 32) 4764 return (bi_load_i32_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0]; 4765 else if (bitsize == 48) 4766 return (bi_load_i48_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0]; 4767 else if (bitsize == 64) 4768 return (bi_load_i64_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0]; 4769 else if (bitsize == 8) 4770 return (bi_load_i8_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0]; 4771 else if (bitsize == 96) 4772 return (bi_load_i96_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0]; 4773 else 4774 unreachable("Invalid parameters for LOAD"); 4775} 4776 4777static inline 4778bi_instr * bi_logb_f32_to(bi_builder *b, bi_index dest0, bi_index src0) 4779{ 4780 bi_instr *I = rzalloc(b->shader, bi_instr); 4781 I->op = BI_OPCODE_LOGB_F32; 4782 I->dest[0] = dest0; 4783 I->src[0] = src0; 4784 bi_builder_insert(&b->cursor, I); 4785 return I; 4786} 4787 4788static inline 4789bi_index bi_logb_f32(bi_builder *b, bi_index src0) 4790{ 4791 return (bi_logb_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 4792} 4793 4794 4795static inline 4796bi_instr * bi_logb_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0) 4797{ 4798 bi_instr *I = rzalloc(b->shader, bi_instr); 4799 I->op = BI_OPCODE_LOGB_V2F16; 4800 I->dest[0] = dest0; 4801 I->src[0] = src0; 4802 bi_builder_insert(&b->cursor, I); 4803 return I; 4804} 4805 4806static inline 4807bi_index bi_logb_v2f16(bi_builder *b, bi_index src0) 4808{ 4809 return (bi_logb_v2f16_to(b, bi_temp(b->shader), src0))->dest[0]; 4810} 4811 4812 4813static inline 4814bi_instr * bi_logb_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0) 4815{ 4816 if (bitsize == 32) 4817 return (bi_logb_f32_to(b, dest0, src0)); 4818 else if (bitsize == 16) 4819 return (bi_logb_v2f16_to(b, dest0, src0)); 4820 else 4821 unreachable("Invalid parameters for LOGB"); 4822} 4823 4824static inline 4825bi_index bi_logb(bi_builder *b, unsigned bitsize, bi_index src0) 4826{ 4827 if (bitsize == 32) 4828 return (bi_logb_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 4829 else if (bitsize == 16) 4830 return (bi_logb_v2f16_to(b, bi_temp(b->shader), src0))->dest[0]; 4831 else 4832 unreachable("Invalid parameters for LOGB"); 4833} 4834 4835static inline 4836bi_instr * bi_lrot_double_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bool bytes2, bool result_word) 4837{ 4838 bi_instr *I = rzalloc(b->shader, bi_instr); 4839 I->op = BI_OPCODE_LROT_DOUBLE_I32; 4840 I->dest[0] = dest0; 4841 I->src[0] = src0; 4842 I->src[1] = src1; 4843 I->src[2] = src2; 4844 I->bytes2 = bytes2; 4845 I->result_word = result_word; 4846 bi_builder_insert(&b->cursor, I); 4847 return I; 4848} 4849 4850static inline 4851bi_index bi_lrot_double_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bool bytes2, bool result_word) 4852{ 4853 return (bi_lrot_double_i32_to(b, bi_temp(b->shader), src0, src1, src2, bytes2, result_word))->dest[0]; 4854} 4855 4856 4857static inline 4858bi_instr * bi_lshift_and_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 4859{ 4860 bi_instr *I = rzalloc(b->shader, bi_instr); 4861 I->op = BI_OPCODE_LSHIFT_AND_I32; 4862 I->dest[0] = dest0; 4863 I->src[0] = src0; 4864 I->src[1] = src1; 4865 I->src[2] = src2; 4866 bi_builder_insert(&b->cursor, I); 4867 return I; 4868} 4869 4870static inline 4871bi_index bi_lshift_and_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 4872{ 4873 return (bi_lshift_and_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 4874} 4875 4876 4877static inline 4878bi_instr * bi_lshift_and_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 4879{ 4880 bi_instr *I = rzalloc(b->shader, bi_instr); 4881 I->op = BI_OPCODE_LSHIFT_AND_V2I16; 4882 I->dest[0] = dest0; 4883 I->src[0] = src0; 4884 I->src[1] = src1; 4885 I->src[2] = src2; 4886 bi_builder_insert(&b->cursor, I); 4887 return I; 4888} 4889 4890static inline 4891bi_index bi_lshift_and_v2i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 4892{ 4893 return (bi_lshift_and_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 4894} 4895 4896 4897static inline 4898bi_instr * bi_lshift_and_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 4899{ 4900 bi_instr *I = rzalloc(b->shader, bi_instr); 4901 I->op = BI_OPCODE_LSHIFT_AND_V4I8; 4902 I->dest[0] = dest0; 4903 I->src[0] = src0; 4904 I->src[1] = src1; 4905 I->src[2] = src2; 4906 bi_builder_insert(&b->cursor, I); 4907 return I; 4908} 4909 4910static inline 4911bi_index bi_lshift_and_v4i8(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 4912{ 4913 return (bi_lshift_and_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 4914} 4915 4916 4917static inline 4918bi_instr * bi_lshift_and_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 4919{ 4920 if (bitsize == 32) 4921 return (bi_lshift_and_i32_to(b, dest0, src0, src1, src2)); 4922 else if (bitsize == 16) 4923 return (bi_lshift_and_v2i16_to(b, dest0, src0, src1, src2)); 4924 else if (bitsize == 8) 4925 return (bi_lshift_and_v4i8_to(b, dest0, src0, src1, src2)); 4926 else 4927 unreachable("Invalid parameters for LSHIFT_AND"); 4928} 4929 4930static inline 4931bi_index bi_lshift_and(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2) 4932{ 4933 if (bitsize == 32) 4934 return (bi_lshift_and_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 4935 else if (bitsize == 16) 4936 return (bi_lshift_and_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 4937 else if (bitsize == 8) 4938 return (bi_lshift_and_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 4939 else 4940 unreachable("Invalid parameters for LSHIFT_AND"); 4941} 4942 4943static inline 4944bi_instr * bi_lshift_double_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bool bytes2, bool result_word) 4945{ 4946 bi_instr *I = rzalloc(b->shader, bi_instr); 4947 I->op = BI_OPCODE_LSHIFT_DOUBLE_I32; 4948 I->dest[0] = dest0; 4949 I->src[0] = src0; 4950 I->src[1] = src1; 4951 I->src[2] = src2; 4952 I->bytes2 = bytes2; 4953 I->result_word = result_word; 4954 bi_builder_insert(&b->cursor, I); 4955 return I; 4956} 4957 4958static inline 4959bi_index bi_lshift_double_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bool bytes2, bool result_word) 4960{ 4961 return (bi_lshift_double_i32_to(b, bi_temp(b->shader), src0, src1, src2, bytes2, result_word))->dest[0]; 4962} 4963 4964 4965static inline 4966bi_instr * bi_lshift_or_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 4967{ 4968 bi_instr *I = rzalloc(b->shader, bi_instr); 4969 I->op = BI_OPCODE_LSHIFT_OR_I32; 4970 I->dest[0] = dest0; 4971 I->src[0] = src0; 4972 I->src[1] = src1; 4973 I->src[2] = src2; 4974 bi_builder_insert(&b->cursor, I); 4975 return I; 4976} 4977 4978static inline 4979bi_index bi_lshift_or_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 4980{ 4981 return (bi_lshift_or_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 4982} 4983 4984 4985static inline 4986bi_instr * bi_lshift_or_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 4987{ 4988 bi_instr *I = rzalloc(b->shader, bi_instr); 4989 I->op = BI_OPCODE_LSHIFT_OR_V2I16; 4990 I->dest[0] = dest0; 4991 I->src[0] = src0; 4992 I->src[1] = src1; 4993 I->src[2] = src2; 4994 bi_builder_insert(&b->cursor, I); 4995 return I; 4996} 4997 4998static inline 4999bi_index bi_lshift_or_v2i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 5000{ 5001 return (bi_lshift_or_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5002} 5003 5004 5005static inline 5006bi_instr * bi_lshift_or_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 5007{ 5008 bi_instr *I = rzalloc(b->shader, bi_instr); 5009 I->op = BI_OPCODE_LSHIFT_OR_V4I8; 5010 I->dest[0] = dest0; 5011 I->src[0] = src0; 5012 I->src[1] = src1; 5013 I->src[2] = src2; 5014 bi_builder_insert(&b->cursor, I); 5015 return I; 5016} 5017 5018static inline 5019bi_index bi_lshift_or_v4i8(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 5020{ 5021 return (bi_lshift_or_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5022} 5023 5024 5025static inline 5026bi_instr * bi_lshift_or_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 5027{ 5028 if (bitsize == 32) 5029 return (bi_lshift_or_i32_to(b, dest0, src0, src1, src2)); 5030 else if (bitsize == 16) 5031 return (bi_lshift_or_v2i16_to(b, dest0, src0, src1, src2)); 5032 else if (bitsize == 8) 5033 return (bi_lshift_or_v4i8_to(b, dest0, src0, src1, src2)); 5034 else 5035 unreachable("Invalid parameters for LSHIFT_OR"); 5036} 5037 5038static inline 5039bi_index bi_lshift_or(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2) 5040{ 5041 if (bitsize == 32) 5042 return (bi_lshift_or_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5043 else if (bitsize == 16) 5044 return (bi_lshift_or_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5045 else if (bitsize == 8) 5046 return (bi_lshift_or_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5047 else 5048 unreachable("Invalid parameters for LSHIFT_OR"); 5049} 5050 5051static inline 5052bi_instr * bi_lshift_xor_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 5053{ 5054 bi_instr *I = rzalloc(b->shader, bi_instr); 5055 I->op = BI_OPCODE_LSHIFT_XOR_I32; 5056 I->dest[0] = dest0; 5057 I->src[0] = src0; 5058 I->src[1] = src1; 5059 I->src[2] = src2; 5060 bi_builder_insert(&b->cursor, I); 5061 return I; 5062} 5063 5064static inline 5065bi_index bi_lshift_xor_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 5066{ 5067 return (bi_lshift_xor_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5068} 5069 5070 5071static inline 5072bi_instr * bi_lshift_xor_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 5073{ 5074 bi_instr *I = rzalloc(b->shader, bi_instr); 5075 I->op = BI_OPCODE_LSHIFT_XOR_V2I16; 5076 I->dest[0] = dest0; 5077 I->src[0] = src0; 5078 I->src[1] = src1; 5079 I->src[2] = src2; 5080 bi_builder_insert(&b->cursor, I); 5081 return I; 5082} 5083 5084static inline 5085bi_index bi_lshift_xor_v2i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 5086{ 5087 return (bi_lshift_xor_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5088} 5089 5090 5091static inline 5092bi_instr * bi_lshift_xor_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 5093{ 5094 bi_instr *I = rzalloc(b->shader, bi_instr); 5095 I->op = BI_OPCODE_LSHIFT_XOR_V4I8; 5096 I->dest[0] = dest0; 5097 I->src[0] = src0; 5098 I->src[1] = src1; 5099 I->src[2] = src2; 5100 bi_builder_insert(&b->cursor, I); 5101 return I; 5102} 5103 5104static inline 5105bi_index bi_lshift_xor_v4i8(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 5106{ 5107 return (bi_lshift_xor_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5108} 5109 5110 5111static inline 5112bi_instr * bi_lshift_xor_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 5113{ 5114 if (bitsize == 32) 5115 return (bi_lshift_xor_i32_to(b, dest0, src0, src1, src2)); 5116 else if (bitsize == 16) 5117 return (bi_lshift_xor_v2i16_to(b, dest0, src0, src1, src2)); 5118 else if (bitsize == 8) 5119 return (bi_lshift_xor_v4i8_to(b, dest0, src0, src1, src2)); 5120 else 5121 unreachable("Invalid parameters for LSHIFT_XOR"); 5122} 5123 5124static inline 5125bi_index bi_lshift_xor(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2) 5126{ 5127 if (bitsize == 32) 5128 return (bi_lshift_xor_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5129 else if (bitsize == 16) 5130 return (bi_lshift_xor_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5131 else if (bitsize == 8) 5132 return (bi_lshift_xor_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5133 else 5134 unreachable("Invalid parameters for LSHIFT_XOR"); 5135} 5136 5137static inline 5138bi_instr * bi_mkvec_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1) 5139{ 5140 bi_instr *I = rzalloc(b->shader, bi_instr); 5141 I->op = BI_OPCODE_MKVEC_V2I16; 5142 I->dest[0] = dest0; 5143 I->src[0] = src0; 5144 I->src[1] = src1; 5145 bi_builder_insert(&b->cursor, I); 5146 return I; 5147} 5148 5149static inline 5150bi_index bi_mkvec_v2i16(bi_builder *b, bi_index src0, bi_index src1) 5151{ 5152 return (bi_mkvec_v2i16_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 5153} 5154 5155 5156static inline 5157bi_instr * bi_mkvec_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bi_index src3) 5158{ 5159 bi_instr *I = rzalloc(b->shader, bi_instr); 5160 I->op = BI_OPCODE_MKVEC_V4I8; 5161 I->dest[0] = dest0; 5162 I->src[0] = src0; 5163 I->src[1] = src1; 5164 I->src[2] = src2; 5165 I->src[3] = src3; 5166 bi_builder_insert(&b->cursor, I); 5167 return I; 5168} 5169 5170static inline 5171bi_index bi_mkvec_v4i8(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3) 5172{ 5173 return (bi_mkvec_v4i8_to(b, bi_temp(b->shader), src0, src1, src2, src3))->dest[0]; 5174} 5175 5176 5177static inline 5178bi_instr * bi_mov_i32_to(bi_builder *b, bi_index dest0, bi_index src0) 5179{ 5180 bi_instr *I = rzalloc(b->shader, bi_instr); 5181 I->op = BI_OPCODE_MOV_I32; 5182 I->dest[0] = dest0; 5183 I->src[0] = src0; 5184 bi_builder_insert(&b->cursor, I); 5185 return I; 5186} 5187 5188static inline 5189bi_index bi_mov_i32(bi_builder *b, bi_index src0) 5190{ 5191 return (bi_mov_i32_to(b, bi_temp(b->shader), src0))->dest[0]; 5192} 5193 5194 5195static inline 5196bi_instr * bi_mux_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_mux mux) 5197{ 5198 bi_instr *I = rzalloc(b->shader, bi_instr); 5199 I->op = BI_OPCODE_MUX_I32; 5200 I->dest[0] = dest0; 5201 I->src[0] = src0; 5202 I->src[1] = src1; 5203 I->src[2] = src2; 5204 I->mux = mux; 5205 bi_builder_insert(&b->cursor, I); 5206 return I; 5207} 5208 5209static inline 5210bi_index bi_mux_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_mux mux) 5211{ 5212 return (bi_mux_i32_to(b, bi_temp(b->shader), src0, src1, src2, mux))->dest[0]; 5213} 5214 5215 5216static inline 5217bi_instr * bi_mux_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_mux mux) 5218{ 5219 bi_instr *I = rzalloc(b->shader, bi_instr); 5220 I->op = BI_OPCODE_MUX_V2I16; 5221 I->dest[0] = dest0; 5222 I->src[0] = src0; 5223 I->src[1] = src1; 5224 I->src[2] = src2; 5225 I->mux = mux; 5226 bi_builder_insert(&b->cursor, I); 5227 return I; 5228} 5229 5230static inline 5231bi_index bi_mux_v2i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_mux mux) 5232{ 5233 return (bi_mux_v2i16_to(b, bi_temp(b->shader), src0, src1, src2, mux))->dest[0]; 5234} 5235 5236 5237static inline 5238bi_instr * bi_mux_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_mux mux) 5239{ 5240 bi_instr *I = rzalloc(b->shader, bi_instr); 5241 I->op = BI_OPCODE_MUX_V4I8; 5242 I->dest[0] = dest0; 5243 I->src[0] = src0; 5244 I->src[1] = src1; 5245 I->src[2] = src2; 5246 I->mux = mux; 5247 bi_builder_insert(&b->cursor, I); 5248 return I; 5249} 5250 5251static inline 5252bi_index bi_mux_v4i8(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_mux mux) 5253{ 5254 return (bi_mux_v4i8_to(b, bi_temp(b->shader), src0, src1, src2, mux))->dest[0]; 5255} 5256 5257 5258static inline 5259bi_instr * bi_mux_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_mux mux) 5260{ 5261 if (bitsize == 32) 5262 return (bi_mux_i32_to(b, dest0, src0, src1, src2, mux)); 5263 else if (bitsize == 16) 5264 return (bi_mux_v2i16_to(b, dest0, src0, src1, src2, mux)); 5265 else if (bitsize == 8) 5266 return (bi_mux_v4i8_to(b, dest0, src0, src1, src2, mux)); 5267 else 5268 unreachable("Invalid parameters for MUX"); 5269} 5270 5271static inline 5272bi_index bi_mux(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2, enum bi_mux mux) 5273{ 5274 if (bitsize == 32) 5275 return (bi_mux_i32_to(b, bi_temp(b->shader), src0, src1, src2, mux))->dest[0]; 5276 else if (bitsize == 16) 5277 return (bi_mux_v2i16_to(b, bi_temp(b->shader), src0, src1, src2, mux))->dest[0]; 5278 else if (bitsize == 8) 5279 return (bi_mux_v4i8_to(b, bi_temp(b->shader), src0, src1, src2, mux))->dest[0]; 5280 else 5281 unreachable("Invalid parameters for MUX"); 5282} 5283 5284static inline 5285bi_instr * bi_nop_to(bi_builder *b, bi_index dest0) 5286{ 5287 bi_instr *I = rzalloc(b->shader, bi_instr); 5288 I->op = BI_OPCODE_NOP; 5289 I->dest[0] = dest0; 5290 bi_builder_insert(&b->cursor, I); 5291 return I; 5292} 5293 5294static inline 5295bi_index bi_nop(bi_builder *b) 5296{ 5297 return (bi_nop_to(b, bi_temp(b->shader)))->dest[0]; 5298} 5299 5300 5301static inline 5302bi_instr * bi_patom_c_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_atom_opc atom_opc, uint32_t sr_count) 5303{ 5304 bi_instr *I = rzalloc(b->shader, bi_instr); 5305 I->op = BI_OPCODE_PATOM_C_I32; 5306 I->dest[0] = dest0; 5307 I->src[0] = src0; 5308 I->src[1] = src1; 5309 I->src[2] = src2; 5310 I->atom_opc = atom_opc; 5311 I->sr_count = sr_count; 5312 bi_builder_insert(&b->cursor, I); 5313 return I; 5314} 5315 5316static inline 5317bi_index bi_patom_c_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_atom_opc atom_opc, uint32_t sr_count) 5318{ 5319 return (bi_patom_c_i32_to(b, bi_temp(b->shader), src0, src1, src2, atom_opc, sr_count))->dest[0]; 5320} 5321 5322 5323static inline 5324bi_instr * bi_patom_c1_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc, uint32_t sr_count) 5325{ 5326 bi_instr *I = rzalloc(b->shader, bi_instr); 5327 I->op = BI_OPCODE_PATOM_C1_I32; 5328 I->dest[0] = dest0; 5329 I->src[0] = src0; 5330 I->src[1] = src1; 5331 I->atom_opc = atom_opc; 5332 I->sr_count = sr_count; 5333 bi_builder_insert(&b->cursor, I); 5334 return I; 5335} 5336 5337static inline 5338bi_index bi_patom_c1_i32(bi_builder *b, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc, uint32_t sr_count) 5339{ 5340 return (bi_patom_c1_i32_to(b, bi_temp(b->shader), src0, src1, atom_opc, sr_count))->dest[0]; 5341} 5342 5343 5344static inline 5345bi_instr * bi_popcount_i32_to(bi_builder *b, bi_index dest0, bi_index src0) 5346{ 5347 bi_instr *I = rzalloc(b->shader, bi_instr); 5348 I->op = BI_OPCODE_POPCOUNT_I32; 5349 I->dest[0] = dest0; 5350 I->src[0] = src0; 5351 bi_builder_insert(&b->cursor, I); 5352 return I; 5353} 5354 5355static inline 5356bi_index bi_popcount_i32(bi_builder *b, bi_index src0) 5357{ 5358 return (bi_popcount_i32_to(b, bi_temp(b->shader), src0))->dest[0]; 5359} 5360 5361 5362static inline 5363bi_instr * bi_quiet_f32_to(bi_builder *b, bi_index dest0, bi_index src0) 5364{ 5365 bi_instr *I = rzalloc(b->shader, bi_instr); 5366 I->op = BI_OPCODE_QUIET_F32; 5367 I->dest[0] = dest0; 5368 I->src[0] = src0; 5369 bi_builder_insert(&b->cursor, I); 5370 return I; 5371} 5372 5373static inline 5374bi_index bi_quiet_f32(bi_builder *b, bi_index src0) 5375{ 5376 return (bi_quiet_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 5377} 5378 5379 5380static inline 5381bi_instr * bi_quiet_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0) 5382{ 5383 bi_instr *I = rzalloc(b->shader, bi_instr); 5384 I->op = BI_OPCODE_QUIET_V2F16; 5385 I->dest[0] = dest0; 5386 I->src[0] = src0; 5387 bi_builder_insert(&b->cursor, I); 5388 return I; 5389} 5390 5391static inline 5392bi_index bi_quiet_v2f16(bi_builder *b, bi_index src0) 5393{ 5394 return (bi_quiet_v2f16_to(b, bi_temp(b->shader), src0))->dest[0]; 5395} 5396 5397 5398static inline 5399bi_instr * bi_quiet_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0) 5400{ 5401 if (bitsize == 32) 5402 return (bi_quiet_f32_to(b, dest0, src0)); 5403 else if (bitsize == 16) 5404 return (bi_quiet_v2f16_to(b, dest0, src0)); 5405 else 5406 unreachable("Invalid parameters for QUIET"); 5407} 5408 5409static inline 5410bi_index bi_quiet(bi_builder *b, unsigned bitsize, bi_index src0) 5411{ 5412 if (bitsize == 32) 5413 return (bi_quiet_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 5414 else if (bitsize == 16) 5415 return (bi_quiet_v2f16_to(b, bi_temp(b->shader), src0))->dest[0]; 5416 else 5417 unreachable("Invalid parameters for QUIET"); 5418} 5419 5420static inline 5421bi_instr * bi_rrot_double_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bool bytes2, bool result_word) 5422{ 5423 bi_instr *I = rzalloc(b->shader, bi_instr); 5424 I->op = BI_OPCODE_RROT_DOUBLE_I32; 5425 I->dest[0] = dest0; 5426 I->src[0] = src0; 5427 I->src[1] = src1; 5428 I->src[2] = src2; 5429 I->bytes2 = bytes2; 5430 I->result_word = result_word; 5431 bi_builder_insert(&b->cursor, I); 5432 return I; 5433} 5434 5435static inline 5436bi_index bi_rrot_double_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bool bytes2, bool result_word) 5437{ 5438 return (bi_rrot_double_i32_to(b, bi_temp(b->shader), src0, src1, src2, bytes2, result_word))->dest[0]; 5439} 5440 5441 5442static inline 5443bi_instr * bi_rshift_and_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 5444{ 5445 bi_instr *I = rzalloc(b->shader, bi_instr); 5446 I->op = BI_OPCODE_RSHIFT_AND_I32; 5447 I->dest[0] = dest0; 5448 I->src[0] = src0; 5449 I->src[1] = src1; 5450 I->src[2] = src2; 5451 bi_builder_insert(&b->cursor, I); 5452 return I; 5453} 5454 5455static inline 5456bi_index bi_rshift_and_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 5457{ 5458 return (bi_rshift_and_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5459} 5460 5461 5462static inline 5463bi_instr * bi_rshift_and_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 5464{ 5465 bi_instr *I = rzalloc(b->shader, bi_instr); 5466 I->op = BI_OPCODE_RSHIFT_AND_V2I16; 5467 I->dest[0] = dest0; 5468 I->src[0] = src0; 5469 I->src[1] = src1; 5470 I->src[2] = src2; 5471 bi_builder_insert(&b->cursor, I); 5472 return I; 5473} 5474 5475static inline 5476bi_index bi_rshift_and_v2i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 5477{ 5478 return (bi_rshift_and_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5479} 5480 5481 5482static inline 5483bi_instr * bi_rshift_and_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 5484{ 5485 bi_instr *I = rzalloc(b->shader, bi_instr); 5486 I->op = BI_OPCODE_RSHIFT_AND_V4I8; 5487 I->dest[0] = dest0; 5488 I->src[0] = src0; 5489 I->src[1] = src1; 5490 I->src[2] = src2; 5491 bi_builder_insert(&b->cursor, I); 5492 return I; 5493} 5494 5495static inline 5496bi_index bi_rshift_and_v4i8(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 5497{ 5498 return (bi_rshift_and_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5499} 5500 5501 5502static inline 5503bi_instr * bi_rshift_and_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 5504{ 5505 if (bitsize == 32) 5506 return (bi_rshift_and_i32_to(b, dest0, src0, src1, src2)); 5507 else if (bitsize == 16) 5508 return (bi_rshift_and_v2i16_to(b, dest0, src0, src1, src2)); 5509 else if (bitsize == 8) 5510 return (bi_rshift_and_v4i8_to(b, dest0, src0, src1, src2)); 5511 else 5512 unreachable("Invalid parameters for RSHIFT_AND"); 5513} 5514 5515static inline 5516bi_index bi_rshift_and(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2) 5517{ 5518 if (bitsize == 32) 5519 return (bi_rshift_and_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5520 else if (bitsize == 16) 5521 return (bi_rshift_and_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5522 else if (bitsize == 8) 5523 return (bi_rshift_and_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5524 else 5525 unreachable("Invalid parameters for RSHIFT_AND"); 5526} 5527 5528static inline 5529bi_instr * bi_rshift_double_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bool bytes2, bool result_word) 5530{ 5531 bi_instr *I = rzalloc(b->shader, bi_instr); 5532 I->op = BI_OPCODE_RSHIFT_DOUBLE_I32; 5533 I->dest[0] = dest0; 5534 I->src[0] = src0; 5535 I->src[1] = src1; 5536 I->src[2] = src2; 5537 I->bytes2 = bytes2; 5538 I->result_word = result_word; 5539 bi_builder_insert(&b->cursor, I); 5540 return I; 5541} 5542 5543static inline 5544bi_index bi_rshift_double_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bool bytes2, bool result_word) 5545{ 5546 return (bi_rshift_double_i32_to(b, bi_temp(b->shader), src0, src1, src2, bytes2, result_word))->dest[0]; 5547} 5548 5549 5550static inline 5551bi_instr * bi_rshift_or_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 5552{ 5553 bi_instr *I = rzalloc(b->shader, bi_instr); 5554 I->op = BI_OPCODE_RSHIFT_OR_I32; 5555 I->dest[0] = dest0; 5556 I->src[0] = src0; 5557 I->src[1] = src1; 5558 I->src[2] = src2; 5559 bi_builder_insert(&b->cursor, I); 5560 return I; 5561} 5562 5563static inline 5564bi_index bi_rshift_or_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 5565{ 5566 return (bi_rshift_or_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5567} 5568 5569 5570static inline 5571bi_instr * bi_rshift_or_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 5572{ 5573 bi_instr *I = rzalloc(b->shader, bi_instr); 5574 I->op = BI_OPCODE_RSHIFT_OR_V2I16; 5575 I->dest[0] = dest0; 5576 I->src[0] = src0; 5577 I->src[1] = src1; 5578 I->src[2] = src2; 5579 bi_builder_insert(&b->cursor, I); 5580 return I; 5581} 5582 5583static inline 5584bi_index bi_rshift_or_v2i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 5585{ 5586 return (bi_rshift_or_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5587} 5588 5589 5590static inline 5591bi_instr * bi_rshift_or_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 5592{ 5593 bi_instr *I = rzalloc(b->shader, bi_instr); 5594 I->op = BI_OPCODE_RSHIFT_OR_V4I8; 5595 I->dest[0] = dest0; 5596 I->src[0] = src0; 5597 I->src[1] = src1; 5598 I->src[2] = src2; 5599 bi_builder_insert(&b->cursor, I); 5600 return I; 5601} 5602 5603static inline 5604bi_index bi_rshift_or_v4i8(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 5605{ 5606 return (bi_rshift_or_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5607} 5608 5609 5610static inline 5611bi_instr * bi_rshift_or_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 5612{ 5613 if (bitsize == 32) 5614 return (bi_rshift_or_i32_to(b, dest0, src0, src1, src2)); 5615 else if (bitsize == 16) 5616 return (bi_rshift_or_v2i16_to(b, dest0, src0, src1, src2)); 5617 else if (bitsize == 8) 5618 return (bi_rshift_or_v4i8_to(b, dest0, src0, src1, src2)); 5619 else 5620 unreachable("Invalid parameters for RSHIFT_OR"); 5621} 5622 5623static inline 5624bi_index bi_rshift_or(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2) 5625{ 5626 if (bitsize == 32) 5627 return (bi_rshift_or_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5628 else if (bitsize == 16) 5629 return (bi_rshift_or_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5630 else if (bitsize == 8) 5631 return (bi_rshift_or_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5632 else 5633 unreachable("Invalid parameters for RSHIFT_OR"); 5634} 5635 5636static inline 5637bi_instr * bi_rshift_xor_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 5638{ 5639 bi_instr *I = rzalloc(b->shader, bi_instr); 5640 I->op = BI_OPCODE_RSHIFT_XOR_I32; 5641 I->dest[0] = dest0; 5642 I->src[0] = src0; 5643 I->src[1] = src1; 5644 I->src[2] = src2; 5645 bi_builder_insert(&b->cursor, I); 5646 return I; 5647} 5648 5649static inline 5650bi_index bi_rshift_xor_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 5651{ 5652 return (bi_rshift_xor_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5653} 5654 5655 5656static inline 5657bi_instr * bi_rshift_xor_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 5658{ 5659 bi_instr *I = rzalloc(b->shader, bi_instr); 5660 I->op = BI_OPCODE_RSHIFT_XOR_V2I16; 5661 I->dest[0] = dest0; 5662 I->src[0] = src0; 5663 I->src[1] = src1; 5664 I->src[2] = src2; 5665 bi_builder_insert(&b->cursor, I); 5666 return I; 5667} 5668 5669static inline 5670bi_index bi_rshift_xor_v2i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 5671{ 5672 return (bi_rshift_xor_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5673} 5674 5675 5676static inline 5677bi_instr * bi_rshift_xor_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 5678{ 5679 bi_instr *I = rzalloc(b->shader, bi_instr); 5680 I->op = BI_OPCODE_RSHIFT_XOR_V4I8; 5681 I->dest[0] = dest0; 5682 I->src[0] = src0; 5683 I->src[1] = src1; 5684 I->src[2] = src2; 5685 bi_builder_insert(&b->cursor, I); 5686 return I; 5687} 5688 5689static inline 5690bi_index bi_rshift_xor_v4i8(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 5691{ 5692 return (bi_rshift_xor_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5693} 5694 5695 5696static inline 5697bi_instr * bi_rshift_xor_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 5698{ 5699 if (bitsize == 32) 5700 return (bi_rshift_xor_i32_to(b, dest0, src0, src1, src2)); 5701 else if (bitsize == 16) 5702 return (bi_rshift_xor_v2i16_to(b, dest0, src0, src1, src2)); 5703 else if (bitsize == 8) 5704 return (bi_rshift_xor_v4i8_to(b, dest0, src0, src1, src2)); 5705 else 5706 unreachable("Invalid parameters for RSHIFT_XOR"); 5707} 5708 5709static inline 5710bi_index bi_rshift_xor(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2) 5711{ 5712 if (bitsize == 32) 5713 return (bi_rshift_xor_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5714 else if (bitsize == 16) 5715 return (bi_rshift_xor_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5716 else if (bitsize == 8) 5717 return (bi_rshift_xor_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5718 else 5719 unreachable("Invalid parameters for RSHIFT_XOR"); 5720} 5721 5722static inline 5723bi_instr * bi_s16_to_f32_to(bi_builder *b, bi_index dest0, bi_index src0) 5724{ 5725 bi_instr *I = rzalloc(b->shader, bi_instr); 5726 I->op = BI_OPCODE_S16_TO_F32; 5727 I->dest[0] = dest0; 5728 I->src[0] = src0; 5729 bi_builder_insert(&b->cursor, I); 5730 return I; 5731} 5732 5733static inline 5734bi_index bi_s16_to_f32(bi_builder *b, bi_index src0) 5735{ 5736 return (bi_s16_to_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 5737} 5738 5739 5740static inline 5741bi_instr * bi_s16_to_s32_to(bi_builder *b, bi_index dest0, bi_index src0) 5742{ 5743 bi_instr *I = rzalloc(b->shader, bi_instr); 5744 I->op = BI_OPCODE_S16_TO_S32; 5745 I->dest[0] = dest0; 5746 I->src[0] = src0; 5747 bi_builder_insert(&b->cursor, I); 5748 return I; 5749} 5750 5751static inline 5752bi_index bi_s16_to_s32(bi_builder *b, bi_index src0) 5753{ 5754 return (bi_s16_to_s32_to(b, bi_temp(b->shader), src0))->dest[0]; 5755} 5756 5757 5758static inline 5759bi_instr * bi_s32_to_f32_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round) 5760{ 5761 bi_instr *I = rzalloc(b->shader, bi_instr); 5762 I->op = BI_OPCODE_S32_TO_F32; 5763 I->dest[0] = dest0; 5764 I->src[0] = src0; 5765 I->round = round; 5766 bi_builder_insert(&b->cursor, I); 5767 return I; 5768} 5769 5770static inline 5771bi_index bi_s32_to_f32(bi_builder *b, bi_index src0, enum bi_round round) 5772{ 5773 return (bi_s32_to_f32_to(b, bi_temp(b->shader), src0, round))->dest[0]; 5774} 5775 5776 5777static inline 5778bi_instr * bi_s8_to_f32_to(bi_builder *b, bi_index dest0, bi_index src0) 5779{ 5780 bi_instr *I = rzalloc(b->shader, bi_instr); 5781 I->op = BI_OPCODE_S8_TO_F32; 5782 I->dest[0] = dest0; 5783 I->src[0] = src0; 5784 bi_builder_insert(&b->cursor, I); 5785 return I; 5786} 5787 5788static inline 5789bi_index bi_s8_to_f32(bi_builder *b, bi_index src0) 5790{ 5791 return (bi_s8_to_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 5792} 5793 5794 5795static inline 5796bi_instr * bi_s8_to_s32_to(bi_builder *b, bi_index dest0, bi_index src0) 5797{ 5798 bi_instr *I = rzalloc(b->shader, bi_instr); 5799 I->op = BI_OPCODE_S8_TO_S32; 5800 I->dest[0] = dest0; 5801 I->src[0] = src0; 5802 bi_builder_insert(&b->cursor, I); 5803 return I; 5804} 5805 5806static inline 5807bi_index bi_s8_to_s32(bi_builder *b, bi_index src0) 5808{ 5809 return (bi_s8_to_s32_to(b, bi_temp(b->shader), src0))->dest[0]; 5810} 5811 5812 5813static inline 5814bi_instr * bi_seg_add_to(bi_builder *b, bi_index dest0, bi_index src0, bool preserve_null, enum bi_seg seg) 5815{ 5816 bi_instr *I = rzalloc(b->shader, bi_instr); 5817 I->op = BI_OPCODE_SEG_ADD; 5818 I->dest[0] = dest0; 5819 I->src[0] = src0; 5820 I->seg = seg; 5821 I->preserve_null = preserve_null; 5822 bi_builder_insert(&b->cursor, I); 5823 return I; 5824} 5825 5826static inline 5827bi_index bi_seg_add(bi_builder *b, bi_index src0, bool preserve_null, enum bi_seg seg) 5828{ 5829 return (bi_seg_add_to(b, bi_temp(b->shader), src0, preserve_null, seg))->dest[0]; 5830} 5831 5832 5833static inline 5834bi_instr * bi_seg_add_i64_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool preserve_null, enum bi_seg seg) 5835{ 5836 bi_instr *I = rzalloc(b->shader, bi_instr); 5837 I->op = BI_OPCODE_SEG_ADD_I64; 5838 I->dest[0] = dest0; 5839 I->src[0] = src0; 5840 I->src[1] = src1; 5841 I->seg = seg; 5842 I->preserve_null = preserve_null; 5843 bi_builder_insert(&b->cursor, I); 5844 return I; 5845} 5846 5847static inline 5848bi_index bi_seg_add_i64(bi_builder *b, bi_index src0, bi_index src1, bool preserve_null, enum bi_seg seg) 5849{ 5850 return (bi_seg_add_i64_to(b, bi_temp(b->shader), src0, src1, preserve_null, seg))->dest[0]; 5851} 5852 5853 5854static inline 5855bi_instr * bi_shaddxh_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1) 5856{ 5857 bi_instr *I = rzalloc(b->shader, bi_instr); 5858 I->op = BI_OPCODE_SHADDXH_I32; 5859 I->dest[0] = dest0; 5860 I->src[0] = src0; 5861 I->src[1] = src1; 5862 bi_builder_insert(&b->cursor, I); 5863 return I; 5864} 5865 5866static inline 5867bi_index bi_shaddxh_i32(bi_builder *b, bi_index src0, bi_index src1) 5868{ 5869 return (bi_shaddxh_i32_to(b, bi_temp(b->shader), src0, src1))->dest[0]; 5870} 5871 5872 5873static inline 5874bi_instr * bi_shaddxl_i64_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, uint32_t shift) 5875{ 5876 bi_instr *I = rzalloc(b->shader, bi_instr); 5877 I->op = BI_OPCODE_SHADDXL_I64; 5878 I->dest[0] = dest0; 5879 I->src[0] = src0; 5880 I->src[1] = src1; 5881 I->shift = shift; 5882 bi_builder_insert(&b->cursor, I); 5883 return I; 5884} 5885 5886static inline 5887bi_index bi_shaddxl_i64(bi_builder *b, bi_index src0, bi_index src1, uint32_t shift) 5888{ 5889 return (bi_shaddxl_i64_to(b, bi_temp(b->shader), src0, src1, shift))->dest[0]; 5890} 5891 5892 5893static inline 5894bi_instr * bi_shaddxl_s32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, uint32_t shift) 5895{ 5896 bi_instr *I = rzalloc(b->shader, bi_instr); 5897 I->op = BI_OPCODE_SHADDXL_S32; 5898 I->dest[0] = dest0; 5899 I->src[0] = src0; 5900 I->src[1] = src1; 5901 I->shift = shift; 5902 bi_builder_insert(&b->cursor, I); 5903 return I; 5904} 5905 5906static inline 5907bi_index bi_shaddxl_s32(bi_builder *b, bi_index src0, bi_index src1, uint32_t shift) 5908{ 5909 return (bi_shaddxl_s32_to(b, bi_temp(b->shader), src0, src1, shift))->dest[0]; 5910} 5911 5912 5913static inline 5914bi_instr * bi_shaddxl_u32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, uint32_t shift) 5915{ 5916 bi_instr *I = rzalloc(b->shader, bi_instr); 5917 I->op = BI_OPCODE_SHADDXL_U32; 5918 I->dest[0] = dest0; 5919 I->src[0] = src0; 5920 I->src[1] = src1; 5921 I->shift = shift; 5922 bi_builder_insert(&b->cursor, I); 5923 return I; 5924} 5925 5926static inline 5927bi_index bi_shaddxl_u32(bi_builder *b, bi_index src0, bi_index src1, uint32_t shift) 5928{ 5929 return (bi_shaddxl_u32_to(b, bi_temp(b->shader), src0, src1, shift))->dest[0]; 5930} 5931 5932 5933static inline 5934bi_instr * bi_shaddxl_to(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, uint32_t shift) 5935{ 5936 if ((type == nir_type_uint || type == nir_type_int) && bitsize == 64) 5937 return (bi_shaddxl_i64_to(b, dest0, src0, src1, shift)); 5938 else if ((type == nir_type_int) && bitsize == 32) 5939 return (bi_shaddxl_s32_to(b, dest0, src0, src1, shift)); 5940 else if ((type == nir_type_uint) && bitsize == 32) 5941 return (bi_shaddxl_u32_to(b, dest0, src0, src1, shift)); 5942 else 5943 unreachable("Invalid parameters for SHADDXL"); 5944} 5945 5946static inline 5947bi_index bi_shaddxl(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index src0, bi_index src1, uint32_t shift) 5948{ 5949 if ((type == nir_type_uint || type == nir_type_int) && bitsize == 64) 5950 return (bi_shaddxl_i64_to(b, bi_temp(b->shader), src0, src1, shift))->dest[0]; 5951 else if ((type == nir_type_int) && bitsize == 32) 5952 return (bi_shaddxl_s32_to(b, bi_temp(b->shader), src0, src1, shift))->dest[0]; 5953 else if ((type == nir_type_uint) && bitsize == 32) 5954 return (bi_shaddxl_u32_to(b, bi_temp(b->shader), src0, src1, shift))->dest[0]; 5955 else 5956 unreachable("Invalid parameters for SHADDXL"); 5957} 5958 5959static inline 5960bi_instr * bi_shift_double_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2) 5961{ 5962 bi_instr *I = rzalloc(b->shader, bi_instr); 5963 I->op = BI_OPCODE_SHIFT_DOUBLE_I32; 5964 I->dest[0] = dest0; 5965 I->src[0] = src0; 5966 I->src[1] = src1; 5967 I->src[2] = src2; 5968 bi_builder_insert(&b->cursor, I); 5969 return I; 5970} 5971 5972static inline 5973bi_index bi_shift_double_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2) 5974{ 5975 return (bi_shift_double_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0]; 5976} 5977 5978 5979static inline 5980bi_instr * bi_store_i128(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 5981{ 5982 bi_instr *I = rzalloc(b->shader, bi_instr); 5983 I->op = BI_OPCODE_STORE_I128; 5984 I->src[0] = src0; 5985 I->src[1] = src1; 5986 I->src[2] = src2; 5987 I->seg = seg; 5988 bi_builder_insert(&b->cursor, I); 5989 return I; 5990} 5991 5992 5993static inline 5994bi_instr * bi_store_i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 5995{ 5996 bi_instr *I = rzalloc(b->shader, bi_instr); 5997 I->op = BI_OPCODE_STORE_I16; 5998 I->src[0] = src0; 5999 I->src[1] = src1; 6000 I->src[2] = src2; 6001 I->seg = seg; 6002 I->extend = BI_EXTEND_ZEXT; 6003 bi_builder_insert(&b->cursor, I); 6004 return I; 6005} 6006 6007 6008static inline 6009bi_instr * bi_store_i24(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 6010{ 6011 bi_instr *I = rzalloc(b->shader, bi_instr); 6012 I->op = BI_OPCODE_STORE_I24; 6013 I->src[0] = src0; 6014 I->src[1] = src1; 6015 I->src[2] = src2; 6016 I->seg = seg; 6017 I->extend = BI_EXTEND_ZEXT; 6018 bi_builder_insert(&b->cursor, I); 6019 return I; 6020} 6021 6022 6023static inline 6024bi_instr * bi_store_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 6025{ 6026 bi_instr *I = rzalloc(b->shader, bi_instr); 6027 I->op = BI_OPCODE_STORE_I32; 6028 I->src[0] = src0; 6029 I->src[1] = src1; 6030 I->src[2] = src2; 6031 I->seg = seg; 6032 bi_builder_insert(&b->cursor, I); 6033 return I; 6034} 6035 6036 6037static inline 6038bi_instr * bi_store_i48(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 6039{ 6040 bi_instr *I = rzalloc(b->shader, bi_instr); 6041 I->op = BI_OPCODE_STORE_I48; 6042 I->src[0] = src0; 6043 I->src[1] = src1; 6044 I->src[2] = src2; 6045 I->seg = seg; 6046 bi_builder_insert(&b->cursor, I); 6047 return I; 6048} 6049 6050 6051static inline 6052bi_instr * bi_store_i64(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 6053{ 6054 bi_instr *I = rzalloc(b->shader, bi_instr); 6055 I->op = BI_OPCODE_STORE_I64; 6056 I->src[0] = src0; 6057 I->src[1] = src1; 6058 I->src[2] = src2; 6059 I->seg = seg; 6060 bi_builder_insert(&b->cursor, I); 6061 return I; 6062} 6063 6064 6065static inline 6066bi_instr * bi_store_i8(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 6067{ 6068 bi_instr *I = rzalloc(b->shader, bi_instr); 6069 I->op = BI_OPCODE_STORE_I8; 6070 I->src[0] = src0; 6071 I->src[1] = src1; 6072 I->src[2] = src2; 6073 I->seg = seg; 6074 I->extend = BI_EXTEND_ZEXT; 6075 bi_builder_insert(&b->cursor, I); 6076 return I; 6077} 6078 6079 6080static inline 6081bi_instr * bi_store_i96(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 6082{ 6083 bi_instr *I = rzalloc(b->shader, bi_instr); 6084 I->op = BI_OPCODE_STORE_I96; 6085 I->src[0] = src0; 6086 I->src[1] = src1; 6087 I->src[2] = src2; 6088 I->seg = seg; 6089 bi_builder_insert(&b->cursor, I); 6090 return I; 6091} 6092 6093 6094static inline 6095bi_instr * bi_store(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg) 6096{ 6097 if (bitsize == 128) 6098 return (bi_store_i128(b, src0, src1, src2, seg)); 6099 else if (bitsize == 16) 6100 return (bi_store_i16(b, src0, src1, src2, seg)); 6101 else if (bitsize == 24) 6102 return (bi_store_i24(b, src0, src1, src2, seg)); 6103 else if (bitsize == 32) 6104 return (bi_store_i32(b, src0, src1, src2, seg)); 6105 else if (bitsize == 48) 6106 return (bi_store_i48(b, src0, src1, src2, seg)); 6107 else if (bitsize == 64) 6108 return (bi_store_i64(b, src0, src1, src2, seg)); 6109 else if (bitsize == 8) 6110 return (bi_store_i8(b, src0, src1, src2, seg)); 6111 else if (bitsize == 96) 6112 return (bi_store_i96(b, src0, src1, src2, seg)); 6113 else 6114 unreachable("Invalid parameters for STORE"); 6115} 6116 6117static inline 6118bi_instr * bi_st_cvt(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_register_format register_format, enum bi_vecsize vecsize) 6119{ 6120 bi_instr *I = rzalloc(b->shader, bi_instr); 6121 I->op = BI_OPCODE_ST_CVT; 6122 I->src[0] = src0; 6123 I->src[1] = src1; 6124 I->src[2] = src2; 6125 I->src[3] = src3; 6126 I->register_format = register_format; 6127 I->vecsize = vecsize; 6128 bi_builder_insert(&b->cursor, I); 6129 return I; 6130} 6131 6132 6133static inline 6134bi_instr * bi_st_tile(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_vecsize vecsize) 6135{ 6136 bi_instr *I = rzalloc(b->shader, bi_instr); 6137 I->op = BI_OPCODE_ST_TILE; 6138 I->src[0] = src0; 6139 I->src[1] = src1; 6140 I->src[2] = src2; 6141 I->src[3] = src3; 6142 I->vecsize = vecsize; 6143 bi_builder_insert(&b->cursor, I); 6144 return I; 6145} 6146 6147 6148static inline 6149bi_instr * bi_swz_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0) 6150{ 6151 bi_instr *I = rzalloc(b->shader, bi_instr); 6152 I->op = BI_OPCODE_SWZ_V2I16; 6153 I->dest[0] = dest0; 6154 I->src[0] = src0; 6155 bi_builder_insert(&b->cursor, I); 6156 return I; 6157} 6158 6159static inline 6160bi_index bi_swz_v2i16(bi_builder *b, bi_index src0) 6161{ 6162 return (bi_swz_v2i16_to(b, bi_temp(b->shader), src0))->dest[0]; 6163} 6164 6165 6166static inline 6167bi_instr * bi_swz_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0) 6168{ 6169 bi_instr *I = rzalloc(b->shader, bi_instr); 6170 I->op = BI_OPCODE_SWZ_V4I8; 6171 I->dest[0] = dest0; 6172 I->src[0] = src0; 6173 bi_builder_insert(&b->cursor, I); 6174 return I; 6175} 6176 6177static inline 6178bi_index bi_swz_v4i8(bi_builder *b, bi_index src0) 6179{ 6180 return (bi_swz_v4i8_to(b, bi_temp(b->shader), src0))->dest[0]; 6181} 6182 6183 6184static inline 6185bi_instr * bi_swz_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0) 6186{ 6187 if (bitsize == 16) 6188 return (bi_swz_v2i16_to(b, dest0, src0)); 6189 else if (bitsize == 8) 6190 return (bi_swz_v4i8_to(b, dest0, src0)); 6191 else 6192 unreachable("Invalid parameters for SWZ"); 6193} 6194 6195static inline 6196bi_index bi_swz(bi_builder *b, unsigned bitsize, bi_index src0) 6197{ 6198 if (bitsize == 16) 6199 return (bi_swz_v2i16_to(b, bi_temp(b->shader), src0))->dest[0]; 6200 else if (bitsize == 8) 6201 return (bi_swz_v4i8_to(b, bi_temp(b->shader), src0))->dest[0]; 6202 else 6203 unreachable("Invalid parameters for SWZ"); 6204} 6205 6206static inline 6207bi_instr * bi_texc_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bi_index src3, bool lod_mode, uint32_t sr_count) 6208{ 6209 bi_instr *I = rzalloc(b->shader, bi_instr); 6210 I->op = BI_OPCODE_TEXC; 6211 I->dest[0] = dest0; 6212 I->src[0] = src0; 6213 I->src[1] = src1; 6214 I->src[2] = src2; 6215 I->src[3] = src3; 6216 I->lod_mode = lod_mode; 6217 I->sr_count = sr_count; 6218 bi_builder_insert(&b->cursor, I); 6219 return I; 6220} 6221 6222static inline 6223bi_index bi_texc(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, bool lod_mode, uint32_t sr_count) 6224{ 6225 return (bi_texc_to(b, bi_temp(b->shader), src0, src1, src2, src3, lod_mode, sr_count))->dest[0]; 6226} 6227 6228 6229static inline 6230bi_instr * bi_texs_2d_f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool lod_mode, uint32_t sampler_index, uint32_t texture_index) 6231{ 6232 bi_instr *I = rzalloc(b->shader, bi_instr); 6233 I->op = BI_OPCODE_TEXS_2D_F16; 6234 I->dest[0] = dest0; 6235 I->src[0] = src0; 6236 I->src[1] = src1; 6237 I->lod_mode = lod_mode; 6238 I->sampler_index = sampler_index; 6239 I->texture_index = texture_index; 6240 bi_builder_insert(&b->cursor, I); 6241 return I; 6242} 6243 6244static inline 6245bi_index bi_texs_2d_f16(bi_builder *b, bi_index src0, bi_index src1, bool lod_mode, uint32_t sampler_index, uint32_t texture_index) 6246{ 6247 return (bi_texs_2d_f16_to(b, bi_temp(b->shader), src0, src1, lod_mode, sampler_index, texture_index))->dest[0]; 6248} 6249 6250 6251static inline 6252bi_instr * bi_texs_2d_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool lod_mode, uint32_t sampler_index, uint32_t texture_index) 6253{ 6254 bi_instr *I = rzalloc(b->shader, bi_instr); 6255 I->op = BI_OPCODE_TEXS_2D_F32; 6256 I->dest[0] = dest0; 6257 I->src[0] = src0; 6258 I->src[1] = src1; 6259 I->lod_mode = lod_mode; 6260 I->sampler_index = sampler_index; 6261 I->texture_index = texture_index; 6262 bi_builder_insert(&b->cursor, I); 6263 return I; 6264} 6265 6266static inline 6267bi_index bi_texs_2d_f32(bi_builder *b, bi_index src0, bi_index src1, bool lod_mode, uint32_t sampler_index, uint32_t texture_index) 6268{ 6269 return (bi_texs_2d_f32_to(b, bi_temp(b->shader), src0, src1, lod_mode, sampler_index, texture_index))->dest[0]; 6270} 6271 6272 6273static inline 6274bi_instr * bi_texs_2d_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bool lod_mode, uint32_t sampler_index, uint32_t texture_index) 6275{ 6276 if (bitsize == 16) 6277 return (bi_texs_2d_f16_to(b, dest0, src0, src1, lod_mode, sampler_index, texture_index)); 6278 else if (bitsize == 32) 6279 return (bi_texs_2d_f32_to(b, dest0, src0, src1, lod_mode, sampler_index, texture_index)); 6280 else 6281 unreachable("Invalid parameters for TEXS_2D"); 6282} 6283 6284static inline 6285bi_index bi_texs_2d(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bool lod_mode, uint32_t sampler_index, uint32_t texture_index) 6286{ 6287 if (bitsize == 16) 6288 return (bi_texs_2d_f16_to(b, bi_temp(b->shader), src0, src1, lod_mode, sampler_index, texture_index))->dest[0]; 6289 else if (bitsize == 32) 6290 return (bi_texs_2d_f32_to(b, bi_temp(b->shader), src0, src1, lod_mode, sampler_index, texture_index))->dest[0]; 6291 else 6292 unreachable("Invalid parameters for TEXS_2D"); 6293} 6294 6295static inline 6296bi_instr * bi_texs_cube_f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, uint32_t sampler_index, uint32_t texture_index) 6297{ 6298 bi_instr *I = rzalloc(b->shader, bi_instr); 6299 I->op = BI_OPCODE_TEXS_CUBE_F16; 6300 I->dest[0] = dest0; 6301 I->src[0] = src0; 6302 I->src[1] = src1; 6303 I->src[2] = src2; 6304 I->sampler_index = sampler_index; 6305 I->texture_index = texture_index; 6306 bi_builder_insert(&b->cursor, I); 6307 return I; 6308} 6309 6310static inline 6311bi_index bi_texs_cube_f16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, uint32_t sampler_index, uint32_t texture_index) 6312{ 6313 return (bi_texs_cube_f16_to(b, bi_temp(b->shader), src0, src1, src2, sampler_index, texture_index))->dest[0]; 6314} 6315 6316 6317static inline 6318bi_instr * bi_texs_cube_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, uint32_t sampler_index, uint32_t texture_index) 6319{ 6320 bi_instr *I = rzalloc(b->shader, bi_instr); 6321 I->op = BI_OPCODE_TEXS_CUBE_F32; 6322 I->dest[0] = dest0; 6323 I->src[0] = src0; 6324 I->src[1] = src1; 6325 I->src[2] = src2; 6326 I->sampler_index = sampler_index; 6327 I->texture_index = texture_index; 6328 bi_builder_insert(&b->cursor, I); 6329 return I; 6330} 6331 6332static inline 6333bi_index bi_texs_cube_f32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, uint32_t sampler_index, uint32_t texture_index) 6334{ 6335 return (bi_texs_cube_f32_to(b, bi_temp(b->shader), src0, src1, src2, sampler_index, texture_index))->dest[0]; 6336} 6337 6338 6339static inline 6340bi_instr * bi_texs_cube_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, uint32_t sampler_index, uint32_t texture_index) 6341{ 6342 if (bitsize == 16) 6343 return (bi_texs_cube_f16_to(b, dest0, src0, src1, src2, sampler_index, texture_index)); 6344 else if (bitsize == 32) 6345 return (bi_texs_cube_f32_to(b, dest0, src0, src1, src2, sampler_index, texture_index)); 6346 else 6347 unreachable("Invalid parameters for TEXS_CUBE"); 6348} 6349 6350static inline 6351bi_index bi_texs_cube(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2, uint32_t sampler_index, uint32_t texture_index) 6352{ 6353 if (bitsize == 16) 6354 return (bi_texs_cube_f16_to(b, bi_temp(b->shader), src0, src1, src2, sampler_index, texture_index))->dest[0]; 6355 else if (bitsize == 32) 6356 return (bi_texs_cube_f32_to(b, bi_temp(b->shader), src0, src1, src2, sampler_index, texture_index))->dest[0]; 6357 else 6358 unreachable("Invalid parameters for TEXS_CUBE"); 6359} 6360 6361static inline 6362bi_instr * bi_u16_to_f32_to(bi_builder *b, bi_index dest0, bi_index src0) 6363{ 6364 bi_instr *I = rzalloc(b->shader, bi_instr); 6365 I->op = BI_OPCODE_U16_TO_F32; 6366 I->dest[0] = dest0; 6367 I->src[0] = src0; 6368 bi_builder_insert(&b->cursor, I); 6369 return I; 6370} 6371 6372static inline 6373bi_index bi_u16_to_f32(bi_builder *b, bi_index src0) 6374{ 6375 return (bi_u16_to_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 6376} 6377 6378 6379static inline 6380bi_instr * bi_u16_to_u32_to(bi_builder *b, bi_index dest0, bi_index src0) 6381{ 6382 bi_instr *I = rzalloc(b->shader, bi_instr); 6383 I->op = BI_OPCODE_U16_TO_U32; 6384 I->dest[0] = dest0; 6385 I->src[0] = src0; 6386 bi_builder_insert(&b->cursor, I); 6387 return I; 6388} 6389 6390static inline 6391bi_index bi_u16_to_u32(bi_builder *b, bi_index src0) 6392{ 6393 return (bi_u16_to_u32_to(b, bi_temp(b->shader), src0))->dest[0]; 6394} 6395 6396 6397static inline 6398bi_instr * bi_u32_to_f32_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round) 6399{ 6400 bi_instr *I = rzalloc(b->shader, bi_instr); 6401 I->op = BI_OPCODE_U32_TO_F32; 6402 I->dest[0] = dest0; 6403 I->src[0] = src0; 6404 I->round = round; 6405 bi_builder_insert(&b->cursor, I); 6406 return I; 6407} 6408 6409static inline 6410bi_index bi_u32_to_f32(bi_builder *b, bi_index src0, enum bi_round round) 6411{ 6412 return (bi_u32_to_f32_to(b, bi_temp(b->shader), src0, round))->dest[0]; 6413} 6414 6415 6416static inline 6417bi_instr * bi_u8_to_f32_to(bi_builder *b, bi_index dest0, bi_index src0) 6418{ 6419 bi_instr *I = rzalloc(b->shader, bi_instr); 6420 I->op = BI_OPCODE_U8_TO_F32; 6421 I->dest[0] = dest0; 6422 I->src[0] = src0; 6423 bi_builder_insert(&b->cursor, I); 6424 return I; 6425} 6426 6427static inline 6428bi_index bi_u8_to_f32(bi_builder *b, bi_index src0) 6429{ 6430 return (bi_u8_to_f32_to(b, bi_temp(b->shader), src0))->dest[0]; 6431} 6432 6433 6434static inline 6435bi_instr * bi_u8_to_u32_to(bi_builder *b, bi_index dest0, bi_index src0) 6436{ 6437 bi_instr *I = rzalloc(b->shader, bi_instr); 6438 I->op = BI_OPCODE_U8_TO_U32; 6439 I->dest[0] = dest0; 6440 I->src[0] = src0; 6441 bi_builder_insert(&b->cursor, I); 6442 return I; 6443} 6444 6445static inline 6446bi_index bi_u8_to_u32(bi_builder *b, bi_index src0) 6447{ 6448 return (bi_u8_to_u32_to(b, bi_temp(b->shader), src0))->dest[0]; 6449} 6450 6451 6452static inline 6453bi_instr * bi_v2f16_to_v2s16_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round) 6454{ 6455 bi_instr *I = rzalloc(b->shader, bi_instr); 6456 I->op = BI_OPCODE_V2F16_TO_V2S16; 6457 I->dest[0] = dest0; 6458 I->src[0] = src0; 6459 I->round = round; 6460 bi_builder_insert(&b->cursor, I); 6461 return I; 6462} 6463 6464static inline 6465bi_index bi_v2f16_to_v2s16(bi_builder *b, bi_index src0, enum bi_round round) 6466{ 6467 return (bi_v2f16_to_v2s16_to(b, bi_temp(b->shader), src0, round))->dest[0]; 6468} 6469 6470 6471static inline 6472bi_instr * bi_v2f16_to_v2u16_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round) 6473{ 6474 bi_instr *I = rzalloc(b->shader, bi_instr); 6475 I->op = BI_OPCODE_V2F16_TO_V2U16; 6476 I->dest[0] = dest0; 6477 I->src[0] = src0; 6478 I->round = round; 6479 bi_builder_insert(&b->cursor, I); 6480 return I; 6481} 6482 6483static inline 6484bi_index bi_v2f16_to_v2u16(bi_builder *b, bi_index src0, enum bi_round round) 6485{ 6486 return (bi_v2f16_to_v2u16_to(b, bi_temp(b->shader), src0, round))->dest[0]; 6487} 6488 6489 6490static inline 6491bi_instr * bi_v2f32_to_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round) 6492{ 6493 bi_instr *I = rzalloc(b->shader, bi_instr); 6494 I->op = BI_OPCODE_V2F32_TO_V2F16; 6495 I->dest[0] = dest0; 6496 I->src[0] = src0; 6497 I->src[1] = src1; 6498 I->round = round; 6499 bi_builder_insert(&b->cursor, I); 6500 return I; 6501} 6502 6503static inline 6504bi_index bi_v2f32_to_v2f16(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round) 6505{ 6506 return (bi_v2f32_to_v2f16_to(b, bi_temp(b->shader), src0, src1, round))->dest[0]; 6507} 6508 6509 6510static inline 6511bi_instr * bi_v2s16_to_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round) 6512{ 6513 bi_instr *I = rzalloc(b->shader, bi_instr); 6514 I->op = BI_OPCODE_V2S16_TO_V2F16; 6515 I->dest[0] = dest0; 6516 I->src[0] = src0; 6517 I->round = round; 6518 bi_builder_insert(&b->cursor, I); 6519 return I; 6520} 6521 6522static inline 6523bi_index bi_v2s16_to_v2f16(bi_builder *b, bi_index src0, enum bi_round round) 6524{ 6525 return (bi_v2s16_to_v2f16_to(b, bi_temp(b->shader), src0, round))->dest[0]; 6526} 6527 6528 6529static inline 6530bi_instr * bi_v2s8_to_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0) 6531{ 6532 bi_instr *I = rzalloc(b->shader, bi_instr); 6533 I->op = BI_OPCODE_V2S8_TO_V2F16; 6534 I->dest[0] = dest0; 6535 I->src[0] = src0; 6536 bi_builder_insert(&b->cursor, I); 6537 return I; 6538} 6539 6540static inline 6541bi_index bi_v2s8_to_v2f16(bi_builder *b, bi_index src0) 6542{ 6543 return (bi_v2s8_to_v2f16_to(b, bi_temp(b->shader), src0))->dest[0]; 6544} 6545 6546 6547static inline 6548bi_instr * bi_v2s8_to_v2s16_to(bi_builder *b, bi_index dest0, bi_index src0) 6549{ 6550 bi_instr *I = rzalloc(b->shader, bi_instr); 6551 I->op = BI_OPCODE_V2S8_TO_V2S16; 6552 I->dest[0] = dest0; 6553 I->src[0] = src0; 6554 bi_builder_insert(&b->cursor, I); 6555 return I; 6556} 6557 6558static inline 6559bi_index bi_v2s8_to_v2s16(bi_builder *b, bi_index src0) 6560{ 6561 return (bi_v2s8_to_v2s16_to(b, bi_temp(b->shader), src0))->dest[0]; 6562} 6563 6564 6565static inline 6566bi_instr * bi_v2u16_to_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round) 6567{ 6568 bi_instr *I = rzalloc(b->shader, bi_instr); 6569 I->op = BI_OPCODE_V2U16_TO_V2F16; 6570 I->dest[0] = dest0; 6571 I->src[0] = src0; 6572 I->round = round; 6573 bi_builder_insert(&b->cursor, I); 6574 return I; 6575} 6576 6577static inline 6578bi_index bi_v2u16_to_v2f16(bi_builder *b, bi_index src0, enum bi_round round) 6579{ 6580 return (bi_v2u16_to_v2f16_to(b, bi_temp(b->shader), src0, round))->dest[0]; 6581} 6582 6583 6584static inline 6585bi_instr * bi_v2u8_to_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0) 6586{ 6587 bi_instr *I = rzalloc(b->shader, bi_instr); 6588 I->op = BI_OPCODE_V2U8_TO_V2F16; 6589 I->dest[0] = dest0; 6590 I->src[0] = src0; 6591 bi_builder_insert(&b->cursor, I); 6592 return I; 6593} 6594 6595static inline 6596bi_index bi_v2u8_to_v2f16(bi_builder *b, bi_index src0) 6597{ 6598 return (bi_v2u8_to_v2f16_to(b, bi_temp(b->shader), src0))->dest[0]; 6599} 6600 6601 6602static inline 6603bi_instr * bi_v2u8_to_v2u16_to(bi_builder *b, bi_index dest0, bi_index src0) 6604{ 6605 bi_instr *I = rzalloc(b->shader, bi_instr); 6606 I->op = BI_OPCODE_V2U8_TO_V2U16; 6607 I->dest[0] = dest0; 6608 I->src[0] = src0; 6609 bi_builder_insert(&b->cursor, I); 6610 return I; 6611} 6612 6613static inline 6614bi_index bi_v2u8_to_v2u16(bi_builder *b, bi_index src0) 6615{ 6616 return (bi_v2u8_to_v2u16_to(b, bi_temp(b->shader), src0))->dest[0]; 6617} 6618 6619 6620static inline 6621bi_instr * bi_var_tex_f16_to(bi_builder *b, bi_index dest0, bool lod_mode, enum bi_sample sample, enum bi_update update, uint32_t texture_index, uint32_t varying_index) 6622{ 6623 bi_instr *I = rzalloc(b->shader, bi_instr); 6624 I->op = BI_OPCODE_VAR_TEX_F16; 6625 I->dest[0] = dest0; 6626 I->update = update; 6627 I->lod_mode = lod_mode; 6628 I->sample = sample; 6629 I->texture_index = texture_index; 6630 I->varying_index = varying_index; 6631 bi_builder_insert(&b->cursor, I); 6632 return I; 6633} 6634 6635static inline 6636bi_index bi_var_tex_f16(bi_builder *b, bool lod_mode, enum bi_sample sample, enum bi_update update, uint32_t texture_index, uint32_t varying_index) 6637{ 6638 return (bi_var_tex_f16_to(b, bi_temp(b->shader), lod_mode, sample, update, texture_index, varying_index))->dest[0]; 6639} 6640 6641 6642static inline 6643bi_instr * bi_var_tex_f32_to(bi_builder *b, bi_index dest0, bool lod_mode, enum bi_sample sample, enum bi_update update, uint32_t texture_index, uint32_t varying_index) 6644{ 6645 bi_instr *I = rzalloc(b->shader, bi_instr); 6646 I->op = BI_OPCODE_VAR_TEX_F32; 6647 I->dest[0] = dest0; 6648 I->update = update; 6649 I->lod_mode = lod_mode; 6650 I->sample = sample; 6651 I->texture_index = texture_index; 6652 I->varying_index = varying_index; 6653 bi_builder_insert(&b->cursor, I); 6654 return I; 6655} 6656 6657static inline 6658bi_index bi_var_tex_f32(bi_builder *b, bool lod_mode, enum bi_sample sample, enum bi_update update, uint32_t texture_index, uint32_t varying_index) 6659{ 6660 return (bi_var_tex_f32_to(b, bi_temp(b->shader), lod_mode, sample, update, texture_index, varying_index))->dest[0]; 6661} 6662 6663 6664static inline 6665bi_instr * bi_var_tex_to(bi_builder *b, unsigned bitsize, bi_index dest0, bool lod_mode, enum bi_sample sample, enum bi_update update, uint32_t texture_index, uint32_t varying_index) 6666{ 6667 if (bitsize == 16) 6668 return (bi_var_tex_f16_to(b, dest0, lod_mode, sample, update, texture_index, varying_index)); 6669 else if (bitsize == 32) 6670 return (bi_var_tex_f32_to(b, dest0, lod_mode, sample, update, texture_index, varying_index)); 6671 else 6672 unreachable("Invalid parameters for VAR_TEX"); 6673} 6674 6675static inline 6676bi_index bi_var_tex(bi_builder *b, unsigned bitsize, bool lod_mode, enum bi_sample sample, enum bi_update update, uint32_t texture_index, uint32_t varying_index) 6677{ 6678 if (bitsize == 16) 6679 return (bi_var_tex_f16_to(b, bi_temp(b->shader), lod_mode, sample, update, texture_index, varying_index))->dest[0]; 6680 else if (bitsize == 32) 6681 return (bi_var_tex_f32_to(b, bi_temp(b->shader), lod_mode, sample, update, texture_index, varying_index))->dest[0]; 6682 else 6683 unreachable("Invalid parameters for VAR_TEX"); 6684} 6685 6686static inline 6687bi_instr * bi_vn_asst1_f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bool h, bool l) 6688{ 6689 bi_instr *I = rzalloc(b->shader, bi_instr); 6690 I->op = BI_OPCODE_VN_ASST1_F16; 6691 I->dest[0] = dest0; 6692 I->src[0] = src0; 6693 I->src[1] = src1; 6694 I->src[2] = src2; 6695 I->h = h; 6696 I->l = l; 6697 bi_builder_insert(&b->cursor, I); 6698 return I; 6699} 6700 6701static inline 6702bi_index bi_vn_asst1_f16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bool h, bool l) 6703{ 6704 return (bi_vn_asst1_f16_to(b, bi_temp(b->shader), src0, src1, src2, h, l))->dest[0]; 6705} 6706 6707 6708static inline 6709bi_instr * bi_vn_asst1_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bi_index src3) 6710{ 6711 bi_instr *I = rzalloc(b->shader, bi_instr); 6712 I->op = BI_OPCODE_VN_ASST1_F32; 6713 I->dest[0] = dest0; 6714 I->src[0] = src0; 6715 I->src[1] = src1; 6716 I->src[2] = src2; 6717 I->src[3] = src3; 6718 bi_builder_insert(&b->cursor, I); 6719 return I; 6720} 6721 6722static inline 6723bi_index bi_vn_asst1_f32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3) 6724{ 6725 return (bi_vn_asst1_f32_to(b, bi_temp(b->shader), src0, src1, src2, src3))->dest[0]; 6726} 6727 6728 6729static inline 6730bi_instr * bi_vn_asst2_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bool scale) 6731{ 6732 bi_instr *I = rzalloc(b->shader, bi_instr); 6733 I->op = BI_OPCODE_VN_ASST2_F32; 6734 I->dest[0] = dest0; 6735 I->src[0] = src0; 6736 I->scale = scale; 6737 bi_builder_insert(&b->cursor, I); 6738 return I; 6739} 6740 6741static inline 6742bi_index bi_vn_asst2_f32(bi_builder *b, bi_index src0, bool scale) 6743{ 6744 return (bi_vn_asst2_f32_to(b, bi_temp(b->shader), src0, scale))->dest[0]; 6745} 6746 6747 6748static inline 6749bi_instr * bi_vn_asst2_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0) 6750{ 6751 bi_instr *I = rzalloc(b->shader, bi_instr); 6752 I->op = BI_OPCODE_VN_ASST2_V2F16; 6753 I->dest[0] = dest0; 6754 I->src[0] = src0; 6755 bi_builder_insert(&b->cursor, I); 6756 return I; 6757} 6758 6759static inline 6760bi_index bi_vn_asst2_v2f16(bi_builder *b, bi_index src0) 6761{ 6762 return (bi_vn_asst2_v2f16_to(b, bi_temp(b->shader), src0))->dest[0]; 6763} 6764 6765 6766static inline 6767bi_instr * bi_wmask_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_subgroup subgroup, uint32_t fill) 6768{ 6769 bi_instr *I = rzalloc(b->shader, bi_instr); 6770 I->op = BI_OPCODE_WMASK; 6771 I->dest[0] = dest0; 6772 I->src[0] = src0; 6773 I->subgroup = subgroup; 6774 I->fill = fill; 6775 bi_builder_insert(&b->cursor, I); 6776 return I; 6777} 6778 6779static inline 6780bi_index bi_wmask(bi_builder *b, bi_index src0, enum bi_subgroup subgroup, uint32_t fill) 6781{ 6782 return (bi_wmask_to(b, bi_temp(b->shader), src0, subgroup, fill))->dest[0]; 6783} 6784 6785 6786static inline 6787bi_instr * bi_zs_emit_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bool stencil, bool z) 6788{ 6789 bi_instr *I = rzalloc(b->shader, bi_instr); 6790 I->op = BI_OPCODE_ZS_EMIT; 6791 I->dest[0] = dest0; 6792 I->src[0] = src0; 6793 I->src[1] = src1; 6794 I->src[2] = src2; 6795 I->stencil = stencil; 6796 I->z = z; 6797 bi_builder_insert(&b->cursor, I); 6798 return I; 6799} 6800 6801static inline 6802bi_index bi_zs_emit(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bool stencil, bool z) 6803{ 6804 return (bi_zs_emit_to(b, bi_temp(b->shader), src0, src1, src2, stencil, z))->dest[0]; 6805} 6806 6807 6808#endif 6809