196c5ddc4Srjs/*
296c5ddc4Srjs * Copyright (C) 2020 Collabora, Ltd.
396c5ddc4Srjs *
496c5ddc4Srjs * Permission is hereby granted, free of charge, to any person obtaining a
596c5ddc4Srjs * copy of this software and associated documentation files (the "Software"),
696c5ddc4Srjs * to deal in the Software without restriction, including without limitation
796c5ddc4Srjs * the rights to use, copy, modify, merge, publish, distribute, sublicense,
896c5ddc4Srjs * and/or sell copies of the Software, and to permit persons to whom the
996c5ddc4Srjs * Software is furnished to do so, subject to the following conditions:
1096c5ddc4Srjs *
1196c5ddc4Srjs * The above copyright notice and this permission notice (including the next
1296c5ddc4Srjs * paragraph) shall be included in all copies or substantial portions of the
1396c5ddc4Srjs * Software.
1496c5ddc4Srjs *
1596c5ddc4Srjs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1696c5ddc4Srjs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1796c5ddc4Srjs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1896c5ddc4Srjs * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1996c5ddc4Srjs * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2096c5ddc4Srjs * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2196c5ddc4Srjs * SOFTWARE.
2296c5ddc4Srjs */
2396c5ddc4Srjs
2496c5ddc4Srjs/* Autogenerated file, do not edit */
2596c5ddc4Srjs
2696c5ddc4Srjs
2796c5ddc4Srjs#ifndef _BI_BUILDER_H_
2896c5ddc4Srjs#define _BI_BUILDER_H_
2996c5ddc4Srjs
3096c5ddc4Srjs#include "compiler.h"
3196c5ddc4Srjs
3296c5ddc4Srjs
3396c5ddc4Srjs
3496c5ddc4Srjsstatic inline
3596c5ddc4Srjsbi_instr * bi_acmpstore_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
3696c5ddc4Srjs{
3796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
3896c5ddc4Srjs    I->op = BI_OPCODE_ACMPSTORE_I32;
3996c5ddc4Srjs    I->src[0] = src0;
4096c5ddc4Srjs    I->src[1] = src1;
4196c5ddc4Srjs    I->src[2] = src2;
4296c5ddc4Srjs    I->seg = seg;
4396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
4496c5ddc4Srjs    return I;
4596c5ddc4Srjs}
4696c5ddc4Srjs
4796c5ddc4Srjs
4896c5ddc4Srjsstatic inline
4996c5ddc4Srjsbi_instr * bi_acmpstore_i64(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
5096c5ddc4Srjs{
5196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
5296c5ddc4Srjs    I->op = BI_OPCODE_ACMPSTORE_I64;
5396c5ddc4Srjs    I->src[0] = src0;
5496c5ddc4Srjs    I->src[1] = src1;
5596c5ddc4Srjs    I->src[2] = src2;
5696c5ddc4Srjs    I->seg = seg;
5796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
5896c5ddc4Srjs    return I;
5996c5ddc4Srjs}
6096c5ddc4Srjs
6196c5ddc4Srjs
6296c5ddc4Srjsstatic inline
6396c5ddc4Srjsbi_instr * bi_acmpstore(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
6496c5ddc4Srjs{
6596c5ddc4Srjs    if (bitsize == 32)
6696c5ddc4Srjs        return (bi_acmpstore_i32(b, src0, src1, src2, seg));
6796c5ddc4Srjs    else if (bitsize == 64)
6896c5ddc4Srjs        return (bi_acmpstore_i64(b, src0, src1, src2, seg));
6996c5ddc4Srjs    else
7096c5ddc4Srjs        unreachable("Invalid parameters for ACMPSTORE");
7196c5ddc4Srjs}
7296c5ddc4Srjs
7396c5ddc4Srjsstatic inline
7496c5ddc4Srjsbi_instr * bi_acmpxchg_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
7596c5ddc4Srjs{
7696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
7796c5ddc4Srjs    I->op = BI_OPCODE_ACMPXCHG_I32;
7896c5ddc4Srjs    I->dest[0] = dest0;
7996c5ddc4Srjs    I->src[0] = src0;
8096c5ddc4Srjs    I->src[1] = src1;
8196c5ddc4Srjs    I->src[2] = src2;
8296c5ddc4Srjs    I->seg = seg;
8396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
8496c5ddc4Srjs    return I;
8596c5ddc4Srjs}
8696c5ddc4Srjs
8796c5ddc4Srjsstatic inline
8896c5ddc4Srjsbi_index bi_acmpxchg_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
8996c5ddc4Srjs{
9096c5ddc4Srjs    return (bi_acmpxchg_i32_to(b, bi_temp(b->shader), src0, src1, src2, seg))->dest[0];
9196c5ddc4Srjs}
9296c5ddc4Srjs
9396c5ddc4Srjs
9496c5ddc4Srjsstatic inline
9596c5ddc4Srjsbi_instr * bi_acmpxchg_i64_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
9696c5ddc4Srjs{
9796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
9896c5ddc4Srjs    I->op = BI_OPCODE_ACMPXCHG_I64;
9996c5ddc4Srjs    I->dest[0] = dest0;
10096c5ddc4Srjs    I->src[0] = src0;
10196c5ddc4Srjs    I->src[1] = src1;
10296c5ddc4Srjs    I->src[2] = src2;
10396c5ddc4Srjs    I->seg = seg;
10496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
10596c5ddc4Srjs    return I;
10696c5ddc4Srjs}
10796c5ddc4Srjs
10896c5ddc4Srjsstatic inline
10996c5ddc4Srjsbi_index bi_acmpxchg_i64(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
11096c5ddc4Srjs{
11196c5ddc4Srjs    return (bi_acmpxchg_i64_to(b, bi_temp(b->shader), src0, src1, src2, seg))->dest[0];
11296c5ddc4Srjs}
11396c5ddc4Srjs
11496c5ddc4Srjs
11596c5ddc4Srjsstatic inline
11696c5ddc4Srjsbi_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)
11796c5ddc4Srjs{
11896c5ddc4Srjs    if (bitsize == 32)
11996c5ddc4Srjs        return (bi_acmpxchg_i32_to(b, dest0, src0, src1, src2, seg));
12096c5ddc4Srjs    else if (bitsize == 64)
12196c5ddc4Srjs        return (bi_acmpxchg_i64_to(b, dest0, src0, src1, src2, seg));
12296c5ddc4Srjs    else
12396c5ddc4Srjs        unreachable("Invalid parameters for ACMPXCHG");
12496c5ddc4Srjs}
12596c5ddc4Srjs
12696c5ddc4Srjsstatic inline
12796c5ddc4Srjsbi_index bi_acmpxchg(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
12896c5ddc4Srjs{
12996c5ddc4Srjs    if (bitsize == 32)
13096c5ddc4Srjs        return (bi_acmpxchg_i32_to(b, bi_temp(b->shader), src0, src1, src2, seg))->dest[0];
13196c5ddc4Srjs    else if (bitsize == 64)
13296c5ddc4Srjs        return (bi_acmpxchg_i64_to(b, bi_temp(b->shader), src0, src1, src2, seg))->dest[0];
13396c5ddc4Srjs    else
13496c5ddc4Srjs        unreachable("Invalid parameters for ACMPXCHG");
13596c5ddc4Srjs}
13696c5ddc4Srjs
13796c5ddc4Srjsstatic inline
13896c5ddc4Srjsbi_instr * bi_arshift_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
13996c5ddc4Srjs{
14096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
14196c5ddc4Srjs    I->op = BI_OPCODE_ARSHIFT_I32;
14296c5ddc4Srjs    I->dest[0] = dest0;
14396c5ddc4Srjs    I->src[0] = src0;
14496c5ddc4Srjs    I->src[1] = src1;
14596c5ddc4Srjs    I->src[2] = src2;
14696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
14796c5ddc4Srjs    return I;
14896c5ddc4Srjs}
14996c5ddc4Srjs
15096c5ddc4Srjsstatic inline
15196c5ddc4Srjsbi_index bi_arshift_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
15296c5ddc4Srjs{
15396c5ddc4Srjs    return (bi_arshift_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
15496c5ddc4Srjs}
15596c5ddc4Srjs
15696c5ddc4Srjs
15796c5ddc4Srjsstatic inline
15896c5ddc4Srjsbi_instr * bi_arshift_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
15996c5ddc4Srjs{
16096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
16196c5ddc4Srjs    I->op = BI_OPCODE_ARSHIFT_V2I16;
16296c5ddc4Srjs    I->dest[0] = dest0;
16396c5ddc4Srjs    I->src[0] = src0;
16496c5ddc4Srjs    I->src[1] = src1;
16596c5ddc4Srjs    I->src[2] = src2;
16696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
16796c5ddc4Srjs    return I;
16896c5ddc4Srjs}
16996c5ddc4Srjs
17096c5ddc4Srjsstatic inline
17196c5ddc4Srjsbi_index bi_arshift_v2i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
17296c5ddc4Srjs{
17396c5ddc4Srjs    return (bi_arshift_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
17496c5ddc4Srjs}
17596c5ddc4Srjs
17696c5ddc4Srjs
17796c5ddc4Srjsstatic inline
17896c5ddc4Srjsbi_instr * bi_arshift_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
17996c5ddc4Srjs{
18096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
18196c5ddc4Srjs    I->op = BI_OPCODE_ARSHIFT_V4I8;
18296c5ddc4Srjs    I->dest[0] = dest0;
18396c5ddc4Srjs    I->src[0] = src0;
18496c5ddc4Srjs    I->src[1] = src1;
18596c5ddc4Srjs    I->src[2] = src2;
18696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
18796c5ddc4Srjs    return I;
18896c5ddc4Srjs}
18996c5ddc4Srjs
19096c5ddc4Srjsstatic inline
19196c5ddc4Srjsbi_index bi_arshift_v4i8(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
19296c5ddc4Srjs{
19396c5ddc4Srjs    return (bi_arshift_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
19496c5ddc4Srjs}
19596c5ddc4Srjs
19696c5ddc4Srjs
19796c5ddc4Srjsstatic inline
19896c5ddc4Srjsbi_instr * bi_arshift_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
19996c5ddc4Srjs{
20096c5ddc4Srjs    if (bitsize == 32)
20196c5ddc4Srjs        return (bi_arshift_i32_to(b, dest0, src0, src1, src2));
20296c5ddc4Srjs    else if (bitsize == 16)
20396c5ddc4Srjs        return (bi_arshift_v2i16_to(b, dest0, src0, src1, src2));
20496c5ddc4Srjs    else if (bitsize == 8)
20596c5ddc4Srjs        return (bi_arshift_v4i8_to(b, dest0, src0, src1, src2));
20696c5ddc4Srjs    else
20796c5ddc4Srjs        unreachable("Invalid parameters for ARSHIFT");
20896c5ddc4Srjs}
20996c5ddc4Srjs
21096c5ddc4Srjsstatic inline
21196c5ddc4Srjsbi_index bi_arshift(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2)
21296c5ddc4Srjs{
21396c5ddc4Srjs    if (bitsize == 32)
21496c5ddc4Srjs        return (bi_arshift_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
21596c5ddc4Srjs    else if (bitsize == 16)
21696c5ddc4Srjs        return (bi_arshift_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
21796c5ddc4Srjs    else if (bitsize == 8)
21896c5ddc4Srjs        return (bi_arshift_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
21996c5ddc4Srjs    else
22096c5ddc4Srjs        unreachable("Invalid parameters for ARSHIFT");
22196c5ddc4Srjs}
22296c5ddc4Srjs
22396c5ddc4Srjsstatic inline
22496c5ddc4Srjsbi_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)
22596c5ddc4Srjs{
22696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
22796c5ddc4Srjs    I->op = BI_OPCODE_ARSHIFT_DOUBLE_I32;
22896c5ddc4Srjs    I->dest[0] = dest0;
22996c5ddc4Srjs    I->src[0] = src0;
23096c5ddc4Srjs    I->src[1] = src1;
23196c5ddc4Srjs    I->src[2] = src2;
23296c5ddc4Srjs    I->bytes2 = bytes2;
23396c5ddc4Srjs    I->result_word = result_word;
23496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
23596c5ddc4Srjs    return I;
23696c5ddc4Srjs}
23796c5ddc4Srjs
23896c5ddc4Srjsstatic inline
23996c5ddc4Srjsbi_index bi_arshift_double_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bool bytes2, bool result_word)
24096c5ddc4Srjs{
24196c5ddc4Srjs    return (bi_arshift_double_i32_to(b, bi_temp(b->shader), src0, src1, src2, bytes2, result_word))->dest[0];
24296c5ddc4Srjs}
24396c5ddc4Srjs
24496c5ddc4Srjs
24596c5ddc4Srjsstatic inline
24696c5ddc4Srjsbi_instr * bi_atest_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1)
24796c5ddc4Srjs{
24896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
24996c5ddc4Srjs    I->op = BI_OPCODE_ATEST;
25096c5ddc4Srjs    I->dest[0] = dest0;
25196c5ddc4Srjs    I->src[0] = src0;
25296c5ddc4Srjs    I->src[1] = src1;
25396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
25496c5ddc4Srjs    return I;
25596c5ddc4Srjs}
25696c5ddc4Srjs
25796c5ddc4Srjsstatic inline
25896c5ddc4Srjsbi_index bi_atest(bi_builder *b, bi_index src0, bi_index src1)
25996c5ddc4Srjs{
26096c5ddc4Srjs    return (bi_atest_to(b, bi_temp(b->shader), src0, src1))->dest[0];
26196c5ddc4Srjs}
26296c5ddc4Srjs
26396c5ddc4Srjs
26496c5ddc4Srjsstatic inline
26596c5ddc4Srjsbi_instr * bi_atom_c_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_atom_opc atom_opc)
26696c5ddc4Srjs{
26796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
26896c5ddc4Srjs    I->op = BI_OPCODE_ATOM_C_I32;
26996c5ddc4Srjs    I->src[0] = src0;
27096c5ddc4Srjs    I->src[1] = src1;
27196c5ddc4Srjs    I->src[2] = src2;
27296c5ddc4Srjs    I->atom_opc = atom_opc;
27396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
27496c5ddc4Srjs    return I;
27596c5ddc4Srjs}
27696c5ddc4Srjs
27796c5ddc4Srjs
27896c5ddc4Srjsstatic inline
27996c5ddc4Srjsbi_instr * bi_atom_c_i64(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_atom_opc atom_opc)
28096c5ddc4Srjs{
28196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
28296c5ddc4Srjs    I->op = BI_OPCODE_ATOM_C_I64;
28396c5ddc4Srjs    I->src[0] = src0;
28496c5ddc4Srjs    I->src[1] = src1;
28596c5ddc4Srjs    I->src[2] = src2;
28696c5ddc4Srjs    I->atom_opc = atom_opc;
28796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
28896c5ddc4Srjs    return I;
28996c5ddc4Srjs}
29096c5ddc4Srjs
29196c5ddc4Srjs
29296c5ddc4Srjsstatic inline
29396c5ddc4Srjsbi_instr * bi_atom_c(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2, enum bi_atom_opc atom_opc)
29496c5ddc4Srjs{
29596c5ddc4Srjs    if (bitsize == 32)
29696c5ddc4Srjs        return (bi_atom_c_i32(b, src0, src1, src2, atom_opc));
29796c5ddc4Srjs    else if (bitsize == 64)
29896c5ddc4Srjs        return (bi_atom_c_i64(b, src0, src1, src2, atom_opc));
29996c5ddc4Srjs    else
30096c5ddc4Srjs        unreachable("Invalid parameters for ATOM_C");
30196c5ddc4Srjs}
30296c5ddc4Srjs
30396c5ddc4Srjsstatic inline
30496c5ddc4Srjsbi_instr * bi_atom_c1_i32(bi_builder *b, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc)
30596c5ddc4Srjs{
30696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
30796c5ddc4Srjs    I->op = BI_OPCODE_ATOM_C1_I32;
30896c5ddc4Srjs    I->src[0] = src0;
30996c5ddc4Srjs    I->src[1] = src1;
31096c5ddc4Srjs    I->atom_opc = atom_opc;
31196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
31296c5ddc4Srjs    return I;
31396c5ddc4Srjs}
31496c5ddc4Srjs
31596c5ddc4Srjs
31696c5ddc4Srjsstatic inline
31796c5ddc4Srjsbi_instr * bi_atom_c1_i64(bi_builder *b, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc)
31896c5ddc4Srjs{
31996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
32096c5ddc4Srjs    I->op = BI_OPCODE_ATOM_C1_I64;
32196c5ddc4Srjs    I->src[0] = src0;
32296c5ddc4Srjs    I->src[1] = src1;
32396c5ddc4Srjs    I->atom_opc = atom_opc;
32496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
32596c5ddc4Srjs    return I;
32696c5ddc4Srjs}
32796c5ddc4Srjs
32896c5ddc4Srjs
32996c5ddc4Srjsstatic inline
33096c5ddc4Srjsbi_instr * bi_atom_c1(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc)
33196c5ddc4Srjs{
33296c5ddc4Srjs    if (bitsize == 32)
33396c5ddc4Srjs        return (bi_atom_c1_i32(b, src0, src1, atom_opc));
33496c5ddc4Srjs    else if (bitsize == 64)
33596c5ddc4Srjs        return (bi_atom_c1_i64(b, src0, src1, atom_opc));
33696c5ddc4Srjs    else
33796c5ddc4Srjs        unreachable("Invalid parameters for ATOM_C1");
33896c5ddc4Srjs}
33996c5ddc4Srjs
34096c5ddc4Srjsstatic inline
34196c5ddc4Srjsbi_instr * bi_atom_c1_return_i32(bi_builder *b, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc)
34296c5ddc4Srjs{
34396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
34496c5ddc4Srjs    I->op = BI_OPCODE_ATOM_C1_RETURN_I32;
34596c5ddc4Srjs    I->src[0] = src0;
34696c5ddc4Srjs    I->src[1] = src1;
34796c5ddc4Srjs    I->atom_opc = atom_opc;
34896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
34996c5ddc4Srjs    return I;
35096c5ddc4Srjs}
35196c5ddc4Srjs
35296c5ddc4Srjs
35396c5ddc4Srjsstatic inline
35496c5ddc4Srjsbi_instr * bi_atom_c1_return_i64(bi_builder *b, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc)
35596c5ddc4Srjs{
35696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
35796c5ddc4Srjs    I->op = BI_OPCODE_ATOM_C1_RETURN_I64;
35896c5ddc4Srjs    I->src[0] = src0;
35996c5ddc4Srjs    I->src[1] = src1;
36096c5ddc4Srjs    I->atom_opc = atom_opc;
36196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
36296c5ddc4Srjs    return I;
36396c5ddc4Srjs}
36496c5ddc4Srjs
36596c5ddc4Srjs
36696c5ddc4Srjsstatic inline
36796c5ddc4Srjsbi_instr * bi_atom_c1_return(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc)
36896c5ddc4Srjs{
36996c5ddc4Srjs    if (bitsize == 32)
37096c5ddc4Srjs        return (bi_atom_c1_return_i32(b, src0, src1, atom_opc));
37196c5ddc4Srjs    else if (bitsize == 64)
37296c5ddc4Srjs        return (bi_atom_c1_return_i64(b, src0, src1, atom_opc));
37396c5ddc4Srjs    else
37496c5ddc4Srjs        unreachable("Invalid parameters for ATOM_C1_RETURN");
37596c5ddc4Srjs}
37696c5ddc4Srjs
37796c5ddc4Srjsstatic inline
37896c5ddc4Srjsbi_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)
37996c5ddc4Srjs{
38096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
38196c5ddc4Srjs    I->op = BI_OPCODE_ATOM_CX;
38296c5ddc4Srjs    I->dest[0] = dest0;
38396c5ddc4Srjs    I->src[0] = src0;
38496c5ddc4Srjs    I->src[1] = src1;
38596c5ddc4Srjs    I->src[2] = src2;
38696c5ddc4Srjs    I->src[3] = src3;
38796c5ddc4Srjs    I->sr_count = sr_count;
38896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
38996c5ddc4Srjs    return I;
39096c5ddc4Srjs}
39196c5ddc4Srjs
39296c5ddc4Srjsstatic inline
39396c5ddc4Srjsbi_index bi_atom_cx(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, uint32_t sr_count)
39496c5ddc4Srjs{
39596c5ddc4Srjs    return (bi_atom_cx_to(b, bi_temp(b->shader), src0, src1, src2, src3, sr_count))->dest[0];
39696c5ddc4Srjs}
39796c5ddc4Srjs
39896c5ddc4Srjs
39996c5ddc4Srjsstatic inline
40096c5ddc4Srjsbi_instr * bi_atom_c_return_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_atom_opc atom_opc)
40196c5ddc4Srjs{
40296c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
40396c5ddc4Srjs    I->op = BI_OPCODE_ATOM_C_RETURN_I32;
40496c5ddc4Srjs    I->src[0] = src0;
40596c5ddc4Srjs    I->src[1] = src1;
40696c5ddc4Srjs    I->src[2] = src2;
40796c5ddc4Srjs    I->atom_opc = atom_opc;
40896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
40996c5ddc4Srjs    return I;
41096c5ddc4Srjs}
41196c5ddc4Srjs
41296c5ddc4Srjs
41396c5ddc4Srjsstatic inline
41496c5ddc4Srjsbi_instr * bi_atom_c_return_i64(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_atom_opc atom_opc)
41596c5ddc4Srjs{
41696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
41796c5ddc4Srjs    I->op = BI_OPCODE_ATOM_C_RETURN_I64;
41896c5ddc4Srjs    I->src[0] = src0;
41996c5ddc4Srjs    I->src[1] = src1;
42096c5ddc4Srjs    I->src[2] = src2;
42196c5ddc4Srjs    I->atom_opc = atom_opc;
42296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
42396c5ddc4Srjs    return I;
42496c5ddc4Srjs}
42596c5ddc4Srjs
42696c5ddc4Srjs
42796c5ddc4Srjsstatic inline
42896c5ddc4Srjsbi_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)
42996c5ddc4Srjs{
43096c5ddc4Srjs    if (bitsize == 32)
43196c5ddc4Srjs        return (bi_atom_c_return_i32(b, src0, src1, src2, atom_opc));
43296c5ddc4Srjs    else if (bitsize == 64)
43396c5ddc4Srjs        return (bi_atom_c_return_i64(b, src0, src1, src2, atom_opc));
43496c5ddc4Srjs    else
43596c5ddc4Srjs        unreachable("Invalid parameters for ATOM_C_RETURN");
43696c5ddc4Srjs}
43796c5ddc4Srjs
43896c5ddc4Srjsstatic inline
43996c5ddc4Srjsbi_instr * bi_atom_post_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc)
44096c5ddc4Srjs{
44196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
44296c5ddc4Srjs    I->op = BI_OPCODE_ATOM_POST_I32;
44396c5ddc4Srjs    I->dest[0] = dest0;
44496c5ddc4Srjs    I->src[0] = src0;
44596c5ddc4Srjs    I->src[1] = src1;
44696c5ddc4Srjs    I->atom_opc = atom_opc;
44796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
44896c5ddc4Srjs    return I;
44996c5ddc4Srjs}
45096c5ddc4Srjs
45196c5ddc4Srjsstatic inline
45296c5ddc4Srjsbi_index bi_atom_post_i32(bi_builder *b, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc)
45396c5ddc4Srjs{
45496c5ddc4Srjs    return (bi_atom_post_i32_to(b, bi_temp(b->shader), src0, src1, atom_opc))->dest[0];
45596c5ddc4Srjs}
45696c5ddc4Srjs
45796c5ddc4Srjs
45896c5ddc4Srjsstatic inline
45996c5ddc4Srjsbi_instr * bi_atom_post_i64_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc)
46096c5ddc4Srjs{
46196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
46296c5ddc4Srjs    I->op = BI_OPCODE_ATOM_POST_I64;
46396c5ddc4Srjs    I->dest[0] = dest0;
46496c5ddc4Srjs    I->src[0] = src0;
46596c5ddc4Srjs    I->src[1] = src1;
46696c5ddc4Srjs    I->atom_opc = atom_opc;
46796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
46896c5ddc4Srjs    return I;
46996c5ddc4Srjs}
47096c5ddc4Srjs
47196c5ddc4Srjsstatic inline
47296c5ddc4Srjsbi_index bi_atom_post_i64(bi_builder *b, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc)
47396c5ddc4Srjs{
47496c5ddc4Srjs    return (bi_atom_post_i64_to(b, bi_temp(b->shader), src0, src1, atom_opc))->dest[0];
47596c5ddc4Srjs}
47696c5ddc4Srjs
47796c5ddc4Srjs
47896c5ddc4Srjsstatic inline
47996c5ddc4Srjsbi_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)
48096c5ddc4Srjs{
48196c5ddc4Srjs    if (bitsize == 32)
48296c5ddc4Srjs        return (bi_atom_post_i32_to(b, dest0, src0, src1, atom_opc));
48396c5ddc4Srjs    else if (bitsize == 64)
48496c5ddc4Srjs        return (bi_atom_post_i64_to(b, dest0, src0, src1, atom_opc));
48596c5ddc4Srjs    else
48696c5ddc4Srjs        unreachable("Invalid parameters for ATOM_POST");
48796c5ddc4Srjs}
48896c5ddc4Srjs
48996c5ddc4Srjsstatic inline
49096c5ddc4Srjsbi_index bi_atom_post(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc)
49196c5ddc4Srjs{
49296c5ddc4Srjs    if (bitsize == 32)
49396c5ddc4Srjs        return (bi_atom_post_i32_to(b, bi_temp(b->shader), src0, src1, atom_opc))->dest[0];
49496c5ddc4Srjs    else if (bitsize == 64)
49596c5ddc4Srjs        return (bi_atom_post_i64_to(b, bi_temp(b->shader), src0, src1, atom_opc))->dest[0];
49696c5ddc4Srjs    else
49796c5ddc4Srjs        unreachable("Invalid parameters for ATOM_POST");
49896c5ddc4Srjs}
49996c5ddc4Srjs
50096c5ddc4Srjsstatic inline
50196c5ddc4Srjsbi_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)
50296c5ddc4Srjs{
50396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
50496c5ddc4Srjs    I->op = BI_OPCODE_ATOM_PRE_I64;
50596c5ddc4Srjs    I->dest[0] = dest0;
50696c5ddc4Srjs    I->src[0] = src0;
50796c5ddc4Srjs    I->src[1] = src1;
50896c5ddc4Srjs    I->src[2] = src2;
50996c5ddc4Srjs    I->atom_opc = atom_opc;
51096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
51196c5ddc4Srjs    return I;
51296c5ddc4Srjs}
51396c5ddc4Srjs
51496c5ddc4Srjsstatic inline
51596c5ddc4Srjsbi_index bi_atom_pre_i64(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_atom_opc atom_opc)
51696c5ddc4Srjs{
51796c5ddc4Srjs    return (bi_atom_pre_i64_to(b, bi_temp(b->shader), src0, src1, src2, atom_opc))->dest[0];
51896c5ddc4Srjs}
51996c5ddc4Srjs
52096c5ddc4Srjs
52196c5ddc4Srjsstatic inline
52296c5ddc4Srjsbi_instr * bi_axchg_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
52396c5ddc4Srjs{
52496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
52596c5ddc4Srjs    I->op = BI_OPCODE_AXCHG_I32;
52696c5ddc4Srjs    I->dest[0] = dest0;
52796c5ddc4Srjs    I->src[0] = src0;
52896c5ddc4Srjs    I->src[1] = src1;
52996c5ddc4Srjs    I->src[2] = src2;
53096c5ddc4Srjs    I->seg = seg;
53196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
53296c5ddc4Srjs    return I;
53396c5ddc4Srjs}
53496c5ddc4Srjs
53596c5ddc4Srjsstatic inline
53696c5ddc4Srjsbi_index bi_axchg_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
53796c5ddc4Srjs{
53896c5ddc4Srjs    return (bi_axchg_i32_to(b, bi_temp(b->shader), src0, src1, src2, seg))->dest[0];
53996c5ddc4Srjs}
54096c5ddc4Srjs
54196c5ddc4Srjs
54296c5ddc4Srjsstatic inline
54396c5ddc4Srjsbi_instr * bi_axchg_i64_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
54496c5ddc4Srjs{
54596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
54696c5ddc4Srjs    I->op = BI_OPCODE_AXCHG_I64;
54796c5ddc4Srjs    I->dest[0] = dest0;
54896c5ddc4Srjs    I->src[0] = src0;
54996c5ddc4Srjs    I->src[1] = src1;
55096c5ddc4Srjs    I->src[2] = src2;
55196c5ddc4Srjs    I->seg = seg;
55296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
55396c5ddc4Srjs    return I;
55496c5ddc4Srjs}
55596c5ddc4Srjs
55696c5ddc4Srjsstatic inline
55796c5ddc4Srjsbi_index bi_axchg_i64(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
55896c5ddc4Srjs{
55996c5ddc4Srjs    return (bi_axchg_i64_to(b, bi_temp(b->shader), src0, src1, src2, seg))->dest[0];
56096c5ddc4Srjs}
56196c5ddc4Srjs
56296c5ddc4Srjs
56396c5ddc4Srjsstatic inline
56496c5ddc4Srjsbi_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)
56596c5ddc4Srjs{
56696c5ddc4Srjs    if (bitsize == 32)
56796c5ddc4Srjs        return (bi_axchg_i32_to(b, dest0, src0, src1, src2, seg));
56896c5ddc4Srjs    else if (bitsize == 64)
56996c5ddc4Srjs        return (bi_axchg_i64_to(b, dest0, src0, src1, src2, seg));
57096c5ddc4Srjs    else
57196c5ddc4Srjs        unreachable("Invalid parameters for AXCHG");
57296c5ddc4Srjs}
57396c5ddc4Srjs
57496c5ddc4Srjsstatic inline
57596c5ddc4Srjsbi_index bi_axchg(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
57696c5ddc4Srjs{
57796c5ddc4Srjs    if (bitsize == 32)
57896c5ddc4Srjs        return (bi_axchg_i32_to(b, bi_temp(b->shader), src0, src1, src2, seg))->dest[0];
57996c5ddc4Srjs    else if (bitsize == 64)
58096c5ddc4Srjs        return (bi_axchg_i64_to(b, bi_temp(b->shader), src0, src1, src2, seg))->dest[0];
58196c5ddc4Srjs    else
58296c5ddc4Srjs        unreachable("Invalid parameters for AXCHG");
58396c5ddc4Srjs}
58496c5ddc4Srjs
58596c5ddc4Srjsstatic inline
58696c5ddc4Srjsbi_instr * bi_barrier(bi_builder *b)
58796c5ddc4Srjs{
58896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
58996c5ddc4Srjs    I->op = BI_OPCODE_BARRIER;
59096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
59196c5ddc4Srjs    return I;
59296c5ddc4Srjs}
59396c5ddc4Srjs
59496c5ddc4Srjs
59596c5ddc4Srjsstatic inline
59696c5ddc4Srjsbi_instr * bi_bitrev_i32_to(bi_builder *b, bi_index dest0, bi_index src0)
59796c5ddc4Srjs{
59896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
59996c5ddc4Srjs    I->op = BI_OPCODE_BITREV_I32;
60096c5ddc4Srjs    I->dest[0] = dest0;
60196c5ddc4Srjs    I->src[0] = src0;
60296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
60396c5ddc4Srjs    return I;
60496c5ddc4Srjs}
60596c5ddc4Srjs
60696c5ddc4Srjsstatic inline
60796c5ddc4Srjsbi_index bi_bitrev_i32(bi_builder *b, bi_index src0)
60896c5ddc4Srjs{
60996c5ddc4Srjs    return (bi_bitrev_i32_to(b, bi_temp(b->shader), src0))->dest[0];
61096c5ddc4Srjs}
61196c5ddc4Srjs
61296c5ddc4Srjs
61396c5ddc4Srjsstatic inline
61496c5ddc4Srjsbi_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)
61596c5ddc4Srjs{
61696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
61796c5ddc4Srjs    I->op = BI_OPCODE_BLEND;
61896c5ddc4Srjs    I->dest[0] = dest0;
61996c5ddc4Srjs    I->src[0] = src0;
62096c5ddc4Srjs    I->src[1] = src1;
62196c5ddc4Srjs    I->src[2] = src2;
62296c5ddc4Srjs    I->src[3] = src3;
62396c5ddc4Srjs    I->sr_count = sr_count;
62496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
62596c5ddc4Srjs    return I;
62696c5ddc4Srjs}
62796c5ddc4Srjs
62896c5ddc4Srjsstatic inline
62996c5ddc4Srjsbi_index bi_blend(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, uint32_t sr_count)
63096c5ddc4Srjs{
63196c5ddc4Srjs    return (bi_blend_to(b, bi_temp(b->shader), src0, src1, src2, src3, sr_count))->dest[0];
63296c5ddc4Srjs}
63396c5ddc4Srjs
63496c5ddc4Srjs
63596c5ddc4Srjsstatic inline
63696c5ddc4Srjsbi_instr * bi_branch_f16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_cmpf cmpf)
63796c5ddc4Srjs{
63896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
63996c5ddc4Srjs    I->op = BI_OPCODE_BRANCH_F16;
64096c5ddc4Srjs    I->src[0] = src0;
64196c5ddc4Srjs    I->src[1] = src1;
64296c5ddc4Srjs    I->src[2] = src2;
64396c5ddc4Srjs    I->cmpf = cmpf;
64496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
64596c5ddc4Srjs    return I;
64696c5ddc4Srjs}
64796c5ddc4Srjs
64896c5ddc4Srjs
64996c5ddc4Srjsstatic inline
65096c5ddc4Srjsbi_instr * bi_branch_f32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_cmpf cmpf)
65196c5ddc4Srjs{
65296c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
65396c5ddc4Srjs    I->op = BI_OPCODE_BRANCH_F32;
65496c5ddc4Srjs    I->src[0] = src0;
65596c5ddc4Srjs    I->src[1] = src1;
65696c5ddc4Srjs    I->src[2] = src2;
65796c5ddc4Srjs    I->cmpf = cmpf;
65896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
65996c5ddc4Srjs    return I;
66096c5ddc4Srjs}
66196c5ddc4Srjs
66296c5ddc4Srjs
66396c5ddc4Srjsstatic inline
66496c5ddc4Srjsbi_instr * bi_branch_i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_cmpf cmpf)
66596c5ddc4Srjs{
66696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
66796c5ddc4Srjs    I->op = BI_OPCODE_BRANCH_I16;
66896c5ddc4Srjs    I->src[0] = src0;
66996c5ddc4Srjs    I->src[1] = src1;
67096c5ddc4Srjs    I->src[2] = src2;
67196c5ddc4Srjs    I->cmpf = cmpf;
67296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
67396c5ddc4Srjs    return I;
67496c5ddc4Srjs}
67596c5ddc4Srjs
67696c5ddc4Srjs
67796c5ddc4Srjsstatic inline
67896c5ddc4Srjsbi_instr * bi_branch_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_cmpf cmpf)
67996c5ddc4Srjs{
68096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
68196c5ddc4Srjs    I->op = BI_OPCODE_BRANCH_I32;
68296c5ddc4Srjs    I->src[0] = src0;
68396c5ddc4Srjs    I->src[1] = src1;
68496c5ddc4Srjs    I->src[2] = src2;
68596c5ddc4Srjs    I->cmpf = cmpf;
68696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
68796c5ddc4Srjs    return I;
68896c5ddc4Srjs}
68996c5ddc4Srjs
69096c5ddc4Srjs
69196c5ddc4Srjsstatic inline
69296c5ddc4Srjsbi_instr * bi_branch_s16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_cmpf cmpf)
69396c5ddc4Srjs{
69496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
69596c5ddc4Srjs    I->op = BI_OPCODE_BRANCH_S16;
69696c5ddc4Srjs    I->src[0] = src0;
69796c5ddc4Srjs    I->src[1] = src1;
69896c5ddc4Srjs    I->src[2] = src2;
69996c5ddc4Srjs    I->cmpf = cmpf;
70096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
70196c5ddc4Srjs    return I;
70296c5ddc4Srjs}
70396c5ddc4Srjs
70496c5ddc4Srjs
70596c5ddc4Srjsstatic inline
70696c5ddc4Srjsbi_instr * bi_branch_s32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_cmpf cmpf)
70796c5ddc4Srjs{
70896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
70996c5ddc4Srjs    I->op = BI_OPCODE_BRANCH_S32;
71096c5ddc4Srjs    I->src[0] = src0;
71196c5ddc4Srjs    I->src[1] = src1;
71296c5ddc4Srjs    I->src[2] = src2;
71396c5ddc4Srjs    I->cmpf = cmpf;
71496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
71596c5ddc4Srjs    return I;
71696c5ddc4Srjs}
71796c5ddc4Srjs
71896c5ddc4Srjs
71996c5ddc4Srjsstatic inline
72096c5ddc4Srjsbi_instr * bi_branch_u16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_cmpf cmpf)
72196c5ddc4Srjs{
72296c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
72396c5ddc4Srjs    I->op = BI_OPCODE_BRANCH_U16;
72496c5ddc4Srjs    I->src[0] = src0;
72596c5ddc4Srjs    I->src[1] = src1;
72696c5ddc4Srjs    I->src[2] = src2;
72796c5ddc4Srjs    I->cmpf = cmpf;
72896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
72996c5ddc4Srjs    return I;
73096c5ddc4Srjs}
73196c5ddc4Srjs
73296c5ddc4Srjs
73396c5ddc4Srjsstatic inline
73496c5ddc4Srjsbi_instr * bi_branch_u32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_cmpf cmpf)
73596c5ddc4Srjs{
73696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
73796c5ddc4Srjs    I->op = BI_OPCODE_BRANCH_U32;
73896c5ddc4Srjs    I->src[0] = src0;
73996c5ddc4Srjs    I->src[1] = src1;
74096c5ddc4Srjs    I->src[2] = src2;
74196c5ddc4Srjs    I->cmpf = cmpf;
74296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
74396c5ddc4Srjs    return I;
74496c5ddc4Srjs}
74596c5ddc4Srjs
74696c5ddc4Srjs
74796c5ddc4Srjsstatic inline
74896c5ddc4Srjsbi_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)
74996c5ddc4Srjs{
75096c5ddc4Srjs    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))
75196c5ddc4Srjs        return (bi_branch_f16(b, src0, src1, src2, cmpf));
75296c5ddc4Srjs    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))
75396c5ddc4Srjs        return (bi_branch_f32(b, src0, src1, src2, cmpf));
75496c5ddc4Srjs    else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE))
75596c5ddc4Srjs        return (bi_branch_i16(b, src0, src1, src2, cmpf));
75696c5ddc4Srjs    else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE))
75796c5ddc4Srjs        return (bi_branch_i32(b, src0, src1, src2, cmpf));
75896c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
75996c5ddc4Srjs        return (bi_branch_s16(b, src0, src1, src2, cmpf));
76096c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
76196c5ddc4Srjs        return (bi_branch_s32(b, src0, src1, src2, cmpf));
76296c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
76396c5ddc4Srjs        return (bi_branch_u16(b, src0, src1, src2, cmpf));
76496c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
76596c5ddc4Srjs        return (bi_branch_u32(b, src0, src1, src2, cmpf));
76696c5ddc4Srjs    else
76796c5ddc4Srjs        unreachable("Invalid parameters for BRANCH");
76896c5ddc4Srjs}
76996c5ddc4Srjs
77096c5ddc4Srjsstatic inline
77196c5ddc4Srjsbi_instr * bi_branchc_i16(bi_builder *b, bi_index src0, bi_index src1, bool combine)
77296c5ddc4Srjs{
77396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
77496c5ddc4Srjs    I->op = BI_OPCODE_BRANCHC_I16;
77596c5ddc4Srjs    I->src[0] = src0;
77696c5ddc4Srjs    I->src[1] = src1;
77796c5ddc4Srjs    I->combine = combine;
77896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
77996c5ddc4Srjs    return I;
78096c5ddc4Srjs}
78196c5ddc4Srjs
78296c5ddc4Srjs
78396c5ddc4Srjsstatic inline
78496c5ddc4Srjsbi_instr * bi_branchc_i32(bi_builder *b, bi_index src0, bi_index src1, bool combine)
78596c5ddc4Srjs{
78696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
78796c5ddc4Srjs    I->op = BI_OPCODE_BRANCHC_I32;
78896c5ddc4Srjs    I->src[0] = src0;
78996c5ddc4Srjs    I->src[1] = src1;
79096c5ddc4Srjs    I->combine = combine;
79196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
79296c5ddc4Srjs    return I;
79396c5ddc4Srjs}
79496c5ddc4Srjs
79596c5ddc4Srjs
79696c5ddc4Srjsstatic inline
79796c5ddc4Srjsbi_instr * bi_branchc(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bool combine)
79896c5ddc4Srjs{
79996c5ddc4Srjs    if (bitsize == 16)
80096c5ddc4Srjs        return (bi_branchc_i16(b, src0, src1, combine));
80196c5ddc4Srjs    else if (bitsize == 32)
80296c5ddc4Srjs        return (bi_branchc_i32(b, src0, src1, combine));
80396c5ddc4Srjs    else
80496c5ddc4Srjs        unreachable("Invalid parameters for BRANCHC");
80596c5ddc4Srjs}
80696c5ddc4Srjs
80796c5ddc4Srjsstatic inline
80896c5ddc4Srjsbi_instr * bi_branchz_f16(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf)
80996c5ddc4Srjs{
81096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
81196c5ddc4Srjs    I->op = BI_OPCODE_BRANCHZ_F16;
81296c5ddc4Srjs    I->src[0] = src0;
81396c5ddc4Srjs    I->src[1] = src1;
81496c5ddc4Srjs    I->cmpf = cmpf;
81596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
81696c5ddc4Srjs    return I;
81796c5ddc4Srjs}
81896c5ddc4Srjs
81996c5ddc4Srjs
82096c5ddc4Srjsstatic inline
82196c5ddc4Srjsbi_instr * bi_branchz_f32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf)
82296c5ddc4Srjs{
82396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
82496c5ddc4Srjs    I->op = BI_OPCODE_BRANCHZ_F32;
82596c5ddc4Srjs    I->src[0] = src0;
82696c5ddc4Srjs    I->src[1] = src1;
82796c5ddc4Srjs    I->cmpf = cmpf;
82896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
82996c5ddc4Srjs    return I;
83096c5ddc4Srjs}
83196c5ddc4Srjs
83296c5ddc4Srjs
83396c5ddc4Srjsstatic inline
83496c5ddc4Srjsbi_instr * bi_branchz_i16(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf)
83596c5ddc4Srjs{
83696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
83796c5ddc4Srjs    I->op = BI_OPCODE_BRANCHZ_I16;
83896c5ddc4Srjs    I->src[0] = src0;
83996c5ddc4Srjs    I->src[1] = src1;
84096c5ddc4Srjs    I->cmpf = cmpf;
84196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
84296c5ddc4Srjs    return I;
84396c5ddc4Srjs}
84496c5ddc4Srjs
84596c5ddc4Srjs
84696c5ddc4Srjsstatic inline
84796c5ddc4Srjsbi_instr * bi_branchz_i32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf)
84896c5ddc4Srjs{
84996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
85096c5ddc4Srjs    I->op = BI_OPCODE_BRANCHZ_I32;
85196c5ddc4Srjs    I->src[0] = src0;
85296c5ddc4Srjs    I->src[1] = src1;
85396c5ddc4Srjs    I->cmpf = cmpf;
85496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
85596c5ddc4Srjs    return I;
85696c5ddc4Srjs}
85796c5ddc4Srjs
85896c5ddc4Srjs
85996c5ddc4Srjsstatic inline
86096c5ddc4Srjsbi_instr * bi_branchz_s16(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf)
86196c5ddc4Srjs{
86296c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
86396c5ddc4Srjs    I->op = BI_OPCODE_BRANCHZ_S16;
86496c5ddc4Srjs    I->src[0] = src0;
86596c5ddc4Srjs    I->src[1] = src1;
86696c5ddc4Srjs    I->cmpf = cmpf;
86796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
86896c5ddc4Srjs    return I;
86996c5ddc4Srjs}
87096c5ddc4Srjs
87196c5ddc4Srjs
87296c5ddc4Srjsstatic inline
87396c5ddc4Srjsbi_instr * bi_branchz_s32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf)
87496c5ddc4Srjs{
87596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
87696c5ddc4Srjs    I->op = BI_OPCODE_BRANCHZ_S32;
87796c5ddc4Srjs    I->src[0] = src0;
87896c5ddc4Srjs    I->src[1] = src1;
87996c5ddc4Srjs    I->cmpf = cmpf;
88096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
88196c5ddc4Srjs    return I;
88296c5ddc4Srjs}
88396c5ddc4Srjs
88496c5ddc4Srjs
88596c5ddc4Srjsstatic inline
88696c5ddc4Srjsbi_instr * bi_branchz_u16(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf)
88796c5ddc4Srjs{
88896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
88996c5ddc4Srjs    I->op = BI_OPCODE_BRANCHZ_U16;
89096c5ddc4Srjs    I->src[0] = src0;
89196c5ddc4Srjs    I->src[1] = src1;
89296c5ddc4Srjs    I->cmpf = cmpf;
89396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
89496c5ddc4Srjs    return I;
89596c5ddc4Srjs}
89696c5ddc4Srjs
89796c5ddc4Srjs
89896c5ddc4Srjsstatic inline
89996c5ddc4Srjsbi_instr * bi_branchz_u32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf)
90096c5ddc4Srjs{
90196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
90296c5ddc4Srjs    I->op = BI_OPCODE_BRANCHZ_U32;
90396c5ddc4Srjs    I->src[0] = src0;
90496c5ddc4Srjs    I->src[1] = src1;
90596c5ddc4Srjs    I->cmpf = cmpf;
90696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
90796c5ddc4Srjs    return I;
90896c5ddc4Srjs}
90996c5ddc4Srjs
91096c5ddc4Srjs
91196c5ddc4Srjsstatic inline
91296c5ddc4Srjsbi_instr * bi_branchz(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index src0, bi_index src1, enum bi_cmpf cmpf)
91396c5ddc4Srjs{
91496c5ddc4Srjs    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))
91596c5ddc4Srjs        return (bi_branchz_f16(b, src0, src1, cmpf));
91696c5ddc4Srjs    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))
91796c5ddc4Srjs        return (bi_branchz_f32(b, src0, src1, cmpf));
91896c5ddc4Srjs    else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE))
91996c5ddc4Srjs        return (bi_branchz_i16(b, src0, src1, cmpf));
92096c5ddc4Srjs    else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE))
92196c5ddc4Srjs        return (bi_branchz_i32(b, src0, src1, cmpf));
92296c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
92396c5ddc4Srjs        return (bi_branchz_s16(b, src0, src1, cmpf));
92496c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
92596c5ddc4Srjs        return (bi_branchz_s32(b, src0, src1, cmpf));
92696c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
92796c5ddc4Srjs        return (bi_branchz_u16(b, src0, src1, cmpf));
92896c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
92996c5ddc4Srjs        return (bi_branchz_u32(b, src0, src1, cmpf));
93096c5ddc4Srjs    else
93196c5ddc4Srjs        unreachable("Invalid parameters for BRANCHZ");
93296c5ddc4Srjs}
93396c5ddc4Srjs
93496c5ddc4Srjsstatic inline
93596c5ddc4Srjsbi_instr * bi_branch_diverg(bi_builder *b, bi_index src0)
93696c5ddc4Srjs{
93796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
93896c5ddc4Srjs    I->op = BI_OPCODE_BRANCH_DIVERG;
93996c5ddc4Srjs    I->src[0] = src0;
94096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
94196c5ddc4Srjs    return I;
94296c5ddc4Srjs}
94396c5ddc4Srjs
94496c5ddc4Srjs
94596c5ddc4Srjsstatic inline
94696c5ddc4Srjsbi_instr * bi_branch_lowbits_f32(bi_builder *b, bi_index src0, bi_index src1)
94796c5ddc4Srjs{
94896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
94996c5ddc4Srjs    I->op = BI_OPCODE_BRANCH_LOWBITS_F32;
95096c5ddc4Srjs    I->src[0] = src0;
95196c5ddc4Srjs    I->src[1] = src1;
95296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
95396c5ddc4Srjs    return I;
95496c5ddc4Srjs}
95596c5ddc4Srjs
95696c5ddc4Srjs
95796c5ddc4Srjsstatic inline
95896c5ddc4Srjsbi_instr * bi_branch_no_diverg(bi_builder *b, bi_index src0)
95996c5ddc4Srjs{
96096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
96196c5ddc4Srjs    I->op = BI_OPCODE_BRANCH_NO_DIVERG;
96296c5ddc4Srjs    I->src[0] = src0;
96396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
96496c5ddc4Srjs    return I;
96596c5ddc4Srjs}
96696c5ddc4Srjs
96796c5ddc4Srjs
96896c5ddc4Srjsstatic inline
96996c5ddc4Srjsbi_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)
97096c5ddc4Srjs{
97196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
97296c5ddc4Srjs    I->op = BI_OPCODE_CLPER_I32;
97396c5ddc4Srjs    I->dest[0] = dest0;
97496c5ddc4Srjs    I->src[0] = src0;
97596c5ddc4Srjs    I->src[1] = src1;
97696c5ddc4Srjs    I->lane_op = lane_op;
97796c5ddc4Srjs    I->subgroup = subgroup;
97896c5ddc4Srjs    I->inactive_result = inactive_result;
97996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
98096c5ddc4Srjs    return I;
98196c5ddc4Srjs}
98296c5ddc4Srjs
98396c5ddc4Srjsstatic inline
98496c5ddc4Srjsbi_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)
98596c5ddc4Srjs{
98696c5ddc4Srjs    return (bi_clper_i32_to(b, bi_temp(b->shader), src0, src1, inactive_result, lane_op, subgroup))->dest[0];
98796c5ddc4Srjs}
98896c5ddc4Srjs
98996c5ddc4Srjs
99096c5ddc4Srjsstatic inline
99196c5ddc4Srjsbi_instr * bi_clper_v6_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1)
99296c5ddc4Srjs{
99396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
99496c5ddc4Srjs    I->op = BI_OPCODE_CLPER_V6_I32;
99596c5ddc4Srjs    I->dest[0] = dest0;
99696c5ddc4Srjs    I->src[0] = src0;
99796c5ddc4Srjs    I->src[1] = src1;
99896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
99996c5ddc4Srjs    return I;
100096c5ddc4Srjs}
100196c5ddc4Srjs
100296c5ddc4Srjsstatic inline
100396c5ddc4Srjsbi_index bi_clper_v6_i32(bi_builder *b, bi_index src0, bi_index src1)
100496c5ddc4Srjs{
100596c5ddc4Srjs    return (bi_clper_v6_i32_to(b, bi_temp(b->shader), src0, src1))->dest[0];
100696c5ddc4Srjs}
100796c5ddc4Srjs
100896c5ddc4Srjs
100996c5ddc4Srjsstatic inline
101096c5ddc4Srjsbi_instr * bi_clz_u32_to(bi_builder *b, bi_index dest0, bi_index src0, bool mask)
101196c5ddc4Srjs{
101296c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
101396c5ddc4Srjs    I->op = BI_OPCODE_CLZ_U32;
101496c5ddc4Srjs    I->dest[0] = dest0;
101596c5ddc4Srjs    I->src[0] = src0;
101696c5ddc4Srjs    I->mask = mask;
101796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
101896c5ddc4Srjs    return I;
101996c5ddc4Srjs}
102096c5ddc4Srjs
102196c5ddc4Srjsstatic inline
102296c5ddc4Srjsbi_index bi_clz_u32(bi_builder *b, bi_index src0, bool mask)
102396c5ddc4Srjs{
102496c5ddc4Srjs    return (bi_clz_u32_to(b, bi_temp(b->shader), src0, mask))->dest[0];
102596c5ddc4Srjs}
102696c5ddc4Srjs
102796c5ddc4Srjs
102896c5ddc4Srjsstatic inline
102996c5ddc4Srjsbi_instr * bi_clz_v2u16_to(bi_builder *b, bi_index dest0, bi_index src0, bool mask)
103096c5ddc4Srjs{
103196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
103296c5ddc4Srjs    I->op = BI_OPCODE_CLZ_V2U16;
103396c5ddc4Srjs    I->dest[0] = dest0;
103496c5ddc4Srjs    I->src[0] = src0;
103596c5ddc4Srjs    I->mask = mask;
103696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
103796c5ddc4Srjs    return I;
103896c5ddc4Srjs}
103996c5ddc4Srjs
104096c5ddc4Srjsstatic inline
104196c5ddc4Srjsbi_index bi_clz_v2u16(bi_builder *b, bi_index src0, bool mask)
104296c5ddc4Srjs{
104396c5ddc4Srjs    return (bi_clz_v2u16_to(b, bi_temp(b->shader), src0, mask))->dest[0];
104496c5ddc4Srjs}
104596c5ddc4Srjs
104696c5ddc4Srjs
104796c5ddc4Srjsstatic inline
104896c5ddc4Srjsbi_instr * bi_clz_v4u8_to(bi_builder *b, bi_index dest0, bi_index src0, bool mask)
104996c5ddc4Srjs{
105096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
105196c5ddc4Srjs    I->op = BI_OPCODE_CLZ_V4U8;
105296c5ddc4Srjs    I->dest[0] = dest0;
105396c5ddc4Srjs    I->src[0] = src0;
105496c5ddc4Srjs    I->mask = mask;
105596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
105696c5ddc4Srjs    return I;
105796c5ddc4Srjs}
105896c5ddc4Srjs
105996c5ddc4Srjsstatic inline
106096c5ddc4Srjsbi_index bi_clz_v4u8(bi_builder *b, bi_index src0, bool mask)
106196c5ddc4Srjs{
106296c5ddc4Srjs    return (bi_clz_v4u8_to(b, bi_temp(b->shader), src0, mask))->dest[0];
106396c5ddc4Srjs}
106496c5ddc4Srjs
106596c5ddc4Srjs
106696c5ddc4Srjsstatic inline
106796c5ddc4Srjsbi_instr * bi_clz_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bool mask)
106896c5ddc4Srjs{
106996c5ddc4Srjs    if (bitsize == 32)
107096c5ddc4Srjs        return (bi_clz_u32_to(b, dest0, src0, mask));
107196c5ddc4Srjs    else if (bitsize == 16)
107296c5ddc4Srjs        return (bi_clz_v2u16_to(b, dest0, src0, mask));
107396c5ddc4Srjs    else if (bitsize == 8)
107496c5ddc4Srjs        return (bi_clz_v4u8_to(b, dest0, src0, mask));
107596c5ddc4Srjs    else
107696c5ddc4Srjs        unreachable("Invalid parameters for CLZ");
107796c5ddc4Srjs}
107896c5ddc4Srjs
107996c5ddc4Srjsstatic inline
108096c5ddc4Srjsbi_index bi_clz(bi_builder *b, unsigned bitsize, bi_index src0, bool mask)
108196c5ddc4Srjs{
108296c5ddc4Srjs    if (bitsize == 32)
108396c5ddc4Srjs        return (bi_clz_u32_to(b, bi_temp(b->shader), src0, mask))->dest[0];
108496c5ddc4Srjs    else if (bitsize == 16)
108596c5ddc4Srjs        return (bi_clz_v2u16_to(b, bi_temp(b->shader), src0, mask))->dest[0];
108696c5ddc4Srjs    else if (bitsize == 8)
108796c5ddc4Srjs        return (bi_clz_v4u8_to(b, bi_temp(b->shader), src0, mask))->dest[0];
108896c5ddc4Srjs    else
108996c5ddc4Srjs        unreachable("Invalid parameters for CLZ");
109096c5ddc4Srjs}
109196c5ddc4Srjs
109296c5ddc4Srjsstatic inline
109396c5ddc4Srjsbi_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)
109496c5ddc4Srjs{
109596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
109696c5ddc4Srjs    I->op = BI_OPCODE_CSEL_F32;
109796c5ddc4Srjs    I->dest[0] = dest0;
109896c5ddc4Srjs    I->src[0] = src0;
109996c5ddc4Srjs    I->src[1] = src1;
110096c5ddc4Srjs    I->src[2] = src2;
110196c5ddc4Srjs    I->src[3] = src3;
110296c5ddc4Srjs    I->cmpf = cmpf;
110396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
110496c5ddc4Srjs    return I;
110596c5ddc4Srjs}
110696c5ddc4Srjs
110796c5ddc4Srjsstatic inline
110896c5ddc4Srjsbi_index bi_csel_f32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf)
110996c5ddc4Srjs{
111096c5ddc4Srjs    return (bi_csel_f32_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0];
111196c5ddc4Srjs}
111296c5ddc4Srjs
111396c5ddc4Srjs
111496c5ddc4Srjsstatic inline
111596c5ddc4Srjsbi_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)
111696c5ddc4Srjs{
111796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
111896c5ddc4Srjs    I->op = BI_OPCODE_CSEL_I32;
111996c5ddc4Srjs    I->dest[0] = dest0;
112096c5ddc4Srjs    I->src[0] = src0;
112196c5ddc4Srjs    I->src[1] = src1;
112296c5ddc4Srjs    I->src[2] = src2;
112396c5ddc4Srjs    I->src[3] = src3;
112496c5ddc4Srjs    I->cmpf = cmpf;
112596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
112696c5ddc4Srjs    return I;
112796c5ddc4Srjs}
112896c5ddc4Srjs
112996c5ddc4Srjsstatic inline
113096c5ddc4Srjsbi_index bi_csel_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf)
113196c5ddc4Srjs{
113296c5ddc4Srjs    return (bi_csel_i32_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0];
113396c5ddc4Srjs}
113496c5ddc4Srjs
113596c5ddc4Srjs
113696c5ddc4Srjsstatic inline
113796c5ddc4Srjsbi_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)
113896c5ddc4Srjs{
113996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
114096c5ddc4Srjs    I->op = BI_OPCODE_CSEL_S32;
114196c5ddc4Srjs    I->dest[0] = dest0;
114296c5ddc4Srjs    I->src[0] = src0;
114396c5ddc4Srjs    I->src[1] = src1;
114496c5ddc4Srjs    I->src[2] = src2;
114596c5ddc4Srjs    I->src[3] = src3;
114696c5ddc4Srjs    I->cmpf = cmpf;
114796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
114896c5ddc4Srjs    return I;
114996c5ddc4Srjs}
115096c5ddc4Srjs
115196c5ddc4Srjsstatic inline
115296c5ddc4Srjsbi_index bi_csel_s32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf)
115396c5ddc4Srjs{
115496c5ddc4Srjs    return (bi_csel_s32_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0];
115596c5ddc4Srjs}
115696c5ddc4Srjs
115796c5ddc4Srjs
115896c5ddc4Srjsstatic inline
115996c5ddc4Srjsbi_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)
116096c5ddc4Srjs{
116196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
116296c5ddc4Srjs    I->op = BI_OPCODE_CSEL_U32;
116396c5ddc4Srjs    I->dest[0] = dest0;
116496c5ddc4Srjs    I->src[0] = src0;
116596c5ddc4Srjs    I->src[1] = src1;
116696c5ddc4Srjs    I->src[2] = src2;
116796c5ddc4Srjs    I->src[3] = src3;
116896c5ddc4Srjs    I->cmpf = cmpf;
116996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
117096c5ddc4Srjs    return I;
117196c5ddc4Srjs}
117296c5ddc4Srjs
117396c5ddc4Srjsstatic inline
117496c5ddc4Srjsbi_index bi_csel_u32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf)
117596c5ddc4Srjs{
117696c5ddc4Srjs    return (bi_csel_u32_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0];
117796c5ddc4Srjs}
117896c5ddc4Srjs
117996c5ddc4Srjs
118096c5ddc4Srjsstatic inline
118196c5ddc4Srjsbi_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)
118296c5ddc4Srjs{
118396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
118496c5ddc4Srjs    I->op = BI_OPCODE_CSEL_V2F16;
118596c5ddc4Srjs    I->dest[0] = dest0;
118696c5ddc4Srjs    I->src[0] = src0;
118796c5ddc4Srjs    I->src[1] = src1;
118896c5ddc4Srjs    I->src[2] = src2;
118996c5ddc4Srjs    I->src[3] = src3;
119096c5ddc4Srjs    I->cmpf = cmpf;
119196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
119296c5ddc4Srjs    return I;
119396c5ddc4Srjs}
119496c5ddc4Srjs
119596c5ddc4Srjsstatic inline
119696c5ddc4Srjsbi_index bi_csel_v2f16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf)
119796c5ddc4Srjs{
119896c5ddc4Srjs    return (bi_csel_v2f16_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0];
119996c5ddc4Srjs}
120096c5ddc4Srjs
120196c5ddc4Srjs
120296c5ddc4Srjsstatic inline
120396c5ddc4Srjsbi_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)
120496c5ddc4Srjs{
120596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
120696c5ddc4Srjs    I->op = BI_OPCODE_CSEL_V2I16;
120796c5ddc4Srjs    I->dest[0] = dest0;
120896c5ddc4Srjs    I->src[0] = src0;
120996c5ddc4Srjs    I->src[1] = src1;
121096c5ddc4Srjs    I->src[2] = src2;
121196c5ddc4Srjs    I->src[3] = src3;
121296c5ddc4Srjs    I->cmpf = cmpf;
121396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
121496c5ddc4Srjs    return I;
121596c5ddc4Srjs}
121696c5ddc4Srjs
121796c5ddc4Srjsstatic inline
121896c5ddc4Srjsbi_index bi_csel_v2i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf)
121996c5ddc4Srjs{
122096c5ddc4Srjs    return (bi_csel_v2i16_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0];
122196c5ddc4Srjs}
122296c5ddc4Srjs
122396c5ddc4Srjs
122496c5ddc4Srjsstatic inline
122596c5ddc4Srjsbi_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)
122696c5ddc4Srjs{
122796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
122896c5ddc4Srjs    I->op = BI_OPCODE_CSEL_V2S16;
122996c5ddc4Srjs    I->dest[0] = dest0;
123096c5ddc4Srjs    I->src[0] = src0;
123196c5ddc4Srjs    I->src[1] = src1;
123296c5ddc4Srjs    I->src[2] = src2;
123396c5ddc4Srjs    I->src[3] = src3;
123496c5ddc4Srjs    I->cmpf = cmpf;
123596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
123696c5ddc4Srjs    return I;
123796c5ddc4Srjs}
123896c5ddc4Srjs
123996c5ddc4Srjsstatic inline
124096c5ddc4Srjsbi_index bi_csel_v2s16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf)
124196c5ddc4Srjs{
124296c5ddc4Srjs    return (bi_csel_v2s16_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0];
124396c5ddc4Srjs}
124496c5ddc4Srjs
124596c5ddc4Srjs
124696c5ddc4Srjsstatic inline
124796c5ddc4Srjsbi_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)
124896c5ddc4Srjs{
124996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
125096c5ddc4Srjs    I->op = BI_OPCODE_CSEL_V2U16;
125196c5ddc4Srjs    I->dest[0] = dest0;
125296c5ddc4Srjs    I->src[0] = src0;
125396c5ddc4Srjs    I->src[1] = src1;
125496c5ddc4Srjs    I->src[2] = src2;
125596c5ddc4Srjs    I->src[3] = src3;
125696c5ddc4Srjs    I->cmpf = cmpf;
125796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
125896c5ddc4Srjs    return I;
125996c5ddc4Srjs}
126096c5ddc4Srjs
126196c5ddc4Srjsstatic inline
126296c5ddc4Srjsbi_index bi_csel_v2u16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_cmpf cmpf)
126396c5ddc4Srjs{
126496c5ddc4Srjs    return (bi_csel_v2u16_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0];
126596c5ddc4Srjs}
126696c5ddc4Srjs
126796c5ddc4Srjs
126896c5ddc4Srjsstatic inline
126996c5ddc4Srjsbi_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)
127096c5ddc4Srjs{
127196c5ddc4Srjs    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))
127296c5ddc4Srjs        return (bi_csel_f32_to(b, dest0, src0, src1, src2, src3, cmpf));
127396c5ddc4Srjs    else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE))
127496c5ddc4Srjs        return (bi_csel_i32_to(b, dest0, src0, src1, src2, src3, cmpf));
127596c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
127696c5ddc4Srjs        return (bi_csel_s32_to(b, dest0, src0, src1, src2, src3, cmpf));
127796c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
127896c5ddc4Srjs        return (bi_csel_u32_to(b, dest0, src0, src1, src2, src3, cmpf));
127996c5ddc4Srjs    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))
128096c5ddc4Srjs        return (bi_csel_v2f16_to(b, dest0, src0, src1, src2, src3, cmpf));
128196c5ddc4Srjs    else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE))
128296c5ddc4Srjs        return (bi_csel_v2i16_to(b, dest0, src0, src1, src2, src3, cmpf));
128396c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
128496c5ddc4Srjs        return (bi_csel_v2s16_to(b, dest0, src0, src1, src2, src3, cmpf));
128596c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
128696c5ddc4Srjs        return (bi_csel_v2u16_to(b, dest0, src0, src1, src2, src3, cmpf));
128796c5ddc4Srjs    else
128896c5ddc4Srjs        unreachable("Invalid parameters for CSEL");
128996c5ddc4Srjs}
129096c5ddc4Srjs
129196c5ddc4Srjsstatic inline
129296c5ddc4Srjsbi_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)
129396c5ddc4Srjs{
129496c5ddc4Srjs    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))
129596c5ddc4Srjs        return (bi_csel_f32_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0];
129696c5ddc4Srjs    else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE))
129796c5ddc4Srjs        return (bi_csel_i32_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0];
129896c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
129996c5ddc4Srjs        return (bi_csel_s32_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0];
130096c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
130196c5ddc4Srjs        return (bi_csel_u32_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0];
130296c5ddc4Srjs    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))
130396c5ddc4Srjs        return (bi_csel_v2f16_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0];
130496c5ddc4Srjs    else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE))
130596c5ddc4Srjs        return (bi_csel_v2i16_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0];
130696c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
130796c5ddc4Srjs        return (bi_csel_v2s16_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0];
130896c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
130996c5ddc4Srjs        return (bi_csel_v2u16_to(b, bi_temp(b->shader), src0, src1, src2, src3, cmpf))->dest[0];
131096c5ddc4Srjs    else
131196c5ddc4Srjs        unreachable("Invalid parameters for CSEL");
131296c5ddc4Srjs}
131396c5ddc4Srjs
131496c5ddc4Srjsstatic inline
131596c5ddc4Srjsbi_instr * bi_cubeface_to(bi_builder *b, bi_index dest0, bi_index dest1, bi_index src0, bi_index src1, bi_index src2)
131696c5ddc4Srjs{
131796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
131896c5ddc4Srjs    I->op = BI_OPCODE_CUBEFACE;
131996c5ddc4Srjs    I->dest[0] = dest0;
132096c5ddc4Srjs    I->dest[1] = dest1;
132196c5ddc4Srjs    I->src[0] = src0;
132296c5ddc4Srjs    I->src[1] = src1;
132396c5ddc4Srjs    I->src[2] = src2;
132496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
132596c5ddc4Srjs    return I;
132696c5ddc4Srjs}
132796c5ddc4Srjs
132896c5ddc4Srjs
132996c5ddc4Srjsstatic inline
133096c5ddc4Srjsbi_instr * bi_cubeface1_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
133196c5ddc4Srjs{
133296c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
133396c5ddc4Srjs    I->op = BI_OPCODE_CUBEFACE1;
133496c5ddc4Srjs    I->dest[0] = dest0;
133596c5ddc4Srjs    I->src[0] = src0;
133696c5ddc4Srjs    I->src[1] = src1;
133796c5ddc4Srjs    I->src[2] = src2;
133896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
133996c5ddc4Srjs    return I;
134096c5ddc4Srjs}
134196c5ddc4Srjs
134296c5ddc4Srjsstatic inline
134396c5ddc4Srjsbi_index bi_cubeface1(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
134496c5ddc4Srjs{
134596c5ddc4Srjs    return (bi_cubeface1_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
134696c5ddc4Srjs}
134796c5ddc4Srjs
134896c5ddc4Srjs
134996c5ddc4Srjsstatic inline
135096c5ddc4Srjsbi_instr * bi_cubeface2_to(bi_builder *b, bi_index dest0, bi_index src0)
135196c5ddc4Srjs{
135296c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
135396c5ddc4Srjs    I->op = BI_OPCODE_CUBEFACE2;
135496c5ddc4Srjs    I->dest[0] = dest0;
135596c5ddc4Srjs    I->src[0] = src0;
135696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
135796c5ddc4Srjs    return I;
135896c5ddc4Srjs}
135996c5ddc4Srjs
136096c5ddc4Srjsstatic inline
136196c5ddc4Srjsbi_index bi_cubeface2(bi_builder *b, bi_index src0)
136296c5ddc4Srjs{
136396c5ddc4Srjs    return (bi_cubeface2_to(b, bi_temp(b->shader), src0))->dest[0];
136496c5ddc4Srjs}
136596c5ddc4Srjs
136696c5ddc4Srjs
136796c5ddc4Srjsstatic inline
136896c5ddc4Srjsbi_instr * bi_cube_ssel_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
136996c5ddc4Srjs{
137096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
137196c5ddc4Srjs    I->op = BI_OPCODE_CUBE_SSEL;
137296c5ddc4Srjs    I->dest[0] = dest0;
137396c5ddc4Srjs    I->src[0] = src0;
137496c5ddc4Srjs    I->src[1] = src1;
137596c5ddc4Srjs    I->src[2] = src2;
137696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
137796c5ddc4Srjs    return I;
137896c5ddc4Srjs}
137996c5ddc4Srjs
138096c5ddc4Srjsstatic inline
138196c5ddc4Srjsbi_index bi_cube_ssel(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
138296c5ddc4Srjs{
138396c5ddc4Srjs    return (bi_cube_ssel_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
138496c5ddc4Srjs}
138596c5ddc4Srjs
138696c5ddc4Srjs
138796c5ddc4Srjsstatic inline
138896c5ddc4Srjsbi_instr * bi_cube_tsel_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
138996c5ddc4Srjs{
139096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
139196c5ddc4Srjs    I->op = BI_OPCODE_CUBE_TSEL;
139296c5ddc4Srjs    I->dest[0] = dest0;
139396c5ddc4Srjs    I->src[0] = src0;
139496c5ddc4Srjs    I->src[1] = src1;
139596c5ddc4Srjs    I->src[2] = src2;
139696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
139796c5ddc4Srjs    return I;
139896c5ddc4Srjs}
139996c5ddc4Srjs
140096c5ddc4Srjsstatic inline
140196c5ddc4Srjsbi_index bi_cube_tsel(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
140296c5ddc4Srjs{
140396c5ddc4Srjs    return (bi_cube_tsel_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
140496c5ddc4Srjs}
140596c5ddc4Srjs
140696c5ddc4Srjs
140796c5ddc4Srjsstatic inline
140896c5ddc4Srjsbi_instr * bi_discard_b32(bi_builder *b, bi_index src0)
140996c5ddc4Srjs{
141096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
141196c5ddc4Srjs    I->op = BI_OPCODE_DISCARD_B32;
141296c5ddc4Srjs    I->src[0] = src0;
141396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
141496c5ddc4Srjs    return I;
141596c5ddc4Srjs}
141696c5ddc4Srjs
141796c5ddc4Srjs
141896c5ddc4Srjsstatic inline
141996c5ddc4Srjsbi_instr * bi_discard_f32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf)
142096c5ddc4Srjs{
142196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
142296c5ddc4Srjs    I->op = BI_OPCODE_DISCARD_F32;
142396c5ddc4Srjs    I->src[0] = src0;
142496c5ddc4Srjs    I->src[1] = src1;
142596c5ddc4Srjs    I->cmpf = cmpf;
142696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
142796c5ddc4Srjs    return I;
142896c5ddc4Srjs}
142996c5ddc4Srjs
143096c5ddc4Srjs
143196c5ddc4Srjsstatic inline
143296c5ddc4Srjsbi_instr * bi_dtsel_imm_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_table table)
143396c5ddc4Srjs{
143496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
143596c5ddc4Srjs    I->op = BI_OPCODE_DTSEL_IMM;
143696c5ddc4Srjs    I->dest[0] = dest0;
143796c5ddc4Srjs    I->src[0] = src0;
143896c5ddc4Srjs    I->table = table;
143996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
144096c5ddc4Srjs    return I;
144196c5ddc4Srjs}
144296c5ddc4Srjs
144396c5ddc4Srjsstatic inline
144496c5ddc4Srjsbi_index bi_dtsel_imm(bi_builder *b, bi_index src0, enum bi_table table)
144596c5ddc4Srjs{
144696c5ddc4Srjs    return (bi_dtsel_imm_to(b, bi_temp(b->shader), src0, table))->dest[0];
144796c5ddc4Srjs}
144896c5ddc4Srjs
144996c5ddc4Srjs
145096c5ddc4Srjsstatic inline
145196c5ddc4Srjsbi_instr * bi_f16_to_f32_to(bi_builder *b, bi_index dest0, bi_index src0)
145296c5ddc4Srjs{
145396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
145496c5ddc4Srjs    I->op = BI_OPCODE_F16_TO_F32;
145596c5ddc4Srjs    I->dest[0] = dest0;
145696c5ddc4Srjs    I->src[0] = src0;
145796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
145896c5ddc4Srjs    return I;
145996c5ddc4Srjs}
146096c5ddc4Srjs
146196c5ddc4Srjsstatic inline
146296c5ddc4Srjsbi_index bi_f16_to_f32(bi_builder *b, bi_index src0)
146396c5ddc4Srjs{
146496c5ddc4Srjs    return (bi_f16_to_f32_to(b, bi_temp(b->shader), src0))->dest[0];
146596c5ddc4Srjs}
146696c5ddc4Srjs
146796c5ddc4Srjs
146896c5ddc4Srjsstatic inline
146996c5ddc4Srjsbi_instr * bi_f16_to_s32_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round)
147096c5ddc4Srjs{
147196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
147296c5ddc4Srjs    I->op = BI_OPCODE_F16_TO_S32;
147396c5ddc4Srjs    I->dest[0] = dest0;
147496c5ddc4Srjs    I->src[0] = src0;
147596c5ddc4Srjs    I->round = round;
147696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
147796c5ddc4Srjs    return I;
147896c5ddc4Srjs}
147996c5ddc4Srjs
148096c5ddc4Srjsstatic inline
148196c5ddc4Srjsbi_index bi_f16_to_s32(bi_builder *b, bi_index src0, enum bi_round round)
148296c5ddc4Srjs{
148396c5ddc4Srjs    return (bi_f16_to_s32_to(b, bi_temp(b->shader), src0, round))->dest[0];
148496c5ddc4Srjs}
148596c5ddc4Srjs
148696c5ddc4Srjs
148796c5ddc4Srjsstatic inline
148896c5ddc4Srjsbi_instr * bi_f16_to_u32_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round)
148996c5ddc4Srjs{
149096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
149196c5ddc4Srjs    I->op = BI_OPCODE_F16_TO_U32;
149296c5ddc4Srjs    I->dest[0] = dest0;
149396c5ddc4Srjs    I->src[0] = src0;
149496c5ddc4Srjs    I->round = round;
149596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
149696c5ddc4Srjs    return I;
149796c5ddc4Srjs}
149896c5ddc4Srjs
149996c5ddc4Srjsstatic inline
150096c5ddc4Srjsbi_index bi_f16_to_u32(bi_builder *b, bi_index src0, enum bi_round round)
150196c5ddc4Srjs{
150296c5ddc4Srjs    return (bi_f16_to_u32_to(b, bi_temp(b->shader), src0, round))->dest[0];
150396c5ddc4Srjs}
150496c5ddc4Srjs
150596c5ddc4Srjs
150696c5ddc4Srjsstatic inline
150796c5ddc4Srjsbi_instr * bi_f32_to_s32_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round)
150896c5ddc4Srjs{
150996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
151096c5ddc4Srjs    I->op = BI_OPCODE_F32_TO_S32;
151196c5ddc4Srjs    I->dest[0] = dest0;
151296c5ddc4Srjs    I->src[0] = src0;
151396c5ddc4Srjs    I->round = round;
151496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
151596c5ddc4Srjs    return I;
151696c5ddc4Srjs}
151796c5ddc4Srjs
151896c5ddc4Srjsstatic inline
151996c5ddc4Srjsbi_index bi_f32_to_s32(bi_builder *b, bi_index src0, enum bi_round round)
152096c5ddc4Srjs{
152196c5ddc4Srjs    return (bi_f32_to_s32_to(b, bi_temp(b->shader), src0, round))->dest[0];
152296c5ddc4Srjs}
152396c5ddc4Srjs
152496c5ddc4Srjs
152596c5ddc4Srjsstatic inline
152696c5ddc4Srjsbi_instr * bi_f32_to_u32_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round)
152796c5ddc4Srjs{
152896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
152996c5ddc4Srjs    I->op = BI_OPCODE_F32_TO_U32;
153096c5ddc4Srjs    I->dest[0] = dest0;
153196c5ddc4Srjs    I->src[0] = src0;
153296c5ddc4Srjs    I->round = round;
153396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
153496c5ddc4Srjs    return I;
153596c5ddc4Srjs}
153696c5ddc4Srjs
153796c5ddc4Srjsstatic inline
153896c5ddc4Srjsbi_index bi_f32_to_u32(bi_builder *b, bi_index src0, enum bi_round round)
153996c5ddc4Srjs{
154096c5ddc4Srjs    return (bi_f32_to_u32_to(b, bi_temp(b->shader), src0, round))->dest[0];
154196c5ddc4Srjs}
154296c5ddc4Srjs
154396c5ddc4Srjs
154496c5ddc4Srjsstatic inline
154596c5ddc4Srjsbi_instr * bi_fabsneg_f32_to(bi_builder *b, bi_index dest0, bi_index src0)
154696c5ddc4Srjs{
154796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
154896c5ddc4Srjs    I->op = BI_OPCODE_FABSNEG_F32;
154996c5ddc4Srjs    I->dest[0] = dest0;
155096c5ddc4Srjs    I->src[0] = src0;
155196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
155296c5ddc4Srjs    return I;
155396c5ddc4Srjs}
155496c5ddc4Srjs
155596c5ddc4Srjsstatic inline
155696c5ddc4Srjsbi_index bi_fabsneg_f32(bi_builder *b, bi_index src0)
155796c5ddc4Srjs{
155896c5ddc4Srjs    return (bi_fabsneg_f32_to(b, bi_temp(b->shader), src0))->dest[0];
155996c5ddc4Srjs}
156096c5ddc4Srjs
156196c5ddc4Srjs
156296c5ddc4Srjsstatic inline
156396c5ddc4Srjsbi_instr * bi_fabsneg_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0)
156496c5ddc4Srjs{
156596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
156696c5ddc4Srjs    I->op = BI_OPCODE_FABSNEG_V2F16;
156796c5ddc4Srjs    I->dest[0] = dest0;
156896c5ddc4Srjs    I->src[0] = src0;
156996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
157096c5ddc4Srjs    return I;
157196c5ddc4Srjs}
157296c5ddc4Srjs
157396c5ddc4Srjsstatic inline
157496c5ddc4Srjsbi_index bi_fabsneg_v2f16(bi_builder *b, bi_index src0)
157596c5ddc4Srjs{
157696c5ddc4Srjs    return (bi_fabsneg_v2f16_to(b, bi_temp(b->shader), src0))->dest[0];
157796c5ddc4Srjs}
157896c5ddc4Srjs
157996c5ddc4Srjs
158096c5ddc4Srjsstatic inline
158196c5ddc4Srjsbi_instr * bi_fabsneg_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0)
158296c5ddc4Srjs{
158396c5ddc4Srjs    if (bitsize == 32)
158496c5ddc4Srjs        return (bi_fabsneg_f32_to(b, dest0, src0));
158596c5ddc4Srjs    else if (bitsize == 16)
158696c5ddc4Srjs        return (bi_fabsneg_v2f16_to(b, dest0, src0));
158796c5ddc4Srjs    else
158896c5ddc4Srjs        unreachable("Invalid parameters for FABSNEG");
158996c5ddc4Srjs}
159096c5ddc4Srjs
159196c5ddc4Srjsstatic inline
159296c5ddc4Srjsbi_index bi_fabsneg(bi_builder *b, unsigned bitsize, bi_index src0)
159396c5ddc4Srjs{
159496c5ddc4Srjs    if (bitsize == 32)
159596c5ddc4Srjs        return (bi_fabsneg_f32_to(b, bi_temp(b->shader), src0))->dest[0];
159696c5ddc4Srjs    else if (bitsize == 16)
159796c5ddc4Srjs        return (bi_fabsneg_v2f16_to(b, bi_temp(b->shader), src0))->dest[0];
159896c5ddc4Srjs    else
159996c5ddc4Srjs        unreachable("Invalid parameters for FABSNEG");
160096c5ddc4Srjs}
160196c5ddc4Srjs
160296c5ddc4Srjsstatic inline
160396c5ddc4Srjsbi_instr * bi_fadd_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round)
160496c5ddc4Srjs{
160596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
160696c5ddc4Srjs    I->op = BI_OPCODE_FADD_F32;
160796c5ddc4Srjs    I->dest[0] = dest0;
160896c5ddc4Srjs    I->src[0] = src0;
160996c5ddc4Srjs    I->src[1] = src1;
161096c5ddc4Srjs    I->round = round;
161196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
161296c5ddc4Srjs    return I;
161396c5ddc4Srjs}
161496c5ddc4Srjs
161596c5ddc4Srjsstatic inline
161696c5ddc4Srjsbi_index bi_fadd_f32(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round)
161796c5ddc4Srjs{
161896c5ddc4Srjs    return (bi_fadd_f32_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
161996c5ddc4Srjs}
162096c5ddc4Srjs
162196c5ddc4Srjs
162296c5ddc4Srjsstatic inline
162396c5ddc4Srjsbi_instr * bi_fadd_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round)
162496c5ddc4Srjs{
162596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
162696c5ddc4Srjs    I->op = BI_OPCODE_FADD_V2F16;
162796c5ddc4Srjs    I->dest[0] = dest0;
162896c5ddc4Srjs    I->src[0] = src0;
162996c5ddc4Srjs    I->src[1] = src1;
163096c5ddc4Srjs    I->round = round;
163196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
163296c5ddc4Srjs    return I;
163396c5ddc4Srjs}
163496c5ddc4Srjs
163596c5ddc4Srjsstatic inline
163696c5ddc4Srjsbi_index bi_fadd_v2f16(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round)
163796c5ddc4Srjs{
163896c5ddc4Srjs    return (bi_fadd_v2f16_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
163996c5ddc4Srjs}
164096c5ddc4Srjs
164196c5ddc4Srjs
164296c5ddc4Srjsstatic inline
164396c5ddc4Srjsbi_instr * bi_fadd_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round)
164496c5ddc4Srjs{
164596c5ddc4Srjs    if (bitsize == 32)
164696c5ddc4Srjs        return (bi_fadd_f32_to(b, dest0, src0, src1, round));
164796c5ddc4Srjs    else if (bitsize == 16)
164896c5ddc4Srjs        return (bi_fadd_v2f16_to(b, dest0, src0, src1, round));
164996c5ddc4Srjs    else
165096c5ddc4Srjs        unreachable("Invalid parameters for FADD");
165196c5ddc4Srjs}
165296c5ddc4Srjs
165396c5ddc4Srjsstatic inline
165496c5ddc4Srjsbi_index bi_fadd(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, enum bi_round round)
165596c5ddc4Srjs{
165696c5ddc4Srjs    if (bitsize == 32)
165796c5ddc4Srjs        return (bi_fadd_f32_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
165896c5ddc4Srjs    else if (bitsize == 16)
165996c5ddc4Srjs        return (bi_fadd_v2f16_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
166096c5ddc4Srjs    else
166196c5ddc4Srjs        unreachable("Invalid parameters for FADD");
166296c5ddc4Srjs}
166396c5ddc4Srjs
166496c5ddc4Srjsstatic inline
166596c5ddc4Srjsbi_instr * bi_fadd_imm_f32_to(bi_builder *b, bi_index dest0, bi_index src0, uint32_t index)
166696c5ddc4Srjs{
166796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
166896c5ddc4Srjs    I->op = BI_OPCODE_FADD_IMM_F32;
166996c5ddc4Srjs    I->dest[0] = dest0;
167096c5ddc4Srjs    I->src[0] = src0;
167196c5ddc4Srjs    I->index = index;
167296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
167396c5ddc4Srjs    return I;
167496c5ddc4Srjs}
167596c5ddc4Srjs
167696c5ddc4Srjsstatic inline
167796c5ddc4Srjsbi_index bi_fadd_imm_f32(bi_builder *b, bi_index src0, uint32_t index)
167896c5ddc4Srjs{
167996c5ddc4Srjs    return (bi_fadd_imm_f32_to(b, bi_temp(b->shader), src0, index))->dest[0];
168096c5ddc4Srjs}
168196c5ddc4Srjs
168296c5ddc4Srjs
168396c5ddc4Srjsstatic inline
168496c5ddc4Srjsbi_instr * bi_fadd_imm_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, uint32_t index)
168596c5ddc4Srjs{
168696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
168796c5ddc4Srjs    I->op = BI_OPCODE_FADD_IMM_V2F16;
168896c5ddc4Srjs    I->dest[0] = dest0;
168996c5ddc4Srjs    I->src[0] = src0;
169096c5ddc4Srjs    I->index = index;
169196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
169296c5ddc4Srjs    return I;
169396c5ddc4Srjs}
169496c5ddc4Srjs
169596c5ddc4Srjsstatic inline
169696c5ddc4Srjsbi_index bi_fadd_imm_v2f16(bi_builder *b, bi_index src0, uint32_t index)
169796c5ddc4Srjs{
169896c5ddc4Srjs    return (bi_fadd_imm_v2f16_to(b, bi_temp(b->shader), src0, index))->dest[0];
169996c5ddc4Srjs}
170096c5ddc4Srjs
170196c5ddc4Srjs
170296c5ddc4Srjsstatic inline
170396c5ddc4Srjsbi_instr * bi_fadd_imm_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, uint32_t index)
170496c5ddc4Srjs{
170596c5ddc4Srjs    if (bitsize == 32)
170696c5ddc4Srjs        return (bi_fadd_imm_f32_to(b, dest0, src0, index));
170796c5ddc4Srjs    else if (bitsize == 16)
170896c5ddc4Srjs        return (bi_fadd_imm_v2f16_to(b, dest0, src0, index));
170996c5ddc4Srjs    else
171096c5ddc4Srjs        unreachable("Invalid parameters for FADD_IMM");
171196c5ddc4Srjs}
171296c5ddc4Srjs
171396c5ddc4Srjsstatic inline
171496c5ddc4Srjsbi_index bi_fadd_imm(bi_builder *b, unsigned bitsize, bi_index src0, uint32_t index)
171596c5ddc4Srjs{
171696c5ddc4Srjs    if (bitsize == 32)
171796c5ddc4Srjs        return (bi_fadd_imm_f32_to(b, bi_temp(b->shader), src0, index))->dest[0];
171896c5ddc4Srjs    else if (bitsize == 16)
171996c5ddc4Srjs        return (bi_fadd_imm_v2f16_to(b, bi_temp(b->shader), src0, index))->dest[0];
172096c5ddc4Srjs    else
172196c5ddc4Srjs        unreachable("Invalid parameters for FADD_IMM");
172296c5ddc4Srjs}
172396c5ddc4Srjs
172496c5ddc4Srjsstatic inline
172596c5ddc4Srjsbi_instr * bi_fadd_lscale_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1)
172696c5ddc4Srjs{
172796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
172896c5ddc4Srjs    I->op = BI_OPCODE_FADD_LSCALE_F32;
172996c5ddc4Srjs    I->dest[0] = dest0;
173096c5ddc4Srjs    I->src[0] = src0;
173196c5ddc4Srjs    I->src[1] = src1;
173296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
173396c5ddc4Srjs    return I;
173496c5ddc4Srjs}
173596c5ddc4Srjs
173696c5ddc4Srjsstatic inline
173796c5ddc4Srjsbi_index bi_fadd_lscale_f32(bi_builder *b, bi_index src0, bi_index src1)
173896c5ddc4Srjs{
173996c5ddc4Srjs    return (bi_fadd_lscale_f32_to(b, bi_temp(b->shader), src0, src1))->dest[0];
174096c5ddc4Srjs}
174196c5ddc4Srjs
174296c5ddc4Srjs
174396c5ddc4Srjsstatic inline
174496c5ddc4Srjsbi_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)
174596c5ddc4Srjs{
174696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
174796c5ddc4Srjs    I->op = BI_OPCODE_FADD_RSCALE_F32;
174896c5ddc4Srjs    I->dest[0] = dest0;
174996c5ddc4Srjs    I->src[0] = src0;
175096c5ddc4Srjs    I->src[1] = src1;
175196c5ddc4Srjs    I->src[2] = src2;
175296c5ddc4Srjs    I->special = special;
175396c5ddc4Srjs    I->round = round;
175496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
175596c5ddc4Srjs    return I;
175696c5ddc4Srjs}
175796c5ddc4Srjs
175896c5ddc4Srjsstatic inline
175996c5ddc4Srjsbi_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)
176096c5ddc4Srjs{
176196c5ddc4Srjs    return (bi_fadd_rscale_f32_to(b, bi_temp(b->shader), src0, src1, src2, round, special))->dest[0];
176296c5ddc4Srjs}
176396c5ddc4Srjs
176496c5ddc4Srjs
176596c5ddc4Srjsstatic inline
176696c5ddc4Srjsbi_instr * bi_fclamp_f32_to(bi_builder *b, bi_index dest0, bi_index src0)
176796c5ddc4Srjs{
176896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
176996c5ddc4Srjs    I->op = BI_OPCODE_FCLAMP_F32;
177096c5ddc4Srjs    I->dest[0] = dest0;
177196c5ddc4Srjs    I->src[0] = src0;
177296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
177396c5ddc4Srjs    return I;
177496c5ddc4Srjs}
177596c5ddc4Srjs
177696c5ddc4Srjsstatic inline
177796c5ddc4Srjsbi_index bi_fclamp_f32(bi_builder *b, bi_index src0)
177896c5ddc4Srjs{
177996c5ddc4Srjs    return (bi_fclamp_f32_to(b, bi_temp(b->shader), src0))->dest[0];
178096c5ddc4Srjs}
178196c5ddc4Srjs
178296c5ddc4Srjs
178396c5ddc4Srjsstatic inline
178496c5ddc4Srjsbi_instr * bi_fclamp_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0)
178596c5ddc4Srjs{
178696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
178796c5ddc4Srjs    I->op = BI_OPCODE_FCLAMP_V2F16;
178896c5ddc4Srjs    I->dest[0] = dest0;
178996c5ddc4Srjs    I->src[0] = src0;
179096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
179196c5ddc4Srjs    return I;
179296c5ddc4Srjs}
179396c5ddc4Srjs
179496c5ddc4Srjsstatic inline
179596c5ddc4Srjsbi_index bi_fclamp_v2f16(bi_builder *b, bi_index src0)
179696c5ddc4Srjs{
179796c5ddc4Srjs    return (bi_fclamp_v2f16_to(b, bi_temp(b->shader), src0))->dest[0];
179896c5ddc4Srjs}
179996c5ddc4Srjs
180096c5ddc4Srjs
180196c5ddc4Srjsstatic inline
180296c5ddc4Srjsbi_instr * bi_fclamp_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0)
180396c5ddc4Srjs{
180496c5ddc4Srjs    if (bitsize == 32)
180596c5ddc4Srjs        return (bi_fclamp_f32_to(b, dest0, src0));
180696c5ddc4Srjs    else if (bitsize == 16)
180796c5ddc4Srjs        return (bi_fclamp_v2f16_to(b, dest0, src0));
180896c5ddc4Srjs    else
180996c5ddc4Srjs        unreachable("Invalid parameters for FCLAMP");
181096c5ddc4Srjs}
181196c5ddc4Srjs
181296c5ddc4Srjsstatic inline
181396c5ddc4Srjsbi_index bi_fclamp(bi_builder *b, unsigned bitsize, bi_index src0)
181496c5ddc4Srjs{
181596c5ddc4Srjs    if (bitsize == 32)
181696c5ddc4Srjs        return (bi_fclamp_f32_to(b, bi_temp(b->shader), src0))->dest[0];
181796c5ddc4Srjs    else if (bitsize == 16)
181896c5ddc4Srjs        return (bi_fclamp_v2f16_to(b, bi_temp(b->shader), src0))->dest[0];
181996c5ddc4Srjs    else
182096c5ddc4Srjs        unreachable("Invalid parameters for FCLAMP");
182196c5ddc4Srjs}
182296c5ddc4Srjs
182396c5ddc4Srjsstatic inline
182496c5ddc4Srjsbi_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)
182596c5ddc4Srjs{
182696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
182796c5ddc4Srjs    I->op = BI_OPCODE_FCMP_F32;
182896c5ddc4Srjs    I->dest[0] = dest0;
182996c5ddc4Srjs    I->src[0] = src0;
183096c5ddc4Srjs    I->src[1] = src1;
183196c5ddc4Srjs    I->cmpf = cmpf;
183296c5ddc4Srjs    I->result_type = result_type;
183396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
183496c5ddc4Srjs    return I;
183596c5ddc4Srjs}
183696c5ddc4Srjs
183796c5ddc4Srjsstatic inline
183896c5ddc4Srjsbi_index bi_fcmp_f32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type)
183996c5ddc4Srjs{
184096c5ddc4Srjs    return (bi_fcmp_f32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
184196c5ddc4Srjs}
184296c5ddc4Srjs
184396c5ddc4Srjs
184496c5ddc4Srjsstatic inline
184596c5ddc4Srjsbi_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)
184696c5ddc4Srjs{
184796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
184896c5ddc4Srjs    I->op = BI_OPCODE_FCMP_V2F16;
184996c5ddc4Srjs    I->dest[0] = dest0;
185096c5ddc4Srjs    I->src[0] = src0;
185196c5ddc4Srjs    I->src[1] = src1;
185296c5ddc4Srjs    I->cmpf = cmpf;
185396c5ddc4Srjs    I->result_type = result_type;
185496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
185596c5ddc4Srjs    return I;
185696c5ddc4Srjs}
185796c5ddc4Srjs
185896c5ddc4Srjsstatic inline
185996c5ddc4Srjsbi_index bi_fcmp_v2f16(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type)
186096c5ddc4Srjs{
186196c5ddc4Srjs    return (bi_fcmp_v2f16_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
186296c5ddc4Srjs}
186396c5ddc4Srjs
186496c5ddc4Srjs
186596c5ddc4Srjsstatic inline
186696c5ddc4Srjsbi_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)
186796c5ddc4Srjs{
186896c5ddc4Srjs    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))
186996c5ddc4Srjs        return (bi_fcmp_f32_to(b, dest0, src0, src1, cmpf, result_type));
187096c5ddc4Srjs    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))
187196c5ddc4Srjs        return (bi_fcmp_v2f16_to(b, dest0, src0, src1, cmpf, result_type));
187296c5ddc4Srjs    else
187396c5ddc4Srjs        unreachable("Invalid parameters for FCMP");
187496c5ddc4Srjs}
187596c5ddc4Srjs
187696c5ddc4Srjsstatic inline
187796c5ddc4Srjsbi_index bi_fcmp(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type)
187896c5ddc4Srjs{
187996c5ddc4Srjs    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))
188096c5ddc4Srjs        return (bi_fcmp_f32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
188196c5ddc4Srjs    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))
188296c5ddc4Srjs        return (bi_fcmp_v2f16_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
188396c5ddc4Srjs    else
188496c5ddc4Srjs        unreachable("Invalid parameters for FCMP");
188596c5ddc4Srjs}
188696c5ddc4Srjs
188796c5ddc4Srjsstatic inline
188896c5ddc4Srjsbi_instr * bi_fcos_table_u6_to(bi_builder *b, bi_index dest0, bi_index src0, bool offset)
188996c5ddc4Srjs{
189096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
189196c5ddc4Srjs    I->op = BI_OPCODE_FCOS_TABLE_U6;
189296c5ddc4Srjs    I->dest[0] = dest0;
189396c5ddc4Srjs    I->src[0] = src0;
189496c5ddc4Srjs    I->offset = offset;
189596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
189696c5ddc4Srjs    return I;
189796c5ddc4Srjs}
189896c5ddc4Srjs
189996c5ddc4Srjsstatic inline
190096c5ddc4Srjsbi_index bi_fcos_table_u6(bi_builder *b, bi_index src0, bool offset)
190196c5ddc4Srjs{
190296c5ddc4Srjs    return (bi_fcos_table_u6_to(b, bi_temp(b->shader), src0, offset))->dest[0];
190396c5ddc4Srjs}
190496c5ddc4Srjs
190596c5ddc4Srjs
190696c5ddc4Srjsstatic inline
190796c5ddc4Srjsbi_instr * bi_fexp_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1)
190896c5ddc4Srjs{
190996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
191096c5ddc4Srjs    I->op = BI_OPCODE_FEXP_F32;
191196c5ddc4Srjs    I->dest[0] = dest0;
191296c5ddc4Srjs    I->src[0] = src0;
191396c5ddc4Srjs    I->src[1] = src1;
191496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
191596c5ddc4Srjs    return I;
191696c5ddc4Srjs}
191796c5ddc4Srjs
191896c5ddc4Srjsstatic inline
191996c5ddc4Srjsbi_index bi_fexp_f32(bi_builder *b, bi_index src0, bi_index src1)
192096c5ddc4Srjs{
192196c5ddc4Srjs    return (bi_fexp_f32_to(b, bi_temp(b->shader), src0, src1))->dest[0];
192296c5ddc4Srjs}
192396c5ddc4Srjs
192496c5ddc4Srjs
192596c5ddc4Srjsstatic inline
192696c5ddc4Srjsbi_instr * bi_fexp_table_u4_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_adj adj)
192796c5ddc4Srjs{
192896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
192996c5ddc4Srjs    I->op = BI_OPCODE_FEXP_TABLE_U4;
193096c5ddc4Srjs    I->dest[0] = dest0;
193196c5ddc4Srjs    I->src[0] = src0;
193296c5ddc4Srjs    I->adj = adj;
193396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
193496c5ddc4Srjs    return I;
193596c5ddc4Srjs}
193696c5ddc4Srjs
193796c5ddc4Srjsstatic inline
193896c5ddc4Srjsbi_index bi_fexp_table_u4(bi_builder *b, bi_index src0, enum bi_adj adj)
193996c5ddc4Srjs{
194096c5ddc4Srjs    return (bi_fexp_table_u4_to(b, bi_temp(b->shader), src0, adj))->dest[0];
194196c5ddc4Srjs}
194296c5ddc4Srjs
194396c5ddc4Srjs
194496c5ddc4Srjsstatic inline
194596c5ddc4Srjsbi_instr * bi_flogd_f32_to(bi_builder *b, bi_index dest0, bi_index src0)
194696c5ddc4Srjs{
194796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
194896c5ddc4Srjs    I->op = BI_OPCODE_FLOGD_F32;
194996c5ddc4Srjs    I->dest[0] = dest0;
195096c5ddc4Srjs    I->src[0] = src0;
195196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
195296c5ddc4Srjs    return I;
195396c5ddc4Srjs}
195496c5ddc4Srjs
195596c5ddc4Srjsstatic inline
195696c5ddc4Srjsbi_index bi_flogd_f32(bi_builder *b, bi_index src0)
195796c5ddc4Srjs{
195896c5ddc4Srjs    return (bi_flogd_f32_to(b, bi_temp(b->shader), src0))->dest[0];
195996c5ddc4Srjs}
196096c5ddc4Srjs
196196c5ddc4Srjs
196296c5ddc4Srjsstatic inline
196396c5ddc4Srjsbi_instr * bi_flog_table_f32_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_mode mode, enum bi_precision precision)
196496c5ddc4Srjs{
196596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
196696c5ddc4Srjs    I->op = BI_OPCODE_FLOG_TABLE_F32;
196796c5ddc4Srjs    I->dest[0] = dest0;
196896c5ddc4Srjs    I->src[0] = src0;
196996c5ddc4Srjs    I->mode = mode;
197096c5ddc4Srjs    I->precision = precision;
197196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
197296c5ddc4Srjs    return I;
197396c5ddc4Srjs}
197496c5ddc4Srjs
197596c5ddc4Srjsstatic inline
197696c5ddc4Srjsbi_index bi_flog_table_f32(bi_builder *b, bi_index src0, enum bi_mode mode, enum bi_precision precision)
197796c5ddc4Srjs{
197896c5ddc4Srjs    return (bi_flog_table_f32_to(b, bi_temp(b->shader), src0, mode, precision))->dest[0];
197996c5ddc4Srjs}
198096c5ddc4Srjs
198196c5ddc4Srjs
198296c5ddc4Srjsstatic inline
198396c5ddc4Srjsbi_instr * bi_flshift_double_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bool bytes2)
198496c5ddc4Srjs{
198596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
198696c5ddc4Srjs    I->op = BI_OPCODE_FLSHIFT_DOUBLE_I32;
198796c5ddc4Srjs    I->dest[0] = dest0;
198896c5ddc4Srjs    I->src[0] = src0;
198996c5ddc4Srjs    I->src[1] = src1;
199096c5ddc4Srjs    I->src[2] = src2;
199196c5ddc4Srjs    I->bytes2 = bytes2;
199296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
199396c5ddc4Srjs    return I;
199496c5ddc4Srjs}
199596c5ddc4Srjs
199696c5ddc4Srjsstatic inline
199796c5ddc4Srjsbi_index bi_flshift_double_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bool bytes2)
199896c5ddc4Srjs{
199996c5ddc4Srjs    return (bi_flshift_double_i32_to(b, bi_temp(b->shader), src0, src1, src2, bytes2))->dest[0];
200096c5ddc4Srjs}
200196c5ddc4Srjs
200296c5ddc4Srjs
200396c5ddc4Srjsstatic inline
200496c5ddc4Srjsbi_instr * bi_fma_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_round round)
200596c5ddc4Srjs{
200696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
200796c5ddc4Srjs    I->op = BI_OPCODE_FMA_F32;
200896c5ddc4Srjs    I->dest[0] = dest0;
200996c5ddc4Srjs    I->src[0] = src0;
201096c5ddc4Srjs    I->src[1] = src1;
201196c5ddc4Srjs    I->src[2] = src2;
201296c5ddc4Srjs    I->round = round;
201396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
201496c5ddc4Srjs    return I;
201596c5ddc4Srjs}
201696c5ddc4Srjs
201796c5ddc4Srjsstatic inline
201896c5ddc4Srjsbi_index bi_fma_f32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_round round)
201996c5ddc4Srjs{
202096c5ddc4Srjs    return (bi_fma_f32_to(b, bi_temp(b->shader), src0, src1, src2, round))->dest[0];
202196c5ddc4Srjs}
202296c5ddc4Srjs
202396c5ddc4Srjs
202496c5ddc4Srjsstatic inline
202596c5ddc4Srjsbi_instr * bi_fma_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_round round)
202696c5ddc4Srjs{
202796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
202896c5ddc4Srjs    I->op = BI_OPCODE_FMA_V2F16;
202996c5ddc4Srjs    I->dest[0] = dest0;
203096c5ddc4Srjs    I->src[0] = src0;
203196c5ddc4Srjs    I->src[1] = src1;
203296c5ddc4Srjs    I->src[2] = src2;
203396c5ddc4Srjs    I->round = round;
203496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
203596c5ddc4Srjs    return I;
203696c5ddc4Srjs}
203796c5ddc4Srjs
203896c5ddc4Srjsstatic inline
203996c5ddc4Srjsbi_index bi_fma_v2f16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_round round)
204096c5ddc4Srjs{
204196c5ddc4Srjs    return (bi_fma_v2f16_to(b, bi_temp(b->shader), src0, src1, src2, round))->dest[0];
204296c5ddc4Srjs}
204396c5ddc4Srjs
204496c5ddc4Srjs
204596c5ddc4Srjsstatic inline
204696c5ddc4Srjsbi_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)
204796c5ddc4Srjs{
204896c5ddc4Srjs    if (bitsize == 32)
204996c5ddc4Srjs        return (bi_fma_f32_to(b, dest0, src0, src1, src2, round));
205096c5ddc4Srjs    else if (bitsize == 16)
205196c5ddc4Srjs        return (bi_fma_v2f16_to(b, dest0, src0, src1, src2, round));
205296c5ddc4Srjs    else
205396c5ddc4Srjs        unreachable("Invalid parameters for FMA");
205496c5ddc4Srjs}
205596c5ddc4Srjs
205696c5ddc4Srjsstatic inline
205796c5ddc4Srjsbi_index bi_fma(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2, enum bi_round round)
205896c5ddc4Srjs{
205996c5ddc4Srjs    if (bitsize == 32)
206096c5ddc4Srjs        return (bi_fma_f32_to(b, bi_temp(b->shader), src0, src1, src2, round))->dest[0];
206196c5ddc4Srjs    else if (bitsize == 16)
206296c5ddc4Srjs        return (bi_fma_v2f16_to(b, bi_temp(b->shader), src0, src1, src2, round))->dest[0];
206396c5ddc4Srjs    else
206496c5ddc4Srjs        unreachable("Invalid parameters for FMA");
206596c5ddc4Srjs}
206696c5ddc4Srjs
206796c5ddc4Srjsstatic inline
206896c5ddc4Srjsbi_instr * bi_fmax_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1)
206996c5ddc4Srjs{
207096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
207196c5ddc4Srjs    I->op = BI_OPCODE_FMAX_F32;
207296c5ddc4Srjs    I->dest[0] = dest0;
207396c5ddc4Srjs    I->src[0] = src0;
207496c5ddc4Srjs    I->src[1] = src1;
207596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
207696c5ddc4Srjs    return I;
207796c5ddc4Srjs}
207896c5ddc4Srjs
207996c5ddc4Srjsstatic inline
208096c5ddc4Srjsbi_index bi_fmax_f32(bi_builder *b, bi_index src0, bi_index src1)
208196c5ddc4Srjs{
208296c5ddc4Srjs    return (bi_fmax_f32_to(b, bi_temp(b->shader), src0, src1))->dest[0];
208396c5ddc4Srjs}
208496c5ddc4Srjs
208596c5ddc4Srjs
208696c5ddc4Srjsstatic inline
208796c5ddc4Srjsbi_instr * bi_fmax_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1)
208896c5ddc4Srjs{
208996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
209096c5ddc4Srjs    I->op = BI_OPCODE_FMAX_V2F16;
209196c5ddc4Srjs    I->dest[0] = dest0;
209296c5ddc4Srjs    I->src[0] = src0;
209396c5ddc4Srjs    I->src[1] = src1;
209496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
209596c5ddc4Srjs    return I;
209696c5ddc4Srjs}
209796c5ddc4Srjs
209896c5ddc4Srjsstatic inline
209996c5ddc4Srjsbi_index bi_fmax_v2f16(bi_builder *b, bi_index src0, bi_index src1)
210096c5ddc4Srjs{
210196c5ddc4Srjs    return (bi_fmax_v2f16_to(b, bi_temp(b->shader), src0, src1))->dest[0];
210296c5ddc4Srjs}
210396c5ddc4Srjs
210496c5ddc4Srjs
210596c5ddc4Srjsstatic inline
210696c5ddc4Srjsbi_instr * bi_fmax_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1)
210796c5ddc4Srjs{
210896c5ddc4Srjs    if (bitsize == 32)
210996c5ddc4Srjs        return (bi_fmax_f32_to(b, dest0, src0, src1));
211096c5ddc4Srjs    else if (bitsize == 16)
211196c5ddc4Srjs        return (bi_fmax_v2f16_to(b, dest0, src0, src1));
211296c5ddc4Srjs    else
211396c5ddc4Srjs        unreachable("Invalid parameters for FMAX");
211496c5ddc4Srjs}
211596c5ddc4Srjs
211696c5ddc4Srjsstatic inline
211796c5ddc4Srjsbi_index bi_fmax(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1)
211896c5ddc4Srjs{
211996c5ddc4Srjs    if (bitsize == 32)
212096c5ddc4Srjs        return (bi_fmax_f32_to(b, bi_temp(b->shader), src0, src1))->dest[0];
212196c5ddc4Srjs    else if (bitsize == 16)
212296c5ddc4Srjs        return (bi_fmax_v2f16_to(b, bi_temp(b->shader), src0, src1))->dest[0];
212396c5ddc4Srjs    else
212496c5ddc4Srjs        unreachable("Invalid parameters for FMAX");
212596c5ddc4Srjs}
212696c5ddc4Srjs
212796c5ddc4Srjsstatic inline
212896c5ddc4Srjsbi_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)
212996c5ddc4Srjs{
213096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
213196c5ddc4Srjs    I->op = BI_OPCODE_FMA_RSCALE_F32;
213296c5ddc4Srjs    I->dest[0] = dest0;
213396c5ddc4Srjs    I->src[0] = src0;
213496c5ddc4Srjs    I->src[1] = src1;
213596c5ddc4Srjs    I->src[2] = src2;
213696c5ddc4Srjs    I->src[3] = src3;
213796c5ddc4Srjs    I->round = round;
213896c5ddc4Srjs    I->special = special;
213996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
214096c5ddc4Srjs    return I;
214196c5ddc4Srjs}
214296c5ddc4Srjs
214396c5ddc4Srjsstatic inline
214496c5ddc4Srjsbi_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)
214596c5ddc4Srjs{
214696c5ddc4Srjs    return (bi_fma_rscale_f32_to(b, bi_temp(b->shader), src0, src1, src2, src3, round, special))->dest[0];
214796c5ddc4Srjs}
214896c5ddc4Srjs
214996c5ddc4Srjs
215096c5ddc4Srjsstatic inline
215196c5ddc4Srjsbi_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)
215296c5ddc4Srjs{
215396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
215496c5ddc4Srjs    I->op = BI_OPCODE_FMA_RSCALE_V2F16;
215596c5ddc4Srjs    I->dest[0] = dest0;
215696c5ddc4Srjs    I->src[0] = src0;
215796c5ddc4Srjs    I->src[1] = src1;
215896c5ddc4Srjs    I->src[2] = src2;
215996c5ddc4Srjs    I->src[3] = src3;
216096c5ddc4Srjs    I->round = round;
216196c5ddc4Srjs    I->special = special;
216296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
216396c5ddc4Srjs    return I;
216496c5ddc4Srjs}
216596c5ddc4Srjs
216696c5ddc4Srjsstatic inline
216796c5ddc4Srjsbi_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)
216896c5ddc4Srjs{
216996c5ddc4Srjs    return (bi_fma_rscale_v2f16_to(b, bi_temp(b->shader), src0, src1, src2, src3, round, special))->dest[0];
217096c5ddc4Srjs}
217196c5ddc4Srjs
217296c5ddc4Srjs
217396c5ddc4Srjsstatic inline
217496c5ddc4Srjsbi_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)
217596c5ddc4Srjs{
217696c5ddc4Srjs    if (bitsize == 32)
217796c5ddc4Srjs        return (bi_fma_rscale_f32_to(b, dest0, src0, src1, src2, src3, round, special));
217896c5ddc4Srjs    else if (bitsize == 16)
217996c5ddc4Srjs        return (bi_fma_rscale_v2f16_to(b, dest0, src0, src1, src2, src3, round, special));
218096c5ddc4Srjs    else
218196c5ddc4Srjs        unreachable("Invalid parameters for FMA_RSCALE");
218296c5ddc4Srjs}
218396c5ddc4Srjs
218496c5ddc4Srjsstatic inline
218596c5ddc4Srjsbi_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)
218696c5ddc4Srjs{
218796c5ddc4Srjs    if (bitsize == 32)
218896c5ddc4Srjs        return (bi_fma_rscale_f32_to(b, bi_temp(b->shader), src0, src1, src2, src3, round, special))->dest[0];
218996c5ddc4Srjs    else if (bitsize == 16)
219096c5ddc4Srjs        return (bi_fma_rscale_v2f16_to(b, bi_temp(b->shader), src0, src1, src2, src3, round, special))->dest[0];
219196c5ddc4Srjs    else
219296c5ddc4Srjs        unreachable("Invalid parameters for FMA_RSCALE");
219396c5ddc4Srjs}
219496c5ddc4Srjs
219596c5ddc4Srjsstatic inline
219696c5ddc4Srjsbi_instr * bi_fmin_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1)
219796c5ddc4Srjs{
219896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
219996c5ddc4Srjs    I->op = BI_OPCODE_FMIN_F32;
220096c5ddc4Srjs    I->dest[0] = dest0;
220196c5ddc4Srjs    I->src[0] = src0;
220296c5ddc4Srjs    I->src[1] = src1;
220396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
220496c5ddc4Srjs    return I;
220596c5ddc4Srjs}
220696c5ddc4Srjs
220796c5ddc4Srjsstatic inline
220896c5ddc4Srjsbi_index bi_fmin_f32(bi_builder *b, bi_index src0, bi_index src1)
220996c5ddc4Srjs{
221096c5ddc4Srjs    return (bi_fmin_f32_to(b, bi_temp(b->shader), src0, src1))->dest[0];
221196c5ddc4Srjs}
221296c5ddc4Srjs
221396c5ddc4Srjs
221496c5ddc4Srjsstatic inline
221596c5ddc4Srjsbi_instr * bi_fmin_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1)
221696c5ddc4Srjs{
221796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
221896c5ddc4Srjs    I->op = BI_OPCODE_FMIN_V2F16;
221996c5ddc4Srjs    I->dest[0] = dest0;
222096c5ddc4Srjs    I->src[0] = src0;
222196c5ddc4Srjs    I->src[1] = src1;
222296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
222396c5ddc4Srjs    return I;
222496c5ddc4Srjs}
222596c5ddc4Srjs
222696c5ddc4Srjsstatic inline
222796c5ddc4Srjsbi_index bi_fmin_v2f16(bi_builder *b, bi_index src0, bi_index src1)
222896c5ddc4Srjs{
222996c5ddc4Srjs    return (bi_fmin_v2f16_to(b, bi_temp(b->shader), src0, src1))->dest[0];
223096c5ddc4Srjs}
223196c5ddc4Srjs
223296c5ddc4Srjs
223396c5ddc4Srjsstatic inline
223496c5ddc4Srjsbi_instr * bi_fmin_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1)
223596c5ddc4Srjs{
223696c5ddc4Srjs    if (bitsize == 32)
223796c5ddc4Srjs        return (bi_fmin_f32_to(b, dest0, src0, src1));
223896c5ddc4Srjs    else if (bitsize == 16)
223996c5ddc4Srjs        return (bi_fmin_v2f16_to(b, dest0, src0, src1));
224096c5ddc4Srjs    else
224196c5ddc4Srjs        unreachable("Invalid parameters for FMIN");
224296c5ddc4Srjs}
224396c5ddc4Srjs
224496c5ddc4Srjsstatic inline
224596c5ddc4Srjsbi_index bi_fmin(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1)
224696c5ddc4Srjs{
224796c5ddc4Srjs    if (bitsize == 32)
224896c5ddc4Srjs        return (bi_fmin_f32_to(b, bi_temp(b->shader), src0, src1))->dest[0];
224996c5ddc4Srjs    else if (bitsize == 16)
225096c5ddc4Srjs        return (bi_fmin_v2f16_to(b, bi_temp(b->shader), src0, src1))->dest[0];
225196c5ddc4Srjs    else
225296c5ddc4Srjs        unreachable("Invalid parameters for FMIN");
225396c5ddc4Srjs}
225496c5ddc4Srjs
225596c5ddc4Srjsstatic inline
225696c5ddc4Srjsbi_instr * bi_fmul_cslice_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1)
225796c5ddc4Srjs{
225896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
225996c5ddc4Srjs    I->op = BI_OPCODE_FMUL_CSLICE;
226096c5ddc4Srjs    I->dest[0] = dest0;
226196c5ddc4Srjs    I->src[0] = src0;
226296c5ddc4Srjs    I->src[1] = src1;
226396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
226496c5ddc4Srjs    return I;
226596c5ddc4Srjs}
226696c5ddc4Srjs
226796c5ddc4Srjsstatic inline
226896c5ddc4Srjsbi_index bi_fmul_cslice(bi_builder *b, bi_index src0, bi_index src1)
226996c5ddc4Srjs{
227096c5ddc4Srjs    return (bi_fmul_cslice_to(b, bi_temp(b->shader), src0, src1))->dest[0];
227196c5ddc4Srjs}
227296c5ddc4Srjs
227396c5ddc4Srjs
227496c5ddc4Srjsstatic inline
227596c5ddc4Srjsbi_instr * bi_fmul_slice_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1)
227696c5ddc4Srjs{
227796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
227896c5ddc4Srjs    I->op = BI_OPCODE_FMUL_SLICE_F32;
227996c5ddc4Srjs    I->dest[0] = dest0;
228096c5ddc4Srjs    I->src[0] = src0;
228196c5ddc4Srjs    I->src[1] = src1;
228296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
228396c5ddc4Srjs    return I;
228496c5ddc4Srjs}
228596c5ddc4Srjs
228696c5ddc4Srjsstatic inline
228796c5ddc4Srjsbi_index bi_fmul_slice_f32(bi_builder *b, bi_index src0, bi_index src1)
228896c5ddc4Srjs{
228996c5ddc4Srjs    return (bi_fmul_slice_f32_to(b, bi_temp(b->shader), src0, src1))->dest[0];
229096c5ddc4Srjs}
229196c5ddc4Srjs
229296c5ddc4Srjs
229396c5ddc4Srjsstatic inline
229496c5ddc4Srjsbi_instr * bi_fpclass_f16_to(bi_builder *b, bi_index dest0, bi_index src0)
229596c5ddc4Srjs{
229696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
229796c5ddc4Srjs    I->op = BI_OPCODE_FPCLASS_F16;
229896c5ddc4Srjs    I->dest[0] = dest0;
229996c5ddc4Srjs    I->src[0] = src0;
230096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
230196c5ddc4Srjs    return I;
230296c5ddc4Srjs}
230396c5ddc4Srjs
230496c5ddc4Srjsstatic inline
230596c5ddc4Srjsbi_index bi_fpclass_f16(bi_builder *b, bi_index src0)
230696c5ddc4Srjs{
230796c5ddc4Srjs    return (bi_fpclass_f16_to(b, bi_temp(b->shader), src0))->dest[0];
230896c5ddc4Srjs}
230996c5ddc4Srjs
231096c5ddc4Srjs
231196c5ddc4Srjsstatic inline
231296c5ddc4Srjsbi_instr * bi_fpclass_f32_to(bi_builder *b, bi_index dest0, bi_index src0)
231396c5ddc4Srjs{
231496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
231596c5ddc4Srjs    I->op = BI_OPCODE_FPCLASS_F32;
231696c5ddc4Srjs    I->dest[0] = dest0;
231796c5ddc4Srjs    I->src[0] = src0;
231896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
231996c5ddc4Srjs    return I;
232096c5ddc4Srjs}
232196c5ddc4Srjs
232296c5ddc4Srjsstatic inline
232396c5ddc4Srjsbi_index bi_fpclass_f32(bi_builder *b, bi_index src0)
232496c5ddc4Srjs{
232596c5ddc4Srjs    return (bi_fpclass_f32_to(b, bi_temp(b->shader), src0))->dest[0];
232696c5ddc4Srjs}
232796c5ddc4Srjs
232896c5ddc4Srjs
232996c5ddc4Srjsstatic inline
233096c5ddc4Srjsbi_instr * bi_fpclass_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0)
233196c5ddc4Srjs{
233296c5ddc4Srjs    if (bitsize == 16)
233396c5ddc4Srjs        return (bi_fpclass_f16_to(b, dest0, src0));
233496c5ddc4Srjs    else if (bitsize == 32)
233596c5ddc4Srjs        return (bi_fpclass_f32_to(b, dest0, src0));
233696c5ddc4Srjs    else
233796c5ddc4Srjs        unreachable("Invalid parameters for FPCLASS");
233896c5ddc4Srjs}
233996c5ddc4Srjs
234096c5ddc4Srjsstatic inline
234196c5ddc4Srjsbi_index bi_fpclass(bi_builder *b, unsigned bitsize, bi_index src0)
234296c5ddc4Srjs{
234396c5ddc4Srjs    if (bitsize == 16)
234496c5ddc4Srjs        return (bi_fpclass_f16_to(b, bi_temp(b->shader), src0))->dest[0];
234596c5ddc4Srjs    else if (bitsize == 32)
234696c5ddc4Srjs        return (bi_fpclass_f32_to(b, bi_temp(b->shader), src0))->dest[0];
234796c5ddc4Srjs    else
234896c5ddc4Srjs        unreachable("Invalid parameters for FPCLASS");
234996c5ddc4Srjs}
235096c5ddc4Srjs
235196c5ddc4Srjsstatic inline
235296c5ddc4Srjsbi_instr * bi_fpow_sc_apply_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1)
235396c5ddc4Srjs{
235496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
235596c5ddc4Srjs    I->op = BI_OPCODE_FPOW_SC_APPLY;
235696c5ddc4Srjs    I->dest[0] = dest0;
235796c5ddc4Srjs    I->src[0] = src0;
235896c5ddc4Srjs    I->src[1] = src1;
235996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
236096c5ddc4Srjs    return I;
236196c5ddc4Srjs}
236296c5ddc4Srjs
236396c5ddc4Srjsstatic inline
236496c5ddc4Srjsbi_index bi_fpow_sc_apply(bi_builder *b, bi_index src0, bi_index src1)
236596c5ddc4Srjs{
236696c5ddc4Srjs    return (bi_fpow_sc_apply_to(b, bi_temp(b->shader), src0, src1))->dest[0];
236796c5ddc4Srjs}
236896c5ddc4Srjs
236996c5ddc4Srjs
237096c5ddc4Srjsstatic inline
237196c5ddc4Srjsbi_instr * bi_fpow_sc_det_f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_func func)
237296c5ddc4Srjs{
237396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
237496c5ddc4Srjs    I->op = BI_OPCODE_FPOW_SC_DET_F16;
237596c5ddc4Srjs    I->dest[0] = dest0;
237696c5ddc4Srjs    I->src[0] = src0;
237796c5ddc4Srjs    I->src[1] = src1;
237896c5ddc4Srjs    I->func = func;
237996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
238096c5ddc4Srjs    return I;
238196c5ddc4Srjs}
238296c5ddc4Srjs
238396c5ddc4Srjsstatic inline
238496c5ddc4Srjsbi_index bi_fpow_sc_det_f16(bi_builder *b, bi_index src0, bi_index src1, enum bi_func func)
238596c5ddc4Srjs{
238696c5ddc4Srjs    return (bi_fpow_sc_det_f16_to(b, bi_temp(b->shader), src0, src1, func))->dest[0];
238796c5ddc4Srjs}
238896c5ddc4Srjs
238996c5ddc4Srjs
239096c5ddc4Srjsstatic inline
239196c5ddc4Srjsbi_instr * bi_fpow_sc_det_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_func func)
239296c5ddc4Srjs{
239396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
239496c5ddc4Srjs    I->op = BI_OPCODE_FPOW_SC_DET_F32;
239596c5ddc4Srjs    I->dest[0] = dest0;
239696c5ddc4Srjs    I->src[0] = src0;
239796c5ddc4Srjs    I->src[1] = src1;
239896c5ddc4Srjs    I->func = func;
239996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
240096c5ddc4Srjs    return I;
240196c5ddc4Srjs}
240296c5ddc4Srjs
240396c5ddc4Srjsstatic inline
240496c5ddc4Srjsbi_index bi_fpow_sc_det_f32(bi_builder *b, bi_index src0, bi_index src1, enum bi_func func)
240596c5ddc4Srjs{
240696c5ddc4Srjs    return (bi_fpow_sc_det_f32_to(b, bi_temp(b->shader), src0, src1, func))->dest[0];
240796c5ddc4Srjs}
240896c5ddc4Srjs
240996c5ddc4Srjs
241096c5ddc4Srjsstatic inline
241196c5ddc4Srjsbi_instr * bi_fpow_sc_det_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, enum bi_func func)
241296c5ddc4Srjs{
241396c5ddc4Srjs    if (bitsize == 16)
241496c5ddc4Srjs        return (bi_fpow_sc_det_f16_to(b, dest0, src0, src1, func));
241596c5ddc4Srjs    else if (bitsize == 32)
241696c5ddc4Srjs        return (bi_fpow_sc_det_f32_to(b, dest0, src0, src1, func));
241796c5ddc4Srjs    else
241896c5ddc4Srjs        unreachable("Invalid parameters for FPOW_SC_DET");
241996c5ddc4Srjs}
242096c5ddc4Srjs
242196c5ddc4Srjsstatic inline
242296c5ddc4Srjsbi_index bi_fpow_sc_det(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, enum bi_func func)
242396c5ddc4Srjs{
242496c5ddc4Srjs    if (bitsize == 16)
242596c5ddc4Srjs        return (bi_fpow_sc_det_f16_to(b, bi_temp(b->shader), src0, src1, func))->dest[0];
242696c5ddc4Srjs    else if (bitsize == 32)
242796c5ddc4Srjs        return (bi_fpow_sc_det_f32_to(b, bi_temp(b->shader), src0, src1, func))->dest[0];
242896c5ddc4Srjs    else
242996c5ddc4Srjs        unreachable("Invalid parameters for FPOW_SC_DET");
243096c5ddc4Srjs}
243196c5ddc4Srjs
243296c5ddc4Srjsstatic inline
243396c5ddc4Srjsbi_instr * bi_frcp_f16_to(bi_builder *b, bi_index dest0, bi_index src0)
243496c5ddc4Srjs{
243596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
243696c5ddc4Srjs    I->op = BI_OPCODE_FRCP_F16;
243796c5ddc4Srjs    I->dest[0] = dest0;
243896c5ddc4Srjs    I->src[0] = src0;
243996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
244096c5ddc4Srjs    return I;
244196c5ddc4Srjs}
244296c5ddc4Srjs
244396c5ddc4Srjsstatic inline
244496c5ddc4Srjsbi_index bi_frcp_f16(bi_builder *b, bi_index src0)
244596c5ddc4Srjs{
244696c5ddc4Srjs    return (bi_frcp_f16_to(b, bi_temp(b->shader), src0))->dest[0];
244796c5ddc4Srjs}
244896c5ddc4Srjs
244996c5ddc4Srjs
245096c5ddc4Srjsstatic inline
245196c5ddc4Srjsbi_instr * bi_frcp_f32_to(bi_builder *b, bi_index dest0, bi_index src0)
245296c5ddc4Srjs{
245396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
245496c5ddc4Srjs    I->op = BI_OPCODE_FRCP_F32;
245596c5ddc4Srjs    I->dest[0] = dest0;
245696c5ddc4Srjs    I->src[0] = src0;
245796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
245896c5ddc4Srjs    return I;
245996c5ddc4Srjs}
246096c5ddc4Srjs
246196c5ddc4Srjsstatic inline
246296c5ddc4Srjsbi_index bi_frcp_f32(bi_builder *b, bi_index src0)
246396c5ddc4Srjs{
246496c5ddc4Srjs    return (bi_frcp_f32_to(b, bi_temp(b->shader), src0))->dest[0];
246596c5ddc4Srjs}
246696c5ddc4Srjs
246796c5ddc4Srjs
246896c5ddc4Srjsstatic inline
246996c5ddc4Srjsbi_instr * bi_frcp_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0)
247096c5ddc4Srjs{
247196c5ddc4Srjs    if (bitsize == 16)
247296c5ddc4Srjs        return (bi_frcp_f16_to(b, dest0, src0));
247396c5ddc4Srjs    else if (bitsize == 32)
247496c5ddc4Srjs        return (bi_frcp_f32_to(b, dest0, src0));
247596c5ddc4Srjs    else
247696c5ddc4Srjs        unreachable("Invalid parameters for FRCP");
247796c5ddc4Srjs}
247896c5ddc4Srjs
247996c5ddc4Srjsstatic inline
248096c5ddc4Srjsbi_index bi_frcp(bi_builder *b, unsigned bitsize, bi_index src0)
248196c5ddc4Srjs{
248296c5ddc4Srjs    if (bitsize == 16)
248396c5ddc4Srjs        return (bi_frcp_f16_to(b, bi_temp(b->shader), src0))->dest[0];
248496c5ddc4Srjs    else if (bitsize == 32)
248596c5ddc4Srjs        return (bi_frcp_f32_to(b, bi_temp(b->shader), src0))->dest[0];
248696c5ddc4Srjs    else
248796c5ddc4Srjs        unreachable("Invalid parameters for FRCP");
248896c5ddc4Srjs}
248996c5ddc4Srjs
249096c5ddc4Srjsstatic inline
249196c5ddc4Srjsbi_instr * bi_frcp_approx_f32_to(bi_builder *b, bi_index dest0, bi_index src0)
249296c5ddc4Srjs{
249396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
249496c5ddc4Srjs    I->op = BI_OPCODE_FRCP_APPROX_F32;
249596c5ddc4Srjs    I->dest[0] = dest0;
249696c5ddc4Srjs    I->src[0] = src0;
249796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
249896c5ddc4Srjs    return I;
249996c5ddc4Srjs}
250096c5ddc4Srjs
250196c5ddc4Srjsstatic inline
250296c5ddc4Srjsbi_index bi_frcp_approx_f32(bi_builder *b, bi_index src0)
250396c5ddc4Srjs{
250496c5ddc4Srjs    return (bi_frcp_approx_f32_to(b, bi_temp(b->shader), src0))->dest[0];
250596c5ddc4Srjs}
250696c5ddc4Srjs
250796c5ddc4Srjs
250896c5ddc4Srjsstatic inline
250996c5ddc4Srjsbi_instr * bi_frexpe_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bool log, bool sqrt)
251096c5ddc4Srjs{
251196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
251296c5ddc4Srjs    I->op = BI_OPCODE_FREXPE_F32;
251396c5ddc4Srjs    I->dest[0] = dest0;
251496c5ddc4Srjs    I->src[0] = src0;
251596c5ddc4Srjs    I->sqrt = sqrt;
251696c5ddc4Srjs    I->log = log;
251796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
251896c5ddc4Srjs    return I;
251996c5ddc4Srjs}
252096c5ddc4Srjs
252196c5ddc4Srjsstatic inline
252296c5ddc4Srjsbi_index bi_frexpe_f32(bi_builder *b, bi_index src0, bool log, bool sqrt)
252396c5ddc4Srjs{
252496c5ddc4Srjs    return (bi_frexpe_f32_to(b, bi_temp(b->shader), src0, log, sqrt))->dest[0];
252596c5ddc4Srjs}
252696c5ddc4Srjs
252796c5ddc4Srjs
252896c5ddc4Srjsstatic inline
252996c5ddc4Srjsbi_instr * bi_frexpe_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bool log, bool sqrt)
253096c5ddc4Srjs{
253196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
253296c5ddc4Srjs    I->op = BI_OPCODE_FREXPE_V2F16;
253396c5ddc4Srjs    I->dest[0] = dest0;
253496c5ddc4Srjs    I->src[0] = src0;
253596c5ddc4Srjs    I->sqrt = sqrt;
253696c5ddc4Srjs    I->log = log;
253796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
253896c5ddc4Srjs    return I;
253996c5ddc4Srjs}
254096c5ddc4Srjs
254196c5ddc4Srjsstatic inline
254296c5ddc4Srjsbi_index bi_frexpe_v2f16(bi_builder *b, bi_index src0, bool log, bool sqrt)
254396c5ddc4Srjs{
254496c5ddc4Srjs    return (bi_frexpe_v2f16_to(b, bi_temp(b->shader), src0, log, sqrt))->dest[0];
254596c5ddc4Srjs}
254696c5ddc4Srjs
254796c5ddc4Srjs
254896c5ddc4Srjsstatic inline
254996c5ddc4Srjsbi_instr * bi_frexpe_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bool log, bool sqrt)
255096c5ddc4Srjs{
255196c5ddc4Srjs    if (bitsize == 32)
255296c5ddc4Srjs        return (bi_frexpe_f32_to(b, dest0, src0, log, sqrt));
255396c5ddc4Srjs    else if (bitsize == 16)
255496c5ddc4Srjs        return (bi_frexpe_v2f16_to(b, dest0, src0, log, sqrt));
255596c5ddc4Srjs    else
255696c5ddc4Srjs        unreachable("Invalid parameters for FREXPE");
255796c5ddc4Srjs}
255896c5ddc4Srjs
255996c5ddc4Srjsstatic inline
256096c5ddc4Srjsbi_index bi_frexpe(bi_builder *b, unsigned bitsize, bi_index src0, bool log, bool sqrt)
256196c5ddc4Srjs{
256296c5ddc4Srjs    if (bitsize == 32)
256396c5ddc4Srjs        return (bi_frexpe_f32_to(b, bi_temp(b->shader), src0, log, sqrt))->dest[0];
256496c5ddc4Srjs    else if (bitsize == 16)
256596c5ddc4Srjs        return (bi_frexpe_v2f16_to(b, bi_temp(b->shader), src0, log, sqrt))->dest[0];
256696c5ddc4Srjs    else
256796c5ddc4Srjs        unreachable("Invalid parameters for FREXPE");
256896c5ddc4Srjs}
256996c5ddc4Srjs
257096c5ddc4Srjsstatic inline
257196c5ddc4Srjsbi_instr * bi_frexpm_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bool log, bool sqrt)
257296c5ddc4Srjs{
257396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
257496c5ddc4Srjs    I->op = BI_OPCODE_FREXPM_F32;
257596c5ddc4Srjs    I->dest[0] = dest0;
257696c5ddc4Srjs    I->src[0] = src0;
257796c5ddc4Srjs    I->sqrt = sqrt;
257896c5ddc4Srjs    I->log = log;
257996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
258096c5ddc4Srjs    return I;
258196c5ddc4Srjs}
258296c5ddc4Srjs
258396c5ddc4Srjsstatic inline
258496c5ddc4Srjsbi_index bi_frexpm_f32(bi_builder *b, bi_index src0, bool log, bool sqrt)
258596c5ddc4Srjs{
258696c5ddc4Srjs    return (bi_frexpm_f32_to(b, bi_temp(b->shader), src0, log, sqrt))->dest[0];
258796c5ddc4Srjs}
258896c5ddc4Srjs
258996c5ddc4Srjs
259096c5ddc4Srjsstatic inline
259196c5ddc4Srjsbi_instr * bi_frexpm_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bool log, bool sqrt)
259296c5ddc4Srjs{
259396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
259496c5ddc4Srjs    I->op = BI_OPCODE_FREXPM_V2F16;
259596c5ddc4Srjs    I->dest[0] = dest0;
259696c5ddc4Srjs    I->src[0] = src0;
259796c5ddc4Srjs    I->sqrt = sqrt;
259896c5ddc4Srjs    I->log = log;
259996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
260096c5ddc4Srjs    return I;
260196c5ddc4Srjs}
260296c5ddc4Srjs
260396c5ddc4Srjsstatic inline
260496c5ddc4Srjsbi_index bi_frexpm_v2f16(bi_builder *b, bi_index src0, bool log, bool sqrt)
260596c5ddc4Srjs{
260696c5ddc4Srjs    return (bi_frexpm_v2f16_to(b, bi_temp(b->shader), src0, log, sqrt))->dest[0];
260796c5ddc4Srjs}
260896c5ddc4Srjs
260996c5ddc4Srjs
261096c5ddc4Srjsstatic inline
261196c5ddc4Srjsbi_instr * bi_frexpm_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bool log, bool sqrt)
261296c5ddc4Srjs{
261396c5ddc4Srjs    if (bitsize == 32)
261496c5ddc4Srjs        return (bi_frexpm_f32_to(b, dest0, src0, log, sqrt));
261596c5ddc4Srjs    else if (bitsize == 16)
261696c5ddc4Srjs        return (bi_frexpm_v2f16_to(b, dest0, src0, log, sqrt));
261796c5ddc4Srjs    else
261896c5ddc4Srjs        unreachable("Invalid parameters for FREXPM");
261996c5ddc4Srjs}
262096c5ddc4Srjs
262196c5ddc4Srjsstatic inline
262296c5ddc4Srjsbi_index bi_frexpm(bi_builder *b, unsigned bitsize, bi_index src0, bool log, bool sqrt)
262396c5ddc4Srjs{
262496c5ddc4Srjs    if (bitsize == 32)
262596c5ddc4Srjs        return (bi_frexpm_f32_to(b, bi_temp(b->shader), src0, log, sqrt))->dest[0];
262696c5ddc4Srjs    else if (bitsize == 16)
262796c5ddc4Srjs        return (bi_frexpm_v2f16_to(b, bi_temp(b->shader), src0, log, sqrt))->dest[0];
262896c5ddc4Srjs    else
262996c5ddc4Srjs        unreachable("Invalid parameters for FREXPM");
263096c5ddc4Srjs}
263196c5ddc4Srjs
263296c5ddc4Srjsstatic inline
263396c5ddc4Srjsbi_instr * bi_fround_f32_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round)
263496c5ddc4Srjs{
263596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
263696c5ddc4Srjs    I->op = BI_OPCODE_FROUND_F32;
263796c5ddc4Srjs    I->dest[0] = dest0;
263896c5ddc4Srjs    I->src[0] = src0;
263996c5ddc4Srjs    I->round = round;
264096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
264196c5ddc4Srjs    return I;
264296c5ddc4Srjs}
264396c5ddc4Srjs
264496c5ddc4Srjsstatic inline
264596c5ddc4Srjsbi_index bi_fround_f32(bi_builder *b, bi_index src0, enum bi_round round)
264696c5ddc4Srjs{
264796c5ddc4Srjs    return (bi_fround_f32_to(b, bi_temp(b->shader), src0, round))->dest[0];
264896c5ddc4Srjs}
264996c5ddc4Srjs
265096c5ddc4Srjs
265196c5ddc4Srjsstatic inline
265296c5ddc4Srjsbi_instr * bi_fround_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round)
265396c5ddc4Srjs{
265496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
265596c5ddc4Srjs    I->op = BI_OPCODE_FROUND_V2F16;
265696c5ddc4Srjs    I->dest[0] = dest0;
265796c5ddc4Srjs    I->src[0] = src0;
265896c5ddc4Srjs    I->round = round;
265996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
266096c5ddc4Srjs    return I;
266196c5ddc4Srjs}
266296c5ddc4Srjs
266396c5ddc4Srjsstatic inline
266496c5ddc4Srjsbi_index bi_fround_v2f16(bi_builder *b, bi_index src0, enum bi_round round)
266596c5ddc4Srjs{
266696c5ddc4Srjs    return (bi_fround_v2f16_to(b, bi_temp(b->shader), src0, round))->dest[0];
266796c5ddc4Srjs}
266896c5ddc4Srjs
266996c5ddc4Srjs
267096c5ddc4Srjsstatic inline
267196c5ddc4Srjsbi_instr * bi_fround_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, enum bi_round round)
267296c5ddc4Srjs{
267396c5ddc4Srjs    if (bitsize == 32)
267496c5ddc4Srjs        return (bi_fround_f32_to(b, dest0, src0, round));
267596c5ddc4Srjs    else if (bitsize == 16)
267696c5ddc4Srjs        return (bi_fround_v2f16_to(b, dest0, src0, round));
267796c5ddc4Srjs    else
267896c5ddc4Srjs        unreachable("Invalid parameters for FROUND");
267996c5ddc4Srjs}
268096c5ddc4Srjs
268196c5ddc4Srjsstatic inline
268296c5ddc4Srjsbi_index bi_fround(bi_builder *b, unsigned bitsize, bi_index src0, enum bi_round round)
268396c5ddc4Srjs{
268496c5ddc4Srjs    if (bitsize == 32)
268596c5ddc4Srjs        return (bi_fround_f32_to(b, bi_temp(b->shader), src0, round))->dest[0];
268696c5ddc4Srjs    else if (bitsize == 16)
268796c5ddc4Srjs        return (bi_fround_v2f16_to(b, bi_temp(b->shader), src0, round))->dest[0];
268896c5ddc4Srjs    else
268996c5ddc4Srjs        unreachable("Invalid parameters for FROUND");
269096c5ddc4Srjs}
269196c5ddc4Srjs
269296c5ddc4Srjsstatic inline
269396c5ddc4Srjsbi_instr * bi_frscale_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1)
269496c5ddc4Srjs{
269596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
269696c5ddc4Srjs    I->op = BI_OPCODE_FRSCALE_F32;
269796c5ddc4Srjs    I->dest[0] = dest0;
269896c5ddc4Srjs    I->src[0] = src0;
269996c5ddc4Srjs    I->src[1] = src1;
270096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
270196c5ddc4Srjs    return I;
270296c5ddc4Srjs}
270396c5ddc4Srjs
270496c5ddc4Srjsstatic inline
270596c5ddc4Srjsbi_index bi_frscale_f32(bi_builder *b, bi_index src0, bi_index src1)
270696c5ddc4Srjs{
270796c5ddc4Srjs    return (bi_frscale_f32_to(b, bi_temp(b->shader), src0, src1))->dest[0];
270896c5ddc4Srjs}
270996c5ddc4Srjs
271096c5ddc4Srjs
271196c5ddc4Srjsstatic inline
271296c5ddc4Srjsbi_instr * bi_frscale_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1)
271396c5ddc4Srjs{
271496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
271596c5ddc4Srjs    I->op = BI_OPCODE_FRSCALE_V2F16;
271696c5ddc4Srjs    I->dest[0] = dest0;
271796c5ddc4Srjs    I->src[0] = src0;
271896c5ddc4Srjs    I->src[1] = src1;
271996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
272096c5ddc4Srjs    return I;
272196c5ddc4Srjs}
272296c5ddc4Srjs
272396c5ddc4Srjsstatic inline
272496c5ddc4Srjsbi_index bi_frscale_v2f16(bi_builder *b, bi_index src0, bi_index src1)
272596c5ddc4Srjs{
272696c5ddc4Srjs    return (bi_frscale_v2f16_to(b, bi_temp(b->shader), src0, src1))->dest[0];
272796c5ddc4Srjs}
272896c5ddc4Srjs
272996c5ddc4Srjs
273096c5ddc4Srjsstatic inline
273196c5ddc4Srjsbi_instr * bi_frscale_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1)
273296c5ddc4Srjs{
273396c5ddc4Srjs    if (bitsize == 32)
273496c5ddc4Srjs        return (bi_frscale_f32_to(b, dest0, src0, src1));
273596c5ddc4Srjs    else if (bitsize == 16)
273696c5ddc4Srjs        return (bi_frscale_v2f16_to(b, dest0, src0, src1));
273796c5ddc4Srjs    else
273896c5ddc4Srjs        unreachable("Invalid parameters for FRSCALE");
273996c5ddc4Srjs}
274096c5ddc4Srjs
274196c5ddc4Srjsstatic inline
274296c5ddc4Srjsbi_index bi_frscale(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1)
274396c5ddc4Srjs{
274496c5ddc4Srjs    if (bitsize == 32)
274596c5ddc4Srjs        return (bi_frscale_f32_to(b, bi_temp(b->shader), src0, src1))->dest[0];
274696c5ddc4Srjs    else if (bitsize == 16)
274796c5ddc4Srjs        return (bi_frscale_v2f16_to(b, bi_temp(b->shader), src0, src1))->dest[0];
274896c5ddc4Srjs    else
274996c5ddc4Srjs        unreachable("Invalid parameters for FRSCALE");
275096c5ddc4Srjs}
275196c5ddc4Srjs
275296c5ddc4Srjsstatic inline
275396c5ddc4Srjsbi_instr * bi_frshift_double_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bool bytes2)
275496c5ddc4Srjs{
275596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
275696c5ddc4Srjs    I->op = BI_OPCODE_FRSHIFT_DOUBLE_I32;
275796c5ddc4Srjs    I->dest[0] = dest0;
275896c5ddc4Srjs    I->src[0] = src0;
275996c5ddc4Srjs    I->src[1] = src1;
276096c5ddc4Srjs    I->src[2] = src2;
276196c5ddc4Srjs    I->bytes2 = bytes2;
276296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
276396c5ddc4Srjs    return I;
276496c5ddc4Srjs}
276596c5ddc4Srjs
276696c5ddc4Srjsstatic inline
276796c5ddc4Srjsbi_index bi_frshift_double_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bool bytes2)
276896c5ddc4Srjs{
276996c5ddc4Srjs    return (bi_frshift_double_i32_to(b, bi_temp(b->shader), src0, src1, src2, bytes2))->dest[0];
277096c5ddc4Srjs}
277196c5ddc4Srjs
277296c5ddc4Srjs
277396c5ddc4Srjsstatic inline
277496c5ddc4Srjsbi_instr * bi_frsq_f16_to(bi_builder *b, bi_index dest0, bi_index src0)
277596c5ddc4Srjs{
277696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
277796c5ddc4Srjs    I->op = BI_OPCODE_FRSQ_F16;
277896c5ddc4Srjs    I->dest[0] = dest0;
277996c5ddc4Srjs    I->src[0] = src0;
278096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
278196c5ddc4Srjs    return I;
278296c5ddc4Srjs}
278396c5ddc4Srjs
278496c5ddc4Srjsstatic inline
278596c5ddc4Srjsbi_index bi_frsq_f16(bi_builder *b, bi_index src0)
278696c5ddc4Srjs{
278796c5ddc4Srjs    return (bi_frsq_f16_to(b, bi_temp(b->shader), src0))->dest[0];
278896c5ddc4Srjs}
278996c5ddc4Srjs
279096c5ddc4Srjs
279196c5ddc4Srjsstatic inline
279296c5ddc4Srjsbi_instr * bi_frsq_f32_to(bi_builder *b, bi_index dest0, bi_index src0)
279396c5ddc4Srjs{
279496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
279596c5ddc4Srjs    I->op = BI_OPCODE_FRSQ_F32;
279696c5ddc4Srjs    I->dest[0] = dest0;
279796c5ddc4Srjs    I->src[0] = src0;
279896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
279996c5ddc4Srjs    return I;
280096c5ddc4Srjs}
280196c5ddc4Srjs
280296c5ddc4Srjsstatic inline
280396c5ddc4Srjsbi_index bi_frsq_f32(bi_builder *b, bi_index src0)
280496c5ddc4Srjs{
280596c5ddc4Srjs    return (bi_frsq_f32_to(b, bi_temp(b->shader), src0))->dest[0];
280696c5ddc4Srjs}
280796c5ddc4Srjs
280896c5ddc4Srjs
280996c5ddc4Srjsstatic inline
281096c5ddc4Srjsbi_instr * bi_frsq_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0)
281196c5ddc4Srjs{
281296c5ddc4Srjs    if (bitsize == 16)
281396c5ddc4Srjs        return (bi_frsq_f16_to(b, dest0, src0));
281496c5ddc4Srjs    else if (bitsize == 32)
281596c5ddc4Srjs        return (bi_frsq_f32_to(b, dest0, src0));
281696c5ddc4Srjs    else
281796c5ddc4Srjs        unreachable("Invalid parameters for FRSQ");
281896c5ddc4Srjs}
281996c5ddc4Srjs
282096c5ddc4Srjsstatic inline
282196c5ddc4Srjsbi_index bi_frsq(bi_builder *b, unsigned bitsize, bi_index src0)
282296c5ddc4Srjs{
282396c5ddc4Srjs    if (bitsize == 16)
282496c5ddc4Srjs        return (bi_frsq_f16_to(b, bi_temp(b->shader), src0))->dest[0];
282596c5ddc4Srjs    else if (bitsize == 32)
282696c5ddc4Srjs        return (bi_frsq_f32_to(b, bi_temp(b->shader), src0))->dest[0];
282796c5ddc4Srjs    else
282896c5ddc4Srjs        unreachable("Invalid parameters for FRSQ");
282996c5ddc4Srjs}
283096c5ddc4Srjs
283196c5ddc4Srjsstatic inline
283296c5ddc4Srjsbi_instr * bi_frsq_approx_f32_to(bi_builder *b, bi_index dest0, bi_index src0)
283396c5ddc4Srjs{
283496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
283596c5ddc4Srjs    I->op = BI_OPCODE_FRSQ_APPROX_F32;
283696c5ddc4Srjs    I->dest[0] = dest0;
283796c5ddc4Srjs    I->src[0] = src0;
283896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
283996c5ddc4Srjs    return I;
284096c5ddc4Srjs}
284196c5ddc4Srjs
284296c5ddc4Srjsstatic inline
284396c5ddc4Srjsbi_index bi_frsq_approx_f32(bi_builder *b, bi_index src0)
284496c5ddc4Srjs{
284596c5ddc4Srjs    return (bi_frsq_approx_f32_to(b, bi_temp(b->shader), src0))->dest[0];
284696c5ddc4Srjs}
284796c5ddc4Srjs
284896c5ddc4Srjs
284996c5ddc4Srjsstatic inline
285096c5ddc4Srjsbi_instr * bi_fsincos_offset_u6_to(bi_builder *b, bi_index dest0, bi_index src0, bool scale)
285196c5ddc4Srjs{
285296c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
285396c5ddc4Srjs    I->op = BI_OPCODE_FSINCOS_OFFSET_U6;
285496c5ddc4Srjs    I->dest[0] = dest0;
285596c5ddc4Srjs    I->src[0] = src0;
285696c5ddc4Srjs    I->scale = scale;
285796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
285896c5ddc4Srjs    return I;
285996c5ddc4Srjs}
286096c5ddc4Srjs
286196c5ddc4Srjsstatic inline
286296c5ddc4Srjsbi_index bi_fsincos_offset_u6(bi_builder *b, bi_index src0, bool scale)
286396c5ddc4Srjs{
286496c5ddc4Srjs    return (bi_fsincos_offset_u6_to(b, bi_temp(b->shader), src0, scale))->dest[0];
286596c5ddc4Srjs}
286696c5ddc4Srjs
286796c5ddc4Srjs
286896c5ddc4Srjsstatic inline
286996c5ddc4Srjsbi_instr * bi_fsin_table_u6_to(bi_builder *b, bi_index dest0, bi_index src0, bool offset)
287096c5ddc4Srjs{
287196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
287296c5ddc4Srjs    I->op = BI_OPCODE_FSIN_TABLE_U6;
287396c5ddc4Srjs    I->dest[0] = dest0;
287496c5ddc4Srjs    I->src[0] = src0;
287596c5ddc4Srjs    I->offset = offset;
287696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
287796c5ddc4Srjs    return I;
287896c5ddc4Srjs}
287996c5ddc4Srjs
288096c5ddc4Srjsstatic inline
288196c5ddc4Srjsbi_index bi_fsin_table_u6(bi_builder *b, bi_index src0, bool offset)
288296c5ddc4Srjs{
288396c5ddc4Srjs    return (bi_fsin_table_u6_to(b, bi_temp(b->shader), src0, offset))->dest[0];
288496c5ddc4Srjs}
288596c5ddc4Srjs
288696c5ddc4Srjs
288796c5ddc4Srjsstatic inline
288896c5ddc4Srjsbi_instr * bi_hadd_s32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round)
288996c5ddc4Srjs{
289096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
289196c5ddc4Srjs    I->op = BI_OPCODE_HADD_S32;
289296c5ddc4Srjs    I->dest[0] = dest0;
289396c5ddc4Srjs    I->src[0] = src0;
289496c5ddc4Srjs    I->src[1] = src1;
289596c5ddc4Srjs    I->round = round;
289696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
289796c5ddc4Srjs    return I;
289896c5ddc4Srjs}
289996c5ddc4Srjs
290096c5ddc4Srjsstatic inline
290196c5ddc4Srjsbi_index bi_hadd_s32(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round)
290296c5ddc4Srjs{
290396c5ddc4Srjs    return (bi_hadd_s32_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
290496c5ddc4Srjs}
290596c5ddc4Srjs
290696c5ddc4Srjs
290796c5ddc4Srjsstatic inline
290896c5ddc4Srjsbi_instr * bi_hadd_u32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round)
290996c5ddc4Srjs{
291096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
291196c5ddc4Srjs    I->op = BI_OPCODE_HADD_U32;
291296c5ddc4Srjs    I->dest[0] = dest0;
291396c5ddc4Srjs    I->src[0] = src0;
291496c5ddc4Srjs    I->src[1] = src1;
291596c5ddc4Srjs    I->round = round;
291696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
291796c5ddc4Srjs    return I;
291896c5ddc4Srjs}
291996c5ddc4Srjs
292096c5ddc4Srjsstatic inline
292196c5ddc4Srjsbi_index bi_hadd_u32(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round)
292296c5ddc4Srjs{
292396c5ddc4Srjs    return (bi_hadd_u32_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
292496c5ddc4Srjs}
292596c5ddc4Srjs
292696c5ddc4Srjs
292796c5ddc4Srjsstatic inline
292896c5ddc4Srjsbi_instr * bi_hadd_v2s16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round)
292996c5ddc4Srjs{
293096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
293196c5ddc4Srjs    I->op = BI_OPCODE_HADD_V2S16;
293296c5ddc4Srjs    I->dest[0] = dest0;
293396c5ddc4Srjs    I->src[0] = src0;
293496c5ddc4Srjs    I->src[1] = src1;
293596c5ddc4Srjs    I->round = round;
293696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
293796c5ddc4Srjs    return I;
293896c5ddc4Srjs}
293996c5ddc4Srjs
294096c5ddc4Srjsstatic inline
294196c5ddc4Srjsbi_index bi_hadd_v2s16(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round)
294296c5ddc4Srjs{
294396c5ddc4Srjs    return (bi_hadd_v2s16_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
294496c5ddc4Srjs}
294596c5ddc4Srjs
294696c5ddc4Srjs
294796c5ddc4Srjsstatic inline
294896c5ddc4Srjsbi_instr * bi_hadd_v2u16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round)
294996c5ddc4Srjs{
295096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
295196c5ddc4Srjs    I->op = BI_OPCODE_HADD_V2U16;
295296c5ddc4Srjs    I->dest[0] = dest0;
295396c5ddc4Srjs    I->src[0] = src0;
295496c5ddc4Srjs    I->src[1] = src1;
295596c5ddc4Srjs    I->round = round;
295696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
295796c5ddc4Srjs    return I;
295896c5ddc4Srjs}
295996c5ddc4Srjs
296096c5ddc4Srjsstatic inline
296196c5ddc4Srjsbi_index bi_hadd_v2u16(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round)
296296c5ddc4Srjs{
296396c5ddc4Srjs    return (bi_hadd_v2u16_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
296496c5ddc4Srjs}
296596c5ddc4Srjs
296696c5ddc4Srjs
296796c5ddc4Srjsstatic inline
296896c5ddc4Srjsbi_instr * bi_hadd_v4s8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round)
296996c5ddc4Srjs{
297096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
297196c5ddc4Srjs    I->op = BI_OPCODE_HADD_V4S8;
297296c5ddc4Srjs    I->dest[0] = dest0;
297396c5ddc4Srjs    I->src[0] = src0;
297496c5ddc4Srjs    I->src[1] = src1;
297596c5ddc4Srjs    I->round = round;
297696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
297796c5ddc4Srjs    return I;
297896c5ddc4Srjs}
297996c5ddc4Srjs
298096c5ddc4Srjsstatic inline
298196c5ddc4Srjsbi_index bi_hadd_v4s8(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round)
298296c5ddc4Srjs{
298396c5ddc4Srjs    return (bi_hadd_v4s8_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
298496c5ddc4Srjs}
298596c5ddc4Srjs
298696c5ddc4Srjs
298796c5ddc4Srjsstatic inline
298896c5ddc4Srjsbi_instr * bi_hadd_v4u8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round)
298996c5ddc4Srjs{
299096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
299196c5ddc4Srjs    I->op = BI_OPCODE_HADD_V4U8;
299296c5ddc4Srjs    I->dest[0] = dest0;
299396c5ddc4Srjs    I->src[0] = src0;
299496c5ddc4Srjs    I->src[1] = src1;
299596c5ddc4Srjs    I->round = round;
299696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
299796c5ddc4Srjs    return I;
299896c5ddc4Srjs}
299996c5ddc4Srjs
300096c5ddc4Srjsstatic inline
300196c5ddc4Srjsbi_index bi_hadd_v4u8(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round)
300296c5ddc4Srjs{
300396c5ddc4Srjs    return (bi_hadd_v4u8_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
300496c5ddc4Srjs}
300596c5ddc4Srjs
300696c5ddc4Srjs
300796c5ddc4Srjsstatic inline
300896c5ddc4Srjsbi_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)
300996c5ddc4Srjs{
301096c5ddc4Srjs    if ((type == nir_type_int) && bitsize == 32)
301196c5ddc4Srjs        return (bi_hadd_s32_to(b, dest0, src0, src1, round));
301296c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 32)
301396c5ddc4Srjs        return (bi_hadd_u32_to(b, dest0, src0, src1, round));
301496c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 16)
301596c5ddc4Srjs        return (bi_hadd_v2s16_to(b, dest0, src0, src1, round));
301696c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 16)
301796c5ddc4Srjs        return (bi_hadd_v2u16_to(b, dest0, src0, src1, round));
301896c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 8)
301996c5ddc4Srjs        return (bi_hadd_v4s8_to(b, dest0, src0, src1, round));
302096c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 8)
302196c5ddc4Srjs        return (bi_hadd_v4u8_to(b, dest0, src0, src1, round));
302296c5ddc4Srjs    else
302396c5ddc4Srjs        unreachable("Invalid parameters for HADD");
302496c5ddc4Srjs}
302596c5ddc4Srjs
302696c5ddc4Srjsstatic inline
302796c5ddc4Srjsbi_index bi_hadd(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index src0, bi_index src1, enum bi_round round)
302896c5ddc4Srjs{
302996c5ddc4Srjs    if ((type == nir_type_int) && bitsize == 32)
303096c5ddc4Srjs        return (bi_hadd_s32_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
303196c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 32)
303296c5ddc4Srjs        return (bi_hadd_u32_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
303396c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 16)
303496c5ddc4Srjs        return (bi_hadd_v2s16_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
303596c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 16)
303696c5ddc4Srjs        return (bi_hadd_v2u16_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
303796c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 8)
303896c5ddc4Srjs        return (bi_hadd_v4s8_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
303996c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 8)
304096c5ddc4Srjs        return (bi_hadd_v4u8_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
304196c5ddc4Srjs    else
304296c5ddc4Srjs        unreachable("Invalid parameters for HADD");
304396c5ddc4Srjs}
304496c5ddc4Srjs
304596c5ddc4Srjsstatic inline
304696c5ddc4Srjsbi_instr * bi_iabs_s32_to(bi_builder *b, bi_index dest0, bi_index src0)
304796c5ddc4Srjs{
304896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
304996c5ddc4Srjs    I->op = BI_OPCODE_IABS_S32;
305096c5ddc4Srjs    I->dest[0] = dest0;
305196c5ddc4Srjs    I->src[0] = src0;
305296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
305396c5ddc4Srjs    return I;
305496c5ddc4Srjs}
305596c5ddc4Srjs
305696c5ddc4Srjsstatic inline
305796c5ddc4Srjsbi_index bi_iabs_s32(bi_builder *b, bi_index src0)
305896c5ddc4Srjs{
305996c5ddc4Srjs    return (bi_iabs_s32_to(b, bi_temp(b->shader), src0))->dest[0];
306096c5ddc4Srjs}
306196c5ddc4Srjs
306296c5ddc4Srjs
306396c5ddc4Srjsstatic inline
306496c5ddc4Srjsbi_instr * bi_iabs_v2s16_to(bi_builder *b, bi_index dest0, bi_index src0)
306596c5ddc4Srjs{
306696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
306796c5ddc4Srjs    I->op = BI_OPCODE_IABS_V2S16;
306896c5ddc4Srjs    I->dest[0] = dest0;
306996c5ddc4Srjs    I->src[0] = src0;
307096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
307196c5ddc4Srjs    return I;
307296c5ddc4Srjs}
307396c5ddc4Srjs
307496c5ddc4Srjsstatic inline
307596c5ddc4Srjsbi_index bi_iabs_v2s16(bi_builder *b, bi_index src0)
307696c5ddc4Srjs{
307796c5ddc4Srjs    return (bi_iabs_v2s16_to(b, bi_temp(b->shader), src0))->dest[0];
307896c5ddc4Srjs}
307996c5ddc4Srjs
308096c5ddc4Srjs
308196c5ddc4Srjsstatic inline
308296c5ddc4Srjsbi_instr * bi_iabs_v4s8_to(bi_builder *b, bi_index dest0, bi_index src0)
308396c5ddc4Srjs{
308496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
308596c5ddc4Srjs    I->op = BI_OPCODE_IABS_V4S8;
308696c5ddc4Srjs    I->dest[0] = dest0;
308796c5ddc4Srjs    I->src[0] = src0;
308896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
308996c5ddc4Srjs    return I;
309096c5ddc4Srjs}
309196c5ddc4Srjs
309296c5ddc4Srjsstatic inline
309396c5ddc4Srjsbi_index bi_iabs_v4s8(bi_builder *b, bi_index src0)
309496c5ddc4Srjs{
309596c5ddc4Srjs    return (bi_iabs_v4s8_to(b, bi_temp(b->shader), src0))->dest[0];
309696c5ddc4Srjs}
309796c5ddc4Srjs
309896c5ddc4Srjs
309996c5ddc4Srjsstatic inline
310096c5ddc4Srjsbi_instr * bi_iabs_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0)
310196c5ddc4Srjs{
310296c5ddc4Srjs    if (bitsize == 32)
310396c5ddc4Srjs        return (bi_iabs_s32_to(b, dest0, src0));
310496c5ddc4Srjs    else if (bitsize == 16)
310596c5ddc4Srjs        return (bi_iabs_v2s16_to(b, dest0, src0));
310696c5ddc4Srjs    else if (bitsize == 8)
310796c5ddc4Srjs        return (bi_iabs_v4s8_to(b, dest0, src0));
310896c5ddc4Srjs    else
310996c5ddc4Srjs        unreachable("Invalid parameters for IABS");
311096c5ddc4Srjs}
311196c5ddc4Srjs
311296c5ddc4Srjsstatic inline
311396c5ddc4Srjsbi_index bi_iabs(bi_builder *b, unsigned bitsize, bi_index src0)
311496c5ddc4Srjs{
311596c5ddc4Srjs    if (bitsize == 32)
311696c5ddc4Srjs        return (bi_iabs_s32_to(b, bi_temp(b->shader), src0))->dest[0];
311796c5ddc4Srjs    else if (bitsize == 16)
311896c5ddc4Srjs        return (bi_iabs_v2s16_to(b, bi_temp(b->shader), src0))->dest[0];
311996c5ddc4Srjs    else if (bitsize == 8)
312096c5ddc4Srjs        return (bi_iabs_v4s8_to(b, bi_temp(b->shader), src0))->dest[0];
312196c5ddc4Srjs    else
312296c5ddc4Srjs        unreachable("Invalid parameters for IABS");
312396c5ddc4Srjs}
312496c5ddc4Srjs
312596c5ddc4Srjsstatic inline
312696c5ddc4Srjsbi_instr * bi_iadd_s32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate)
312796c5ddc4Srjs{
312896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
312996c5ddc4Srjs    I->op = BI_OPCODE_IADD_S32;
313096c5ddc4Srjs    I->dest[0] = dest0;
313196c5ddc4Srjs    I->src[0] = src0;
313296c5ddc4Srjs    I->src[1] = src1;
313396c5ddc4Srjs    I->saturate = saturate;
313496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
313596c5ddc4Srjs    return I;
313696c5ddc4Srjs}
313796c5ddc4Srjs
313896c5ddc4Srjsstatic inline
313996c5ddc4Srjsbi_index bi_iadd_s32(bi_builder *b, bi_index src0, bi_index src1, bool saturate)
314096c5ddc4Srjs{
314196c5ddc4Srjs    return (bi_iadd_s32_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
314296c5ddc4Srjs}
314396c5ddc4Srjs
314496c5ddc4Srjs
314596c5ddc4Srjsstatic inline
314696c5ddc4Srjsbi_instr * bi_iadd_u32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate)
314796c5ddc4Srjs{
314896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
314996c5ddc4Srjs    I->op = BI_OPCODE_IADD_U32;
315096c5ddc4Srjs    I->dest[0] = dest0;
315196c5ddc4Srjs    I->src[0] = src0;
315296c5ddc4Srjs    I->src[1] = src1;
315396c5ddc4Srjs    I->saturate = saturate;
315496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
315596c5ddc4Srjs    return I;
315696c5ddc4Srjs}
315796c5ddc4Srjs
315896c5ddc4Srjsstatic inline
315996c5ddc4Srjsbi_index bi_iadd_u32(bi_builder *b, bi_index src0, bi_index src1, bool saturate)
316096c5ddc4Srjs{
316196c5ddc4Srjs    return (bi_iadd_u32_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
316296c5ddc4Srjs}
316396c5ddc4Srjs
316496c5ddc4Srjs
316596c5ddc4Srjsstatic inline
316696c5ddc4Srjsbi_instr * bi_iadd_v2s16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate)
316796c5ddc4Srjs{
316896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
316996c5ddc4Srjs    I->op = BI_OPCODE_IADD_V2S16;
317096c5ddc4Srjs    I->dest[0] = dest0;
317196c5ddc4Srjs    I->src[0] = src0;
317296c5ddc4Srjs    I->src[1] = src1;
317396c5ddc4Srjs    I->saturate = saturate;
317496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
317596c5ddc4Srjs    return I;
317696c5ddc4Srjs}
317796c5ddc4Srjs
317896c5ddc4Srjsstatic inline
317996c5ddc4Srjsbi_index bi_iadd_v2s16(bi_builder *b, bi_index src0, bi_index src1, bool saturate)
318096c5ddc4Srjs{
318196c5ddc4Srjs    return (bi_iadd_v2s16_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
318296c5ddc4Srjs}
318396c5ddc4Srjs
318496c5ddc4Srjs
318596c5ddc4Srjsstatic inline
318696c5ddc4Srjsbi_instr * bi_iadd_v2u16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate)
318796c5ddc4Srjs{
318896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
318996c5ddc4Srjs    I->op = BI_OPCODE_IADD_V2U16;
319096c5ddc4Srjs    I->dest[0] = dest0;
319196c5ddc4Srjs    I->src[0] = src0;
319296c5ddc4Srjs    I->src[1] = src1;
319396c5ddc4Srjs    I->saturate = saturate;
319496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
319596c5ddc4Srjs    return I;
319696c5ddc4Srjs}
319796c5ddc4Srjs
319896c5ddc4Srjsstatic inline
319996c5ddc4Srjsbi_index bi_iadd_v2u16(bi_builder *b, bi_index src0, bi_index src1, bool saturate)
320096c5ddc4Srjs{
320196c5ddc4Srjs    return (bi_iadd_v2u16_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
320296c5ddc4Srjs}
320396c5ddc4Srjs
320496c5ddc4Srjs
320596c5ddc4Srjsstatic inline
320696c5ddc4Srjsbi_instr * bi_iadd_v4s8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate)
320796c5ddc4Srjs{
320896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
320996c5ddc4Srjs    I->op = BI_OPCODE_IADD_V4S8;
321096c5ddc4Srjs    I->dest[0] = dest0;
321196c5ddc4Srjs    I->src[0] = src0;
321296c5ddc4Srjs    I->src[1] = src1;
321396c5ddc4Srjs    I->saturate = saturate;
321496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
321596c5ddc4Srjs    return I;
321696c5ddc4Srjs}
321796c5ddc4Srjs
321896c5ddc4Srjsstatic inline
321996c5ddc4Srjsbi_index bi_iadd_v4s8(bi_builder *b, bi_index src0, bi_index src1, bool saturate)
322096c5ddc4Srjs{
322196c5ddc4Srjs    return (bi_iadd_v4s8_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
322296c5ddc4Srjs}
322396c5ddc4Srjs
322496c5ddc4Srjs
322596c5ddc4Srjsstatic inline
322696c5ddc4Srjsbi_instr * bi_iadd_v4u8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate)
322796c5ddc4Srjs{
322896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
322996c5ddc4Srjs    I->op = BI_OPCODE_IADD_V4U8;
323096c5ddc4Srjs    I->dest[0] = dest0;
323196c5ddc4Srjs    I->src[0] = src0;
323296c5ddc4Srjs    I->src[1] = src1;
323396c5ddc4Srjs    I->saturate = saturate;
323496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
323596c5ddc4Srjs    return I;
323696c5ddc4Srjs}
323796c5ddc4Srjs
323896c5ddc4Srjsstatic inline
323996c5ddc4Srjsbi_index bi_iadd_v4u8(bi_builder *b, bi_index src0, bi_index src1, bool saturate)
324096c5ddc4Srjs{
324196c5ddc4Srjs    return (bi_iadd_v4u8_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
324296c5ddc4Srjs}
324396c5ddc4Srjs
324496c5ddc4Srjs
324596c5ddc4Srjsstatic inline
324696c5ddc4Srjsbi_instr * bi_iadd_to(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bool saturate)
324796c5ddc4Srjs{
324896c5ddc4Srjs    if ((type == nir_type_int) && bitsize == 32)
324996c5ddc4Srjs        return (bi_iadd_s32_to(b, dest0, src0, src1, saturate));
325096c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 32)
325196c5ddc4Srjs        return (bi_iadd_u32_to(b, dest0, src0, src1, saturate));
325296c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 16)
325396c5ddc4Srjs        return (bi_iadd_v2s16_to(b, dest0, src0, src1, saturate));
325496c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 16)
325596c5ddc4Srjs        return (bi_iadd_v2u16_to(b, dest0, src0, src1, saturate));
325696c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 8)
325796c5ddc4Srjs        return (bi_iadd_v4s8_to(b, dest0, src0, src1, saturate));
325896c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 8)
325996c5ddc4Srjs        return (bi_iadd_v4u8_to(b, dest0, src0, src1, saturate));
326096c5ddc4Srjs    else
326196c5ddc4Srjs        unreachable("Invalid parameters for IADD");
326296c5ddc4Srjs}
326396c5ddc4Srjs
326496c5ddc4Srjsstatic inline
326596c5ddc4Srjsbi_index bi_iadd(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index src0, bi_index src1, bool saturate)
326696c5ddc4Srjs{
326796c5ddc4Srjs    if ((type == nir_type_int) && bitsize == 32)
326896c5ddc4Srjs        return (bi_iadd_s32_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
326996c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 32)
327096c5ddc4Srjs        return (bi_iadd_u32_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
327196c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 16)
327296c5ddc4Srjs        return (bi_iadd_v2s16_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
327396c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 16)
327496c5ddc4Srjs        return (bi_iadd_v2u16_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
327596c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 8)
327696c5ddc4Srjs        return (bi_iadd_v4s8_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
327796c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 8)
327896c5ddc4Srjs        return (bi_iadd_v4u8_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
327996c5ddc4Srjs    else
328096c5ddc4Srjs        unreachable("Invalid parameters for IADD");
328196c5ddc4Srjs}
328296c5ddc4Srjs
328396c5ddc4Srjsstatic inline
328496c5ddc4Srjsbi_instr * bi_iaddc_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
328596c5ddc4Srjs{
328696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
328796c5ddc4Srjs    I->op = BI_OPCODE_IADDC_I32;
328896c5ddc4Srjs    I->dest[0] = dest0;
328996c5ddc4Srjs    I->src[0] = src0;
329096c5ddc4Srjs    I->src[1] = src1;
329196c5ddc4Srjs    I->src[2] = src2;
329296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
329396c5ddc4Srjs    return I;
329496c5ddc4Srjs}
329596c5ddc4Srjs
329696c5ddc4Srjsstatic inline
329796c5ddc4Srjsbi_index bi_iaddc_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
329896c5ddc4Srjs{
329996c5ddc4Srjs    return (bi_iaddc_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
330096c5ddc4Srjs}
330196c5ddc4Srjs
330296c5ddc4Srjs
330396c5ddc4Srjsstatic inline
330496c5ddc4Srjsbi_instr * bi_iadd_imm_i32_to(bi_builder *b, bi_index dest0, bi_index src0, uint32_t index)
330596c5ddc4Srjs{
330696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
330796c5ddc4Srjs    I->op = BI_OPCODE_IADD_IMM_I32;
330896c5ddc4Srjs    I->dest[0] = dest0;
330996c5ddc4Srjs    I->src[0] = src0;
331096c5ddc4Srjs    I->index = index;
331196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
331296c5ddc4Srjs    return I;
331396c5ddc4Srjs}
331496c5ddc4Srjs
331596c5ddc4Srjsstatic inline
331696c5ddc4Srjsbi_index bi_iadd_imm_i32(bi_builder *b, bi_index src0, uint32_t index)
331796c5ddc4Srjs{
331896c5ddc4Srjs    return (bi_iadd_imm_i32_to(b, bi_temp(b->shader), src0, index))->dest[0];
331996c5ddc4Srjs}
332096c5ddc4Srjs
332196c5ddc4Srjs
332296c5ddc4Srjsstatic inline
332396c5ddc4Srjsbi_instr * bi_iadd_imm_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, uint32_t index)
332496c5ddc4Srjs{
332596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
332696c5ddc4Srjs    I->op = BI_OPCODE_IADD_IMM_V2I16;
332796c5ddc4Srjs    I->dest[0] = dest0;
332896c5ddc4Srjs    I->src[0] = src0;
332996c5ddc4Srjs    I->index = index;
333096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
333196c5ddc4Srjs    return I;
333296c5ddc4Srjs}
333396c5ddc4Srjs
333496c5ddc4Srjsstatic inline
333596c5ddc4Srjsbi_index bi_iadd_imm_v2i16(bi_builder *b, bi_index src0, uint32_t index)
333696c5ddc4Srjs{
333796c5ddc4Srjs    return (bi_iadd_imm_v2i16_to(b, bi_temp(b->shader), src0, index))->dest[0];
333896c5ddc4Srjs}
333996c5ddc4Srjs
334096c5ddc4Srjs
334196c5ddc4Srjsstatic inline
334296c5ddc4Srjsbi_instr * bi_iadd_imm_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, uint32_t index)
334396c5ddc4Srjs{
334496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
334596c5ddc4Srjs    I->op = BI_OPCODE_IADD_IMM_V4I8;
334696c5ddc4Srjs    I->dest[0] = dest0;
334796c5ddc4Srjs    I->src[0] = src0;
334896c5ddc4Srjs    I->index = index;
334996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
335096c5ddc4Srjs    return I;
335196c5ddc4Srjs}
335296c5ddc4Srjs
335396c5ddc4Srjsstatic inline
335496c5ddc4Srjsbi_index bi_iadd_imm_v4i8(bi_builder *b, bi_index src0, uint32_t index)
335596c5ddc4Srjs{
335696c5ddc4Srjs    return (bi_iadd_imm_v4i8_to(b, bi_temp(b->shader), src0, index))->dest[0];
335796c5ddc4Srjs}
335896c5ddc4Srjs
335996c5ddc4Srjs
336096c5ddc4Srjsstatic inline
336196c5ddc4Srjsbi_instr * bi_iadd_imm_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, uint32_t index)
336296c5ddc4Srjs{
336396c5ddc4Srjs    if (bitsize == 32)
336496c5ddc4Srjs        return (bi_iadd_imm_i32_to(b, dest0, src0, index));
336596c5ddc4Srjs    else if (bitsize == 16)
336696c5ddc4Srjs        return (bi_iadd_imm_v2i16_to(b, dest0, src0, index));
336796c5ddc4Srjs    else if (bitsize == 8)
336896c5ddc4Srjs        return (bi_iadd_imm_v4i8_to(b, dest0, src0, index));
336996c5ddc4Srjs    else
337096c5ddc4Srjs        unreachable("Invalid parameters for IADD_IMM");
337196c5ddc4Srjs}
337296c5ddc4Srjs
337396c5ddc4Srjsstatic inline
337496c5ddc4Srjsbi_index bi_iadd_imm(bi_builder *b, unsigned bitsize, bi_index src0, uint32_t index)
337596c5ddc4Srjs{
337696c5ddc4Srjs    if (bitsize == 32)
337796c5ddc4Srjs        return (bi_iadd_imm_i32_to(b, bi_temp(b->shader), src0, index))->dest[0];
337896c5ddc4Srjs    else if (bitsize == 16)
337996c5ddc4Srjs        return (bi_iadd_imm_v2i16_to(b, bi_temp(b->shader), src0, index))->dest[0];
338096c5ddc4Srjs    else if (bitsize == 8)
338196c5ddc4Srjs        return (bi_iadd_imm_v4i8_to(b, bi_temp(b->shader), src0, index))->dest[0];
338296c5ddc4Srjs    else
338396c5ddc4Srjs        unreachable("Invalid parameters for IADD_IMM");
338496c5ddc4Srjs}
338596c5ddc4Srjs
338696c5ddc4Srjsstatic inline
338796c5ddc4Srjsbi_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)
338896c5ddc4Srjs{
338996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
339096c5ddc4Srjs    I->op = BI_OPCODE_ICMP_I32;
339196c5ddc4Srjs    I->dest[0] = dest0;
339296c5ddc4Srjs    I->src[0] = src0;
339396c5ddc4Srjs    I->src[1] = src1;
339496c5ddc4Srjs    I->result_type = result_type;
339596c5ddc4Srjs    I->cmpf = cmpf;
339696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
339796c5ddc4Srjs    return I;
339896c5ddc4Srjs}
339996c5ddc4Srjs
340096c5ddc4Srjsstatic inline
340196c5ddc4Srjsbi_index bi_icmp_i32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type)
340296c5ddc4Srjs{
340396c5ddc4Srjs    return (bi_icmp_i32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
340496c5ddc4Srjs}
340596c5ddc4Srjs
340696c5ddc4Srjs
340796c5ddc4Srjsstatic inline
340896c5ddc4Srjsbi_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)
340996c5ddc4Srjs{
341096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
341196c5ddc4Srjs    I->op = BI_OPCODE_ICMP_S32;
341296c5ddc4Srjs    I->dest[0] = dest0;
341396c5ddc4Srjs    I->src[0] = src0;
341496c5ddc4Srjs    I->src[1] = src1;
341596c5ddc4Srjs    I->result_type = result_type;
341696c5ddc4Srjs    I->cmpf = cmpf;
341796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
341896c5ddc4Srjs    return I;
341996c5ddc4Srjs}
342096c5ddc4Srjs
342196c5ddc4Srjsstatic inline
342296c5ddc4Srjsbi_index bi_icmp_s32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type)
342396c5ddc4Srjs{
342496c5ddc4Srjs    return (bi_icmp_s32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
342596c5ddc4Srjs}
342696c5ddc4Srjs
342796c5ddc4Srjs
342896c5ddc4Srjsstatic inline
342996c5ddc4Srjsbi_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)
343096c5ddc4Srjs{
343196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
343296c5ddc4Srjs    I->op = BI_OPCODE_ICMP_U32;
343396c5ddc4Srjs    I->dest[0] = dest0;
343496c5ddc4Srjs    I->src[0] = src0;
343596c5ddc4Srjs    I->src[1] = src1;
343696c5ddc4Srjs    I->result_type = result_type;
343796c5ddc4Srjs    I->cmpf = cmpf;
343896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
343996c5ddc4Srjs    return I;
344096c5ddc4Srjs}
344196c5ddc4Srjs
344296c5ddc4Srjsstatic inline
344396c5ddc4Srjsbi_index bi_icmp_u32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type)
344496c5ddc4Srjs{
344596c5ddc4Srjs    return (bi_icmp_u32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
344696c5ddc4Srjs}
344796c5ddc4Srjs
344896c5ddc4Srjs
344996c5ddc4Srjsstatic inline
345096c5ddc4Srjsbi_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)
345196c5ddc4Srjs{
345296c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
345396c5ddc4Srjs    I->op = BI_OPCODE_ICMP_V2I16;
345496c5ddc4Srjs    I->dest[0] = dest0;
345596c5ddc4Srjs    I->src[0] = src0;
345696c5ddc4Srjs    I->src[1] = src1;
345796c5ddc4Srjs    I->result_type = result_type;
345896c5ddc4Srjs    I->cmpf = cmpf;
345996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
346096c5ddc4Srjs    return I;
346196c5ddc4Srjs}
346296c5ddc4Srjs
346396c5ddc4Srjsstatic inline
346496c5ddc4Srjsbi_index bi_icmp_v2i16(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type)
346596c5ddc4Srjs{
346696c5ddc4Srjs    return (bi_icmp_v2i16_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
346796c5ddc4Srjs}
346896c5ddc4Srjs
346996c5ddc4Srjs
347096c5ddc4Srjsstatic inline
347196c5ddc4Srjsbi_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)
347296c5ddc4Srjs{
347396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
347496c5ddc4Srjs    I->op = BI_OPCODE_ICMP_V2S16;
347596c5ddc4Srjs    I->dest[0] = dest0;
347696c5ddc4Srjs    I->src[0] = src0;
347796c5ddc4Srjs    I->src[1] = src1;
347896c5ddc4Srjs    I->result_type = result_type;
347996c5ddc4Srjs    I->cmpf = cmpf;
348096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
348196c5ddc4Srjs    return I;
348296c5ddc4Srjs}
348396c5ddc4Srjs
348496c5ddc4Srjsstatic inline
348596c5ddc4Srjsbi_index bi_icmp_v2s16(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type)
348696c5ddc4Srjs{
348796c5ddc4Srjs    return (bi_icmp_v2s16_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
348896c5ddc4Srjs}
348996c5ddc4Srjs
349096c5ddc4Srjs
349196c5ddc4Srjsstatic inline
349296c5ddc4Srjsbi_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)
349396c5ddc4Srjs{
349496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
349596c5ddc4Srjs    I->op = BI_OPCODE_ICMP_V2U16;
349696c5ddc4Srjs    I->dest[0] = dest0;
349796c5ddc4Srjs    I->src[0] = src0;
349896c5ddc4Srjs    I->src[1] = src1;
349996c5ddc4Srjs    I->result_type = result_type;
350096c5ddc4Srjs    I->cmpf = cmpf;
350196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
350296c5ddc4Srjs    return I;
350396c5ddc4Srjs}
350496c5ddc4Srjs
350596c5ddc4Srjsstatic inline
350696c5ddc4Srjsbi_index bi_icmp_v2u16(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type)
350796c5ddc4Srjs{
350896c5ddc4Srjs    return (bi_icmp_v2u16_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
350996c5ddc4Srjs}
351096c5ddc4Srjs
351196c5ddc4Srjs
351296c5ddc4Srjsstatic inline
351396c5ddc4Srjsbi_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)
351496c5ddc4Srjs{
351596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
351696c5ddc4Srjs    I->op = BI_OPCODE_ICMP_V4I8;
351796c5ddc4Srjs    I->dest[0] = dest0;
351896c5ddc4Srjs    I->src[0] = src0;
351996c5ddc4Srjs    I->src[1] = src1;
352096c5ddc4Srjs    I->result_type = result_type;
352196c5ddc4Srjs    I->cmpf = cmpf;
352296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
352396c5ddc4Srjs    return I;
352496c5ddc4Srjs}
352596c5ddc4Srjs
352696c5ddc4Srjsstatic inline
352796c5ddc4Srjsbi_index bi_icmp_v4i8(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type)
352896c5ddc4Srjs{
352996c5ddc4Srjs    return (bi_icmp_v4i8_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
353096c5ddc4Srjs}
353196c5ddc4Srjs
353296c5ddc4Srjs
353396c5ddc4Srjsstatic inline
353496c5ddc4Srjsbi_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)
353596c5ddc4Srjs{
353696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
353796c5ddc4Srjs    I->op = BI_OPCODE_ICMP_V4S8;
353896c5ddc4Srjs    I->dest[0] = dest0;
353996c5ddc4Srjs    I->src[0] = src0;
354096c5ddc4Srjs    I->src[1] = src1;
354196c5ddc4Srjs    I->result_type = result_type;
354296c5ddc4Srjs    I->cmpf = cmpf;
354396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
354496c5ddc4Srjs    return I;
354596c5ddc4Srjs}
354696c5ddc4Srjs
354796c5ddc4Srjsstatic inline
354896c5ddc4Srjsbi_index bi_icmp_v4s8(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type)
354996c5ddc4Srjs{
355096c5ddc4Srjs    return (bi_icmp_v4s8_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
355196c5ddc4Srjs}
355296c5ddc4Srjs
355396c5ddc4Srjs
355496c5ddc4Srjsstatic inline
355596c5ddc4Srjsbi_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)
355696c5ddc4Srjs{
355796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
355896c5ddc4Srjs    I->op = BI_OPCODE_ICMP_V4U8;
355996c5ddc4Srjs    I->dest[0] = dest0;
356096c5ddc4Srjs    I->src[0] = src0;
356196c5ddc4Srjs    I->src[1] = src1;
356296c5ddc4Srjs    I->result_type = result_type;
356396c5ddc4Srjs    I->cmpf = cmpf;
356496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
356596c5ddc4Srjs    return I;
356696c5ddc4Srjs}
356796c5ddc4Srjs
356896c5ddc4Srjsstatic inline
356996c5ddc4Srjsbi_index bi_icmp_v4u8(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type)
357096c5ddc4Srjs{
357196c5ddc4Srjs    return (bi_icmp_v4u8_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
357296c5ddc4Srjs}
357396c5ddc4Srjs
357496c5ddc4Srjs
357596c5ddc4Srjsstatic inline
357696c5ddc4Srjsbi_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)
357796c5ddc4Srjs{
357896c5ddc4Srjs    if ((type == nir_type_uint || type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE))
357996c5ddc4Srjs        return (bi_icmp_i32_to(b, dest0, src0, src1, cmpf, result_type));
358096c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
358196c5ddc4Srjs        return (bi_icmp_s32_to(b, dest0, src0, src1, cmpf, result_type));
358296c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
358396c5ddc4Srjs        return (bi_icmp_u32_to(b, dest0, src0, src1, cmpf, result_type));
358496c5ddc4Srjs    else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE))
358596c5ddc4Srjs        return (bi_icmp_v2i16_to(b, dest0, src0, src1, cmpf, result_type));
358696c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
358796c5ddc4Srjs        return (bi_icmp_v2s16_to(b, dest0, src0, src1, cmpf, result_type));
358896c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
358996c5ddc4Srjs        return (bi_icmp_v2u16_to(b, dest0, src0, src1, cmpf, result_type));
359096c5ddc4Srjs    else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 8 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE))
359196c5ddc4Srjs        return (bi_icmp_v4i8_to(b, dest0, src0, src1, cmpf, result_type));
359296c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 8 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
359396c5ddc4Srjs        return (bi_icmp_v4s8_to(b, dest0, src0, src1, cmpf, result_type));
359496c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 8 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
359596c5ddc4Srjs        return (bi_icmp_v4u8_to(b, dest0, src0, src1, cmpf, result_type));
359696c5ddc4Srjs    else
359796c5ddc4Srjs        unreachable("Invalid parameters for ICMP");
359896c5ddc4Srjs}
359996c5ddc4Srjs
360096c5ddc4Srjsstatic inline
360196c5ddc4Srjsbi_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)
360296c5ddc4Srjs{
360396c5ddc4Srjs    if ((type == nir_type_uint || type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE))
360496c5ddc4Srjs        return (bi_icmp_i32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
360596c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
360696c5ddc4Srjs        return (bi_icmp_s32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
360796c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 32 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
360896c5ddc4Srjs        return (bi_icmp_u32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
360996c5ddc4Srjs    else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE))
361096c5ddc4Srjs        return (bi_icmp_v2i16_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
361196c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
361296c5ddc4Srjs        return (bi_icmp_v2s16_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
361396c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 16 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
361496c5ddc4Srjs        return (bi_icmp_v2u16_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
361596c5ddc4Srjs    else if ((type == nir_type_uint || type == nir_type_int) && bitsize == 8 && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE))
361696c5ddc4Srjs        return (bi_icmp_v4i8_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
361796c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 8 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
361896c5ddc4Srjs        return (bi_icmp_v4s8_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
361996c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 8 && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE || cmpf == BI_CMPF_LT || cmpf == BI_CMPF_LE))
362096c5ddc4Srjs        return (bi_icmp_v4u8_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
362196c5ddc4Srjs    else
362296c5ddc4Srjs        unreachable("Invalid parameters for ICMP");
362396c5ddc4Srjs}
362496c5ddc4Srjs
362596c5ddc4Srjsstatic inline
362696c5ddc4Srjsbi_instr * bi_icmpf_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
362796c5ddc4Srjs{
362896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
362996c5ddc4Srjs    I->op = BI_OPCODE_ICMPF_I32;
363096c5ddc4Srjs    I->dest[0] = dest0;
363196c5ddc4Srjs    I->src[0] = src0;
363296c5ddc4Srjs    I->src[1] = src1;
363396c5ddc4Srjs    I->src[2] = src2;
363496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
363596c5ddc4Srjs    return I;
363696c5ddc4Srjs}
363796c5ddc4Srjs
363896c5ddc4Srjsstatic inline
363996c5ddc4Srjsbi_index bi_icmpf_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
364096c5ddc4Srjs{
364196c5ddc4Srjs    return (bi_icmpf_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
364296c5ddc4Srjs}
364396c5ddc4Srjs
364496c5ddc4Srjs
364596c5ddc4Srjsstatic inline
364696c5ddc4Srjsbi_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)
364796c5ddc4Srjs{
364896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
364996c5ddc4Srjs    I->op = BI_OPCODE_ICMPI_I32;
365096c5ddc4Srjs    I->dest[0] = dest0;
365196c5ddc4Srjs    I->src[0] = src0;
365296c5ddc4Srjs    I->src[1] = src1;
365396c5ddc4Srjs    I->result_type = result_type;
365496c5ddc4Srjs    I->cmpf = cmpf;
365596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
365696c5ddc4Srjs    return I;
365796c5ddc4Srjs}
365896c5ddc4Srjs
365996c5ddc4Srjsstatic inline
366096c5ddc4Srjsbi_index bi_icmpi_i32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type)
366196c5ddc4Srjs{
366296c5ddc4Srjs    return (bi_icmpi_i32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
366396c5ddc4Srjs}
366496c5ddc4Srjs
366596c5ddc4Srjs
366696c5ddc4Srjsstatic inline
366796c5ddc4Srjsbi_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)
366896c5ddc4Srjs{
366996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
367096c5ddc4Srjs    I->op = BI_OPCODE_ICMPI_S32;
367196c5ddc4Srjs    I->dest[0] = dest0;
367296c5ddc4Srjs    I->src[0] = src0;
367396c5ddc4Srjs    I->src[1] = src1;
367496c5ddc4Srjs    I->result_type = result_type;
367596c5ddc4Srjs    I->cmpf = cmpf;
367696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
367796c5ddc4Srjs    return I;
367896c5ddc4Srjs}
367996c5ddc4Srjs
368096c5ddc4Srjsstatic inline
368196c5ddc4Srjsbi_index bi_icmpi_s32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type)
368296c5ddc4Srjs{
368396c5ddc4Srjs    return (bi_icmpi_s32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
368496c5ddc4Srjs}
368596c5ddc4Srjs
368696c5ddc4Srjs
368796c5ddc4Srjsstatic inline
368896c5ddc4Srjsbi_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)
368996c5ddc4Srjs{
369096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
369196c5ddc4Srjs    I->op = BI_OPCODE_ICMPI_U32;
369296c5ddc4Srjs    I->dest[0] = dest0;
369396c5ddc4Srjs    I->src[0] = src0;
369496c5ddc4Srjs    I->src[1] = src1;
369596c5ddc4Srjs    I->result_type = result_type;
369696c5ddc4Srjs    I->cmpf = cmpf;
369796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
369896c5ddc4Srjs    return I;
369996c5ddc4Srjs}
370096c5ddc4Srjs
370196c5ddc4Srjsstatic inline
370296c5ddc4Srjsbi_index bi_icmpi_u32(bi_builder *b, bi_index src0, bi_index src1, enum bi_cmpf cmpf, enum bi_result_type result_type)
370396c5ddc4Srjs{
370496c5ddc4Srjs    return (bi_icmpi_u32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
370596c5ddc4Srjs}
370696c5ddc4Srjs
370796c5ddc4Srjs
370896c5ddc4Srjsstatic inline
370996c5ddc4Srjsbi_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)
371096c5ddc4Srjs{
371196c5ddc4Srjs    if ((type == nir_type_uint || type == nir_type_int) && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE))
371296c5ddc4Srjs        return (bi_icmpi_i32_to(b, dest0, src0, src1, cmpf, result_type));
371396c5ddc4Srjs    else if ((type == nir_type_int) && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE))
371496c5ddc4Srjs        return (bi_icmpi_s32_to(b, dest0, src0, src1, cmpf, result_type));
371596c5ddc4Srjs    else if ((type == nir_type_uint) && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE))
371696c5ddc4Srjs        return (bi_icmpi_u32_to(b, dest0, src0, src1, cmpf, result_type));
371796c5ddc4Srjs    else
371896c5ddc4Srjs        unreachable("Invalid parameters for ICMPI");
371996c5ddc4Srjs}
372096c5ddc4Srjs
372196c5ddc4Srjsstatic inline
372296c5ddc4Srjsbi_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)
372396c5ddc4Srjs{
372496c5ddc4Srjs    if ((type == nir_type_uint || type == nir_type_int) && (cmpf == BI_CMPF_EQ || cmpf == BI_CMPF_NE))
372596c5ddc4Srjs        return (bi_icmpi_i32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
372696c5ddc4Srjs    else if ((type == nir_type_int) && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE))
372796c5ddc4Srjs        return (bi_icmpi_s32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
372896c5ddc4Srjs    else if ((type == nir_type_uint) && (cmpf == BI_CMPF_GT || cmpf == BI_CMPF_GE))
372996c5ddc4Srjs        return (bi_icmpi_u32_to(b, bi_temp(b->shader), src0, src1, cmpf, result_type))->dest[0];
373096c5ddc4Srjs    else
373196c5ddc4Srjs        unreachable("Invalid parameters for ICMPI");
373296c5ddc4Srjs}
373396c5ddc4Srjs
373496c5ddc4Srjsstatic inline
373596c5ddc4Srjsbi_instr * bi_icmpm_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
373696c5ddc4Srjs{
373796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
373896c5ddc4Srjs    I->op = BI_OPCODE_ICMPM_I32;
373996c5ddc4Srjs    I->dest[0] = dest0;
374096c5ddc4Srjs    I->src[0] = src0;
374196c5ddc4Srjs    I->src[1] = src1;
374296c5ddc4Srjs    I->src[2] = src2;
374396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
374496c5ddc4Srjs    return I;
374596c5ddc4Srjs}
374696c5ddc4Srjs
374796c5ddc4Srjsstatic inline
374896c5ddc4Srjsbi_index bi_icmpm_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
374996c5ddc4Srjs{
375096c5ddc4Srjs    return (bi_icmpm_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
375196c5ddc4Srjs}
375296c5ddc4Srjs
375396c5ddc4Srjs
375496c5ddc4Srjsstatic inline
375596c5ddc4Srjsbi_instr * bi_idp_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1)
375696c5ddc4Srjs{
375796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
375896c5ddc4Srjs    I->op = BI_OPCODE_IDP_V4I8;
375996c5ddc4Srjs    I->dest[0] = dest0;
376096c5ddc4Srjs    I->src[0] = src0;
376196c5ddc4Srjs    I->src[1] = src1;
376296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
376396c5ddc4Srjs    return I;
376496c5ddc4Srjs}
376596c5ddc4Srjs
376696c5ddc4Srjsstatic inline
376796c5ddc4Srjsbi_index bi_idp_v4i8(bi_builder *b, bi_index src0, bi_index src1)
376896c5ddc4Srjs{
376996c5ddc4Srjs    return (bi_idp_v4i8_to(b, bi_temp(b->shader), src0, src1))->dest[0];
377096c5ddc4Srjs}
377196c5ddc4Srjs
377296c5ddc4Srjs
377396c5ddc4Srjsstatic inline
377496c5ddc4Srjsbi_instr * bi_ilogb_f32_to(bi_builder *b, bi_index dest0, bi_index src0)
377596c5ddc4Srjs{
377696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
377796c5ddc4Srjs    I->op = BI_OPCODE_ILOGB_F32;
377896c5ddc4Srjs    I->dest[0] = dest0;
377996c5ddc4Srjs    I->src[0] = src0;
378096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
378196c5ddc4Srjs    return I;
378296c5ddc4Srjs}
378396c5ddc4Srjs
378496c5ddc4Srjsstatic inline
378596c5ddc4Srjsbi_index bi_ilogb_f32(bi_builder *b, bi_index src0)
378696c5ddc4Srjs{
378796c5ddc4Srjs    return (bi_ilogb_f32_to(b, bi_temp(b->shader), src0))->dest[0];
378896c5ddc4Srjs}
378996c5ddc4Srjs
379096c5ddc4Srjs
379196c5ddc4Srjsstatic inline
379296c5ddc4Srjsbi_instr * bi_ilogb_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0)
379396c5ddc4Srjs{
379496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
379596c5ddc4Srjs    I->op = BI_OPCODE_ILOGB_V2F16;
379696c5ddc4Srjs    I->dest[0] = dest0;
379796c5ddc4Srjs    I->src[0] = src0;
379896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
379996c5ddc4Srjs    return I;
380096c5ddc4Srjs}
380196c5ddc4Srjs
380296c5ddc4Srjsstatic inline
380396c5ddc4Srjsbi_index bi_ilogb_v2f16(bi_builder *b, bi_index src0)
380496c5ddc4Srjs{
380596c5ddc4Srjs    return (bi_ilogb_v2f16_to(b, bi_temp(b->shader), src0))->dest[0];
380696c5ddc4Srjs}
380796c5ddc4Srjs
380896c5ddc4Srjs
380996c5ddc4Srjsstatic inline
381096c5ddc4Srjsbi_instr * bi_ilogb_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0)
381196c5ddc4Srjs{
381296c5ddc4Srjs    if (bitsize == 32)
381396c5ddc4Srjs        return (bi_ilogb_f32_to(b, dest0, src0));
381496c5ddc4Srjs    else if (bitsize == 16)
381596c5ddc4Srjs        return (bi_ilogb_v2f16_to(b, dest0, src0));
381696c5ddc4Srjs    else
381796c5ddc4Srjs        unreachable("Invalid parameters for ILOGB");
381896c5ddc4Srjs}
381996c5ddc4Srjs
382096c5ddc4Srjsstatic inline
382196c5ddc4Srjsbi_index bi_ilogb(bi_builder *b, unsigned bitsize, bi_index src0)
382296c5ddc4Srjs{
382396c5ddc4Srjs    if (bitsize == 32)
382496c5ddc4Srjs        return (bi_ilogb_f32_to(b, bi_temp(b->shader), src0))->dest[0];
382596c5ddc4Srjs    else if (bitsize == 16)
382696c5ddc4Srjs        return (bi_ilogb_v2f16_to(b, bi_temp(b->shader), src0))->dest[0];
382796c5ddc4Srjs    else
382896c5ddc4Srjs        unreachable("Invalid parameters for ILOGB");
382996c5ddc4Srjs}
383096c5ddc4Srjs
383196c5ddc4Srjsstatic inline
383296c5ddc4Srjsbi_instr * bi_imov_fma_to(bi_builder *b, bi_index dest0, bool threads)
383396c5ddc4Srjs{
383496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
383596c5ddc4Srjs    I->op = BI_OPCODE_IMOV_FMA;
383696c5ddc4Srjs    I->dest[0] = dest0;
383796c5ddc4Srjs    I->threads = threads;
383896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
383996c5ddc4Srjs    return I;
384096c5ddc4Srjs}
384196c5ddc4Srjs
384296c5ddc4Srjsstatic inline
384396c5ddc4Srjsbi_index bi_imov_fma(bi_builder *b, bool threads)
384496c5ddc4Srjs{
384596c5ddc4Srjs    return (bi_imov_fma_to(b, bi_temp(b->shader), threads))->dest[0];
384696c5ddc4Srjs}
384796c5ddc4Srjs
384896c5ddc4Srjs
384996c5ddc4Srjsstatic inline
385096c5ddc4Srjsbi_instr * bi_imul_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1)
385196c5ddc4Srjs{
385296c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
385396c5ddc4Srjs    I->op = BI_OPCODE_IMUL_I32;
385496c5ddc4Srjs    I->dest[0] = dest0;
385596c5ddc4Srjs    I->src[0] = src0;
385696c5ddc4Srjs    I->src[1] = src1;
385796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
385896c5ddc4Srjs    return I;
385996c5ddc4Srjs}
386096c5ddc4Srjs
386196c5ddc4Srjsstatic inline
386296c5ddc4Srjsbi_index bi_imul_i32(bi_builder *b, bi_index src0, bi_index src1)
386396c5ddc4Srjs{
386496c5ddc4Srjs    return (bi_imul_i32_to(b, bi_temp(b->shader), src0, src1))->dest[0];
386596c5ddc4Srjs}
386696c5ddc4Srjs
386796c5ddc4Srjs
386896c5ddc4Srjsstatic inline
386996c5ddc4Srjsbi_instr * bi_imul_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1)
387096c5ddc4Srjs{
387196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
387296c5ddc4Srjs    I->op = BI_OPCODE_IMUL_V2I16;
387396c5ddc4Srjs    I->dest[0] = dest0;
387496c5ddc4Srjs    I->src[0] = src0;
387596c5ddc4Srjs    I->src[1] = src1;
387696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
387796c5ddc4Srjs    return I;
387896c5ddc4Srjs}
387996c5ddc4Srjs
388096c5ddc4Srjsstatic inline
388196c5ddc4Srjsbi_index bi_imul_v2i16(bi_builder *b, bi_index src0, bi_index src1)
388296c5ddc4Srjs{
388396c5ddc4Srjs    return (bi_imul_v2i16_to(b, bi_temp(b->shader), src0, src1))->dest[0];
388496c5ddc4Srjs}
388596c5ddc4Srjs
388696c5ddc4Srjs
388796c5ddc4Srjsstatic inline
388896c5ddc4Srjsbi_instr * bi_imul_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1)
388996c5ddc4Srjs{
389096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
389196c5ddc4Srjs    I->op = BI_OPCODE_IMUL_V4I8;
389296c5ddc4Srjs    I->dest[0] = dest0;
389396c5ddc4Srjs    I->src[0] = src0;
389496c5ddc4Srjs    I->src[1] = src1;
389596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
389696c5ddc4Srjs    return I;
389796c5ddc4Srjs}
389896c5ddc4Srjs
389996c5ddc4Srjsstatic inline
390096c5ddc4Srjsbi_index bi_imul_v4i8(bi_builder *b, bi_index src0, bi_index src1)
390196c5ddc4Srjs{
390296c5ddc4Srjs    return (bi_imul_v4i8_to(b, bi_temp(b->shader), src0, src1))->dest[0];
390396c5ddc4Srjs}
390496c5ddc4Srjs
390596c5ddc4Srjs
390696c5ddc4Srjsstatic inline
390796c5ddc4Srjsbi_instr * bi_imul_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1)
390896c5ddc4Srjs{
390996c5ddc4Srjs    if (bitsize == 32)
391096c5ddc4Srjs        return (bi_imul_i32_to(b, dest0, src0, src1));
391196c5ddc4Srjs    else if (bitsize == 16)
391296c5ddc4Srjs        return (bi_imul_v2i16_to(b, dest0, src0, src1));
391396c5ddc4Srjs    else if (bitsize == 8)
391496c5ddc4Srjs        return (bi_imul_v4i8_to(b, dest0, src0, src1));
391596c5ddc4Srjs    else
391696c5ddc4Srjs        unreachable("Invalid parameters for IMUL");
391796c5ddc4Srjs}
391896c5ddc4Srjs
391996c5ddc4Srjsstatic inline
392096c5ddc4Srjsbi_index bi_imul(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1)
392196c5ddc4Srjs{
392296c5ddc4Srjs    if (bitsize == 32)
392396c5ddc4Srjs        return (bi_imul_i32_to(b, bi_temp(b->shader), src0, src1))->dest[0];
392496c5ddc4Srjs    else if (bitsize == 16)
392596c5ddc4Srjs        return (bi_imul_v2i16_to(b, bi_temp(b->shader), src0, src1))->dest[0];
392696c5ddc4Srjs    else if (bitsize == 8)
392796c5ddc4Srjs        return (bi_imul_v4i8_to(b, bi_temp(b->shader), src0, src1))->dest[0];
392896c5ddc4Srjs    else
392996c5ddc4Srjs        unreachable("Invalid parameters for IMUL");
393096c5ddc4Srjs}
393196c5ddc4Srjs
393296c5ddc4Srjsstatic inline
393396c5ddc4Srjsbi_instr * bi_imuld_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool threads)
393496c5ddc4Srjs{
393596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
393696c5ddc4Srjs    I->op = BI_OPCODE_IMULD;
393796c5ddc4Srjs    I->dest[0] = dest0;
393896c5ddc4Srjs    I->src[0] = src0;
393996c5ddc4Srjs    I->src[1] = src1;
394096c5ddc4Srjs    I->threads = threads;
394196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
394296c5ddc4Srjs    return I;
394396c5ddc4Srjs}
394496c5ddc4Srjs
394596c5ddc4Srjsstatic inline
394696c5ddc4Srjsbi_index bi_imuld(bi_builder *b, bi_index src0, bi_index src1, bool threads)
394796c5ddc4Srjs{
394896c5ddc4Srjs    return (bi_imuld_to(b, bi_temp(b->shader), src0, src1, threads))->dest[0];
394996c5ddc4Srjs}
395096c5ddc4Srjs
395196c5ddc4Srjs
395296c5ddc4Srjsstatic inline
395396c5ddc4Srjsbi_instr * bi_isub_s32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate)
395496c5ddc4Srjs{
395596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
395696c5ddc4Srjs    I->op = BI_OPCODE_ISUB_S32;
395796c5ddc4Srjs    I->dest[0] = dest0;
395896c5ddc4Srjs    I->src[0] = src0;
395996c5ddc4Srjs    I->src[1] = src1;
396096c5ddc4Srjs    I->saturate = saturate;
396196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
396296c5ddc4Srjs    return I;
396396c5ddc4Srjs}
396496c5ddc4Srjs
396596c5ddc4Srjsstatic inline
396696c5ddc4Srjsbi_index bi_isub_s32(bi_builder *b, bi_index src0, bi_index src1, bool saturate)
396796c5ddc4Srjs{
396896c5ddc4Srjs    return (bi_isub_s32_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
396996c5ddc4Srjs}
397096c5ddc4Srjs
397196c5ddc4Srjs
397296c5ddc4Srjsstatic inline
397396c5ddc4Srjsbi_instr * bi_isub_u32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate)
397496c5ddc4Srjs{
397596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
397696c5ddc4Srjs    I->op = BI_OPCODE_ISUB_U32;
397796c5ddc4Srjs    I->dest[0] = dest0;
397896c5ddc4Srjs    I->src[0] = src0;
397996c5ddc4Srjs    I->src[1] = src1;
398096c5ddc4Srjs    I->saturate = saturate;
398196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
398296c5ddc4Srjs    return I;
398396c5ddc4Srjs}
398496c5ddc4Srjs
398596c5ddc4Srjsstatic inline
398696c5ddc4Srjsbi_index bi_isub_u32(bi_builder *b, bi_index src0, bi_index src1, bool saturate)
398796c5ddc4Srjs{
398896c5ddc4Srjs    return (bi_isub_u32_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
398996c5ddc4Srjs}
399096c5ddc4Srjs
399196c5ddc4Srjs
399296c5ddc4Srjsstatic inline
399396c5ddc4Srjsbi_instr * bi_isub_v2s16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate)
399496c5ddc4Srjs{
399596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
399696c5ddc4Srjs    I->op = BI_OPCODE_ISUB_V2S16;
399796c5ddc4Srjs    I->dest[0] = dest0;
399896c5ddc4Srjs    I->src[0] = src0;
399996c5ddc4Srjs    I->src[1] = src1;
400096c5ddc4Srjs    I->saturate = saturate;
400196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
400296c5ddc4Srjs    return I;
400396c5ddc4Srjs}
400496c5ddc4Srjs
400596c5ddc4Srjsstatic inline
400696c5ddc4Srjsbi_index bi_isub_v2s16(bi_builder *b, bi_index src0, bi_index src1, bool saturate)
400796c5ddc4Srjs{
400896c5ddc4Srjs    return (bi_isub_v2s16_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
400996c5ddc4Srjs}
401096c5ddc4Srjs
401196c5ddc4Srjs
401296c5ddc4Srjsstatic inline
401396c5ddc4Srjsbi_instr * bi_isub_v2u16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate)
401496c5ddc4Srjs{
401596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
401696c5ddc4Srjs    I->op = BI_OPCODE_ISUB_V2U16;
401796c5ddc4Srjs    I->dest[0] = dest0;
401896c5ddc4Srjs    I->src[0] = src0;
401996c5ddc4Srjs    I->src[1] = src1;
402096c5ddc4Srjs    I->saturate = saturate;
402196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
402296c5ddc4Srjs    return I;
402396c5ddc4Srjs}
402496c5ddc4Srjs
402596c5ddc4Srjsstatic inline
402696c5ddc4Srjsbi_index bi_isub_v2u16(bi_builder *b, bi_index src0, bi_index src1, bool saturate)
402796c5ddc4Srjs{
402896c5ddc4Srjs    return (bi_isub_v2u16_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
402996c5ddc4Srjs}
403096c5ddc4Srjs
403196c5ddc4Srjs
403296c5ddc4Srjsstatic inline
403396c5ddc4Srjsbi_instr * bi_isub_v4s8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate)
403496c5ddc4Srjs{
403596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
403696c5ddc4Srjs    I->op = BI_OPCODE_ISUB_V4S8;
403796c5ddc4Srjs    I->dest[0] = dest0;
403896c5ddc4Srjs    I->src[0] = src0;
403996c5ddc4Srjs    I->src[1] = src1;
404096c5ddc4Srjs    I->saturate = saturate;
404196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
404296c5ddc4Srjs    return I;
404396c5ddc4Srjs}
404496c5ddc4Srjs
404596c5ddc4Srjsstatic inline
404696c5ddc4Srjsbi_index bi_isub_v4s8(bi_builder *b, bi_index src0, bi_index src1, bool saturate)
404796c5ddc4Srjs{
404896c5ddc4Srjs    return (bi_isub_v4s8_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
404996c5ddc4Srjs}
405096c5ddc4Srjs
405196c5ddc4Srjs
405296c5ddc4Srjsstatic inline
405396c5ddc4Srjsbi_instr * bi_isub_v4u8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool saturate)
405496c5ddc4Srjs{
405596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
405696c5ddc4Srjs    I->op = BI_OPCODE_ISUB_V4U8;
405796c5ddc4Srjs    I->dest[0] = dest0;
405896c5ddc4Srjs    I->src[0] = src0;
405996c5ddc4Srjs    I->src[1] = src1;
406096c5ddc4Srjs    I->saturate = saturate;
406196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
406296c5ddc4Srjs    return I;
406396c5ddc4Srjs}
406496c5ddc4Srjs
406596c5ddc4Srjsstatic inline
406696c5ddc4Srjsbi_index bi_isub_v4u8(bi_builder *b, bi_index src0, bi_index src1, bool saturate)
406796c5ddc4Srjs{
406896c5ddc4Srjs    return (bi_isub_v4u8_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
406996c5ddc4Srjs}
407096c5ddc4Srjs
407196c5ddc4Srjs
407296c5ddc4Srjsstatic inline
407396c5ddc4Srjsbi_instr * bi_isub_to(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bool saturate)
407496c5ddc4Srjs{
407596c5ddc4Srjs    if ((type == nir_type_int) && bitsize == 32)
407696c5ddc4Srjs        return (bi_isub_s32_to(b, dest0, src0, src1, saturate));
407796c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 32)
407896c5ddc4Srjs        return (bi_isub_u32_to(b, dest0, src0, src1, saturate));
407996c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 16)
408096c5ddc4Srjs        return (bi_isub_v2s16_to(b, dest0, src0, src1, saturate));
408196c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 16)
408296c5ddc4Srjs        return (bi_isub_v2u16_to(b, dest0, src0, src1, saturate));
408396c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 8)
408496c5ddc4Srjs        return (bi_isub_v4s8_to(b, dest0, src0, src1, saturate));
408596c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 8)
408696c5ddc4Srjs        return (bi_isub_v4u8_to(b, dest0, src0, src1, saturate));
408796c5ddc4Srjs    else
408896c5ddc4Srjs        unreachable("Invalid parameters for ISUB");
408996c5ddc4Srjs}
409096c5ddc4Srjs
409196c5ddc4Srjsstatic inline
409296c5ddc4Srjsbi_index bi_isub(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index src0, bi_index src1, bool saturate)
409396c5ddc4Srjs{
409496c5ddc4Srjs    if ((type == nir_type_int) && bitsize == 32)
409596c5ddc4Srjs        return (bi_isub_s32_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
409696c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 32)
409796c5ddc4Srjs        return (bi_isub_u32_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
409896c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 16)
409996c5ddc4Srjs        return (bi_isub_v2s16_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
410096c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 16)
410196c5ddc4Srjs        return (bi_isub_v2u16_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
410296c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 8)
410396c5ddc4Srjs        return (bi_isub_v4s8_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
410496c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 8)
410596c5ddc4Srjs        return (bi_isub_v4u8_to(b, bi_temp(b->shader), src0, src1, saturate))->dest[0];
410696c5ddc4Srjs    else
410796c5ddc4Srjs        unreachable("Invalid parameters for ISUB");
410896c5ddc4Srjs}
410996c5ddc4Srjs
411096c5ddc4Srjsstatic inline
411196c5ddc4Srjsbi_instr * bi_isubb_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
411296c5ddc4Srjs{
411396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
411496c5ddc4Srjs    I->op = BI_OPCODE_ISUBB_I32;
411596c5ddc4Srjs    I->dest[0] = dest0;
411696c5ddc4Srjs    I->src[0] = src0;
411796c5ddc4Srjs    I->src[1] = src1;
411896c5ddc4Srjs    I->src[2] = src2;
411996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
412096c5ddc4Srjs    return I;
412196c5ddc4Srjs}
412296c5ddc4Srjs
412396c5ddc4Srjsstatic inline
412496c5ddc4Srjsbi_index bi_isubb_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
412596c5ddc4Srjs{
412696c5ddc4Srjs    return (bi_isubb_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
412796c5ddc4Srjs}
412896c5ddc4Srjs
412996c5ddc4Srjs
413096c5ddc4Srjsstatic inline
413196c5ddc4Srjsbi_instr * bi_jump(bi_builder *b, bi_index src0)
413296c5ddc4Srjs{
413396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
413496c5ddc4Srjs    I->op = BI_OPCODE_JUMP;
413596c5ddc4Srjs    I->src[0] = src0;
413696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
413796c5ddc4Srjs    return I;
413896c5ddc4Srjs}
413996c5ddc4Srjs
414096c5ddc4Srjs
414196c5ddc4Srjsstatic inline
414296c5ddc4Srjsbi_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)
414396c5ddc4Srjs{
414496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
414596c5ddc4Srjs    I->op = BI_OPCODE_JUMP_EX;
414696c5ddc4Srjs    I->dest[0] = dest0;
414796c5ddc4Srjs    I->src[0] = src0;
414896c5ddc4Srjs    I->src[1] = src1;
414996c5ddc4Srjs    I->src[2] = src2;
415096c5ddc4Srjs    I->test_mode = test_mode;
415196c5ddc4Srjs    I->stack_mode = stack_mode;
415296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
415396c5ddc4Srjs    return I;
415496c5ddc4Srjs}
415596c5ddc4Srjs
415696c5ddc4Srjsstatic inline
415796c5ddc4Srjsbi_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)
415896c5ddc4Srjs{
415996c5ddc4Srjs    return (bi_jump_ex_to(b, bi_temp(b->shader), src0, src1, src2, stack_mode, test_mode))->dest[0];
416096c5ddc4Srjs}
416196c5ddc4Srjs
416296c5ddc4Srjs
416396c5ddc4Srjsstatic inline
416496c5ddc4Srjsbi_instr * bi_ldexp_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round)
416596c5ddc4Srjs{
416696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
416796c5ddc4Srjs    I->op = BI_OPCODE_LDEXP_F32;
416896c5ddc4Srjs    I->dest[0] = dest0;
416996c5ddc4Srjs    I->src[0] = src0;
417096c5ddc4Srjs    I->src[1] = src1;
417196c5ddc4Srjs    I->round = round;
417296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
417396c5ddc4Srjs    return I;
417496c5ddc4Srjs}
417596c5ddc4Srjs
417696c5ddc4Srjsstatic inline
417796c5ddc4Srjsbi_index bi_ldexp_f32(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round)
417896c5ddc4Srjs{
417996c5ddc4Srjs    return (bi_ldexp_f32_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
418096c5ddc4Srjs}
418196c5ddc4Srjs
418296c5ddc4Srjs
418396c5ddc4Srjsstatic inline
418496c5ddc4Srjsbi_instr * bi_ldexp_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round)
418596c5ddc4Srjs{
418696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
418796c5ddc4Srjs    I->op = BI_OPCODE_LDEXP_V2F16;
418896c5ddc4Srjs    I->dest[0] = dest0;
418996c5ddc4Srjs    I->src[0] = src0;
419096c5ddc4Srjs    I->src[1] = src1;
419196c5ddc4Srjs    I->round = round;
419296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
419396c5ddc4Srjs    return I;
419496c5ddc4Srjs}
419596c5ddc4Srjs
419696c5ddc4Srjsstatic inline
419796c5ddc4Srjsbi_index bi_ldexp_v2f16(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round)
419896c5ddc4Srjs{
419996c5ddc4Srjs    return (bi_ldexp_v2f16_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
420096c5ddc4Srjs}
420196c5ddc4Srjs
420296c5ddc4Srjs
420396c5ddc4Srjsstatic inline
420496c5ddc4Srjsbi_instr * bi_ldexp_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round)
420596c5ddc4Srjs{
420696c5ddc4Srjs    if (bitsize == 32)
420796c5ddc4Srjs        return (bi_ldexp_f32_to(b, dest0, src0, src1, round));
420896c5ddc4Srjs    else if (bitsize == 16)
420996c5ddc4Srjs        return (bi_ldexp_v2f16_to(b, dest0, src0, src1, round));
421096c5ddc4Srjs    else
421196c5ddc4Srjs        unreachable("Invalid parameters for LDEXP");
421296c5ddc4Srjs}
421396c5ddc4Srjs
421496c5ddc4Srjsstatic inline
421596c5ddc4Srjsbi_index bi_ldexp(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, enum bi_round round)
421696c5ddc4Srjs{
421796c5ddc4Srjs    if (bitsize == 32)
421896c5ddc4Srjs        return (bi_ldexp_f32_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
421996c5ddc4Srjs    else if (bitsize == 16)
422096c5ddc4Srjs        return (bi_ldexp_v2f16_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
422196c5ddc4Srjs    else
422296c5ddc4Srjs        unreachable("Invalid parameters for LDEXP");
422396c5ddc4Srjs}
422496c5ddc4Srjs
422596c5ddc4Srjsstatic inline
422696c5ddc4Srjsbi_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)
422796c5ddc4Srjs{
422896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
422996c5ddc4Srjs    I->op = BI_OPCODE_LD_ATTR;
423096c5ddc4Srjs    I->dest[0] = dest0;
423196c5ddc4Srjs    I->src[0] = src0;
423296c5ddc4Srjs    I->src[1] = src1;
423396c5ddc4Srjs    I->src[2] = src2;
423496c5ddc4Srjs    I->register_format = register_format;
423596c5ddc4Srjs    I->vecsize = vecsize;
423696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
423796c5ddc4Srjs    return I;
423896c5ddc4Srjs}
423996c5ddc4Srjs
424096c5ddc4Srjsstatic inline
424196c5ddc4Srjsbi_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)
424296c5ddc4Srjs{
424396c5ddc4Srjs    return (bi_ld_attr_to(b, bi_temp(b->shader), src0, src1, src2, register_format, vecsize))->dest[0];
424496c5ddc4Srjs}
424596c5ddc4Srjs
424696c5ddc4Srjs
424796c5ddc4Srjsstatic inline
424896c5ddc4Srjsbi_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)
424996c5ddc4Srjs{
425096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
425196c5ddc4Srjs    I->op = BI_OPCODE_LD_ATTR_IMM;
425296c5ddc4Srjs    I->dest[0] = dest0;
425396c5ddc4Srjs    I->src[0] = src0;
425496c5ddc4Srjs    I->src[1] = src1;
425596c5ddc4Srjs    I->register_format = register_format;
425696c5ddc4Srjs    I->vecsize = vecsize;
425796c5ddc4Srjs    I->attribute_index = attribute_index;
425896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
425996c5ddc4Srjs    return I;
426096c5ddc4Srjs}
426196c5ddc4Srjs
426296c5ddc4Srjsstatic inline
426396c5ddc4Srjsbi_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)
426496c5ddc4Srjs{
426596c5ddc4Srjs    return (bi_ld_attr_imm_to(b, bi_temp(b->shader), src0, src1, register_format, vecsize, attribute_index))->dest[0];
426696c5ddc4Srjs}
426796c5ddc4Srjs
426896c5ddc4Srjs
426996c5ddc4Srjsstatic inline
427096c5ddc4Srjsbi_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)
427196c5ddc4Srjs{
427296c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
427396c5ddc4Srjs    I->op = BI_OPCODE_LD_ATTR_TEX;
427496c5ddc4Srjs    I->dest[0] = dest0;
427596c5ddc4Srjs    I->src[0] = src0;
427696c5ddc4Srjs    I->src[1] = src1;
427796c5ddc4Srjs    I->src[2] = src2;
427896c5ddc4Srjs    I->register_format = register_format;
427996c5ddc4Srjs    I->vecsize = vecsize;
428096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
428196c5ddc4Srjs    return I;
428296c5ddc4Srjs}
428396c5ddc4Srjs
428496c5ddc4Srjsstatic inline
428596c5ddc4Srjsbi_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)
428696c5ddc4Srjs{
428796c5ddc4Srjs    return (bi_ld_attr_tex_to(b, bi_temp(b->shader), src0, src1, src2, register_format, vecsize))->dest[0];
428896c5ddc4Srjs}
428996c5ddc4Srjs
429096c5ddc4Srjs
429196c5ddc4Srjsstatic inline
429296c5ddc4Srjsbi_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)
429396c5ddc4Srjs{
429496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
429596c5ddc4Srjs    I->op = BI_OPCODE_LD_CVT;
429696c5ddc4Srjs    I->dest[0] = dest0;
429796c5ddc4Srjs    I->src[0] = src0;
429896c5ddc4Srjs    I->src[1] = src1;
429996c5ddc4Srjs    I->src[2] = src2;
430096c5ddc4Srjs    I->register_format = register_format;
430196c5ddc4Srjs    I->vecsize = vecsize;
430296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
430396c5ddc4Srjs    return I;
430496c5ddc4Srjs}
430596c5ddc4Srjs
430696c5ddc4Srjsstatic inline
430796c5ddc4Srjsbi_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)
430896c5ddc4Srjs{
430996c5ddc4Srjs    return (bi_ld_cvt_to(b, bi_temp(b->shader), src0, src1, src2, register_format, vecsize))->dest[0];
431096c5ddc4Srjs}
431196c5ddc4Srjs
431296c5ddc4Srjs
431396c5ddc4Srjsstatic inline
431496c5ddc4Srjsbi_instr * bi_ld_gclk_u64_to(bi_builder *b, bi_index dest0, enum bi_source source)
431596c5ddc4Srjs{
431696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
431796c5ddc4Srjs    I->op = BI_OPCODE_LD_GCLK_U64;
431896c5ddc4Srjs    I->dest[0] = dest0;
431996c5ddc4Srjs    I->source = source;
432096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
432196c5ddc4Srjs    return I;
432296c5ddc4Srjs}
432396c5ddc4Srjs
432496c5ddc4Srjsstatic inline
432596c5ddc4Srjsbi_index bi_ld_gclk_u64(bi_builder *b, enum bi_source source)
432696c5ddc4Srjs{
432796c5ddc4Srjs    return (bi_ld_gclk_u64_to(b, bi_temp(b->shader), source))->dest[0];
432896c5ddc4Srjs}
432996c5ddc4Srjs
433096c5ddc4Srjs
433196c5ddc4Srjsstatic inline
433296c5ddc4Srjsbi_instr * bi_ld_tile_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_vecsize vecsize)
433396c5ddc4Srjs{
433496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
433596c5ddc4Srjs    I->op = BI_OPCODE_LD_TILE;
433696c5ddc4Srjs    I->dest[0] = dest0;
433796c5ddc4Srjs    I->src[0] = src0;
433896c5ddc4Srjs    I->src[1] = src1;
433996c5ddc4Srjs    I->src[2] = src2;
434096c5ddc4Srjs    I->vecsize = vecsize;
434196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
434296c5ddc4Srjs    return I;
434396c5ddc4Srjs}
434496c5ddc4Srjs
434596c5ddc4Srjsstatic inline
434696c5ddc4Srjsbi_index bi_ld_tile(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_vecsize vecsize)
434796c5ddc4Srjs{
434896c5ddc4Srjs    return (bi_ld_tile_to(b, bi_temp(b->shader), src0, src1, src2, vecsize))->dest[0];
434996c5ddc4Srjs}
435096c5ddc4Srjs
435196c5ddc4Srjs
435296c5ddc4Srjsstatic inline
435396c5ddc4Srjsbi_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)
435496c5ddc4Srjs{
435596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
435696c5ddc4Srjs    I->op = BI_OPCODE_LD_VAR;
435796c5ddc4Srjs    I->dest[0] = dest0;
435896c5ddc4Srjs    I->src[0] = src0;
435996c5ddc4Srjs    I->src[1] = src1;
436096c5ddc4Srjs    I->vecsize = vecsize;
436196c5ddc4Srjs    I->update = update;
436296c5ddc4Srjs    I->register_format = register_format;
436396c5ddc4Srjs    I->sample = sample;
436496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
436596c5ddc4Srjs    return I;
436696c5ddc4Srjs}
436796c5ddc4Srjs
436896c5ddc4Srjsstatic inline
436996c5ddc4Srjsbi_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)
437096c5ddc4Srjs{
437196c5ddc4Srjs    return (bi_ld_var_to(b, bi_temp(b->shader), src0, src1, register_format, sample, update, vecsize))->dest[0];
437296c5ddc4Srjs}
437396c5ddc4Srjs
437496c5ddc4Srjs
437596c5ddc4Srjsstatic inline
437696c5ddc4Srjsbi_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)
437796c5ddc4Srjs{
437896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
437996c5ddc4Srjs    I->op = BI_OPCODE_LD_VAR_FLAT;
438096c5ddc4Srjs    I->dest[0] = dest0;
438196c5ddc4Srjs    I->src[0] = src0;
438296c5ddc4Srjs    I->vecsize = vecsize;
438396c5ddc4Srjs    I->register_format = register_format;
438496c5ddc4Srjs    I->function = function;
438596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
438696c5ddc4Srjs    return I;
438796c5ddc4Srjs}
438896c5ddc4Srjs
438996c5ddc4Srjsstatic inline
439096c5ddc4Srjsbi_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)
439196c5ddc4Srjs{
439296c5ddc4Srjs    return (bi_ld_var_flat_to(b, bi_temp(b->shader), src0, function, register_format, vecsize))->dest[0];
439396c5ddc4Srjs}
439496c5ddc4Srjs
439596c5ddc4Srjs
439696c5ddc4Srjsstatic inline
439796c5ddc4Srjsbi_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)
439896c5ddc4Srjs{
439996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
440096c5ddc4Srjs    I->op = BI_OPCODE_LD_VAR_FLAT_IMM;
440196c5ddc4Srjs    I->dest[0] = dest0;
440296c5ddc4Srjs    I->vecsize = vecsize;
440396c5ddc4Srjs    I->register_format = register_format;
440496c5ddc4Srjs    I->function = function;
440596c5ddc4Srjs    I->index = index;
440696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
440796c5ddc4Srjs    return I;
440896c5ddc4Srjs}
440996c5ddc4Srjs
441096c5ddc4Srjsstatic inline
441196c5ddc4Srjsbi_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)
441296c5ddc4Srjs{
441396c5ddc4Srjs    return (bi_ld_var_flat_imm_to(b, bi_temp(b->shader), function, register_format, vecsize, index))->dest[0];
441496c5ddc4Srjs}
441596c5ddc4Srjs
441696c5ddc4Srjs
441796c5ddc4Srjsstatic inline
441896c5ddc4Srjsbi_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)
441996c5ddc4Srjs{
442096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
442196c5ddc4Srjs    I->op = BI_OPCODE_LD_VAR_IMM;
442296c5ddc4Srjs    I->dest[0] = dest0;
442396c5ddc4Srjs    I->src[0] = src0;
442496c5ddc4Srjs    I->vecsize = vecsize;
442596c5ddc4Srjs    I->update = update;
442696c5ddc4Srjs    I->register_format = register_format;
442796c5ddc4Srjs    I->sample = sample;
442896c5ddc4Srjs    I->index = index;
442996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
443096c5ddc4Srjs    return I;
443196c5ddc4Srjs}
443296c5ddc4Srjs
443396c5ddc4Srjsstatic inline
443496c5ddc4Srjsbi_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)
443596c5ddc4Srjs{
443696c5ddc4Srjs    return (bi_ld_var_imm_to(b, bi_temp(b->shader), src0, register_format, sample, update, vecsize, index))->dest[0];
443796c5ddc4Srjs}
443896c5ddc4Srjs
443996c5ddc4Srjs
444096c5ddc4Srjsstatic inline
444196c5ddc4Srjsbi_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)
444296c5ddc4Srjs{
444396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
444496c5ddc4Srjs    I->op = BI_OPCODE_LD_VAR_SPECIAL;
444596c5ddc4Srjs    I->dest[0] = dest0;
444696c5ddc4Srjs    I->src[0] = src0;
444796c5ddc4Srjs    I->varying_name = varying_name;
444896c5ddc4Srjs    I->vecsize = vecsize;
444996c5ddc4Srjs    I->update = update;
445096c5ddc4Srjs    I->register_format = register_format;
445196c5ddc4Srjs    I->sample = sample;
445296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
445396c5ddc4Srjs    return I;
445496c5ddc4Srjs}
445596c5ddc4Srjs
445696c5ddc4Srjsstatic inline
445796c5ddc4Srjsbi_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)
445896c5ddc4Srjs{
445996c5ddc4Srjs    return (bi_ld_var_special_to(b, bi_temp(b->shader), src0, register_format, sample, update, varying_name, vecsize))->dest[0];
446096c5ddc4Srjs}
446196c5ddc4Srjs
446296c5ddc4Srjs
446396c5ddc4Srjsstatic inline
446496c5ddc4Srjsbi_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)
446596c5ddc4Srjs{
446696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
446796c5ddc4Srjs    I->op = BI_OPCODE_LEA_ATTR;
446896c5ddc4Srjs    I->dest[0] = dest0;
446996c5ddc4Srjs    I->src[0] = src0;
447096c5ddc4Srjs    I->src[1] = src1;
447196c5ddc4Srjs    I->src[2] = src2;
447296c5ddc4Srjs    I->register_format = register_format;
447396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
447496c5ddc4Srjs    return I;
447596c5ddc4Srjs}
447696c5ddc4Srjs
447796c5ddc4Srjsstatic inline
447896c5ddc4Srjsbi_index bi_lea_attr(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_register_format register_format)
447996c5ddc4Srjs{
448096c5ddc4Srjs    return (bi_lea_attr_to(b, bi_temp(b->shader), src0, src1, src2, register_format))->dest[0];
448196c5ddc4Srjs}
448296c5ddc4Srjs
448396c5ddc4Srjs
448496c5ddc4Srjsstatic inline
448596c5ddc4Srjsbi_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)
448696c5ddc4Srjs{
448796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
448896c5ddc4Srjs    I->op = BI_OPCODE_LEA_ATTR_IMM;
448996c5ddc4Srjs    I->dest[0] = dest0;
449096c5ddc4Srjs    I->src[0] = src0;
449196c5ddc4Srjs    I->src[1] = src1;
449296c5ddc4Srjs    I->register_format = register_format;
449396c5ddc4Srjs    I->attribute_index = attribute_index;
449496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
449596c5ddc4Srjs    return I;
449696c5ddc4Srjs}
449796c5ddc4Srjs
449896c5ddc4Srjsstatic inline
449996c5ddc4Srjsbi_index bi_lea_attr_imm(bi_builder *b, bi_index src0, bi_index src1, enum bi_register_format register_format, uint32_t attribute_index)
450096c5ddc4Srjs{
450196c5ddc4Srjs    return (bi_lea_attr_imm_to(b, bi_temp(b->shader), src0, src1, register_format, attribute_index))->dest[0];
450296c5ddc4Srjs}
450396c5ddc4Srjs
450496c5ddc4Srjs
450596c5ddc4Srjsstatic inline
450696c5ddc4Srjsbi_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)
450796c5ddc4Srjs{
450896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
450996c5ddc4Srjs    I->op = BI_OPCODE_LEA_ATTR_TEX;
451096c5ddc4Srjs    I->dest[0] = dest0;
451196c5ddc4Srjs    I->src[0] = src0;
451296c5ddc4Srjs    I->src[1] = src1;
451396c5ddc4Srjs    I->src[2] = src2;
451496c5ddc4Srjs    I->register_format = register_format;
451596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
451696c5ddc4Srjs    return I;
451796c5ddc4Srjs}
451896c5ddc4Srjs
451996c5ddc4Srjsstatic inline
452096c5ddc4Srjsbi_index bi_lea_attr_tex(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_register_format register_format)
452196c5ddc4Srjs{
452296c5ddc4Srjs    return (bi_lea_attr_tex_to(b, bi_temp(b->shader), src0, src1, src2, register_format))->dest[0];
452396c5ddc4Srjs}
452496c5ddc4Srjs
452596c5ddc4Srjs
452696c5ddc4Srjsstatic inline
452796c5ddc4Srjsbi_instr * bi_lea_tex_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bool format)
452896c5ddc4Srjs{
452996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
453096c5ddc4Srjs    I->op = BI_OPCODE_LEA_TEX;
453196c5ddc4Srjs    I->dest[0] = dest0;
453296c5ddc4Srjs    I->src[0] = src0;
453396c5ddc4Srjs    I->src[1] = src1;
453496c5ddc4Srjs    I->src[2] = src2;
453596c5ddc4Srjs    I->format = format;
453696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
453796c5ddc4Srjs    return I;
453896c5ddc4Srjs}
453996c5ddc4Srjs
454096c5ddc4Srjsstatic inline
454196c5ddc4Srjsbi_index bi_lea_tex(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bool format)
454296c5ddc4Srjs{
454396c5ddc4Srjs    return (bi_lea_tex_to(b, bi_temp(b->shader), src0, src1, src2, format))->dest[0];
454496c5ddc4Srjs}
454596c5ddc4Srjs
454696c5ddc4Srjs
454796c5ddc4Srjsstatic inline
454896c5ddc4Srjsbi_instr * bi_lea_tex_imm_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bool format, uint32_t texture_index)
454996c5ddc4Srjs{
455096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
455196c5ddc4Srjs    I->op = BI_OPCODE_LEA_TEX_IMM;
455296c5ddc4Srjs    I->dest[0] = dest0;
455396c5ddc4Srjs    I->src[0] = src0;
455496c5ddc4Srjs    I->src[1] = src1;
455596c5ddc4Srjs    I->format = format;
455696c5ddc4Srjs    I->texture_index = texture_index;
455796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
455896c5ddc4Srjs    return I;
455996c5ddc4Srjs}
456096c5ddc4Srjs
456196c5ddc4Srjsstatic inline
456296c5ddc4Srjsbi_index bi_lea_tex_imm(bi_builder *b, bi_index src0, bi_index src1, bool format, uint32_t texture_index)
456396c5ddc4Srjs{
456496c5ddc4Srjs    return (bi_lea_tex_imm_to(b, bi_temp(b->shader), src0, src1, format, texture_index))->dest[0];
456596c5ddc4Srjs}
456696c5ddc4Srjs
456796c5ddc4Srjs
456896c5ddc4Srjsstatic inline
456996c5ddc4Srjsbi_instr * bi_load_i128_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_seg seg)
457096c5ddc4Srjs{
457196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
457296c5ddc4Srjs    I->op = BI_OPCODE_LOAD_I128;
457396c5ddc4Srjs    I->dest[0] = dest0;
457496c5ddc4Srjs    I->src[0] = src0;
457596c5ddc4Srjs    I->src[1] = src1;
457696c5ddc4Srjs    I->seg = seg;
457796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
457896c5ddc4Srjs    return I;
457996c5ddc4Srjs}
458096c5ddc4Srjs
458196c5ddc4Srjsstatic inline
458296c5ddc4Srjsbi_index bi_load_i128(bi_builder *b, bi_index src0, bi_index src1, enum bi_seg seg)
458396c5ddc4Srjs{
458496c5ddc4Srjs    return (bi_load_i128_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0];
458596c5ddc4Srjs}
458696c5ddc4Srjs
458796c5ddc4Srjs
458896c5ddc4Srjsstatic inline
458996c5ddc4Srjsbi_instr * bi_load_i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_seg seg)
459096c5ddc4Srjs{
459196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
459296c5ddc4Srjs    I->op = BI_OPCODE_LOAD_I16;
459396c5ddc4Srjs    I->dest[0] = dest0;
459496c5ddc4Srjs    I->src[0] = src0;
459596c5ddc4Srjs    I->src[1] = src1;
459696c5ddc4Srjs    I->seg = seg;
459796c5ddc4Srjs    I->extend = BI_EXTEND_ZEXT;
459896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
459996c5ddc4Srjs    return I;
460096c5ddc4Srjs}
460196c5ddc4Srjs
460296c5ddc4Srjsstatic inline
460396c5ddc4Srjsbi_index bi_load_i16(bi_builder *b, bi_index src0, bi_index src1, enum bi_seg seg)
460496c5ddc4Srjs{
460596c5ddc4Srjs    return (bi_load_i16_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0];
460696c5ddc4Srjs}
460796c5ddc4Srjs
460896c5ddc4Srjs
460996c5ddc4Srjsstatic inline
461096c5ddc4Srjsbi_instr * bi_load_i24_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_seg seg)
461196c5ddc4Srjs{
461296c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
461396c5ddc4Srjs    I->op = BI_OPCODE_LOAD_I24;
461496c5ddc4Srjs    I->dest[0] = dest0;
461596c5ddc4Srjs    I->src[0] = src0;
461696c5ddc4Srjs    I->src[1] = src1;
461796c5ddc4Srjs    I->seg = seg;
461896c5ddc4Srjs    I->extend = BI_EXTEND_ZEXT;
461996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
462096c5ddc4Srjs    return I;
462196c5ddc4Srjs}
462296c5ddc4Srjs
462396c5ddc4Srjsstatic inline
462496c5ddc4Srjsbi_index bi_load_i24(bi_builder *b, bi_index src0, bi_index src1, enum bi_seg seg)
462596c5ddc4Srjs{
462696c5ddc4Srjs    return (bi_load_i24_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0];
462796c5ddc4Srjs}
462896c5ddc4Srjs
462996c5ddc4Srjs
463096c5ddc4Srjsstatic inline
463196c5ddc4Srjsbi_instr * bi_load_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_seg seg)
463296c5ddc4Srjs{
463396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
463496c5ddc4Srjs    I->op = BI_OPCODE_LOAD_I32;
463596c5ddc4Srjs    I->dest[0] = dest0;
463696c5ddc4Srjs    I->src[0] = src0;
463796c5ddc4Srjs    I->src[1] = src1;
463896c5ddc4Srjs    I->seg = seg;
463996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
464096c5ddc4Srjs    return I;
464196c5ddc4Srjs}
464296c5ddc4Srjs
464396c5ddc4Srjsstatic inline
464496c5ddc4Srjsbi_index bi_load_i32(bi_builder *b, bi_index src0, bi_index src1, enum bi_seg seg)
464596c5ddc4Srjs{
464696c5ddc4Srjs    return (bi_load_i32_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0];
464796c5ddc4Srjs}
464896c5ddc4Srjs
464996c5ddc4Srjs
465096c5ddc4Srjsstatic inline
465196c5ddc4Srjsbi_instr * bi_load_i48_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_seg seg)
465296c5ddc4Srjs{
465396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
465496c5ddc4Srjs    I->op = BI_OPCODE_LOAD_I48;
465596c5ddc4Srjs    I->dest[0] = dest0;
465696c5ddc4Srjs    I->src[0] = src0;
465796c5ddc4Srjs    I->src[1] = src1;
465896c5ddc4Srjs    I->seg = seg;
465996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
466096c5ddc4Srjs    return I;
466196c5ddc4Srjs}
466296c5ddc4Srjs
466396c5ddc4Srjsstatic inline
466496c5ddc4Srjsbi_index bi_load_i48(bi_builder *b, bi_index src0, bi_index src1, enum bi_seg seg)
466596c5ddc4Srjs{
466696c5ddc4Srjs    return (bi_load_i48_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0];
466796c5ddc4Srjs}
466896c5ddc4Srjs
466996c5ddc4Srjs
467096c5ddc4Srjsstatic inline
467196c5ddc4Srjsbi_instr * bi_load_i64_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_seg seg)
467296c5ddc4Srjs{
467396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
467496c5ddc4Srjs    I->op = BI_OPCODE_LOAD_I64;
467596c5ddc4Srjs    I->dest[0] = dest0;
467696c5ddc4Srjs    I->src[0] = src0;
467796c5ddc4Srjs    I->src[1] = src1;
467896c5ddc4Srjs    I->seg = seg;
467996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
468096c5ddc4Srjs    return I;
468196c5ddc4Srjs}
468296c5ddc4Srjs
468396c5ddc4Srjsstatic inline
468496c5ddc4Srjsbi_index bi_load_i64(bi_builder *b, bi_index src0, bi_index src1, enum bi_seg seg)
468596c5ddc4Srjs{
468696c5ddc4Srjs    return (bi_load_i64_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0];
468796c5ddc4Srjs}
468896c5ddc4Srjs
468996c5ddc4Srjs
469096c5ddc4Srjsstatic inline
469196c5ddc4Srjsbi_instr * bi_load_i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_seg seg)
469296c5ddc4Srjs{
469396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
469496c5ddc4Srjs    I->op = BI_OPCODE_LOAD_I8;
469596c5ddc4Srjs    I->dest[0] = dest0;
469696c5ddc4Srjs    I->src[0] = src0;
469796c5ddc4Srjs    I->src[1] = src1;
469896c5ddc4Srjs    I->seg = seg;
469996c5ddc4Srjs    I->extend = BI_EXTEND_ZEXT;
470096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
470196c5ddc4Srjs    return I;
470296c5ddc4Srjs}
470396c5ddc4Srjs
470496c5ddc4Srjsstatic inline
470596c5ddc4Srjsbi_index bi_load_i8(bi_builder *b, bi_index src0, bi_index src1, enum bi_seg seg)
470696c5ddc4Srjs{
470796c5ddc4Srjs    return (bi_load_i8_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0];
470896c5ddc4Srjs}
470996c5ddc4Srjs
471096c5ddc4Srjs
471196c5ddc4Srjsstatic inline
471296c5ddc4Srjsbi_instr * bi_load_i96_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_seg seg)
471396c5ddc4Srjs{
471496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
471596c5ddc4Srjs    I->op = BI_OPCODE_LOAD_I96;
471696c5ddc4Srjs    I->dest[0] = dest0;
471796c5ddc4Srjs    I->src[0] = src0;
471896c5ddc4Srjs    I->src[1] = src1;
471996c5ddc4Srjs    I->seg = seg;
472096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
472196c5ddc4Srjs    return I;
472296c5ddc4Srjs}
472396c5ddc4Srjs
472496c5ddc4Srjsstatic inline
472596c5ddc4Srjsbi_index bi_load_i96(bi_builder *b, bi_index src0, bi_index src1, enum bi_seg seg)
472696c5ddc4Srjs{
472796c5ddc4Srjs    return (bi_load_i96_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0];
472896c5ddc4Srjs}
472996c5ddc4Srjs
473096c5ddc4Srjs
473196c5ddc4Srjsstatic inline
473296c5ddc4Srjsbi_instr * bi_load_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, enum bi_seg seg)
473396c5ddc4Srjs{
473496c5ddc4Srjs    if (bitsize == 128)
473596c5ddc4Srjs        return (bi_load_i128_to(b, dest0, src0, src1, seg));
473696c5ddc4Srjs    else if (bitsize == 16)
473796c5ddc4Srjs        return (bi_load_i16_to(b, dest0, src0, src1, seg));
473896c5ddc4Srjs    else if (bitsize == 24)
473996c5ddc4Srjs        return (bi_load_i24_to(b, dest0, src0, src1, seg));
474096c5ddc4Srjs    else if (bitsize == 32)
474196c5ddc4Srjs        return (bi_load_i32_to(b, dest0, src0, src1, seg));
474296c5ddc4Srjs    else if (bitsize == 48)
474396c5ddc4Srjs        return (bi_load_i48_to(b, dest0, src0, src1, seg));
474496c5ddc4Srjs    else if (bitsize == 64)
474596c5ddc4Srjs        return (bi_load_i64_to(b, dest0, src0, src1, seg));
474696c5ddc4Srjs    else if (bitsize == 8)
474796c5ddc4Srjs        return (bi_load_i8_to(b, dest0, src0, src1, seg));
474896c5ddc4Srjs    else if (bitsize == 96)
474996c5ddc4Srjs        return (bi_load_i96_to(b, dest0, src0, src1, seg));
475096c5ddc4Srjs    else
475196c5ddc4Srjs        unreachable("Invalid parameters for LOAD");
475296c5ddc4Srjs}
475396c5ddc4Srjs
475496c5ddc4Srjsstatic inline
475596c5ddc4Srjsbi_index bi_load(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, enum bi_seg seg)
475696c5ddc4Srjs{
475796c5ddc4Srjs    if (bitsize == 128)
475896c5ddc4Srjs        return (bi_load_i128_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0];
475996c5ddc4Srjs    else if (bitsize == 16)
476096c5ddc4Srjs        return (bi_load_i16_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0];
476196c5ddc4Srjs    else if (bitsize == 24)
476296c5ddc4Srjs        return (bi_load_i24_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0];
476396c5ddc4Srjs    else if (bitsize == 32)
476496c5ddc4Srjs        return (bi_load_i32_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0];
476596c5ddc4Srjs    else if (bitsize == 48)
476696c5ddc4Srjs        return (bi_load_i48_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0];
476796c5ddc4Srjs    else if (bitsize == 64)
476896c5ddc4Srjs        return (bi_load_i64_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0];
476996c5ddc4Srjs    else if (bitsize == 8)
477096c5ddc4Srjs        return (bi_load_i8_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0];
477196c5ddc4Srjs    else if (bitsize == 96)
477296c5ddc4Srjs        return (bi_load_i96_to(b, bi_temp(b->shader), src0, src1, seg))->dest[0];
477396c5ddc4Srjs    else
477496c5ddc4Srjs        unreachable("Invalid parameters for LOAD");
477596c5ddc4Srjs}
477696c5ddc4Srjs
477796c5ddc4Srjsstatic inline
477896c5ddc4Srjsbi_instr * bi_logb_f32_to(bi_builder *b, bi_index dest0, bi_index src0)
477996c5ddc4Srjs{
478096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
478196c5ddc4Srjs    I->op = BI_OPCODE_LOGB_F32;
478296c5ddc4Srjs    I->dest[0] = dest0;
478396c5ddc4Srjs    I->src[0] = src0;
478496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
478596c5ddc4Srjs    return I;
478696c5ddc4Srjs}
478796c5ddc4Srjs
478896c5ddc4Srjsstatic inline
478996c5ddc4Srjsbi_index bi_logb_f32(bi_builder *b, bi_index src0)
479096c5ddc4Srjs{
479196c5ddc4Srjs    return (bi_logb_f32_to(b, bi_temp(b->shader), src0))->dest[0];
479296c5ddc4Srjs}
479396c5ddc4Srjs
479496c5ddc4Srjs
479596c5ddc4Srjsstatic inline
479696c5ddc4Srjsbi_instr * bi_logb_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0)
479796c5ddc4Srjs{
479896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
479996c5ddc4Srjs    I->op = BI_OPCODE_LOGB_V2F16;
480096c5ddc4Srjs    I->dest[0] = dest0;
480196c5ddc4Srjs    I->src[0] = src0;
480296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
480396c5ddc4Srjs    return I;
480496c5ddc4Srjs}
480596c5ddc4Srjs
480696c5ddc4Srjsstatic inline
480796c5ddc4Srjsbi_index bi_logb_v2f16(bi_builder *b, bi_index src0)
480896c5ddc4Srjs{
480996c5ddc4Srjs    return (bi_logb_v2f16_to(b, bi_temp(b->shader), src0))->dest[0];
481096c5ddc4Srjs}
481196c5ddc4Srjs
481296c5ddc4Srjs
481396c5ddc4Srjsstatic inline
481496c5ddc4Srjsbi_instr * bi_logb_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0)
481596c5ddc4Srjs{
481696c5ddc4Srjs    if (bitsize == 32)
481796c5ddc4Srjs        return (bi_logb_f32_to(b, dest0, src0));
481896c5ddc4Srjs    else if (bitsize == 16)
481996c5ddc4Srjs        return (bi_logb_v2f16_to(b, dest0, src0));
482096c5ddc4Srjs    else
482196c5ddc4Srjs        unreachable("Invalid parameters for LOGB");
482296c5ddc4Srjs}
482396c5ddc4Srjs
482496c5ddc4Srjsstatic inline
482596c5ddc4Srjsbi_index bi_logb(bi_builder *b, unsigned bitsize, bi_index src0)
482696c5ddc4Srjs{
482796c5ddc4Srjs    if (bitsize == 32)
482896c5ddc4Srjs        return (bi_logb_f32_to(b, bi_temp(b->shader), src0))->dest[0];
482996c5ddc4Srjs    else if (bitsize == 16)
483096c5ddc4Srjs        return (bi_logb_v2f16_to(b, bi_temp(b->shader), src0))->dest[0];
483196c5ddc4Srjs    else
483296c5ddc4Srjs        unreachable("Invalid parameters for LOGB");
483396c5ddc4Srjs}
483496c5ddc4Srjs
483596c5ddc4Srjsstatic inline
483696c5ddc4Srjsbi_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)
483796c5ddc4Srjs{
483896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
483996c5ddc4Srjs    I->op = BI_OPCODE_LROT_DOUBLE_I32;
484096c5ddc4Srjs    I->dest[0] = dest0;
484196c5ddc4Srjs    I->src[0] = src0;
484296c5ddc4Srjs    I->src[1] = src1;
484396c5ddc4Srjs    I->src[2] = src2;
484496c5ddc4Srjs    I->bytes2 = bytes2;
484596c5ddc4Srjs    I->result_word = result_word;
484696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
484796c5ddc4Srjs    return I;
484896c5ddc4Srjs}
484996c5ddc4Srjs
485096c5ddc4Srjsstatic inline
485196c5ddc4Srjsbi_index bi_lrot_double_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bool bytes2, bool result_word)
485296c5ddc4Srjs{
485396c5ddc4Srjs    return (bi_lrot_double_i32_to(b, bi_temp(b->shader), src0, src1, src2, bytes2, result_word))->dest[0];
485496c5ddc4Srjs}
485596c5ddc4Srjs
485696c5ddc4Srjs
485796c5ddc4Srjsstatic inline
485896c5ddc4Srjsbi_instr * bi_lshift_and_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
485996c5ddc4Srjs{
486096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
486196c5ddc4Srjs    I->op = BI_OPCODE_LSHIFT_AND_I32;
486296c5ddc4Srjs    I->dest[0] = dest0;
486396c5ddc4Srjs    I->src[0] = src0;
486496c5ddc4Srjs    I->src[1] = src1;
486596c5ddc4Srjs    I->src[2] = src2;
486696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
486796c5ddc4Srjs    return I;
486896c5ddc4Srjs}
486996c5ddc4Srjs
487096c5ddc4Srjsstatic inline
487196c5ddc4Srjsbi_index bi_lshift_and_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
487296c5ddc4Srjs{
487396c5ddc4Srjs    return (bi_lshift_and_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
487496c5ddc4Srjs}
487596c5ddc4Srjs
487696c5ddc4Srjs
487796c5ddc4Srjsstatic inline
487896c5ddc4Srjsbi_instr * bi_lshift_and_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
487996c5ddc4Srjs{
488096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
488196c5ddc4Srjs    I->op = BI_OPCODE_LSHIFT_AND_V2I16;
488296c5ddc4Srjs    I->dest[0] = dest0;
488396c5ddc4Srjs    I->src[0] = src0;
488496c5ddc4Srjs    I->src[1] = src1;
488596c5ddc4Srjs    I->src[2] = src2;
488696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
488796c5ddc4Srjs    return I;
488896c5ddc4Srjs}
488996c5ddc4Srjs
489096c5ddc4Srjsstatic inline
489196c5ddc4Srjsbi_index bi_lshift_and_v2i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
489296c5ddc4Srjs{
489396c5ddc4Srjs    return (bi_lshift_and_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
489496c5ddc4Srjs}
489596c5ddc4Srjs
489696c5ddc4Srjs
489796c5ddc4Srjsstatic inline
489896c5ddc4Srjsbi_instr * bi_lshift_and_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
489996c5ddc4Srjs{
490096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
490196c5ddc4Srjs    I->op = BI_OPCODE_LSHIFT_AND_V4I8;
490296c5ddc4Srjs    I->dest[0] = dest0;
490396c5ddc4Srjs    I->src[0] = src0;
490496c5ddc4Srjs    I->src[1] = src1;
490596c5ddc4Srjs    I->src[2] = src2;
490696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
490796c5ddc4Srjs    return I;
490896c5ddc4Srjs}
490996c5ddc4Srjs
491096c5ddc4Srjsstatic inline
491196c5ddc4Srjsbi_index bi_lshift_and_v4i8(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
491296c5ddc4Srjs{
491396c5ddc4Srjs    return (bi_lshift_and_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
491496c5ddc4Srjs}
491596c5ddc4Srjs
491696c5ddc4Srjs
491796c5ddc4Srjsstatic inline
491896c5ddc4Srjsbi_instr * bi_lshift_and_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
491996c5ddc4Srjs{
492096c5ddc4Srjs    if (bitsize == 32)
492196c5ddc4Srjs        return (bi_lshift_and_i32_to(b, dest0, src0, src1, src2));
492296c5ddc4Srjs    else if (bitsize == 16)
492396c5ddc4Srjs        return (bi_lshift_and_v2i16_to(b, dest0, src0, src1, src2));
492496c5ddc4Srjs    else if (bitsize == 8)
492596c5ddc4Srjs        return (bi_lshift_and_v4i8_to(b, dest0, src0, src1, src2));
492696c5ddc4Srjs    else
492796c5ddc4Srjs        unreachable("Invalid parameters for LSHIFT_AND");
492896c5ddc4Srjs}
492996c5ddc4Srjs
493096c5ddc4Srjsstatic inline
493196c5ddc4Srjsbi_index bi_lshift_and(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2)
493296c5ddc4Srjs{
493396c5ddc4Srjs    if (bitsize == 32)
493496c5ddc4Srjs        return (bi_lshift_and_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
493596c5ddc4Srjs    else if (bitsize == 16)
493696c5ddc4Srjs        return (bi_lshift_and_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
493796c5ddc4Srjs    else if (bitsize == 8)
493896c5ddc4Srjs        return (bi_lshift_and_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
493996c5ddc4Srjs    else
494096c5ddc4Srjs        unreachable("Invalid parameters for LSHIFT_AND");
494196c5ddc4Srjs}
494296c5ddc4Srjs
494396c5ddc4Srjsstatic inline
494496c5ddc4Srjsbi_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)
494596c5ddc4Srjs{
494696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
494796c5ddc4Srjs    I->op = BI_OPCODE_LSHIFT_DOUBLE_I32;
494896c5ddc4Srjs    I->dest[0] = dest0;
494996c5ddc4Srjs    I->src[0] = src0;
495096c5ddc4Srjs    I->src[1] = src1;
495196c5ddc4Srjs    I->src[2] = src2;
495296c5ddc4Srjs    I->bytes2 = bytes2;
495396c5ddc4Srjs    I->result_word = result_word;
495496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
495596c5ddc4Srjs    return I;
495696c5ddc4Srjs}
495796c5ddc4Srjs
495896c5ddc4Srjsstatic inline
495996c5ddc4Srjsbi_index bi_lshift_double_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bool bytes2, bool result_word)
496096c5ddc4Srjs{
496196c5ddc4Srjs    return (bi_lshift_double_i32_to(b, bi_temp(b->shader), src0, src1, src2, bytes2, result_word))->dest[0];
496296c5ddc4Srjs}
496396c5ddc4Srjs
496496c5ddc4Srjs
496596c5ddc4Srjsstatic inline
496696c5ddc4Srjsbi_instr * bi_lshift_or_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
496796c5ddc4Srjs{
496896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
496996c5ddc4Srjs    I->op = BI_OPCODE_LSHIFT_OR_I32;
497096c5ddc4Srjs    I->dest[0] = dest0;
497196c5ddc4Srjs    I->src[0] = src0;
497296c5ddc4Srjs    I->src[1] = src1;
497396c5ddc4Srjs    I->src[2] = src2;
497496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
497596c5ddc4Srjs    return I;
497696c5ddc4Srjs}
497796c5ddc4Srjs
497896c5ddc4Srjsstatic inline
497996c5ddc4Srjsbi_index bi_lshift_or_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
498096c5ddc4Srjs{
498196c5ddc4Srjs    return (bi_lshift_or_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
498296c5ddc4Srjs}
498396c5ddc4Srjs
498496c5ddc4Srjs
498596c5ddc4Srjsstatic inline
498696c5ddc4Srjsbi_instr * bi_lshift_or_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
498796c5ddc4Srjs{
498896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
498996c5ddc4Srjs    I->op = BI_OPCODE_LSHIFT_OR_V2I16;
499096c5ddc4Srjs    I->dest[0] = dest0;
499196c5ddc4Srjs    I->src[0] = src0;
499296c5ddc4Srjs    I->src[1] = src1;
499396c5ddc4Srjs    I->src[2] = src2;
499496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
499596c5ddc4Srjs    return I;
499696c5ddc4Srjs}
499796c5ddc4Srjs
499896c5ddc4Srjsstatic inline
499996c5ddc4Srjsbi_index bi_lshift_or_v2i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
500096c5ddc4Srjs{
500196c5ddc4Srjs    return (bi_lshift_or_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
500296c5ddc4Srjs}
500396c5ddc4Srjs
500496c5ddc4Srjs
500596c5ddc4Srjsstatic inline
500696c5ddc4Srjsbi_instr * bi_lshift_or_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
500796c5ddc4Srjs{
500896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
500996c5ddc4Srjs    I->op = BI_OPCODE_LSHIFT_OR_V4I8;
501096c5ddc4Srjs    I->dest[0] = dest0;
501196c5ddc4Srjs    I->src[0] = src0;
501296c5ddc4Srjs    I->src[1] = src1;
501396c5ddc4Srjs    I->src[2] = src2;
501496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
501596c5ddc4Srjs    return I;
501696c5ddc4Srjs}
501796c5ddc4Srjs
501896c5ddc4Srjsstatic inline
501996c5ddc4Srjsbi_index bi_lshift_or_v4i8(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
502096c5ddc4Srjs{
502196c5ddc4Srjs    return (bi_lshift_or_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
502296c5ddc4Srjs}
502396c5ddc4Srjs
502496c5ddc4Srjs
502596c5ddc4Srjsstatic inline
502696c5ddc4Srjsbi_instr * bi_lshift_or_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
502796c5ddc4Srjs{
502896c5ddc4Srjs    if (bitsize == 32)
502996c5ddc4Srjs        return (bi_lshift_or_i32_to(b, dest0, src0, src1, src2));
503096c5ddc4Srjs    else if (bitsize == 16)
503196c5ddc4Srjs        return (bi_lshift_or_v2i16_to(b, dest0, src0, src1, src2));
503296c5ddc4Srjs    else if (bitsize == 8)
503396c5ddc4Srjs        return (bi_lshift_or_v4i8_to(b, dest0, src0, src1, src2));
503496c5ddc4Srjs    else
503596c5ddc4Srjs        unreachable("Invalid parameters for LSHIFT_OR");
503696c5ddc4Srjs}
503796c5ddc4Srjs
503896c5ddc4Srjsstatic inline
503996c5ddc4Srjsbi_index bi_lshift_or(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2)
504096c5ddc4Srjs{
504196c5ddc4Srjs    if (bitsize == 32)
504296c5ddc4Srjs        return (bi_lshift_or_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
504396c5ddc4Srjs    else if (bitsize == 16)
504496c5ddc4Srjs        return (bi_lshift_or_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
504596c5ddc4Srjs    else if (bitsize == 8)
504696c5ddc4Srjs        return (bi_lshift_or_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
504796c5ddc4Srjs    else
504896c5ddc4Srjs        unreachable("Invalid parameters for LSHIFT_OR");
504996c5ddc4Srjs}
505096c5ddc4Srjs
505196c5ddc4Srjsstatic inline
505296c5ddc4Srjsbi_instr * bi_lshift_xor_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
505396c5ddc4Srjs{
505496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
505596c5ddc4Srjs    I->op = BI_OPCODE_LSHIFT_XOR_I32;
505696c5ddc4Srjs    I->dest[0] = dest0;
505796c5ddc4Srjs    I->src[0] = src0;
505896c5ddc4Srjs    I->src[1] = src1;
505996c5ddc4Srjs    I->src[2] = src2;
506096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
506196c5ddc4Srjs    return I;
506296c5ddc4Srjs}
506396c5ddc4Srjs
506496c5ddc4Srjsstatic inline
506596c5ddc4Srjsbi_index bi_lshift_xor_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
506696c5ddc4Srjs{
506796c5ddc4Srjs    return (bi_lshift_xor_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
506896c5ddc4Srjs}
506996c5ddc4Srjs
507096c5ddc4Srjs
507196c5ddc4Srjsstatic inline
507296c5ddc4Srjsbi_instr * bi_lshift_xor_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
507396c5ddc4Srjs{
507496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
507596c5ddc4Srjs    I->op = BI_OPCODE_LSHIFT_XOR_V2I16;
507696c5ddc4Srjs    I->dest[0] = dest0;
507796c5ddc4Srjs    I->src[0] = src0;
507896c5ddc4Srjs    I->src[1] = src1;
507996c5ddc4Srjs    I->src[2] = src2;
508096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
508196c5ddc4Srjs    return I;
508296c5ddc4Srjs}
508396c5ddc4Srjs
508496c5ddc4Srjsstatic inline
508596c5ddc4Srjsbi_index bi_lshift_xor_v2i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
508696c5ddc4Srjs{
508796c5ddc4Srjs    return (bi_lshift_xor_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
508896c5ddc4Srjs}
508996c5ddc4Srjs
509096c5ddc4Srjs
509196c5ddc4Srjsstatic inline
509296c5ddc4Srjsbi_instr * bi_lshift_xor_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
509396c5ddc4Srjs{
509496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
509596c5ddc4Srjs    I->op = BI_OPCODE_LSHIFT_XOR_V4I8;
509696c5ddc4Srjs    I->dest[0] = dest0;
509796c5ddc4Srjs    I->src[0] = src0;
509896c5ddc4Srjs    I->src[1] = src1;
509996c5ddc4Srjs    I->src[2] = src2;
510096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
510196c5ddc4Srjs    return I;
510296c5ddc4Srjs}
510396c5ddc4Srjs
510496c5ddc4Srjsstatic inline
510596c5ddc4Srjsbi_index bi_lshift_xor_v4i8(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
510696c5ddc4Srjs{
510796c5ddc4Srjs    return (bi_lshift_xor_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
510896c5ddc4Srjs}
510996c5ddc4Srjs
511096c5ddc4Srjs
511196c5ddc4Srjsstatic inline
511296c5ddc4Srjsbi_instr * bi_lshift_xor_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
511396c5ddc4Srjs{
511496c5ddc4Srjs    if (bitsize == 32)
511596c5ddc4Srjs        return (bi_lshift_xor_i32_to(b, dest0, src0, src1, src2));
511696c5ddc4Srjs    else if (bitsize == 16)
511796c5ddc4Srjs        return (bi_lshift_xor_v2i16_to(b, dest0, src0, src1, src2));
511896c5ddc4Srjs    else if (bitsize == 8)
511996c5ddc4Srjs        return (bi_lshift_xor_v4i8_to(b, dest0, src0, src1, src2));
512096c5ddc4Srjs    else
512196c5ddc4Srjs        unreachable("Invalid parameters for LSHIFT_XOR");
512296c5ddc4Srjs}
512396c5ddc4Srjs
512496c5ddc4Srjsstatic inline
512596c5ddc4Srjsbi_index bi_lshift_xor(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2)
512696c5ddc4Srjs{
512796c5ddc4Srjs    if (bitsize == 32)
512896c5ddc4Srjs        return (bi_lshift_xor_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
512996c5ddc4Srjs    else if (bitsize == 16)
513096c5ddc4Srjs        return (bi_lshift_xor_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
513196c5ddc4Srjs    else if (bitsize == 8)
513296c5ddc4Srjs        return (bi_lshift_xor_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
513396c5ddc4Srjs    else
513496c5ddc4Srjs        unreachable("Invalid parameters for LSHIFT_XOR");
513596c5ddc4Srjs}
513696c5ddc4Srjs
513796c5ddc4Srjsstatic inline
513896c5ddc4Srjsbi_instr * bi_mkvec_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1)
513996c5ddc4Srjs{
514096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
514196c5ddc4Srjs    I->op = BI_OPCODE_MKVEC_V2I16;
514296c5ddc4Srjs    I->dest[0] = dest0;
514396c5ddc4Srjs    I->src[0] = src0;
514496c5ddc4Srjs    I->src[1] = src1;
514596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
514696c5ddc4Srjs    return I;
514796c5ddc4Srjs}
514896c5ddc4Srjs
514996c5ddc4Srjsstatic inline
515096c5ddc4Srjsbi_index bi_mkvec_v2i16(bi_builder *b, bi_index src0, bi_index src1)
515196c5ddc4Srjs{
515296c5ddc4Srjs    return (bi_mkvec_v2i16_to(b, bi_temp(b->shader), src0, src1))->dest[0];
515396c5ddc4Srjs}
515496c5ddc4Srjs
515596c5ddc4Srjs
515696c5ddc4Srjsstatic inline
515796c5ddc4Srjsbi_instr * bi_mkvec_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bi_index src3)
515896c5ddc4Srjs{
515996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
516096c5ddc4Srjs    I->op = BI_OPCODE_MKVEC_V4I8;
516196c5ddc4Srjs    I->dest[0] = dest0;
516296c5ddc4Srjs    I->src[0] = src0;
516396c5ddc4Srjs    I->src[1] = src1;
516496c5ddc4Srjs    I->src[2] = src2;
516596c5ddc4Srjs    I->src[3] = src3;
516696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
516796c5ddc4Srjs    return I;
516896c5ddc4Srjs}
516996c5ddc4Srjs
517096c5ddc4Srjsstatic inline
517196c5ddc4Srjsbi_index bi_mkvec_v4i8(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3)
517296c5ddc4Srjs{
517396c5ddc4Srjs    return (bi_mkvec_v4i8_to(b, bi_temp(b->shader), src0, src1, src2, src3))->dest[0];
517496c5ddc4Srjs}
517596c5ddc4Srjs
517696c5ddc4Srjs
517796c5ddc4Srjsstatic inline
517896c5ddc4Srjsbi_instr * bi_mov_i32_to(bi_builder *b, bi_index dest0, bi_index src0)
517996c5ddc4Srjs{
518096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
518196c5ddc4Srjs    I->op = BI_OPCODE_MOV_I32;
518296c5ddc4Srjs    I->dest[0] = dest0;
518396c5ddc4Srjs    I->src[0] = src0;
518496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
518596c5ddc4Srjs    return I;
518696c5ddc4Srjs}
518796c5ddc4Srjs
518896c5ddc4Srjsstatic inline
518996c5ddc4Srjsbi_index bi_mov_i32(bi_builder *b, bi_index src0)
519096c5ddc4Srjs{
519196c5ddc4Srjs    return (bi_mov_i32_to(b, bi_temp(b->shader), src0))->dest[0];
519296c5ddc4Srjs}
519396c5ddc4Srjs
519496c5ddc4Srjs
519596c5ddc4Srjsstatic inline
519696c5ddc4Srjsbi_instr * bi_mux_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_mux mux)
519796c5ddc4Srjs{
519896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
519996c5ddc4Srjs    I->op = BI_OPCODE_MUX_I32;
520096c5ddc4Srjs    I->dest[0] = dest0;
520196c5ddc4Srjs    I->src[0] = src0;
520296c5ddc4Srjs    I->src[1] = src1;
520396c5ddc4Srjs    I->src[2] = src2;
520496c5ddc4Srjs    I->mux = mux;
520596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
520696c5ddc4Srjs    return I;
520796c5ddc4Srjs}
520896c5ddc4Srjs
520996c5ddc4Srjsstatic inline
521096c5ddc4Srjsbi_index bi_mux_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_mux mux)
521196c5ddc4Srjs{
521296c5ddc4Srjs    return (bi_mux_i32_to(b, bi_temp(b->shader), src0, src1, src2, mux))->dest[0];
521396c5ddc4Srjs}
521496c5ddc4Srjs
521596c5ddc4Srjs
521696c5ddc4Srjsstatic inline
521796c5ddc4Srjsbi_instr * bi_mux_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_mux mux)
521896c5ddc4Srjs{
521996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
522096c5ddc4Srjs    I->op = BI_OPCODE_MUX_V2I16;
522196c5ddc4Srjs    I->dest[0] = dest0;
522296c5ddc4Srjs    I->src[0] = src0;
522396c5ddc4Srjs    I->src[1] = src1;
522496c5ddc4Srjs    I->src[2] = src2;
522596c5ddc4Srjs    I->mux = mux;
522696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
522796c5ddc4Srjs    return I;
522896c5ddc4Srjs}
522996c5ddc4Srjs
523096c5ddc4Srjsstatic inline
523196c5ddc4Srjsbi_index bi_mux_v2i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_mux mux)
523296c5ddc4Srjs{
523396c5ddc4Srjs    return (bi_mux_v2i16_to(b, bi_temp(b->shader), src0, src1, src2, mux))->dest[0];
523496c5ddc4Srjs}
523596c5ddc4Srjs
523696c5ddc4Srjs
523796c5ddc4Srjsstatic inline
523896c5ddc4Srjsbi_instr * bi_mux_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, enum bi_mux mux)
523996c5ddc4Srjs{
524096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
524196c5ddc4Srjs    I->op = BI_OPCODE_MUX_V4I8;
524296c5ddc4Srjs    I->dest[0] = dest0;
524396c5ddc4Srjs    I->src[0] = src0;
524496c5ddc4Srjs    I->src[1] = src1;
524596c5ddc4Srjs    I->src[2] = src2;
524696c5ddc4Srjs    I->mux = mux;
524796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
524896c5ddc4Srjs    return I;
524996c5ddc4Srjs}
525096c5ddc4Srjs
525196c5ddc4Srjsstatic inline
525296c5ddc4Srjsbi_index bi_mux_v4i8(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_mux mux)
525396c5ddc4Srjs{
525496c5ddc4Srjs    return (bi_mux_v4i8_to(b, bi_temp(b->shader), src0, src1, src2, mux))->dest[0];
525596c5ddc4Srjs}
525696c5ddc4Srjs
525796c5ddc4Srjs
525896c5ddc4Srjsstatic inline
525996c5ddc4Srjsbi_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)
526096c5ddc4Srjs{
526196c5ddc4Srjs    if (bitsize == 32)
526296c5ddc4Srjs        return (bi_mux_i32_to(b, dest0, src0, src1, src2, mux));
526396c5ddc4Srjs    else if (bitsize == 16)
526496c5ddc4Srjs        return (bi_mux_v2i16_to(b, dest0, src0, src1, src2, mux));
526596c5ddc4Srjs    else if (bitsize == 8)
526696c5ddc4Srjs        return (bi_mux_v4i8_to(b, dest0, src0, src1, src2, mux));
526796c5ddc4Srjs    else
526896c5ddc4Srjs        unreachable("Invalid parameters for MUX");
526996c5ddc4Srjs}
527096c5ddc4Srjs
527196c5ddc4Srjsstatic inline
527296c5ddc4Srjsbi_index bi_mux(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2, enum bi_mux mux)
527396c5ddc4Srjs{
527496c5ddc4Srjs    if (bitsize == 32)
527596c5ddc4Srjs        return (bi_mux_i32_to(b, bi_temp(b->shader), src0, src1, src2, mux))->dest[0];
527696c5ddc4Srjs    else if (bitsize == 16)
527796c5ddc4Srjs        return (bi_mux_v2i16_to(b, bi_temp(b->shader), src0, src1, src2, mux))->dest[0];
527896c5ddc4Srjs    else if (bitsize == 8)
527996c5ddc4Srjs        return (bi_mux_v4i8_to(b, bi_temp(b->shader), src0, src1, src2, mux))->dest[0];
528096c5ddc4Srjs    else
528196c5ddc4Srjs        unreachable("Invalid parameters for MUX");
528296c5ddc4Srjs}
528396c5ddc4Srjs
528496c5ddc4Srjsstatic inline
528596c5ddc4Srjsbi_instr * bi_nop_to(bi_builder *b, bi_index dest0)
528696c5ddc4Srjs{
528796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
528896c5ddc4Srjs    I->op = BI_OPCODE_NOP;
528996c5ddc4Srjs    I->dest[0] = dest0;
529096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
529196c5ddc4Srjs    return I;
529296c5ddc4Srjs}
529396c5ddc4Srjs
529496c5ddc4Srjsstatic inline
529596c5ddc4Srjsbi_index bi_nop(bi_builder *b)
529696c5ddc4Srjs{
529796c5ddc4Srjs    return (bi_nop_to(b, bi_temp(b->shader)))->dest[0];
529896c5ddc4Srjs}
529996c5ddc4Srjs
530096c5ddc4Srjs
530196c5ddc4Srjsstatic inline
530296c5ddc4Srjsbi_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)
530396c5ddc4Srjs{
530496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
530596c5ddc4Srjs    I->op = BI_OPCODE_PATOM_C_I32;
530696c5ddc4Srjs    I->dest[0] = dest0;
530796c5ddc4Srjs    I->src[0] = src0;
530896c5ddc4Srjs    I->src[1] = src1;
530996c5ddc4Srjs    I->src[2] = src2;
531096c5ddc4Srjs    I->atom_opc = atom_opc;
531196c5ddc4Srjs    I->sr_count = sr_count;
531296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
531396c5ddc4Srjs    return I;
531496c5ddc4Srjs}
531596c5ddc4Srjs
531696c5ddc4Srjsstatic inline
531796c5ddc4Srjsbi_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)
531896c5ddc4Srjs{
531996c5ddc4Srjs    return (bi_patom_c_i32_to(b, bi_temp(b->shader), src0, src1, src2, atom_opc, sr_count))->dest[0];
532096c5ddc4Srjs}
532196c5ddc4Srjs
532296c5ddc4Srjs
532396c5ddc4Srjsstatic inline
532496c5ddc4Srjsbi_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)
532596c5ddc4Srjs{
532696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
532796c5ddc4Srjs    I->op = BI_OPCODE_PATOM_C1_I32;
532896c5ddc4Srjs    I->dest[0] = dest0;
532996c5ddc4Srjs    I->src[0] = src0;
533096c5ddc4Srjs    I->src[1] = src1;
533196c5ddc4Srjs    I->atom_opc = atom_opc;
533296c5ddc4Srjs    I->sr_count = sr_count;
533396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
533496c5ddc4Srjs    return I;
533596c5ddc4Srjs}
533696c5ddc4Srjs
533796c5ddc4Srjsstatic inline
533896c5ddc4Srjsbi_index bi_patom_c1_i32(bi_builder *b, bi_index src0, bi_index src1, enum bi_atom_opc atom_opc, uint32_t sr_count)
533996c5ddc4Srjs{
534096c5ddc4Srjs    return (bi_patom_c1_i32_to(b, bi_temp(b->shader), src0, src1, atom_opc, sr_count))->dest[0];
534196c5ddc4Srjs}
534296c5ddc4Srjs
534396c5ddc4Srjs
534496c5ddc4Srjsstatic inline
534596c5ddc4Srjsbi_instr * bi_popcount_i32_to(bi_builder *b, bi_index dest0, bi_index src0)
534696c5ddc4Srjs{
534796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
534896c5ddc4Srjs    I->op = BI_OPCODE_POPCOUNT_I32;
534996c5ddc4Srjs    I->dest[0] = dest0;
535096c5ddc4Srjs    I->src[0] = src0;
535196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
535296c5ddc4Srjs    return I;
535396c5ddc4Srjs}
535496c5ddc4Srjs
535596c5ddc4Srjsstatic inline
535696c5ddc4Srjsbi_index bi_popcount_i32(bi_builder *b, bi_index src0)
535796c5ddc4Srjs{
535896c5ddc4Srjs    return (bi_popcount_i32_to(b, bi_temp(b->shader), src0))->dest[0];
535996c5ddc4Srjs}
536096c5ddc4Srjs
536196c5ddc4Srjs
536296c5ddc4Srjsstatic inline
536396c5ddc4Srjsbi_instr * bi_quiet_f32_to(bi_builder *b, bi_index dest0, bi_index src0)
536496c5ddc4Srjs{
536596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
536696c5ddc4Srjs    I->op = BI_OPCODE_QUIET_F32;
536796c5ddc4Srjs    I->dest[0] = dest0;
536896c5ddc4Srjs    I->src[0] = src0;
536996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
537096c5ddc4Srjs    return I;
537196c5ddc4Srjs}
537296c5ddc4Srjs
537396c5ddc4Srjsstatic inline
537496c5ddc4Srjsbi_index bi_quiet_f32(bi_builder *b, bi_index src0)
537596c5ddc4Srjs{
537696c5ddc4Srjs    return (bi_quiet_f32_to(b, bi_temp(b->shader), src0))->dest[0];
537796c5ddc4Srjs}
537896c5ddc4Srjs
537996c5ddc4Srjs
538096c5ddc4Srjsstatic inline
538196c5ddc4Srjsbi_instr * bi_quiet_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0)
538296c5ddc4Srjs{
538396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
538496c5ddc4Srjs    I->op = BI_OPCODE_QUIET_V2F16;
538596c5ddc4Srjs    I->dest[0] = dest0;
538696c5ddc4Srjs    I->src[0] = src0;
538796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
538896c5ddc4Srjs    return I;
538996c5ddc4Srjs}
539096c5ddc4Srjs
539196c5ddc4Srjsstatic inline
539296c5ddc4Srjsbi_index bi_quiet_v2f16(bi_builder *b, bi_index src0)
539396c5ddc4Srjs{
539496c5ddc4Srjs    return (bi_quiet_v2f16_to(b, bi_temp(b->shader), src0))->dest[0];
539596c5ddc4Srjs}
539696c5ddc4Srjs
539796c5ddc4Srjs
539896c5ddc4Srjsstatic inline
539996c5ddc4Srjsbi_instr * bi_quiet_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0)
540096c5ddc4Srjs{
540196c5ddc4Srjs    if (bitsize == 32)
540296c5ddc4Srjs        return (bi_quiet_f32_to(b, dest0, src0));
540396c5ddc4Srjs    else if (bitsize == 16)
540496c5ddc4Srjs        return (bi_quiet_v2f16_to(b, dest0, src0));
540596c5ddc4Srjs    else
540696c5ddc4Srjs        unreachable("Invalid parameters for QUIET");
540796c5ddc4Srjs}
540896c5ddc4Srjs
540996c5ddc4Srjsstatic inline
541096c5ddc4Srjsbi_index bi_quiet(bi_builder *b, unsigned bitsize, bi_index src0)
541196c5ddc4Srjs{
541296c5ddc4Srjs    if (bitsize == 32)
541396c5ddc4Srjs        return (bi_quiet_f32_to(b, bi_temp(b->shader), src0))->dest[0];
541496c5ddc4Srjs    else if (bitsize == 16)
541596c5ddc4Srjs        return (bi_quiet_v2f16_to(b, bi_temp(b->shader), src0))->dest[0];
541696c5ddc4Srjs    else
541796c5ddc4Srjs        unreachable("Invalid parameters for QUIET");
541896c5ddc4Srjs}
541996c5ddc4Srjs
542096c5ddc4Srjsstatic inline
542196c5ddc4Srjsbi_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)
542296c5ddc4Srjs{
542396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
542496c5ddc4Srjs    I->op = BI_OPCODE_RROT_DOUBLE_I32;
542596c5ddc4Srjs    I->dest[0] = dest0;
542696c5ddc4Srjs    I->src[0] = src0;
542796c5ddc4Srjs    I->src[1] = src1;
542896c5ddc4Srjs    I->src[2] = src2;
542996c5ddc4Srjs    I->bytes2 = bytes2;
543096c5ddc4Srjs    I->result_word = result_word;
543196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
543296c5ddc4Srjs    return I;
543396c5ddc4Srjs}
543496c5ddc4Srjs
543596c5ddc4Srjsstatic inline
543696c5ddc4Srjsbi_index bi_rrot_double_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bool bytes2, bool result_word)
543796c5ddc4Srjs{
543896c5ddc4Srjs    return (bi_rrot_double_i32_to(b, bi_temp(b->shader), src0, src1, src2, bytes2, result_word))->dest[0];
543996c5ddc4Srjs}
544096c5ddc4Srjs
544196c5ddc4Srjs
544296c5ddc4Srjsstatic inline
544396c5ddc4Srjsbi_instr * bi_rshift_and_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
544496c5ddc4Srjs{
544596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
544696c5ddc4Srjs    I->op = BI_OPCODE_RSHIFT_AND_I32;
544796c5ddc4Srjs    I->dest[0] = dest0;
544896c5ddc4Srjs    I->src[0] = src0;
544996c5ddc4Srjs    I->src[1] = src1;
545096c5ddc4Srjs    I->src[2] = src2;
545196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
545296c5ddc4Srjs    return I;
545396c5ddc4Srjs}
545496c5ddc4Srjs
545596c5ddc4Srjsstatic inline
545696c5ddc4Srjsbi_index bi_rshift_and_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
545796c5ddc4Srjs{
545896c5ddc4Srjs    return (bi_rshift_and_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
545996c5ddc4Srjs}
546096c5ddc4Srjs
546196c5ddc4Srjs
546296c5ddc4Srjsstatic inline
546396c5ddc4Srjsbi_instr * bi_rshift_and_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
546496c5ddc4Srjs{
546596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
546696c5ddc4Srjs    I->op = BI_OPCODE_RSHIFT_AND_V2I16;
546796c5ddc4Srjs    I->dest[0] = dest0;
546896c5ddc4Srjs    I->src[0] = src0;
546996c5ddc4Srjs    I->src[1] = src1;
547096c5ddc4Srjs    I->src[2] = src2;
547196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
547296c5ddc4Srjs    return I;
547396c5ddc4Srjs}
547496c5ddc4Srjs
547596c5ddc4Srjsstatic inline
547696c5ddc4Srjsbi_index bi_rshift_and_v2i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
547796c5ddc4Srjs{
547896c5ddc4Srjs    return (bi_rshift_and_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
547996c5ddc4Srjs}
548096c5ddc4Srjs
548196c5ddc4Srjs
548296c5ddc4Srjsstatic inline
548396c5ddc4Srjsbi_instr * bi_rshift_and_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
548496c5ddc4Srjs{
548596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
548696c5ddc4Srjs    I->op = BI_OPCODE_RSHIFT_AND_V4I8;
548796c5ddc4Srjs    I->dest[0] = dest0;
548896c5ddc4Srjs    I->src[0] = src0;
548996c5ddc4Srjs    I->src[1] = src1;
549096c5ddc4Srjs    I->src[2] = src2;
549196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
549296c5ddc4Srjs    return I;
549396c5ddc4Srjs}
549496c5ddc4Srjs
549596c5ddc4Srjsstatic inline
549696c5ddc4Srjsbi_index bi_rshift_and_v4i8(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
549796c5ddc4Srjs{
549896c5ddc4Srjs    return (bi_rshift_and_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
549996c5ddc4Srjs}
550096c5ddc4Srjs
550196c5ddc4Srjs
550296c5ddc4Srjsstatic inline
550396c5ddc4Srjsbi_instr * bi_rshift_and_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
550496c5ddc4Srjs{
550596c5ddc4Srjs    if (bitsize == 32)
550696c5ddc4Srjs        return (bi_rshift_and_i32_to(b, dest0, src0, src1, src2));
550796c5ddc4Srjs    else if (bitsize == 16)
550896c5ddc4Srjs        return (bi_rshift_and_v2i16_to(b, dest0, src0, src1, src2));
550996c5ddc4Srjs    else if (bitsize == 8)
551096c5ddc4Srjs        return (bi_rshift_and_v4i8_to(b, dest0, src0, src1, src2));
551196c5ddc4Srjs    else
551296c5ddc4Srjs        unreachable("Invalid parameters for RSHIFT_AND");
551396c5ddc4Srjs}
551496c5ddc4Srjs
551596c5ddc4Srjsstatic inline
551696c5ddc4Srjsbi_index bi_rshift_and(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2)
551796c5ddc4Srjs{
551896c5ddc4Srjs    if (bitsize == 32)
551996c5ddc4Srjs        return (bi_rshift_and_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
552096c5ddc4Srjs    else if (bitsize == 16)
552196c5ddc4Srjs        return (bi_rshift_and_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
552296c5ddc4Srjs    else if (bitsize == 8)
552396c5ddc4Srjs        return (bi_rshift_and_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
552496c5ddc4Srjs    else
552596c5ddc4Srjs        unreachable("Invalid parameters for RSHIFT_AND");
552696c5ddc4Srjs}
552796c5ddc4Srjs
552896c5ddc4Srjsstatic inline
552996c5ddc4Srjsbi_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)
553096c5ddc4Srjs{
553196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
553296c5ddc4Srjs    I->op = BI_OPCODE_RSHIFT_DOUBLE_I32;
553396c5ddc4Srjs    I->dest[0] = dest0;
553496c5ddc4Srjs    I->src[0] = src0;
553596c5ddc4Srjs    I->src[1] = src1;
553696c5ddc4Srjs    I->src[2] = src2;
553796c5ddc4Srjs    I->bytes2 = bytes2;
553896c5ddc4Srjs    I->result_word = result_word;
553996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
554096c5ddc4Srjs    return I;
554196c5ddc4Srjs}
554296c5ddc4Srjs
554396c5ddc4Srjsstatic inline
554496c5ddc4Srjsbi_index bi_rshift_double_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bool bytes2, bool result_word)
554596c5ddc4Srjs{
554696c5ddc4Srjs    return (bi_rshift_double_i32_to(b, bi_temp(b->shader), src0, src1, src2, bytes2, result_word))->dest[0];
554796c5ddc4Srjs}
554896c5ddc4Srjs
554996c5ddc4Srjs
555096c5ddc4Srjsstatic inline
555196c5ddc4Srjsbi_instr * bi_rshift_or_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
555296c5ddc4Srjs{
555396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
555496c5ddc4Srjs    I->op = BI_OPCODE_RSHIFT_OR_I32;
555596c5ddc4Srjs    I->dest[0] = dest0;
555696c5ddc4Srjs    I->src[0] = src0;
555796c5ddc4Srjs    I->src[1] = src1;
555896c5ddc4Srjs    I->src[2] = src2;
555996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
556096c5ddc4Srjs    return I;
556196c5ddc4Srjs}
556296c5ddc4Srjs
556396c5ddc4Srjsstatic inline
556496c5ddc4Srjsbi_index bi_rshift_or_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
556596c5ddc4Srjs{
556696c5ddc4Srjs    return (bi_rshift_or_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
556796c5ddc4Srjs}
556896c5ddc4Srjs
556996c5ddc4Srjs
557096c5ddc4Srjsstatic inline
557196c5ddc4Srjsbi_instr * bi_rshift_or_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
557296c5ddc4Srjs{
557396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
557496c5ddc4Srjs    I->op = BI_OPCODE_RSHIFT_OR_V2I16;
557596c5ddc4Srjs    I->dest[0] = dest0;
557696c5ddc4Srjs    I->src[0] = src0;
557796c5ddc4Srjs    I->src[1] = src1;
557896c5ddc4Srjs    I->src[2] = src2;
557996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
558096c5ddc4Srjs    return I;
558196c5ddc4Srjs}
558296c5ddc4Srjs
558396c5ddc4Srjsstatic inline
558496c5ddc4Srjsbi_index bi_rshift_or_v2i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
558596c5ddc4Srjs{
558696c5ddc4Srjs    return (bi_rshift_or_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
558796c5ddc4Srjs}
558896c5ddc4Srjs
558996c5ddc4Srjs
559096c5ddc4Srjsstatic inline
559196c5ddc4Srjsbi_instr * bi_rshift_or_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
559296c5ddc4Srjs{
559396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
559496c5ddc4Srjs    I->op = BI_OPCODE_RSHIFT_OR_V4I8;
559596c5ddc4Srjs    I->dest[0] = dest0;
559696c5ddc4Srjs    I->src[0] = src0;
559796c5ddc4Srjs    I->src[1] = src1;
559896c5ddc4Srjs    I->src[2] = src2;
559996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
560096c5ddc4Srjs    return I;
560196c5ddc4Srjs}
560296c5ddc4Srjs
560396c5ddc4Srjsstatic inline
560496c5ddc4Srjsbi_index bi_rshift_or_v4i8(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
560596c5ddc4Srjs{
560696c5ddc4Srjs    return (bi_rshift_or_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
560796c5ddc4Srjs}
560896c5ddc4Srjs
560996c5ddc4Srjs
561096c5ddc4Srjsstatic inline
561196c5ddc4Srjsbi_instr * bi_rshift_or_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
561296c5ddc4Srjs{
561396c5ddc4Srjs    if (bitsize == 32)
561496c5ddc4Srjs        return (bi_rshift_or_i32_to(b, dest0, src0, src1, src2));
561596c5ddc4Srjs    else if (bitsize == 16)
561696c5ddc4Srjs        return (bi_rshift_or_v2i16_to(b, dest0, src0, src1, src2));
561796c5ddc4Srjs    else if (bitsize == 8)
561896c5ddc4Srjs        return (bi_rshift_or_v4i8_to(b, dest0, src0, src1, src2));
561996c5ddc4Srjs    else
562096c5ddc4Srjs        unreachable("Invalid parameters for RSHIFT_OR");
562196c5ddc4Srjs}
562296c5ddc4Srjs
562396c5ddc4Srjsstatic inline
562496c5ddc4Srjsbi_index bi_rshift_or(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2)
562596c5ddc4Srjs{
562696c5ddc4Srjs    if (bitsize == 32)
562796c5ddc4Srjs        return (bi_rshift_or_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
562896c5ddc4Srjs    else if (bitsize == 16)
562996c5ddc4Srjs        return (bi_rshift_or_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
563096c5ddc4Srjs    else if (bitsize == 8)
563196c5ddc4Srjs        return (bi_rshift_or_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
563296c5ddc4Srjs    else
563396c5ddc4Srjs        unreachable("Invalid parameters for RSHIFT_OR");
563496c5ddc4Srjs}
563596c5ddc4Srjs
563696c5ddc4Srjsstatic inline
563796c5ddc4Srjsbi_instr * bi_rshift_xor_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
563896c5ddc4Srjs{
563996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
564096c5ddc4Srjs    I->op = BI_OPCODE_RSHIFT_XOR_I32;
564196c5ddc4Srjs    I->dest[0] = dest0;
564296c5ddc4Srjs    I->src[0] = src0;
564396c5ddc4Srjs    I->src[1] = src1;
564496c5ddc4Srjs    I->src[2] = src2;
564596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
564696c5ddc4Srjs    return I;
564796c5ddc4Srjs}
564896c5ddc4Srjs
564996c5ddc4Srjsstatic inline
565096c5ddc4Srjsbi_index bi_rshift_xor_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
565196c5ddc4Srjs{
565296c5ddc4Srjs    return (bi_rshift_xor_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
565396c5ddc4Srjs}
565496c5ddc4Srjs
565596c5ddc4Srjs
565696c5ddc4Srjsstatic inline
565796c5ddc4Srjsbi_instr * bi_rshift_xor_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
565896c5ddc4Srjs{
565996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
566096c5ddc4Srjs    I->op = BI_OPCODE_RSHIFT_XOR_V2I16;
566196c5ddc4Srjs    I->dest[0] = dest0;
566296c5ddc4Srjs    I->src[0] = src0;
566396c5ddc4Srjs    I->src[1] = src1;
566496c5ddc4Srjs    I->src[2] = src2;
566596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
566696c5ddc4Srjs    return I;
566796c5ddc4Srjs}
566896c5ddc4Srjs
566996c5ddc4Srjsstatic inline
567096c5ddc4Srjsbi_index bi_rshift_xor_v2i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
567196c5ddc4Srjs{
567296c5ddc4Srjs    return (bi_rshift_xor_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
567396c5ddc4Srjs}
567496c5ddc4Srjs
567596c5ddc4Srjs
567696c5ddc4Srjsstatic inline
567796c5ddc4Srjsbi_instr * bi_rshift_xor_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
567896c5ddc4Srjs{
567996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
568096c5ddc4Srjs    I->op = BI_OPCODE_RSHIFT_XOR_V4I8;
568196c5ddc4Srjs    I->dest[0] = dest0;
568296c5ddc4Srjs    I->src[0] = src0;
568396c5ddc4Srjs    I->src[1] = src1;
568496c5ddc4Srjs    I->src[2] = src2;
568596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
568696c5ddc4Srjs    return I;
568796c5ddc4Srjs}
568896c5ddc4Srjs
568996c5ddc4Srjsstatic inline
569096c5ddc4Srjsbi_index bi_rshift_xor_v4i8(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
569196c5ddc4Srjs{
569296c5ddc4Srjs    return (bi_rshift_xor_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
569396c5ddc4Srjs}
569496c5ddc4Srjs
569596c5ddc4Srjs
569696c5ddc4Srjsstatic inline
569796c5ddc4Srjsbi_instr * bi_rshift_xor_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
569896c5ddc4Srjs{
569996c5ddc4Srjs    if (bitsize == 32)
570096c5ddc4Srjs        return (bi_rshift_xor_i32_to(b, dest0, src0, src1, src2));
570196c5ddc4Srjs    else if (bitsize == 16)
570296c5ddc4Srjs        return (bi_rshift_xor_v2i16_to(b, dest0, src0, src1, src2));
570396c5ddc4Srjs    else if (bitsize == 8)
570496c5ddc4Srjs        return (bi_rshift_xor_v4i8_to(b, dest0, src0, src1, src2));
570596c5ddc4Srjs    else
570696c5ddc4Srjs        unreachable("Invalid parameters for RSHIFT_XOR");
570796c5ddc4Srjs}
570896c5ddc4Srjs
570996c5ddc4Srjsstatic inline
571096c5ddc4Srjsbi_index bi_rshift_xor(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2)
571196c5ddc4Srjs{
571296c5ddc4Srjs    if (bitsize == 32)
571396c5ddc4Srjs        return (bi_rshift_xor_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
571496c5ddc4Srjs    else if (bitsize == 16)
571596c5ddc4Srjs        return (bi_rshift_xor_v2i16_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
571696c5ddc4Srjs    else if (bitsize == 8)
571796c5ddc4Srjs        return (bi_rshift_xor_v4i8_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
571896c5ddc4Srjs    else
571996c5ddc4Srjs        unreachable("Invalid parameters for RSHIFT_XOR");
572096c5ddc4Srjs}
572196c5ddc4Srjs
572296c5ddc4Srjsstatic inline
572396c5ddc4Srjsbi_instr * bi_s16_to_f32_to(bi_builder *b, bi_index dest0, bi_index src0)
572496c5ddc4Srjs{
572596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
572696c5ddc4Srjs    I->op = BI_OPCODE_S16_TO_F32;
572796c5ddc4Srjs    I->dest[0] = dest0;
572896c5ddc4Srjs    I->src[0] = src0;
572996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
573096c5ddc4Srjs    return I;
573196c5ddc4Srjs}
573296c5ddc4Srjs
573396c5ddc4Srjsstatic inline
573496c5ddc4Srjsbi_index bi_s16_to_f32(bi_builder *b, bi_index src0)
573596c5ddc4Srjs{
573696c5ddc4Srjs    return (bi_s16_to_f32_to(b, bi_temp(b->shader), src0))->dest[0];
573796c5ddc4Srjs}
573896c5ddc4Srjs
573996c5ddc4Srjs
574096c5ddc4Srjsstatic inline
574196c5ddc4Srjsbi_instr * bi_s16_to_s32_to(bi_builder *b, bi_index dest0, bi_index src0)
574296c5ddc4Srjs{
574396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
574496c5ddc4Srjs    I->op = BI_OPCODE_S16_TO_S32;
574596c5ddc4Srjs    I->dest[0] = dest0;
574696c5ddc4Srjs    I->src[0] = src0;
574796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
574896c5ddc4Srjs    return I;
574996c5ddc4Srjs}
575096c5ddc4Srjs
575196c5ddc4Srjsstatic inline
575296c5ddc4Srjsbi_index bi_s16_to_s32(bi_builder *b, bi_index src0)
575396c5ddc4Srjs{
575496c5ddc4Srjs    return (bi_s16_to_s32_to(b, bi_temp(b->shader), src0))->dest[0];
575596c5ddc4Srjs}
575696c5ddc4Srjs
575796c5ddc4Srjs
575896c5ddc4Srjsstatic inline
575996c5ddc4Srjsbi_instr * bi_s32_to_f32_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round)
576096c5ddc4Srjs{
576196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
576296c5ddc4Srjs    I->op = BI_OPCODE_S32_TO_F32;
576396c5ddc4Srjs    I->dest[0] = dest0;
576496c5ddc4Srjs    I->src[0] = src0;
576596c5ddc4Srjs    I->round = round;
576696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
576796c5ddc4Srjs    return I;
576896c5ddc4Srjs}
576996c5ddc4Srjs
577096c5ddc4Srjsstatic inline
577196c5ddc4Srjsbi_index bi_s32_to_f32(bi_builder *b, bi_index src0, enum bi_round round)
577296c5ddc4Srjs{
577396c5ddc4Srjs    return (bi_s32_to_f32_to(b, bi_temp(b->shader), src0, round))->dest[0];
577496c5ddc4Srjs}
577596c5ddc4Srjs
577696c5ddc4Srjs
577796c5ddc4Srjsstatic inline
577896c5ddc4Srjsbi_instr * bi_s8_to_f32_to(bi_builder *b, bi_index dest0, bi_index src0)
577996c5ddc4Srjs{
578096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
578196c5ddc4Srjs    I->op = BI_OPCODE_S8_TO_F32;
578296c5ddc4Srjs    I->dest[0] = dest0;
578396c5ddc4Srjs    I->src[0] = src0;
578496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
578596c5ddc4Srjs    return I;
578696c5ddc4Srjs}
578796c5ddc4Srjs
578896c5ddc4Srjsstatic inline
578996c5ddc4Srjsbi_index bi_s8_to_f32(bi_builder *b, bi_index src0)
579096c5ddc4Srjs{
579196c5ddc4Srjs    return (bi_s8_to_f32_to(b, bi_temp(b->shader), src0))->dest[0];
579296c5ddc4Srjs}
579396c5ddc4Srjs
579496c5ddc4Srjs
579596c5ddc4Srjsstatic inline
579696c5ddc4Srjsbi_instr * bi_s8_to_s32_to(bi_builder *b, bi_index dest0, bi_index src0)
579796c5ddc4Srjs{
579896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
579996c5ddc4Srjs    I->op = BI_OPCODE_S8_TO_S32;
580096c5ddc4Srjs    I->dest[0] = dest0;
580196c5ddc4Srjs    I->src[0] = src0;
580296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
580396c5ddc4Srjs    return I;
580496c5ddc4Srjs}
580596c5ddc4Srjs
580696c5ddc4Srjsstatic inline
580796c5ddc4Srjsbi_index bi_s8_to_s32(bi_builder *b, bi_index src0)
580896c5ddc4Srjs{
580996c5ddc4Srjs    return (bi_s8_to_s32_to(b, bi_temp(b->shader), src0))->dest[0];
581096c5ddc4Srjs}
581196c5ddc4Srjs
581296c5ddc4Srjs
581396c5ddc4Srjsstatic inline
581496c5ddc4Srjsbi_instr * bi_seg_add_to(bi_builder *b, bi_index dest0, bi_index src0, bool preserve_null, enum bi_seg seg)
581596c5ddc4Srjs{
581696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
581796c5ddc4Srjs    I->op = BI_OPCODE_SEG_ADD;
581896c5ddc4Srjs    I->dest[0] = dest0;
581996c5ddc4Srjs    I->src[0] = src0;
582096c5ddc4Srjs    I->seg = seg;
582196c5ddc4Srjs    I->preserve_null = preserve_null;
582296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
582396c5ddc4Srjs    return I;
582496c5ddc4Srjs}
582596c5ddc4Srjs
582696c5ddc4Srjsstatic inline
582796c5ddc4Srjsbi_index bi_seg_add(bi_builder *b, bi_index src0, bool preserve_null, enum bi_seg seg)
582896c5ddc4Srjs{
582996c5ddc4Srjs    return (bi_seg_add_to(b, bi_temp(b->shader), src0, preserve_null, seg))->dest[0];
583096c5ddc4Srjs}
583196c5ddc4Srjs
583296c5ddc4Srjs
583396c5ddc4Srjsstatic inline
583496c5ddc4Srjsbi_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)
583596c5ddc4Srjs{
583696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
583796c5ddc4Srjs    I->op = BI_OPCODE_SEG_ADD_I64;
583896c5ddc4Srjs    I->dest[0] = dest0;
583996c5ddc4Srjs    I->src[0] = src0;
584096c5ddc4Srjs    I->src[1] = src1;
584196c5ddc4Srjs    I->seg = seg;
584296c5ddc4Srjs    I->preserve_null = preserve_null;
584396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
584496c5ddc4Srjs    return I;
584596c5ddc4Srjs}
584696c5ddc4Srjs
584796c5ddc4Srjsstatic inline
584896c5ddc4Srjsbi_index bi_seg_add_i64(bi_builder *b, bi_index src0, bi_index src1, bool preserve_null, enum bi_seg seg)
584996c5ddc4Srjs{
585096c5ddc4Srjs    return (bi_seg_add_i64_to(b, bi_temp(b->shader), src0, src1, preserve_null, seg))->dest[0];
585196c5ddc4Srjs}
585296c5ddc4Srjs
585396c5ddc4Srjs
585496c5ddc4Srjsstatic inline
585596c5ddc4Srjsbi_instr * bi_shaddxh_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1)
585696c5ddc4Srjs{
585796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
585896c5ddc4Srjs    I->op = BI_OPCODE_SHADDXH_I32;
585996c5ddc4Srjs    I->dest[0] = dest0;
586096c5ddc4Srjs    I->src[0] = src0;
586196c5ddc4Srjs    I->src[1] = src1;
586296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
586396c5ddc4Srjs    return I;
586496c5ddc4Srjs}
586596c5ddc4Srjs
586696c5ddc4Srjsstatic inline
586796c5ddc4Srjsbi_index bi_shaddxh_i32(bi_builder *b, bi_index src0, bi_index src1)
586896c5ddc4Srjs{
586996c5ddc4Srjs    return (bi_shaddxh_i32_to(b, bi_temp(b->shader), src0, src1))->dest[0];
587096c5ddc4Srjs}
587196c5ddc4Srjs
587296c5ddc4Srjs
587396c5ddc4Srjsstatic inline
587496c5ddc4Srjsbi_instr * bi_shaddxl_i64_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, uint32_t shift)
587596c5ddc4Srjs{
587696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
587796c5ddc4Srjs    I->op = BI_OPCODE_SHADDXL_I64;
587896c5ddc4Srjs    I->dest[0] = dest0;
587996c5ddc4Srjs    I->src[0] = src0;
588096c5ddc4Srjs    I->src[1] = src1;
588196c5ddc4Srjs    I->shift = shift;
588296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
588396c5ddc4Srjs    return I;
588496c5ddc4Srjs}
588596c5ddc4Srjs
588696c5ddc4Srjsstatic inline
588796c5ddc4Srjsbi_index bi_shaddxl_i64(bi_builder *b, bi_index src0, bi_index src1, uint32_t shift)
588896c5ddc4Srjs{
588996c5ddc4Srjs    return (bi_shaddxl_i64_to(b, bi_temp(b->shader), src0, src1, shift))->dest[0];
589096c5ddc4Srjs}
589196c5ddc4Srjs
589296c5ddc4Srjs
589396c5ddc4Srjsstatic inline
589496c5ddc4Srjsbi_instr * bi_shaddxl_s32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, uint32_t shift)
589596c5ddc4Srjs{
589696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
589796c5ddc4Srjs    I->op = BI_OPCODE_SHADDXL_S32;
589896c5ddc4Srjs    I->dest[0] = dest0;
589996c5ddc4Srjs    I->src[0] = src0;
590096c5ddc4Srjs    I->src[1] = src1;
590196c5ddc4Srjs    I->shift = shift;
590296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
590396c5ddc4Srjs    return I;
590496c5ddc4Srjs}
590596c5ddc4Srjs
590696c5ddc4Srjsstatic inline
590796c5ddc4Srjsbi_index bi_shaddxl_s32(bi_builder *b, bi_index src0, bi_index src1, uint32_t shift)
590896c5ddc4Srjs{
590996c5ddc4Srjs    return (bi_shaddxl_s32_to(b, bi_temp(b->shader), src0, src1, shift))->dest[0];
591096c5ddc4Srjs}
591196c5ddc4Srjs
591296c5ddc4Srjs
591396c5ddc4Srjsstatic inline
591496c5ddc4Srjsbi_instr * bi_shaddxl_u32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, uint32_t shift)
591596c5ddc4Srjs{
591696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
591796c5ddc4Srjs    I->op = BI_OPCODE_SHADDXL_U32;
591896c5ddc4Srjs    I->dest[0] = dest0;
591996c5ddc4Srjs    I->src[0] = src0;
592096c5ddc4Srjs    I->src[1] = src1;
592196c5ddc4Srjs    I->shift = shift;
592296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
592396c5ddc4Srjs    return I;
592496c5ddc4Srjs}
592596c5ddc4Srjs
592696c5ddc4Srjsstatic inline
592796c5ddc4Srjsbi_index bi_shaddxl_u32(bi_builder *b, bi_index src0, bi_index src1, uint32_t shift)
592896c5ddc4Srjs{
592996c5ddc4Srjs    return (bi_shaddxl_u32_to(b, bi_temp(b->shader), src0, src1, shift))->dest[0];
593096c5ddc4Srjs}
593196c5ddc4Srjs
593296c5ddc4Srjs
593396c5ddc4Srjsstatic inline
593496c5ddc4Srjsbi_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)
593596c5ddc4Srjs{
593696c5ddc4Srjs    if ((type == nir_type_uint || type == nir_type_int) && bitsize == 64)
593796c5ddc4Srjs        return (bi_shaddxl_i64_to(b, dest0, src0, src1, shift));
593896c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 32)
593996c5ddc4Srjs        return (bi_shaddxl_s32_to(b, dest0, src0, src1, shift));
594096c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 32)
594196c5ddc4Srjs        return (bi_shaddxl_u32_to(b, dest0, src0, src1, shift));
594296c5ddc4Srjs    else
594396c5ddc4Srjs        unreachable("Invalid parameters for SHADDXL");
594496c5ddc4Srjs}
594596c5ddc4Srjs
594696c5ddc4Srjsstatic inline
594796c5ddc4Srjsbi_index bi_shaddxl(bi_builder *b, nir_alu_type type, unsigned bitsize, bi_index src0, bi_index src1, uint32_t shift)
594896c5ddc4Srjs{
594996c5ddc4Srjs    if ((type == nir_type_uint || type == nir_type_int) && bitsize == 64)
595096c5ddc4Srjs        return (bi_shaddxl_i64_to(b, bi_temp(b->shader), src0, src1, shift))->dest[0];
595196c5ddc4Srjs    else if ((type == nir_type_int) && bitsize == 32)
595296c5ddc4Srjs        return (bi_shaddxl_s32_to(b, bi_temp(b->shader), src0, src1, shift))->dest[0];
595396c5ddc4Srjs    else if ((type == nir_type_uint) && bitsize == 32)
595496c5ddc4Srjs        return (bi_shaddxl_u32_to(b, bi_temp(b->shader), src0, src1, shift))->dest[0];
595596c5ddc4Srjs    else
595696c5ddc4Srjs        unreachable("Invalid parameters for SHADDXL");
595796c5ddc4Srjs}
595896c5ddc4Srjs
595996c5ddc4Srjsstatic inline
596096c5ddc4Srjsbi_instr * bi_shift_double_i32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2)
596196c5ddc4Srjs{
596296c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
596396c5ddc4Srjs    I->op = BI_OPCODE_SHIFT_DOUBLE_I32;
596496c5ddc4Srjs    I->dest[0] = dest0;
596596c5ddc4Srjs    I->src[0] = src0;
596696c5ddc4Srjs    I->src[1] = src1;
596796c5ddc4Srjs    I->src[2] = src2;
596896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
596996c5ddc4Srjs    return I;
597096c5ddc4Srjs}
597196c5ddc4Srjs
597296c5ddc4Srjsstatic inline
597396c5ddc4Srjsbi_index bi_shift_double_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2)
597496c5ddc4Srjs{
597596c5ddc4Srjs    return (bi_shift_double_i32_to(b, bi_temp(b->shader), src0, src1, src2))->dest[0];
597696c5ddc4Srjs}
597796c5ddc4Srjs
597896c5ddc4Srjs
597996c5ddc4Srjsstatic inline
598096c5ddc4Srjsbi_instr * bi_store_i128(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
598196c5ddc4Srjs{
598296c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
598396c5ddc4Srjs    I->op = BI_OPCODE_STORE_I128;
598496c5ddc4Srjs    I->src[0] = src0;
598596c5ddc4Srjs    I->src[1] = src1;
598696c5ddc4Srjs    I->src[2] = src2;
598796c5ddc4Srjs    I->seg = seg;
598896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
598996c5ddc4Srjs    return I;
599096c5ddc4Srjs}
599196c5ddc4Srjs
599296c5ddc4Srjs
599396c5ddc4Srjsstatic inline
599496c5ddc4Srjsbi_instr * bi_store_i16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
599596c5ddc4Srjs{
599696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
599796c5ddc4Srjs    I->op = BI_OPCODE_STORE_I16;
599896c5ddc4Srjs    I->src[0] = src0;
599996c5ddc4Srjs    I->src[1] = src1;
600096c5ddc4Srjs    I->src[2] = src2;
600196c5ddc4Srjs    I->seg = seg;
600296c5ddc4Srjs    I->extend = BI_EXTEND_ZEXT;
600396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
600496c5ddc4Srjs    return I;
600596c5ddc4Srjs}
600696c5ddc4Srjs
600796c5ddc4Srjs
600896c5ddc4Srjsstatic inline
600996c5ddc4Srjsbi_instr * bi_store_i24(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
601096c5ddc4Srjs{
601196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
601296c5ddc4Srjs    I->op = BI_OPCODE_STORE_I24;
601396c5ddc4Srjs    I->src[0] = src0;
601496c5ddc4Srjs    I->src[1] = src1;
601596c5ddc4Srjs    I->src[2] = src2;
601696c5ddc4Srjs    I->seg = seg;
601796c5ddc4Srjs    I->extend = BI_EXTEND_ZEXT;
601896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
601996c5ddc4Srjs    return I;
602096c5ddc4Srjs}
602196c5ddc4Srjs
602296c5ddc4Srjs
602396c5ddc4Srjsstatic inline
602496c5ddc4Srjsbi_instr * bi_store_i32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
602596c5ddc4Srjs{
602696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
602796c5ddc4Srjs    I->op = BI_OPCODE_STORE_I32;
602896c5ddc4Srjs    I->src[0] = src0;
602996c5ddc4Srjs    I->src[1] = src1;
603096c5ddc4Srjs    I->src[2] = src2;
603196c5ddc4Srjs    I->seg = seg;
603296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
603396c5ddc4Srjs    return I;
603496c5ddc4Srjs}
603596c5ddc4Srjs
603696c5ddc4Srjs
603796c5ddc4Srjsstatic inline
603896c5ddc4Srjsbi_instr * bi_store_i48(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
603996c5ddc4Srjs{
604096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
604196c5ddc4Srjs    I->op = BI_OPCODE_STORE_I48;
604296c5ddc4Srjs    I->src[0] = src0;
604396c5ddc4Srjs    I->src[1] = src1;
604496c5ddc4Srjs    I->src[2] = src2;
604596c5ddc4Srjs    I->seg = seg;
604696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
604796c5ddc4Srjs    return I;
604896c5ddc4Srjs}
604996c5ddc4Srjs
605096c5ddc4Srjs
605196c5ddc4Srjsstatic inline
605296c5ddc4Srjsbi_instr * bi_store_i64(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
605396c5ddc4Srjs{
605496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
605596c5ddc4Srjs    I->op = BI_OPCODE_STORE_I64;
605696c5ddc4Srjs    I->src[0] = src0;
605796c5ddc4Srjs    I->src[1] = src1;
605896c5ddc4Srjs    I->src[2] = src2;
605996c5ddc4Srjs    I->seg = seg;
606096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
606196c5ddc4Srjs    return I;
606296c5ddc4Srjs}
606396c5ddc4Srjs
606496c5ddc4Srjs
606596c5ddc4Srjsstatic inline
606696c5ddc4Srjsbi_instr * bi_store_i8(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
606796c5ddc4Srjs{
606896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
606996c5ddc4Srjs    I->op = BI_OPCODE_STORE_I8;
607096c5ddc4Srjs    I->src[0] = src0;
607196c5ddc4Srjs    I->src[1] = src1;
607296c5ddc4Srjs    I->src[2] = src2;
607396c5ddc4Srjs    I->seg = seg;
607496c5ddc4Srjs    I->extend = BI_EXTEND_ZEXT;
607596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
607696c5ddc4Srjs    return I;
607796c5ddc4Srjs}
607896c5ddc4Srjs
607996c5ddc4Srjs
608096c5ddc4Srjsstatic inline
608196c5ddc4Srjsbi_instr * bi_store_i96(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
608296c5ddc4Srjs{
608396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
608496c5ddc4Srjs    I->op = BI_OPCODE_STORE_I96;
608596c5ddc4Srjs    I->src[0] = src0;
608696c5ddc4Srjs    I->src[1] = src1;
608796c5ddc4Srjs    I->src[2] = src2;
608896c5ddc4Srjs    I->seg = seg;
608996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
609096c5ddc4Srjs    return I;
609196c5ddc4Srjs}
609296c5ddc4Srjs
609396c5ddc4Srjs
609496c5ddc4Srjsstatic inline
609596c5ddc4Srjsbi_instr * bi_store(bi_builder *b, unsigned bitsize, bi_index src0, bi_index src1, bi_index src2, enum bi_seg seg)
609696c5ddc4Srjs{
609796c5ddc4Srjs    if (bitsize == 128)
609896c5ddc4Srjs        return (bi_store_i128(b, src0, src1, src2, seg));
609996c5ddc4Srjs    else if (bitsize == 16)
610096c5ddc4Srjs        return (bi_store_i16(b, src0, src1, src2, seg));
610196c5ddc4Srjs    else if (bitsize == 24)
610296c5ddc4Srjs        return (bi_store_i24(b, src0, src1, src2, seg));
610396c5ddc4Srjs    else if (bitsize == 32)
610496c5ddc4Srjs        return (bi_store_i32(b, src0, src1, src2, seg));
610596c5ddc4Srjs    else if (bitsize == 48)
610696c5ddc4Srjs        return (bi_store_i48(b, src0, src1, src2, seg));
610796c5ddc4Srjs    else if (bitsize == 64)
610896c5ddc4Srjs        return (bi_store_i64(b, src0, src1, src2, seg));
610996c5ddc4Srjs    else if (bitsize == 8)
611096c5ddc4Srjs        return (bi_store_i8(b, src0, src1, src2, seg));
611196c5ddc4Srjs    else if (bitsize == 96)
611296c5ddc4Srjs        return (bi_store_i96(b, src0, src1, src2, seg));
611396c5ddc4Srjs    else
611496c5ddc4Srjs        unreachable("Invalid parameters for STORE");
611596c5ddc4Srjs}
611696c5ddc4Srjs
611796c5ddc4Srjsstatic inline
611896c5ddc4Srjsbi_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)
611996c5ddc4Srjs{
612096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
612196c5ddc4Srjs    I->op = BI_OPCODE_ST_CVT;
612296c5ddc4Srjs    I->src[0] = src0;
612396c5ddc4Srjs    I->src[1] = src1;
612496c5ddc4Srjs    I->src[2] = src2;
612596c5ddc4Srjs    I->src[3] = src3;
612696c5ddc4Srjs    I->register_format = register_format;
612796c5ddc4Srjs    I->vecsize = vecsize;
612896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
612996c5ddc4Srjs    return I;
613096c5ddc4Srjs}
613196c5ddc4Srjs
613296c5ddc4Srjs
613396c5ddc4Srjsstatic inline
613496c5ddc4Srjsbi_instr * bi_st_tile(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3, enum bi_vecsize vecsize)
613596c5ddc4Srjs{
613696c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
613796c5ddc4Srjs    I->op = BI_OPCODE_ST_TILE;
613896c5ddc4Srjs    I->src[0] = src0;
613996c5ddc4Srjs    I->src[1] = src1;
614096c5ddc4Srjs    I->src[2] = src2;
614196c5ddc4Srjs    I->src[3] = src3;
614296c5ddc4Srjs    I->vecsize = vecsize;
614396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
614496c5ddc4Srjs    return I;
614596c5ddc4Srjs}
614696c5ddc4Srjs
614796c5ddc4Srjs
614896c5ddc4Srjsstatic inline
614996c5ddc4Srjsbi_instr * bi_swz_v2i16_to(bi_builder *b, bi_index dest0, bi_index src0)
615096c5ddc4Srjs{
615196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
615296c5ddc4Srjs    I->op = BI_OPCODE_SWZ_V2I16;
615396c5ddc4Srjs    I->dest[0] = dest0;
615496c5ddc4Srjs    I->src[0] = src0;
615596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
615696c5ddc4Srjs    return I;
615796c5ddc4Srjs}
615896c5ddc4Srjs
615996c5ddc4Srjsstatic inline
616096c5ddc4Srjsbi_index bi_swz_v2i16(bi_builder *b, bi_index src0)
616196c5ddc4Srjs{
616296c5ddc4Srjs    return (bi_swz_v2i16_to(b, bi_temp(b->shader), src0))->dest[0];
616396c5ddc4Srjs}
616496c5ddc4Srjs
616596c5ddc4Srjs
616696c5ddc4Srjsstatic inline
616796c5ddc4Srjsbi_instr * bi_swz_v4i8_to(bi_builder *b, bi_index dest0, bi_index src0)
616896c5ddc4Srjs{
616996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
617096c5ddc4Srjs    I->op = BI_OPCODE_SWZ_V4I8;
617196c5ddc4Srjs    I->dest[0] = dest0;
617296c5ddc4Srjs    I->src[0] = src0;
617396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
617496c5ddc4Srjs    return I;
617596c5ddc4Srjs}
617696c5ddc4Srjs
617796c5ddc4Srjsstatic inline
617896c5ddc4Srjsbi_index bi_swz_v4i8(bi_builder *b, bi_index src0)
617996c5ddc4Srjs{
618096c5ddc4Srjs    return (bi_swz_v4i8_to(b, bi_temp(b->shader), src0))->dest[0];
618196c5ddc4Srjs}
618296c5ddc4Srjs
618396c5ddc4Srjs
618496c5ddc4Srjsstatic inline
618596c5ddc4Srjsbi_instr * bi_swz_to(bi_builder *b, unsigned bitsize, bi_index dest0, bi_index src0)
618696c5ddc4Srjs{
618796c5ddc4Srjs    if (bitsize == 16)
618896c5ddc4Srjs        return (bi_swz_v2i16_to(b, dest0, src0));
618996c5ddc4Srjs    else if (bitsize == 8)
619096c5ddc4Srjs        return (bi_swz_v4i8_to(b, dest0, src0));
619196c5ddc4Srjs    else
619296c5ddc4Srjs        unreachable("Invalid parameters for SWZ");
619396c5ddc4Srjs}
619496c5ddc4Srjs
619596c5ddc4Srjsstatic inline
619696c5ddc4Srjsbi_index bi_swz(bi_builder *b, unsigned bitsize, bi_index src0)
619796c5ddc4Srjs{
619896c5ddc4Srjs    if (bitsize == 16)
619996c5ddc4Srjs        return (bi_swz_v2i16_to(b, bi_temp(b->shader), src0))->dest[0];
620096c5ddc4Srjs    else if (bitsize == 8)
620196c5ddc4Srjs        return (bi_swz_v4i8_to(b, bi_temp(b->shader), src0))->dest[0];
620296c5ddc4Srjs    else
620396c5ddc4Srjs        unreachable("Invalid parameters for SWZ");
620496c5ddc4Srjs}
620596c5ddc4Srjs
620696c5ddc4Srjsstatic inline
620796c5ddc4Srjsbi_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)
620896c5ddc4Srjs{
620996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
621096c5ddc4Srjs    I->op = BI_OPCODE_TEXC;
621196c5ddc4Srjs    I->dest[0] = dest0;
621296c5ddc4Srjs    I->src[0] = src0;
621396c5ddc4Srjs    I->src[1] = src1;
621496c5ddc4Srjs    I->src[2] = src2;
621596c5ddc4Srjs    I->src[3] = src3;
621696c5ddc4Srjs    I->lod_mode = lod_mode;
621796c5ddc4Srjs    I->sr_count = sr_count;
621896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
621996c5ddc4Srjs    return I;
622096c5ddc4Srjs}
622196c5ddc4Srjs
622296c5ddc4Srjsstatic inline
622396c5ddc4Srjsbi_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)
622496c5ddc4Srjs{
622596c5ddc4Srjs    return (bi_texc_to(b, bi_temp(b->shader), src0, src1, src2, src3, lod_mode, sr_count))->dest[0];
622696c5ddc4Srjs}
622796c5ddc4Srjs
622896c5ddc4Srjs
622996c5ddc4Srjsstatic inline
623096c5ddc4Srjsbi_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)
623196c5ddc4Srjs{
623296c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
623396c5ddc4Srjs    I->op = BI_OPCODE_TEXS_2D_F16;
623496c5ddc4Srjs    I->dest[0] = dest0;
623596c5ddc4Srjs    I->src[0] = src0;
623696c5ddc4Srjs    I->src[1] = src1;
623796c5ddc4Srjs    I->lod_mode = lod_mode;
623896c5ddc4Srjs    I->sampler_index = sampler_index;
623996c5ddc4Srjs    I->texture_index = texture_index;
624096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
624196c5ddc4Srjs    return I;
624296c5ddc4Srjs}
624396c5ddc4Srjs
624496c5ddc4Srjsstatic inline
624596c5ddc4Srjsbi_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)
624696c5ddc4Srjs{
624796c5ddc4Srjs    return (bi_texs_2d_f16_to(b, bi_temp(b->shader), src0, src1, lod_mode, sampler_index, texture_index))->dest[0];
624896c5ddc4Srjs}
624996c5ddc4Srjs
625096c5ddc4Srjs
625196c5ddc4Srjsstatic inline
625296c5ddc4Srjsbi_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)
625396c5ddc4Srjs{
625496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
625596c5ddc4Srjs    I->op = BI_OPCODE_TEXS_2D_F32;
625696c5ddc4Srjs    I->dest[0] = dest0;
625796c5ddc4Srjs    I->src[0] = src0;
625896c5ddc4Srjs    I->src[1] = src1;
625996c5ddc4Srjs    I->lod_mode = lod_mode;
626096c5ddc4Srjs    I->sampler_index = sampler_index;
626196c5ddc4Srjs    I->texture_index = texture_index;
626296c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
626396c5ddc4Srjs    return I;
626496c5ddc4Srjs}
626596c5ddc4Srjs
626696c5ddc4Srjsstatic inline
626796c5ddc4Srjsbi_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)
626896c5ddc4Srjs{
626996c5ddc4Srjs    return (bi_texs_2d_f32_to(b, bi_temp(b->shader), src0, src1, lod_mode, sampler_index, texture_index))->dest[0];
627096c5ddc4Srjs}
627196c5ddc4Srjs
627296c5ddc4Srjs
627396c5ddc4Srjsstatic inline
627496c5ddc4Srjsbi_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)
627596c5ddc4Srjs{
627696c5ddc4Srjs    if (bitsize == 16)
627796c5ddc4Srjs        return (bi_texs_2d_f16_to(b, dest0, src0, src1, lod_mode, sampler_index, texture_index));
627896c5ddc4Srjs    else if (bitsize == 32)
627996c5ddc4Srjs        return (bi_texs_2d_f32_to(b, dest0, src0, src1, lod_mode, sampler_index, texture_index));
628096c5ddc4Srjs    else
628196c5ddc4Srjs        unreachable("Invalid parameters for TEXS_2D");
628296c5ddc4Srjs}
628396c5ddc4Srjs
628496c5ddc4Srjsstatic inline
628596c5ddc4Srjsbi_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)
628696c5ddc4Srjs{
628796c5ddc4Srjs    if (bitsize == 16)
628896c5ddc4Srjs        return (bi_texs_2d_f16_to(b, bi_temp(b->shader), src0, src1, lod_mode, sampler_index, texture_index))->dest[0];
628996c5ddc4Srjs    else if (bitsize == 32)
629096c5ddc4Srjs        return (bi_texs_2d_f32_to(b, bi_temp(b->shader), src0, src1, lod_mode, sampler_index, texture_index))->dest[0];
629196c5ddc4Srjs    else
629296c5ddc4Srjs        unreachable("Invalid parameters for TEXS_2D");
629396c5ddc4Srjs}
629496c5ddc4Srjs
629596c5ddc4Srjsstatic inline
629696c5ddc4Srjsbi_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)
629796c5ddc4Srjs{
629896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
629996c5ddc4Srjs    I->op = BI_OPCODE_TEXS_CUBE_F16;
630096c5ddc4Srjs    I->dest[0] = dest0;
630196c5ddc4Srjs    I->src[0] = src0;
630296c5ddc4Srjs    I->src[1] = src1;
630396c5ddc4Srjs    I->src[2] = src2;
630496c5ddc4Srjs    I->sampler_index = sampler_index;
630596c5ddc4Srjs    I->texture_index = texture_index;
630696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
630796c5ddc4Srjs    return I;
630896c5ddc4Srjs}
630996c5ddc4Srjs
631096c5ddc4Srjsstatic inline
631196c5ddc4Srjsbi_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)
631296c5ddc4Srjs{
631396c5ddc4Srjs    return (bi_texs_cube_f16_to(b, bi_temp(b->shader), src0, src1, src2, sampler_index, texture_index))->dest[0];
631496c5ddc4Srjs}
631596c5ddc4Srjs
631696c5ddc4Srjs
631796c5ddc4Srjsstatic inline
631896c5ddc4Srjsbi_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)
631996c5ddc4Srjs{
632096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
632196c5ddc4Srjs    I->op = BI_OPCODE_TEXS_CUBE_F32;
632296c5ddc4Srjs    I->dest[0] = dest0;
632396c5ddc4Srjs    I->src[0] = src0;
632496c5ddc4Srjs    I->src[1] = src1;
632596c5ddc4Srjs    I->src[2] = src2;
632696c5ddc4Srjs    I->sampler_index = sampler_index;
632796c5ddc4Srjs    I->texture_index = texture_index;
632896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
632996c5ddc4Srjs    return I;
633096c5ddc4Srjs}
633196c5ddc4Srjs
633296c5ddc4Srjsstatic inline
633396c5ddc4Srjsbi_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)
633496c5ddc4Srjs{
633596c5ddc4Srjs    return (bi_texs_cube_f32_to(b, bi_temp(b->shader), src0, src1, src2, sampler_index, texture_index))->dest[0];
633696c5ddc4Srjs}
633796c5ddc4Srjs
633896c5ddc4Srjs
633996c5ddc4Srjsstatic inline
634096c5ddc4Srjsbi_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)
634196c5ddc4Srjs{
634296c5ddc4Srjs    if (bitsize == 16)
634396c5ddc4Srjs        return (bi_texs_cube_f16_to(b, dest0, src0, src1, src2, sampler_index, texture_index));
634496c5ddc4Srjs    else if (bitsize == 32)
634596c5ddc4Srjs        return (bi_texs_cube_f32_to(b, dest0, src0, src1, src2, sampler_index, texture_index));
634696c5ddc4Srjs    else
634796c5ddc4Srjs        unreachable("Invalid parameters for TEXS_CUBE");
634896c5ddc4Srjs}
634996c5ddc4Srjs
635096c5ddc4Srjsstatic inline
635196c5ddc4Srjsbi_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)
635296c5ddc4Srjs{
635396c5ddc4Srjs    if (bitsize == 16)
635496c5ddc4Srjs        return (bi_texs_cube_f16_to(b, bi_temp(b->shader), src0, src1, src2, sampler_index, texture_index))->dest[0];
635596c5ddc4Srjs    else if (bitsize == 32)
635696c5ddc4Srjs        return (bi_texs_cube_f32_to(b, bi_temp(b->shader), src0, src1, src2, sampler_index, texture_index))->dest[0];
635796c5ddc4Srjs    else
635896c5ddc4Srjs        unreachable("Invalid parameters for TEXS_CUBE");
635996c5ddc4Srjs}
636096c5ddc4Srjs
636196c5ddc4Srjsstatic inline
636296c5ddc4Srjsbi_instr * bi_u16_to_f32_to(bi_builder *b, bi_index dest0, bi_index src0)
636396c5ddc4Srjs{
636496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
636596c5ddc4Srjs    I->op = BI_OPCODE_U16_TO_F32;
636696c5ddc4Srjs    I->dest[0] = dest0;
636796c5ddc4Srjs    I->src[0] = src0;
636896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
636996c5ddc4Srjs    return I;
637096c5ddc4Srjs}
637196c5ddc4Srjs
637296c5ddc4Srjsstatic inline
637396c5ddc4Srjsbi_index bi_u16_to_f32(bi_builder *b, bi_index src0)
637496c5ddc4Srjs{
637596c5ddc4Srjs    return (bi_u16_to_f32_to(b, bi_temp(b->shader), src0))->dest[0];
637696c5ddc4Srjs}
637796c5ddc4Srjs
637896c5ddc4Srjs
637996c5ddc4Srjsstatic inline
638096c5ddc4Srjsbi_instr * bi_u16_to_u32_to(bi_builder *b, bi_index dest0, bi_index src0)
638196c5ddc4Srjs{
638296c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
638396c5ddc4Srjs    I->op = BI_OPCODE_U16_TO_U32;
638496c5ddc4Srjs    I->dest[0] = dest0;
638596c5ddc4Srjs    I->src[0] = src0;
638696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
638796c5ddc4Srjs    return I;
638896c5ddc4Srjs}
638996c5ddc4Srjs
639096c5ddc4Srjsstatic inline
639196c5ddc4Srjsbi_index bi_u16_to_u32(bi_builder *b, bi_index src0)
639296c5ddc4Srjs{
639396c5ddc4Srjs    return (bi_u16_to_u32_to(b, bi_temp(b->shader), src0))->dest[0];
639496c5ddc4Srjs}
639596c5ddc4Srjs
639696c5ddc4Srjs
639796c5ddc4Srjsstatic inline
639896c5ddc4Srjsbi_instr * bi_u32_to_f32_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round)
639996c5ddc4Srjs{
640096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
640196c5ddc4Srjs    I->op = BI_OPCODE_U32_TO_F32;
640296c5ddc4Srjs    I->dest[0] = dest0;
640396c5ddc4Srjs    I->src[0] = src0;
640496c5ddc4Srjs    I->round = round;
640596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
640696c5ddc4Srjs    return I;
640796c5ddc4Srjs}
640896c5ddc4Srjs
640996c5ddc4Srjsstatic inline
641096c5ddc4Srjsbi_index bi_u32_to_f32(bi_builder *b, bi_index src0, enum bi_round round)
641196c5ddc4Srjs{
641296c5ddc4Srjs    return (bi_u32_to_f32_to(b, bi_temp(b->shader), src0, round))->dest[0];
641396c5ddc4Srjs}
641496c5ddc4Srjs
641596c5ddc4Srjs
641696c5ddc4Srjsstatic inline
641796c5ddc4Srjsbi_instr * bi_u8_to_f32_to(bi_builder *b, bi_index dest0, bi_index src0)
641896c5ddc4Srjs{
641996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
642096c5ddc4Srjs    I->op = BI_OPCODE_U8_TO_F32;
642196c5ddc4Srjs    I->dest[0] = dest0;
642296c5ddc4Srjs    I->src[0] = src0;
642396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
642496c5ddc4Srjs    return I;
642596c5ddc4Srjs}
642696c5ddc4Srjs
642796c5ddc4Srjsstatic inline
642896c5ddc4Srjsbi_index bi_u8_to_f32(bi_builder *b, bi_index src0)
642996c5ddc4Srjs{
643096c5ddc4Srjs    return (bi_u8_to_f32_to(b, bi_temp(b->shader), src0))->dest[0];
643196c5ddc4Srjs}
643296c5ddc4Srjs
643396c5ddc4Srjs
643496c5ddc4Srjsstatic inline
643596c5ddc4Srjsbi_instr * bi_u8_to_u32_to(bi_builder *b, bi_index dest0, bi_index src0)
643696c5ddc4Srjs{
643796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
643896c5ddc4Srjs    I->op = BI_OPCODE_U8_TO_U32;
643996c5ddc4Srjs    I->dest[0] = dest0;
644096c5ddc4Srjs    I->src[0] = src0;
644196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
644296c5ddc4Srjs    return I;
644396c5ddc4Srjs}
644496c5ddc4Srjs
644596c5ddc4Srjsstatic inline
644696c5ddc4Srjsbi_index bi_u8_to_u32(bi_builder *b, bi_index src0)
644796c5ddc4Srjs{
644896c5ddc4Srjs    return (bi_u8_to_u32_to(b, bi_temp(b->shader), src0))->dest[0];
644996c5ddc4Srjs}
645096c5ddc4Srjs
645196c5ddc4Srjs
645296c5ddc4Srjsstatic inline
645396c5ddc4Srjsbi_instr * bi_v2f16_to_v2s16_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round)
645496c5ddc4Srjs{
645596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
645696c5ddc4Srjs    I->op = BI_OPCODE_V2F16_TO_V2S16;
645796c5ddc4Srjs    I->dest[0] = dest0;
645896c5ddc4Srjs    I->src[0] = src0;
645996c5ddc4Srjs    I->round = round;
646096c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
646196c5ddc4Srjs    return I;
646296c5ddc4Srjs}
646396c5ddc4Srjs
646496c5ddc4Srjsstatic inline
646596c5ddc4Srjsbi_index bi_v2f16_to_v2s16(bi_builder *b, bi_index src0, enum bi_round round)
646696c5ddc4Srjs{
646796c5ddc4Srjs    return (bi_v2f16_to_v2s16_to(b, bi_temp(b->shader), src0, round))->dest[0];
646896c5ddc4Srjs}
646996c5ddc4Srjs
647096c5ddc4Srjs
647196c5ddc4Srjsstatic inline
647296c5ddc4Srjsbi_instr * bi_v2f16_to_v2u16_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round)
647396c5ddc4Srjs{
647496c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
647596c5ddc4Srjs    I->op = BI_OPCODE_V2F16_TO_V2U16;
647696c5ddc4Srjs    I->dest[0] = dest0;
647796c5ddc4Srjs    I->src[0] = src0;
647896c5ddc4Srjs    I->round = round;
647996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
648096c5ddc4Srjs    return I;
648196c5ddc4Srjs}
648296c5ddc4Srjs
648396c5ddc4Srjsstatic inline
648496c5ddc4Srjsbi_index bi_v2f16_to_v2u16(bi_builder *b, bi_index src0, enum bi_round round)
648596c5ddc4Srjs{
648696c5ddc4Srjs    return (bi_v2f16_to_v2u16_to(b, bi_temp(b->shader), src0, round))->dest[0];
648796c5ddc4Srjs}
648896c5ddc4Srjs
648996c5ddc4Srjs
649096c5ddc4Srjsstatic inline
649196c5ddc4Srjsbi_instr * bi_v2f32_to_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, enum bi_round round)
649296c5ddc4Srjs{
649396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
649496c5ddc4Srjs    I->op = BI_OPCODE_V2F32_TO_V2F16;
649596c5ddc4Srjs    I->dest[0] = dest0;
649696c5ddc4Srjs    I->src[0] = src0;
649796c5ddc4Srjs    I->src[1] = src1;
649896c5ddc4Srjs    I->round = round;
649996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
650096c5ddc4Srjs    return I;
650196c5ddc4Srjs}
650296c5ddc4Srjs
650396c5ddc4Srjsstatic inline
650496c5ddc4Srjsbi_index bi_v2f32_to_v2f16(bi_builder *b, bi_index src0, bi_index src1, enum bi_round round)
650596c5ddc4Srjs{
650696c5ddc4Srjs    return (bi_v2f32_to_v2f16_to(b, bi_temp(b->shader), src0, src1, round))->dest[0];
650796c5ddc4Srjs}
650896c5ddc4Srjs
650996c5ddc4Srjs
651096c5ddc4Srjsstatic inline
651196c5ddc4Srjsbi_instr * bi_v2s16_to_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round)
651296c5ddc4Srjs{
651396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
651496c5ddc4Srjs    I->op = BI_OPCODE_V2S16_TO_V2F16;
651596c5ddc4Srjs    I->dest[0] = dest0;
651696c5ddc4Srjs    I->src[0] = src0;
651796c5ddc4Srjs    I->round = round;
651896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
651996c5ddc4Srjs    return I;
652096c5ddc4Srjs}
652196c5ddc4Srjs
652296c5ddc4Srjsstatic inline
652396c5ddc4Srjsbi_index bi_v2s16_to_v2f16(bi_builder *b, bi_index src0, enum bi_round round)
652496c5ddc4Srjs{
652596c5ddc4Srjs    return (bi_v2s16_to_v2f16_to(b, bi_temp(b->shader), src0, round))->dest[0];
652696c5ddc4Srjs}
652796c5ddc4Srjs
652896c5ddc4Srjs
652996c5ddc4Srjsstatic inline
653096c5ddc4Srjsbi_instr * bi_v2s8_to_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0)
653196c5ddc4Srjs{
653296c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
653396c5ddc4Srjs    I->op = BI_OPCODE_V2S8_TO_V2F16;
653496c5ddc4Srjs    I->dest[0] = dest0;
653596c5ddc4Srjs    I->src[0] = src0;
653696c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
653796c5ddc4Srjs    return I;
653896c5ddc4Srjs}
653996c5ddc4Srjs
654096c5ddc4Srjsstatic inline
654196c5ddc4Srjsbi_index bi_v2s8_to_v2f16(bi_builder *b, bi_index src0)
654296c5ddc4Srjs{
654396c5ddc4Srjs    return (bi_v2s8_to_v2f16_to(b, bi_temp(b->shader), src0))->dest[0];
654496c5ddc4Srjs}
654596c5ddc4Srjs
654696c5ddc4Srjs
654796c5ddc4Srjsstatic inline
654896c5ddc4Srjsbi_instr * bi_v2s8_to_v2s16_to(bi_builder *b, bi_index dest0, bi_index src0)
654996c5ddc4Srjs{
655096c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
655196c5ddc4Srjs    I->op = BI_OPCODE_V2S8_TO_V2S16;
655296c5ddc4Srjs    I->dest[0] = dest0;
655396c5ddc4Srjs    I->src[0] = src0;
655496c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
655596c5ddc4Srjs    return I;
655696c5ddc4Srjs}
655796c5ddc4Srjs
655896c5ddc4Srjsstatic inline
655996c5ddc4Srjsbi_index bi_v2s8_to_v2s16(bi_builder *b, bi_index src0)
656096c5ddc4Srjs{
656196c5ddc4Srjs    return (bi_v2s8_to_v2s16_to(b, bi_temp(b->shader), src0))->dest[0];
656296c5ddc4Srjs}
656396c5ddc4Srjs
656496c5ddc4Srjs
656596c5ddc4Srjsstatic inline
656696c5ddc4Srjsbi_instr * bi_v2u16_to_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_round round)
656796c5ddc4Srjs{
656896c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
656996c5ddc4Srjs    I->op = BI_OPCODE_V2U16_TO_V2F16;
657096c5ddc4Srjs    I->dest[0] = dest0;
657196c5ddc4Srjs    I->src[0] = src0;
657296c5ddc4Srjs    I->round = round;
657396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
657496c5ddc4Srjs    return I;
657596c5ddc4Srjs}
657696c5ddc4Srjs
657796c5ddc4Srjsstatic inline
657896c5ddc4Srjsbi_index bi_v2u16_to_v2f16(bi_builder *b, bi_index src0, enum bi_round round)
657996c5ddc4Srjs{
658096c5ddc4Srjs    return (bi_v2u16_to_v2f16_to(b, bi_temp(b->shader), src0, round))->dest[0];
658196c5ddc4Srjs}
658296c5ddc4Srjs
658396c5ddc4Srjs
658496c5ddc4Srjsstatic inline
658596c5ddc4Srjsbi_instr * bi_v2u8_to_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0)
658696c5ddc4Srjs{
658796c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
658896c5ddc4Srjs    I->op = BI_OPCODE_V2U8_TO_V2F16;
658996c5ddc4Srjs    I->dest[0] = dest0;
659096c5ddc4Srjs    I->src[0] = src0;
659196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
659296c5ddc4Srjs    return I;
659396c5ddc4Srjs}
659496c5ddc4Srjs
659596c5ddc4Srjsstatic inline
659696c5ddc4Srjsbi_index bi_v2u8_to_v2f16(bi_builder *b, bi_index src0)
659796c5ddc4Srjs{
659896c5ddc4Srjs    return (bi_v2u8_to_v2f16_to(b, bi_temp(b->shader), src0))->dest[0];
659996c5ddc4Srjs}
660096c5ddc4Srjs
660196c5ddc4Srjs
660296c5ddc4Srjsstatic inline
660396c5ddc4Srjsbi_instr * bi_v2u8_to_v2u16_to(bi_builder *b, bi_index dest0, bi_index src0)
660496c5ddc4Srjs{
660596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
660696c5ddc4Srjs    I->op = BI_OPCODE_V2U8_TO_V2U16;
660796c5ddc4Srjs    I->dest[0] = dest0;
660896c5ddc4Srjs    I->src[0] = src0;
660996c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
661096c5ddc4Srjs    return I;
661196c5ddc4Srjs}
661296c5ddc4Srjs
661396c5ddc4Srjsstatic inline
661496c5ddc4Srjsbi_index bi_v2u8_to_v2u16(bi_builder *b, bi_index src0)
661596c5ddc4Srjs{
661696c5ddc4Srjs    return (bi_v2u8_to_v2u16_to(b, bi_temp(b->shader), src0))->dest[0];
661796c5ddc4Srjs}
661896c5ddc4Srjs
661996c5ddc4Srjs
662096c5ddc4Srjsstatic inline
662196c5ddc4Srjsbi_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)
662296c5ddc4Srjs{
662396c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
662496c5ddc4Srjs    I->op = BI_OPCODE_VAR_TEX_F16;
662596c5ddc4Srjs    I->dest[0] = dest0;
662696c5ddc4Srjs    I->update = update;
662796c5ddc4Srjs    I->lod_mode = lod_mode;
662896c5ddc4Srjs    I->sample = sample;
662996c5ddc4Srjs    I->texture_index = texture_index;
663096c5ddc4Srjs    I->varying_index = varying_index;
663196c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
663296c5ddc4Srjs    return I;
663396c5ddc4Srjs}
663496c5ddc4Srjs
663596c5ddc4Srjsstatic inline
663696c5ddc4Srjsbi_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)
663796c5ddc4Srjs{
663896c5ddc4Srjs    return (bi_var_tex_f16_to(b, bi_temp(b->shader), lod_mode, sample, update, texture_index, varying_index))->dest[0];
663996c5ddc4Srjs}
664096c5ddc4Srjs
664196c5ddc4Srjs
664296c5ddc4Srjsstatic inline
664396c5ddc4Srjsbi_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)
664496c5ddc4Srjs{
664596c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
664696c5ddc4Srjs    I->op = BI_OPCODE_VAR_TEX_F32;
664796c5ddc4Srjs    I->dest[0] = dest0;
664896c5ddc4Srjs    I->update = update;
664996c5ddc4Srjs    I->lod_mode = lod_mode;
665096c5ddc4Srjs    I->sample = sample;
665196c5ddc4Srjs    I->texture_index = texture_index;
665296c5ddc4Srjs    I->varying_index = varying_index;
665396c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
665496c5ddc4Srjs    return I;
665596c5ddc4Srjs}
665696c5ddc4Srjs
665796c5ddc4Srjsstatic inline
665896c5ddc4Srjsbi_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)
665996c5ddc4Srjs{
666096c5ddc4Srjs    return (bi_var_tex_f32_to(b, bi_temp(b->shader), lod_mode, sample, update, texture_index, varying_index))->dest[0];
666196c5ddc4Srjs}
666296c5ddc4Srjs
666396c5ddc4Srjs
666496c5ddc4Srjsstatic inline
666596c5ddc4Srjsbi_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)
666696c5ddc4Srjs{
666796c5ddc4Srjs    if (bitsize == 16)
666896c5ddc4Srjs        return (bi_var_tex_f16_to(b, dest0, lod_mode, sample, update, texture_index, varying_index));
666996c5ddc4Srjs    else if (bitsize == 32)
667096c5ddc4Srjs        return (bi_var_tex_f32_to(b, dest0, lod_mode, sample, update, texture_index, varying_index));
667196c5ddc4Srjs    else
667296c5ddc4Srjs        unreachable("Invalid parameters for VAR_TEX");
667396c5ddc4Srjs}
667496c5ddc4Srjs
667596c5ddc4Srjsstatic inline
667696c5ddc4Srjsbi_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)
667796c5ddc4Srjs{
667896c5ddc4Srjs    if (bitsize == 16)
667996c5ddc4Srjs        return (bi_var_tex_f16_to(b, bi_temp(b->shader), lod_mode, sample, update, texture_index, varying_index))->dest[0];
668096c5ddc4Srjs    else if (bitsize == 32)
668196c5ddc4Srjs        return (bi_var_tex_f32_to(b, bi_temp(b->shader), lod_mode, sample, update, texture_index, varying_index))->dest[0];
668296c5ddc4Srjs    else
668396c5ddc4Srjs        unreachable("Invalid parameters for VAR_TEX");
668496c5ddc4Srjs}
668596c5ddc4Srjs
668696c5ddc4Srjsstatic inline
668796c5ddc4Srjsbi_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)
668896c5ddc4Srjs{
668996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
669096c5ddc4Srjs    I->op = BI_OPCODE_VN_ASST1_F16;
669196c5ddc4Srjs    I->dest[0] = dest0;
669296c5ddc4Srjs    I->src[0] = src0;
669396c5ddc4Srjs    I->src[1] = src1;
669496c5ddc4Srjs    I->src[2] = src2;
669596c5ddc4Srjs    I->h = h;
669696c5ddc4Srjs    I->l = l;
669796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
669896c5ddc4Srjs    return I;
669996c5ddc4Srjs}
670096c5ddc4Srjs
670196c5ddc4Srjsstatic inline
670296c5ddc4Srjsbi_index bi_vn_asst1_f16(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bool h, bool l)
670396c5ddc4Srjs{
670496c5ddc4Srjs    return (bi_vn_asst1_f16_to(b, bi_temp(b->shader), src0, src1, src2, h, l))->dest[0];
670596c5ddc4Srjs}
670696c5ddc4Srjs
670796c5ddc4Srjs
670896c5ddc4Srjsstatic inline
670996c5ddc4Srjsbi_instr * bi_vn_asst1_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bi_index src3)
671096c5ddc4Srjs{
671196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
671296c5ddc4Srjs    I->op = BI_OPCODE_VN_ASST1_F32;
671396c5ddc4Srjs    I->dest[0] = dest0;
671496c5ddc4Srjs    I->src[0] = src0;
671596c5ddc4Srjs    I->src[1] = src1;
671696c5ddc4Srjs    I->src[2] = src2;
671796c5ddc4Srjs    I->src[3] = src3;
671896c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
671996c5ddc4Srjs    return I;
672096c5ddc4Srjs}
672196c5ddc4Srjs
672296c5ddc4Srjsstatic inline
672396c5ddc4Srjsbi_index bi_vn_asst1_f32(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bi_index src3)
672496c5ddc4Srjs{
672596c5ddc4Srjs    return (bi_vn_asst1_f32_to(b, bi_temp(b->shader), src0, src1, src2, src3))->dest[0];
672696c5ddc4Srjs}
672796c5ddc4Srjs
672896c5ddc4Srjs
672996c5ddc4Srjsstatic inline
673096c5ddc4Srjsbi_instr * bi_vn_asst2_f32_to(bi_builder *b, bi_index dest0, bi_index src0, bool scale)
673196c5ddc4Srjs{
673296c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
673396c5ddc4Srjs    I->op = BI_OPCODE_VN_ASST2_F32;
673496c5ddc4Srjs    I->dest[0] = dest0;
673596c5ddc4Srjs    I->src[0] = src0;
673696c5ddc4Srjs    I->scale = scale;
673796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
673896c5ddc4Srjs    return I;
673996c5ddc4Srjs}
674096c5ddc4Srjs
674196c5ddc4Srjsstatic inline
674296c5ddc4Srjsbi_index bi_vn_asst2_f32(bi_builder *b, bi_index src0, bool scale)
674396c5ddc4Srjs{
674496c5ddc4Srjs    return (bi_vn_asst2_f32_to(b, bi_temp(b->shader), src0, scale))->dest[0];
674596c5ddc4Srjs}
674696c5ddc4Srjs
674796c5ddc4Srjs
674896c5ddc4Srjsstatic inline
674996c5ddc4Srjsbi_instr * bi_vn_asst2_v2f16_to(bi_builder *b, bi_index dest0, bi_index src0)
675096c5ddc4Srjs{
675196c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
675296c5ddc4Srjs    I->op = BI_OPCODE_VN_ASST2_V2F16;
675396c5ddc4Srjs    I->dest[0] = dest0;
675496c5ddc4Srjs    I->src[0] = src0;
675596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
675696c5ddc4Srjs    return I;
675796c5ddc4Srjs}
675896c5ddc4Srjs
675996c5ddc4Srjsstatic inline
676096c5ddc4Srjsbi_index bi_vn_asst2_v2f16(bi_builder *b, bi_index src0)
676196c5ddc4Srjs{
676296c5ddc4Srjs    return (bi_vn_asst2_v2f16_to(b, bi_temp(b->shader), src0))->dest[0];
676396c5ddc4Srjs}
676496c5ddc4Srjs
676596c5ddc4Srjs
676696c5ddc4Srjsstatic inline
676796c5ddc4Srjsbi_instr * bi_wmask_to(bi_builder *b, bi_index dest0, bi_index src0, enum bi_subgroup subgroup, uint32_t fill)
676896c5ddc4Srjs{
676996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
677096c5ddc4Srjs    I->op = BI_OPCODE_WMASK;
677196c5ddc4Srjs    I->dest[0] = dest0;
677296c5ddc4Srjs    I->src[0] = src0;
677396c5ddc4Srjs    I->subgroup = subgroup;
677496c5ddc4Srjs    I->fill = fill;
677596c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
677696c5ddc4Srjs    return I;
677796c5ddc4Srjs}
677896c5ddc4Srjs
677996c5ddc4Srjsstatic inline
678096c5ddc4Srjsbi_index bi_wmask(bi_builder *b, bi_index src0, enum bi_subgroup subgroup, uint32_t fill)
678196c5ddc4Srjs{
678296c5ddc4Srjs    return (bi_wmask_to(b, bi_temp(b->shader), src0, subgroup, fill))->dest[0];
678396c5ddc4Srjs}
678496c5ddc4Srjs
678596c5ddc4Srjs
678696c5ddc4Srjsstatic inline
678796c5ddc4Srjsbi_instr * bi_zs_emit_to(bi_builder *b, bi_index dest0, bi_index src0, bi_index src1, bi_index src2, bool stencil, bool z)
678896c5ddc4Srjs{
678996c5ddc4Srjs    bi_instr *I = rzalloc(b->shader, bi_instr);
679096c5ddc4Srjs    I->op = BI_OPCODE_ZS_EMIT;
679196c5ddc4Srjs    I->dest[0] = dest0;
679296c5ddc4Srjs    I->src[0] = src0;
679396c5ddc4Srjs    I->src[1] = src1;
679496c5ddc4Srjs    I->src[2] = src2;
679596c5ddc4Srjs    I->stencil = stencil;
679696c5ddc4Srjs    I->z = z;
679796c5ddc4Srjs    bi_builder_insert(&b->cursor, I);
679896c5ddc4Srjs    return I;
679996c5ddc4Srjs}
680096c5ddc4Srjs
680196c5ddc4Srjsstatic inline
680296c5ddc4Srjsbi_index bi_zs_emit(bi_builder *b, bi_index src0, bi_index src1, bi_index src2, bool stencil, bool z)
680396c5ddc4Srjs{
680496c5ddc4Srjs    return (bi_zs_emit_to(b, bi_temp(b->shader), src0, src1, src2, stencil, z))->dest[0];
680596c5ddc4Srjs}
680696c5ddc4Srjs
680796c5ddc4Srjs
680896c5ddc4Srjs#endif
6809