2 * Copyright 2012 Christoph Bumiller
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
23 #include "codegen/nv50_ir_target_nvc0.h"
25 // CodeEmitter for GK110 encoding of the Fermi/Kepler ISA.
29 class CodeEmitterGK110
: public CodeEmitter
32 CodeEmitterGK110(const TargetNVC0
*);
34 virtual bool emitInstruction(Instruction
*);
35 virtual uint32_t getMinEncodingSize(const Instruction
*) const;
36 virtual void prepareEmission(Function
*);
38 inline void setProgramType(Program::Type pType
) { progType
= pType
; }
41 const TargetNVC0
*targNVC0
;
43 Program::Type progType
;
45 const bool writeIssueDelays
;
48 void emitForm_21(const Instruction
*, uint32_t opc2
, uint32_t opc1
);
49 void emitForm_C(const Instruction
*, uint32_t opc
, uint8_t ctg
);
50 void emitForm_L(const Instruction
*, uint32_t opc
, uint8_t ctg
, Modifier
, int sCount
= 3);
52 void emitPredicate(const Instruction
*);
54 void setCAddress14(const ValueRef
&);
55 void setShortImmediate(const Instruction
*, const int s
);
56 void setImmediate32(const Instruction
*, const int s
, Modifier
);
57 void setSUConst16(const Instruction
*, const int s
);
59 void modNegAbsF32_3b(const Instruction
*, const int s
);
61 void emitCondCode(CondCode cc
, int pos
, uint8_t mask
);
62 void emitInterpMode(const Instruction
*);
63 void emitLoadStoreType(DataType ty
, const int pos
);
64 void emitCachingMode(CacheMode c
, const int pos
);
65 void emitSUGType(DataType
, const int pos
);
66 void emitSUCachingMode(CacheMode c
);
68 inline uint8_t getSRegEncoding(const ValueRef
&);
70 void emitRoundMode(RoundMode
, const int pos
, const int rintPos
);
71 void emitRoundModeF(RoundMode
, const int pos
);
72 void emitRoundModeI(RoundMode
, const int pos
);
74 void emitNegAbs12(const Instruction
*);
76 void emitNOP(const Instruction
*);
78 void emitLOAD(const Instruction
*);
79 void emitSTORE(const Instruction
*);
80 void emitMOV(const Instruction
*);
81 void emitATOM(const Instruction
*);
82 void emitCCTL(const Instruction
*);
84 void emitINTERP(const Instruction
*);
85 void emitAFETCH(const Instruction
*);
86 void emitPFETCH(const Instruction
*);
87 void emitVFETCH(const Instruction
*);
88 void emitEXPORT(const Instruction
*);
89 void emitOUT(const Instruction
*);
91 void emitUADD(const Instruction
*);
92 void emitFADD(const Instruction
*);
93 void emitDADD(const Instruction
*);
94 void emitIMUL(const Instruction
*);
95 void emitFMUL(const Instruction
*);
96 void emitDMUL(const Instruction
*);
97 void emitIMAD(const Instruction
*);
98 void emitISAD(const Instruction
*);
99 void emitSHLADD(const Instruction
*);
100 void emitFMAD(const Instruction
*);
101 void emitDMAD(const Instruction
*);
102 void emitMADSP(const Instruction
*i
);
104 void emitNOT(const Instruction
*);
105 void emitLogicOp(const Instruction
*, uint8_t subOp
);
106 void emitPOPC(const Instruction
*);
107 void emitINSBF(const Instruction
*);
108 void emitEXTBF(const Instruction
*);
109 void emitBFIND(const Instruction
*);
110 void emitPERMT(const Instruction
*);
111 void emitShift(const Instruction
*);
112 void emitShift64(const Instruction
*);
114 void emitSFnOp(const Instruction
*, uint8_t subOp
);
116 void emitCVT(const Instruction
*);
117 void emitMINMAX(const Instruction
*);
118 void emitPreOp(const Instruction
*);
120 void emitSET(const CmpInstruction
*);
121 void emitSLCT(const CmpInstruction
*);
122 void emitSELP(const Instruction
*);
124 void emitTEXBAR(const Instruction
*);
125 void emitTEX(const TexInstruction
*);
126 void emitTEXCSAA(const TexInstruction
*);
127 void emitTXQ(const TexInstruction
*);
129 void emitQUADOP(const Instruction
*, uint8_t qOp
, uint8_t laneMask
);
131 void emitPIXLD(const Instruction
*);
133 void emitBAR(const Instruction
*);
134 void emitMEMBAR(const Instruction
*);
136 void emitFlow(const Instruction
*);
138 void emitSHFL(const Instruction
*);
140 void emitVOTE(const Instruction
*);
142 void emitSULDGB(const TexInstruction
*);
143 void emitSUSTGx(const TexInstruction
*);
144 void emitSUCLAMPMode(uint16_t);
145 void emitSUCalc(Instruction
*);
147 void emitVSHL(const Instruction
*);
148 void emitVectorSubOp(const Instruction
*);
150 inline void defId(const ValueDef
&, const int pos
);
151 inline void srcId(const ValueRef
&, const int pos
);
152 inline void srcId(const ValueRef
*, const int pos
);
153 inline void srcId(const Instruction
*, int s
, const int pos
);
155 inline void srcAddr32(const ValueRef
&, const int pos
); // address / 4
157 inline bool isLIMM(const ValueRef
&, DataType ty
, bool mod
= false);
160 #define GK110_GPR_ZERO 255
163 if (i->src(s).mod.neg()) code[(0x##b) / 32] |= 1 << ((0x##b) % 32)
165 if (i->src(s).mod.abs()) code[(0x##b) / 32] |= 1 << ((0x##b) % 32)
167 #define NOT_(b, s) if (i->src(s).mod & Modifier(NV50_IR_MOD_NOT)) \
168 code[(0x##b) / 32] |= 1 << ((0x##b) % 32)
170 #define FTZ_(b) if (i->ftz) code[(0x##b) / 32] |= 1 << ((0x##b) % 32)
171 #define DNZ_(b) if (i->dnz) code[(0x##b) / 32] |= 1 << ((0x##b) % 32)
173 #define SAT_(b) if (i->saturate) code[(0x##b) / 32] |= 1 << ((0x##b) % 32)
175 #define RND_(b, t) emitRoundMode##t(i->rnd, 0x##b)
177 #define SDATA(a) ((a).rep()->reg.data)
178 #define DDATA(a) ((a).rep()->reg.data)
180 void CodeEmitterGK110::srcId(const ValueRef
& src
, const int pos
)
182 code
[pos
/ 32] |= (src
.get() ? SDATA(src
).id
: GK110_GPR_ZERO
) << (pos
% 32);
185 void CodeEmitterGK110::srcId(const ValueRef
*src
, const int pos
)
187 code
[pos
/ 32] |= (src
? SDATA(*src
).id
: GK110_GPR_ZERO
) << (pos
% 32);
190 void CodeEmitterGK110::srcId(const Instruction
*insn
, int s
, int pos
)
192 int r
= insn
->srcExists(s
) ? SDATA(insn
->src(s
)).id
: GK110_GPR_ZERO
;
193 code
[pos
/ 32] |= r
<< (pos
% 32);
196 void CodeEmitterGK110::srcAddr32(const ValueRef
& src
, const int pos
)
198 code
[pos
/ 32] |= (SDATA(src
).offset
>> 2) << (pos
% 32);
201 void CodeEmitterGK110::defId(const ValueDef
& def
, const int pos
)
203 code
[pos
/ 32] |= (def
.get() && def
.getFile() != FILE_FLAGS
? DDATA(def
).id
: GK110_GPR_ZERO
) << (pos
% 32);
206 bool CodeEmitterGK110::isLIMM(const ValueRef
& ref
, DataType ty
, bool mod
)
208 const ImmediateValue
*imm
= ref
.get()->asImm();
210 return imm
&& (imm
->reg
.data
.u32
& ((ty
== TYPE_F32
) ? 0xfff : 0xfff00000));
214 CodeEmitterGK110::emitRoundMode(RoundMode rnd
, const int pos
, const int rintPos
)
220 case ROUND_MI
: rint
= true; /* fall through */ case ROUND_M
: n
= 1; break;
221 case ROUND_PI
: rint
= true; /* fall through */ case ROUND_P
: n
= 2; break;
222 case ROUND_ZI
: rint
= true; /* fall through */ case ROUND_Z
: n
= 3; break;
224 rint
= rnd
== ROUND_NI
;
226 assert(rnd
== ROUND_N
|| rnd
== ROUND_NI
);
229 code
[pos
/ 32] |= n
<< (pos
% 32);
230 if (rint
&& rintPos
>= 0)
231 code
[rintPos
/ 32] |= 1 << (rintPos
% 32);
235 CodeEmitterGK110::emitRoundModeF(RoundMode rnd
, const int pos
)
240 case ROUND_M
: n
= 1; break;
241 case ROUND_P
: n
= 2; break;
242 case ROUND_Z
: n
= 3; break;
245 assert(rnd
== ROUND_N
);
248 code
[pos
/ 32] |= n
<< (pos
% 32);
252 CodeEmitterGK110::emitRoundModeI(RoundMode rnd
, const int pos
)
257 case ROUND_MI
: n
= 1; break;
258 case ROUND_PI
: n
= 2; break;
259 case ROUND_ZI
: n
= 3; break;
262 assert(rnd
== ROUND_NI
);
265 code
[pos
/ 32] |= n
<< (pos
% 32);
268 void CodeEmitterGK110::emitCondCode(CondCode cc
, int pos
, uint8_t mask
)
273 case CC_FL
: n
= 0x00; break;
274 case CC_LT
: n
= 0x01; break;
275 case CC_EQ
: n
= 0x02; break;
276 case CC_LE
: n
= 0x03; break;
277 case CC_GT
: n
= 0x04; break;
278 case CC_NE
: n
= 0x05; break;
279 case CC_GE
: n
= 0x06; break;
280 case CC_LTU
: n
= 0x09; break;
281 case CC_EQU
: n
= 0x0a; break;
282 case CC_LEU
: n
= 0x0b; break;
283 case CC_GTU
: n
= 0x0c; break;
284 case CC_NEU
: n
= 0x0d; break;
285 case CC_GEU
: n
= 0x0e; break;
286 case CC_TR
: n
= 0x0f; break;
287 case CC_NO
: n
= 0x10; break;
288 case CC_NC
: n
= 0x11; break;
289 case CC_NS
: n
= 0x12; break;
290 case CC_NA
: n
= 0x13; break;
291 case CC_A
: n
= 0x14; break;
292 case CC_S
: n
= 0x15; break;
293 case CC_C
: n
= 0x16; break;
294 case CC_O
: n
= 0x17; break;
297 assert(!"invalid condition code");
300 code
[pos
/ 32] |= (n
& mask
) << (pos
% 32);
304 CodeEmitterGK110::emitPredicate(const Instruction
*i
)
306 if (i
->predSrc
>= 0) {
307 srcId(i
->src(i
->predSrc
), 18);
308 if (i
->cc
== CC_NOT_P
)
309 code
[0] |= 8 << 18; // negate
310 assert(i
->getPredicate()->reg
.file
== FILE_PREDICATE
);
317 CodeEmitterGK110::setCAddress14(const ValueRef
& src
)
319 const Storage
& res
= src
.get()->asSym()->reg
;
320 const int32_t addr
= res
.data
.offset
/ 4;
322 code
[0] |= (addr
& 0x01ff) << 23;
323 code
[1] |= (addr
& 0x3e00) >> 9;
324 code
[1] |= res
.fileIndex
<< 5;
328 CodeEmitterGK110::setShortImmediate(const Instruction
*i
, const int s
)
330 const uint32_t u32
= i
->getSrc(s
)->asImm()->reg
.data
.u32
;
331 const uint64_t u64
= i
->getSrc(s
)->asImm()->reg
.data
.u64
;
333 if (i
->sType
== TYPE_F32
) {
334 assert(!(u32
& 0x00000fff));
335 code
[0] |= ((u32
& 0x001ff000) >> 12) << 23;
336 code
[1] |= ((u32
& 0x7fe00000) >> 21);
337 code
[1] |= ((u32
& 0x80000000) >> 4);
339 if (i
->sType
== TYPE_F64
) {
340 assert(!(u64
& 0x00000fffffffffffULL
));
341 code
[0] |= ((u64
& 0x001ff00000000000ULL
) >> 44) << 23;
342 code
[1] |= ((u64
& 0x7fe0000000000000ULL
) >> 53);
343 code
[1] |= ((u64
& 0x8000000000000000ULL
) >> 36);
345 assert((u32
& 0xfff00000) == 0 || (u32
& 0xfff00000) == 0xfff00000);
346 code
[0] |= (u32
& 0x001ff) << 23;
347 code
[1] |= (u32
& 0x7fe00) >> 9;
348 code
[1] |= (u32
& 0x80000) << 8;
353 CodeEmitterGK110::setImmediate32(const Instruction
*i
, const int s
,
356 uint32_t u32
= i
->getSrc(s
)->asImm()->reg
.data
.u32
;
359 ImmediateValue
imm(i
->getSrc(s
)->asImm(), i
->sType
);
361 u32
= imm
.reg
.data
.u32
;
364 code
[0] |= u32
<< 23;
369 CodeEmitterGK110::emitForm_L(const Instruction
*i
, uint32_t opc
, uint8_t ctg
,
370 Modifier mod
, int sCount
)
379 for (int s
= 0; s
< sCount
&& i
->srcExists(s
); ++s
) {
380 switch (i
->src(s
).getFile()) {
382 srcId(i
->src(s
), s
? 42 : 10);
385 setImmediate32(i
, s
, mod
);
395 CodeEmitterGK110::emitForm_C(const Instruction
*i
, uint32_t opc
, uint8_t ctg
)
404 switch (i
->src(0).getFile()) {
405 case FILE_MEMORY_CONST
:
406 code
[1] |= 0x4 << 28;
407 setCAddress14(i
->src(0));
410 code
[1] |= 0xc << 28;
411 srcId(i
->src(0), 23);
419 // 0x2 for GPR, c[] and 0x1 for short immediate
421 CodeEmitterGK110::emitForm_21(const Instruction
*i
, uint32_t opc2
,
424 const bool imm
= i
->srcExists(1) && i
->src(1).getFile() == FILE_IMMEDIATE
;
427 if (i
->srcExists(2) && i
->src(2).getFile() == FILE_MEMORY_CONST
)
432 code
[1] = opc1
<< 20;
435 code
[1] = (0xc << 28) | (opc2
<< 20);
442 for (int s
= 0; s
< 3 && i
->srcExists(s
); ++s
) {
443 switch (i
->src(s
).getFile()) {
444 case FILE_MEMORY_CONST
:
445 code
[1] &= (s
== 2) ? ~(0x4 << 28) : ~(0x8 << 28);
446 setCAddress14(i
->src(s
));
449 setShortImmediate(i
, s
);
452 srcId(i
->src(s
), s
? ((s
== 2) ? 42 : s1
) : 10);
455 if (i
->op
== OP_SELP
) {
456 assert(s
== 2 && i
->src(s
).getFile() == FILE_PREDICATE
);
457 srcId(i
->src(s
), 42);
459 // ignore here, can be predicate or flags, but must not be address
467 assert(imm
|| (code
[1] & (0xc << 28)));
471 CodeEmitterGK110::modNegAbsF32_3b(const Instruction
*i
, const int s
)
473 if (i
->src(s
).mod
.abs()) code
[1] &= ~(1 << 27);
474 if (i
->src(s
).mod
.neg()) code
[1] ^= (1 << 27);
478 CodeEmitterGK110::emitNOP(const Instruction
*i
)
480 code
[0] = 0x00003c02;
481 code
[1] = 0x85800000;
486 code
[0] = 0x001c3c02;
490 CodeEmitterGK110::emitFMAD(const Instruction
*i
)
492 bool neg1
= (i
->src(0).mod
^ i
->src(1).mod
).neg();
494 if (isLIMM(i
->src(1), TYPE_F32
)) {
495 assert(i
->getDef(0)->reg
.data
.id
== i
->getSrc(2)->reg
.data
.id
);
497 // last source is dst, so force 2 sources
498 emitForm_L(i
, 0x600, 0x0, 0, 2);
500 if (i
->flagsDef
>= 0)
510 emitForm_21(i
, 0x0c0, 0x940);
530 CodeEmitterGK110::emitDMAD(const Instruction
*i
)
532 assert(!i
->saturate
);
535 emitForm_21(i
, 0x1b8, 0xb38);
540 bool neg1
= (i
->src(0).mod
^ i
->src(1).mod
).neg();
552 CodeEmitterGK110::emitMADSP(const Instruction
*i
)
554 emitForm_21(i
, 0x140, 0xa40);
556 if (i
->subOp
== NV50_IR_SUBOP_MADSP_SD
) {
557 code
[1] |= 0x00c00000;
559 code
[1] |= (i
->subOp
& 0x00f) << 19; // imadp1
560 code
[1] |= (i
->subOp
& 0x0f0) << 20; // imadp2
561 code
[1] |= (i
->subOp
& 0x100) << 11; // imadp3
562 code
[1] |= (i
->subOp
& 0x200) << 15; // imadp3
563 code
[1] |= (i
->subOp
& 0xc00) << 12; // imadp3
566 if (i
->flagsDef
>= 0)
571 CodeEmitterGK110::emitFMUL(const Instruction
*i
)
573 bool neg
= (i
->src(0).mod
^ i
->src(1).mod
).neg();
575 assert(i
->postFactor
>= -3 && i
->postFactor
<= 3);
577 if (isLIMM(i
->src(1), TYPE_F32
)) {
578 emitForm_L(i
, 0x200, 0x2, Modifier(0));
586 assert(i
->postFactor
== 0);
588 emitForm_21(i
, 0x234, 0xc34);
589 code
[1] |= ((i
->postFactor
> 0) ?
590 (7 - i
->postFactor
) : (0 - i
->postFactor
)) << 12;
608 CodeEmitterGK110::emitDMUL(const Instruction
*i
)
610 bool neg
= (i
->src(0).mod
^ i
->src(1).mod
).neg();
612 assert(!i
->postFactor
);
613 assert(!i
->saturate
);
617 emitForm_21(i
, 0x240, 0xc40);
631 CodeEmitterGK110::emitIMUL(const Instruction
*i
)
633 assert(!i
->src(0).mod
.neg() && !i
->src(1).mod
.neg());
634 assert(!i
->src(0).mod
.abs() && !i
->src(1).mod
.abs());
636 if (i
->src(1).getFile() == FILE_IMMEDIATE
) {
637 emitForm_L(i
, 0x280, 2, Modifier(0));
639 if (i
->subOp
== NV50_IR_SUBOP_MUL_HIGH
)
641 if (i
->sType
== TYPE_S32
)
644 emitForm_21(i
, 0x21c, 0xc1c);
646 if (i
->subOp
== NV50_IR_SUBOP_MUL_HIGH
)
648 if (i
->sType
== TYPE_S32
)
654 CodeEmitterGK110::emitFADD(const Instruction
*i
)
656 if (isLIMM(i
->src(1), TYPE_F32
)) {
657 assert(i
->rnd
== ROUND_N
);
658 assert(!i
->saturate
);
660 Modifier mod
= i
->src(1).mod
^
661 Modifier(i
->op
== OP_SUB
? NV50_IR_MOD_NEG
: 0);
663 emitForm_L(i
, 0x400, 0, mod
);
669 emitForm_21(i
, 0x22c, 0xc2c);
678 modNegAbsF32_3b(i
, 1);
679 if (i
->op
== OP_SUB
) code
[1] ^= 1 << 27;
683 if (i
->op
== OP_SUB
) code
[1] ^= 1 << 16;
689 CodeEmitterGK110::emitDADD(const Instruction
*i
)
691 assert(!i
->saturate
);
694 emitForm_21(i
, 0x238, 0xc38);
699 modNegAbsF32_3b(i
, 1);
700 if (i
->op
== OP_SUB
) code
[1] ^= 1 << 27;
704 if (i
->op
== OP_SUB
) code
[1] ^= 1 << 16;
709 CodeEmitterGK110::emitUADD(const Instruction
*i
)
711 uint8_t addOp
= (i
->src(0).mod
.neg() << 1) | i
->src(1).mod
.neg();
716 assert(!i
->src(0).mod
.abs() && !i
->src(1).mod
.abs());
718 if (isLIMM(i
->src(1), TYPE_S32
)) {
719 emitForm_L(i
, 0x400, 1, Modifier((addOp
& 1) ? NV50_IR_MOD_NEG
: 0));
724 assert(i
->flagsDef
< 0);
725 assert(i
->flagsSrc
< 0);
729 emitForm_21(i
, 0x208, 0xc08);
731 assert(addOp
!= 3); // would be add-plus-one
733 code
[1] |= addOp
<< 19;
735 if (i
->flagsDef
>= 0)
736 code
[1] |= 1 << 18; // write carry
737 if (i
->flagsSrc
>= 0)
738 code
[1] |= 1 << 14; // add carry
745 CodeEmitterGK110::emitIMAD(const Instruction
*i
)
748 i
->src(2).mod
.neg() | ((i
->src(0).mod
.neg() ^ i
->src(1).mod
.neg()) << 1);
750 emitForm_21(i
, 0x100, 0xa00);
753 code
[1] |= addOp
<< 26;
755 if (i
->sType
== TYPE_S32
)
756 code
[1] |= (1 << 19) | (1 << 24);
758 if (i
->subOp
== NV50_IR_SUBOP_MUL_HIGH
)
761 if (i
->flagsDef
>= 0) code
[1] |= 1 << 18;
762 if (i
->flagsSrc
>= 0) code
[1] |= 1 << 20;
768 CodeEmitterGK110::emitISAD(const Instruction
*i
)
770 assert(i
->dType
== TYPE_S32
|| i
->dType
== TYPE_U32
);
772 emitForm_21(i
, 0x1f4, 0xb74);
774 if (i
->dType
== TYPE_S32
)
779 CodeEmitterGK110::emitSHLADD(const Instruction
*i
)
781 uint8_t addOp
= (i
->src(0).mod
.neg() << 1) | i
->src(2).mod
.neg();
782 const ImmediateValue
*imm
= i
->src(1).get()->asImm();
785 if (i
->src(2).getFile() == FILE_IMMEDIATE
) {
787 code
[1] = 0xc0c << 20;
790 code
[1] = 0x20c << 20;
792 code
[1] |= addOp
<< 19;
797 srcId(i
->src(0), 10);
799 if (i
->flagsDef
>= 0)
802 assert(!(imm
->reg
.data
.u32
& 0xffffffe0));
803 code
[1] |= imm
->reg
.data
.u32
<< 10;
805 switch (i
->src(2).getFile()) {
807 assert(code
[0] & 0x2);
808 code
[1] |= 0xc << 28;
809 srcId(i
->src(2), 23);
811 case FILE_MEMORY_CONST
:
812 assert(code
[0] & 0x2);
813 code
[1] |= 0x4 << 28;
814 setCAddress14(i
->src(2));
817 assert(code
[0] & 0x1);
818 setShortImmediate(i
, 2);
821 assert(!"bad src2 file");
827 CodeEmitterGK110::emitNOT(const Instruction
*i
)
829 code
[0] = 0x0003fc02; // logop(mov2) dst, 0, not src
830 code
[1] = 0x22003800;
836 switch (i
->src(0).getFile()) {
838 code
[1] |= 0xc << 28;
839 srcId(i
->src(0), 23);
841 case FILE_MEMORY_CONST
:
842 code
[1] |= 0x4 << 28;
843 setCAddress14(i
->src(0));
852 CodeEmitterGK110::emitLogicOp(const Instruction
*i
, uint8_t subOp
)
854 if (i
->def(0).getFile() == FILE_PREDICATE
) {
855 code
[0] = 0x00000002 | (subOp
<< 27);
856 code
[1] = 0x84800000;
861 srcId(i
->src(0), 14);
862 if (i
->src(0).mod
== Modifier(NV50_IR_MOD_NOT
)) code
[0] |= 1 << 17;
863 srcId(i
->src(1), 32);
864 if (i
->src(1).mod
== Modifier(NV50_IR_MOD_NOT
)) code
[1] |= 1 << 3;
866 if (i
->defExists(1)) {
872 if (i
->predSrc
!= 2 && i
->srcExists(2)) {
873 code
[1] |= subOp
<< 16;
874 srcId(i
->src(2), 42);
875 if (i
->src(2).mod
== Modifier(NV50_IR_MOD_NOT
)) code
[1] |= 1 << 13;
880 if (isLIMM(i
->src(1), TYPE_S32
)) {
881 emitForm_L(i
, 0x200, 0, i
->src(1).mod
);
882 code
[1] |= subOp
<< 24;
885 emitForm_21(i
, 0x220, 0xc20);
886 code
[1] |= subOp
<< 12;
893 CodeEmitterGK110::emitPOPC(const Instruction
*i
)
895 assert(!isLIMM(i
->src(1), TYPE_S32
, true));
897 emitForm_21(i
, 0x204, 0xc04);
900 if (!(code
[0] & 0x1))
905 CodeEmitterGK110::emitINSBF(const Instruction
*i
)
907 emitForm_21(i
, 0x1f8, 0xb78);
911 CodeEmitterGK110::emitEXTBF(const Instruction
*i
)
913 emitForm_21(i
, 0x600, 0xc00);
915 if (i
->dType
== TYPE_S32
)
917 if (i
->subOp
== NV50_IR_SUBOP_EXTBF_REV
)
922 CodeEmitterGK110::emitBFIND(const Instruction
*i
)
924 emitForm_C(i
, 0x218, 0x2);
926 if (i
->dType
== TYPE_S32
)
928 if (i
->src(0).mod
== Modifier(NV50_IR_MOD_NOT
))
930 if (i
->subOp
== NV50_IR_SUBOP_BFIND_SAMT
)
935 CodeEmitterGK110::emitPERMT(const Instruction
*i
)
937 emitForm_21(i
, 0x1e0, 0xb60);
939 code
[1] |= i
->subOp
<< 19;
943 CodeEmitterGK110::emitShift(const Instruction
*i
)
945 if (i
->op
== OP_SHR
) {
946 emitForm_21(i
, 0x214, 0xc14);
947 if (isSignedType(i
->dType
))
950 emitForm_21(i
, 0x224, 0xc24);
953 if (i
->subOp
== NV50_IR_SUBOP_SHIFT_WRAP
)
958 CodeEmitterGK110::emitShift64(const Instruction
*i
)
960 if (i
->op
== OP_SHR
) {
961 emitForm_21(i
, 0x27c, 0xc7c);
962 if (isSignedType(i
->sType
))
964 if (i
->subOp
& NV50_IR_SUBOP_SHIFT_HIGH
)
967 emitForm_21(i
, 0xdfc, 0xf7c);
971 if (i
->subOp
& NV50_IR_SUBOP_SHIFT_WRAP
)
976 CodeEmitterGK110::emitPreOp(const Instruction
*i
)
978 emitForm_C(i
, 0x248, 0x2);
980 if (i
->op
== OP_PREEX2
)
988 CodeEmitterGK110::emitSFnOp(const Instruction
*i
, uint8_t subOp
)
990 code
[0] = 0x00000002 | (subOp
<< 23);
991 code
[1] = 0x84000000;
996 srcId(i
->src(0), 10);
1004 CodeEmitterGK110::emitMINMAX(const Instruction
*i
)
1028 emitForm_21(i
, op2
, op1
);
1030 if (i
->dType
== TYPE_S32
)
1032 code
[1] |= (i
->op
== OP_MIN
) ? 0x1c00 : 0x3c00; // [!]pt
1033 code
[1] |= i
->subOp
<< 14;
1034 if (i
->flagsDef
>= 0)
1035 code
[1] |= i
->subOp
<< 18;
1040 if (code
[0] & 0x1) {
1041 modNegAbsF32_3b(i
, 1);
1049 CodeEmitterGK110::emitCVT(const Instruction
*i
)
1051 const bool f2f
= isFloatType(i
->dType
) && isFloatType(i
->sType
);
1052 const bool f2i
= !isFloatType(i
->dType
) && isFloatType(i
->sType
);
1053 const bool i2f
= isFloatType(i
->dType
) && !isFloatType(i
->sType
);
1055 bool sat
= i
->saturate
;
1056 bool abs
= i
->src(0).mod
.abs();
1057 bool neg
= i
->src(0).mod
.neg();
1059 RoundMode rnd
= i
->rnd
;
1062 case OP_CEIL
: rnd
= f2f
? ROUND_PI
: ROUND_P
; break;
1063 case OP_FLOOR
: rnd
= f2f
? ROUND_MI
: ROUND_M
; break;
1064 case OP_TRUNC
: rnd
= f2f
? ROUND_ZI
: ROUND_Z
; break;
1065 case OP_SAT
: sat
= true; break;
1066 case OP_NEG
: neg
= !neg
; break;
1067 case OP_ABS
: abs
= true; neg
= false; break;
1074 if (i
->op
== OP_NEG
&& i
->dType
== TYPE_U32
)
1082 if (f2f
) op
= 0x254;
1083 else if (f2i
) op
= 0x258;
1084 else if (i2f
) op
= 0x25c;
1087 emitForm_C(i
, op
, 0x2);
1090 if (neg
) code
[1] |= 1 << 16;
1091 if (abs
) code
[1] |= 1 << 20;
1092 if (sat
) code
[1] |= 1 << 21;
1094 emitRoundMode(rnd
, 32 + 10, f2f
? (32 + 13) : -1);
1096 code
[0] |= typeSizeofLog2(dType
) << 10;
1097 code
[0] |= typeSizeofLog2(i
->sType
) << 12;
1098 code
[1] |= i
->subOp
<< 12;
1100 if (isSignedIntType(dType
))
1102 if (isSignedIntType(i
->sType
))
1107 CodeEmitterGK110::emitSET(const CmpInstruction
*i
)
1111 if (i
->def(0).getFile() == FILE_PREDICATE
) {
1113 case TYPE_F32
: op2
= 0x1d8; op1
= 0xb58; break;
1114 case TYPE_F64
: op2
= 0x1c0; op1
= 0xb40; break;
1120 emitForm_21(i
, op2
, op1
);
1124 if (!(code
[0] & 0x1)) {
1128 modNegAbsF32_3b(i
, 1);
1132 // normal DST field is negated predicate result
1133 code
[0] = (code
[0] & ~0xfc) | ((code
[0] << 3) & 0xe0);
1134 if (i
->defExists(1))
1135 defId(i
->def(1), 2);
1140 case TYPE_F32
: op2
= 0x000; op1
= 0x800; break;
1141 case TYPE_F64
: op2
= 0x080; op1
= 0x900; break;
1147 emitForm_21(i
, op2
, op1
);
1151 if (!(code
[0] & 0x1)) {
1155 modNegAbsF32_3b(i
, 1);
1159 if (i
->dType
== TYPE_F32
) {
1160 if (isFloatType(i
->sType
))
1166 if (i
->sType
== TYPE_S32
)
1169 if (i
->op
!= OP_SET
) {
1171 case OP_SET_AND
: code
[1] |= 0x0 << 16; break;
1172 case OP_SET_OR
: code
[1] |= 0x1 << 16; break;
1173 case OP_SET_XOR
: code
[1] |= 0x2 << 16; break;
1178 srcId(i
->src(2), 0x2a);
1180 code
[1] |= 0x7 << 10;
1182 if (i
->flagsSrc
>= 0)
1184 emitCondCode(i
->setCond
,
1185 isFloatType(i
->sType
) ? 0x33 : 0x34,
1186 isFloatType(i
->sType
) ? 0xf : 0x7);
1190 CodeEmitterGK110::emitSLCT(const CmpInstruction
*i
)
1192 CondCode cc
= i
->setCond
;
1193 if (i
->src(2).mod
.neg())
1194 cc
= reverseCondCode(cc
);
1196 if (i
->dType
== TYPE_F32
) {
1197 emitForm_21(i
, 0x1d0, 0xb50);
1199 emitCondCode(cc
, 0x33, 0xf);
1201 emitForm_21(i
, 0x1a0, 0xb20);
1202 emitCondCode(cc
, 0x34, 0x7);
1203 if (i
->dType
== TYPE_S32
)
1209 selpFlip(const FixupEntry
*entry
, uint32_t *code
, const FixupData
& data
)
1211 int loc
= entry
->loc
;
1212 if (data
.force_persample_interp
)
1213 code
[loc
+ 1] |= 1 << 13;
1215 code
[loc
+ 1] &= ~(1 << 13);
1218 void CodeEmitterGK110::emitSELP(const Instruction
*i
)
1220 emitForm_21(i
, 0x250, 0x050);
1222 if (i
->src(2).mod
& Modifier(NV50_IR_MOD_NOT
))
1225 if (i
->subOp
== 1) {
1226 addInterp(0, 0, selpFlip
);
1230 void CodeEmitterGK110::emitTEXBAR(const Instruction
*i
)
1232 code
[0] = 0x0000003e | (i
->subOp
<< 23);
1233 code
[1] = 0x77000000;
1238 void CodeEmitterGK110::emitTEXCSAA(const TexInstruction
*i
)
1240 code
[0] = 0x00000002;
1241 code
[1] = 0x76c00000;
1243 code
[1] |= i
->tex
.r
<< 9;
1244 // code[1] |= i->tex.s << (9 + 8);
1246 if (i
->tex
.liveOnly
)
1247 code
[0] |= 0x80000000;
1249 defId(i
->def(0), 2);
1250 srcId(i
->src(0), 10);
1254 isNextIndependentTex(const TexInstruction
*i
)
1256 if (!i
->next
|| !isTextureOp(i
->next
->op
))
1258 if (i
->getDef(0)->interfers(i
->next
->getSrc(0)))
1260 return !i
->next
->srcExists(1) || !i
->getDef(0)->interfers(i
->next
->getSrc(1));
1264 CodeEmitterGK110::emitTEX(const TexInstruction
*i
)
1266 const bool ind
= i
->tex
.rIndirectSrc
>= 0;
1269 code
[0] = 0x00000002;
1272 code
[1] = 0x7e000000;
1275 code
[1] = 0x7e800000;
1278 code
[1] = 0x78000000;
1281 code
[1] = 0x7dc00000;
1284 code
[1] = 0x7d800000;
1290 code
[0] = 0x00000002;
1291 code
[1] = 0x76000000;
1292 code
[1] |= i
->tex
.r
<< 9;
1295 code
[0] = 0x00000002;
1296 code
[1] = 0x76800000;
1297 code
[1] |= i
->tex
.r
<< 9;
1300 code
[0] = 0x00000002;
1301 code
[1] = 0x70000000;
1302 code
[1] |= i
->tex
.r
<< 13;
1305 code
[0] = 0x00000001;
1306 code
[1] = 0x70000000;
1307 code
[1] |= i
->tex
.r
<< 15;
1310 code
[0] = 0x00000001;
1311 code
[1] = 0x60000000;
1312 code
[1] |= i
->tex
.r
<< 15;
1317 code
[1] |= isNextIndependentTex(i
) ? 0x1 : 0x2; // t : p mode
1319 if (i
->tex
.liveOnly
)
1320 code
[0] |= 0x80000000;
1324 case OP_TXB
: code
[1] |= 0x2000; break;
1325 case OP_TXL
: code
[1] |= 0x3000; break;
1329 case OP_TXLQ
: break;
1331 assert(!"invalid texture op");
1335 if (i
->op
== OP_TXF
) {
1336 if (!i
->tex
.levelZero
)
1339 if (i
->tex
.levelZero
) {
1343 if (i
->op
!= OP_TXD
&& i
->tex
.derivAll
)
1348 code
[1] |= i
->tex
.mask
<< 2;
1350 const int src1
= (i
->predSrc
== 1) ? 2 : 1; // if predSrc == 1, !srcExists(2)
1352 defId(i
->def(0), 2);
1353 srcId(i
->src(0), 10);
1356 if (i
->op
== OP_TXG
) code
[1] |= i
->tex
.gatherComp
<< 13;
1359 code
[1] |= (i
->tex
.target
.isCube() ? 3 : (i
->tex
.target
.getDim() - 1)) << 7;
1360 if (i
->tex
.target
.isArray())
1362 if (i
->tex
.target
.isShadow())
1364 if (i
->tex
.target
== TEX_TARGET_2D_MS
||
1365 i
->tex
.target
== TEX_TARGET_2D_MS_ARRAY
)
1368 if (i
->srcExists(src1
) && i
->src(src1
).getFile() == FILE_IMMEDIATE
) {
1372 if (i
->tex
.useOffsets
== 1) {
1374 case OP_TXF
: code
[1] |= 0x200; break;
1375 case OP_TXD
: code
[1] |= 0x00400000; break;
1376 default: code
[1] |= 0x800; break;
1379 if (i
->tex
.useOffsets
== 4)
1384 CodeEmitterGK110::emitTXQ(const TexInstruction
*i
)
1386 code
[0] = 0x00000002;
1387 code
[1] = 0x75400001;
1389 switch (i
->tex
.query
) {
1390 case TXQ_DIMS
: code
[0] |= 0x01 << 25; break;
1391 case TXQ_TYPE
: code
[0] |= 0x02 << 25; break;
1392 case TXQ_SAMPLE_POSITION
: code
[0] |= 0x05 << 25; break;
1393 case TXQ_FILTER
: code
[0] |= 0x10 << 25; break;
1394 case TXQ_LOD
: code
[0] |= 0x12 << 25; break;
1395 case TXQ_BORDER_COLOUR
: code
[0] |= 0x16 << 25; break;
1397 assert(!"invalid texture query");
1401 code
[1] |= i
->tex
.mask
<< 2;
1402 code
[1] |= i
->tex
.r
<< 9;
1403 if (/*i->tex.sIndirectSrc >= 0 || */i
->tex
.rIndirectSrc
>= 0)
1404 code
[1] |= 0x08000000;
1406 defId(i
->def(0), 2);
1407 srcId(i
->src(0), 10);
1413 CodeEmitterGK110::emitQUADOP(const Instruction
*i
, uint8_t qOp
, uint8_t laneMask
)
1415 code
[0] = 0x00000002 | ((qOp
& 1) << 31);
1416 code
[1] = 0x7fc00200 | (qOp
>> 1) | (laneMask
<< 12); // dall
1418 defId(i
->def(0), 2);
1419 srcId(i
->src(0), 10);
1420 srcId((i
->srcExists(1) && i
->predSrc
!= 1) ? i
->src(1) : i
->src(0), 23);
1426 CodeEmitterGK110::emitPIXLD(const Instruction
*i
)
1428 emitForm_L(i
, 0x7f4, 2, Modifier(0));
1429 code
[1] |= i
->subOp
<< 2;
1430 code
[1] |= 0x00070000;
1434 CodeEmitterGK110::emitBAR(const Instruction
*i
)
1436 code
[0] = 0x00000002;
1437 code
[1] = 0x85400000;
1440 case NV50_IR_SUBOP_BAR_ARRIVE
: code
[1] |= 0x08; break;
1441 case NV50_IR_SUBOP_BAR_RED_AND
: code
[1] |= 0x50; break;
1442 case NV50_IR_SUBOP_BAR_RED_OR
: code
[1] |= 0x90; break;
1443 case NV50_IR_SUBOP_BAR_RED_POPC
: code
[1] |= 0x10; break;
1445 assert(i
->subOp
== NV50_IR_SUBOP_BAR_SYNC
);
1452 if (i
->src(0).getFile() == FILE_GPR
) {
1453 srcId(i
->src(0), 10);
1455 ImmediateValue
*imm
= i
->getSrc(0)->asImm();
1457 code
[0] |= imm
->reg
.data
.u32
<< 10;
1462 if (i
->src(1).getFile() == FILE_GPR
) {
1463 srcId(i
->src(1), 23);
1465 ImmediateValue
*imm
= i
->getSrc(0)->asImm();
1467 assert(imm
->reg
.data
.u32
<= 0xfff);
1468 code
[0] |= imm
->reg
.data
.u32
<< 23;
1469 code
[1] |= imm
->reg
.data
.u32
>> 9;
1473 if (i
->srcExists(2) && (i
->predSrc
!= 2)) {
1474 srcId(i
->src(2), 32 + 10);
1475 if (i
->src(2).mod
== Modifier(NV50_IR_MOD_NOT
))
1482 void CodeEmitterGK110::emitMEMBAR(const Instruction
*i
)
1484 code
[0] = 0x00000002 | NV50_IR_SUBOP_MEMBAR_SCOPE(i
->subOp
) << 8;
1485 code
[1] = 0x7cc00000;
1491 CodeEmitterGK110::emitFlow(const Instruction
*i
)
1493 const FlowInstruction
*f
= i
->asFlow();
1495 unsigned mask
; // bit 0: predicate, bit 1: target
1497 code
[0] = 0x00000000;
1501 code
[1] = f
->absolute
? 0x10800000 : 0x12000000;
1502 if (i
->srcExists(0) && i
->src(0).getFile() == FILE_MEMORY_CONST
)
1507 code
[1] = f
->absolute
? 0x11000000 : 0x13000000;
1508 if (i
->srcExists(0) && i
->src(0).getFile() == FILE_MEMORY_CONST
)
1513 case OP_EXIT
: code
[1] = 0x18000000; mask
= 1; break;
1514 case OP_RET
: code
[1] = 0x19000000; mask
= 1; break;
1515 case OP_DISCARD
: code
[1] = 0x19800000; mask
= 1; break;
1516 case OP_BREAK
: code
[1] = 0x1a000000; mask
= 1; break;
1517 case OP_CONT
: code
[1] = 0x1a800000; mask
= 1; break;
1519 case OP_JOINAT
: code
[1] = 0x14800000; mask
= 2; break;
1520 case OP_PREBREAK
: code
[1] = 0x15000000; mask
= 2; break;
1521 case OP_PRECONT
: code
[1] = 0x15800000; mask
= 2; break;
1522 case OP_PRERET
: code
[1] = 0x13800000; mask
= 2; break;
1524 case OP_QUADON
: code
[1] = 0x1b800000; mask
= 0; break;
1525 case OP_QUADPOP
: code
[1] = 0x1c000000; mask
= 0; break;
1526 case OP_BRKPT
: code
[1] = 0x00000000; mask
= 0; break;
1528 assert(!"invalid flow operation");
1534 if (i
->flagsSrc
< 0)
1546 if (f
->op
== OP_CALL
) {
1548 assert(f
->absolute
);
1549 uint32_t pcAbs
= targNVC0
->getBuiltinOffset(f
->target
.builtin
);
1550 addReloc(RelocEntry::TYPE_BUILTIN
, 0, pcAbs
, 0xff800000, 23);
1551 addReloc(RelocEntry::TYPE_BUILTIN
, 1, pcAbs
, 0x007fffff, -9);
1553 assert(!f
->absolute
);
1554 int32_t pcRel
= f
->target
.fn
->binPos
- (codeSize
+ 8);
1555 code
[0] |= (pcRel
& 0x1ff) << 23;
1556 code
[1] |= (pcRel
>> 9) & 0x7fff;
1560 int32_t pcRel
= f
->target
.bb
->binPos
- (codeSize
+ 8);
1561 if (writeIssueDelays
&& !(f
->target
.bb
->binPos
& 0x3f))
1563 // currently we don't want absolute branches
1564 assert(!f
->absolute
);
1565 code
[0] |= (pcRel
& 0x1ff) << 23;
1566 code
[1] |= (pcRel
>> 9) & 0x7fff;
1571 CodeEmitterGK110::emitSHFL(const Instruction
*i
)
1573 const ImmediateValue
*imm
;
1575 code
[0] = 0x00000002;
1576 code
[1] = 0x78800000 | (i
->subOp
<< 1);
1580 defId(i
->def(0), 2);
1581 srcId(i
->src(0), 10);
1583 switch (i
->src(1).getFile()) {
1585 srcId(i
->src(1), 23);
1587 case FILE_IMMEDIATE
:
1588 imm
= i
->getSrc(1)->asImm();
1589 assert(imm
&& imm
->reg
.data
.u32
< 0x20);
1590 code
[0] |= imm
->reg
.data
.u32
<< 23;
1594 assert(!"invalid src1 file");
1598 switch (i
->src(2).getFile()) {
1600 srcId(i
->src(2), 42);
1602 case FILE_IMMEDIATE
:
1603 imm
= i
->getSrc(2)->asImm();
1604 assert(imm
&& imm
->reg
.data
.u32
< 0x2000);
1605 code
[1] |= imm
->reg
.data
.u32
<< 5;
1609 assert(!"invalid src2 file");
1613 if (!i
->defExists(1))
1616 assert(i
->def(1).getFile() == FILE_PREDICATE
);
1617 defId(i
->def(1), 51);
1622 CodeEmitterGK110::emitVOTE(const Instruction
*i
)
1624 const ImmediateValue
*imm
;
1627 code
[0] = 0x00000002;
1628 code
[1] = 0x86c00000 | (i
->subOp
<< 19);
1633 for (int d
= 0; i
->defExists(d
); d
++) {
1634 if (i
->def(d
).getFile() == FILE_PREDICATE
) {
1637 defId(i
->def(d
), 48);
1638 } else if (i
->def(d
).getFile() == FILE_GPR
) {
1641 defId(i
->def(d
), 2);
1643 assert(!"Unhandled def");
1647 code
[0] |= 255 << 2;
1651 switch (i
->src(0).getFile()) {
1652 case FILE_PREDICATE
:
1653 if (i
->src(0).mod
== Modifier(NV50_IR_MOD_NOT
))
1655 srcId(i
->src(0), 42);
1657 case FILE_IMMEDIATE
:
1658 imm
= i
->getSrc(0)->asImm();
1660 u32
= imm
->reg
.data
.u32
;
1661 assert(u32
== 0 || u32
== 1);
1662 code
[1] |= (u32
== 1 ? 0x7 : 0xf) << 10;
1665 assert(!"Unhandled src");
1671 CodeEmitterGK110::emitSUGType(DataType ty
, const int pos
)
1676 case TYPE_S32
: n
= 1; break;
1677 case TYPE_U8
: n
= 2; break;
1678 case TYPE_S8
: n
= 3; break;
1680 assert(ty
== TYPE_U32
);
1683 code
[pos
/ 32] |= n
<< (pos
% 32);
1687 CodeEmitterGK110::emitSUCachingMode(CacheMode c
)
1707 assert(!"invalid caching mode");
1710 code
[0] |= (n
& 1) << 31;
1711 code
[1] |= (n
& 2) >> 1;
1715 CodeEmitterGK110::setSUConst16(const Instruction
*i
, const int s
)
1717 const uint32_t offset
= i
->getSrc(s
)->reg
.data
.offset
;
1719 assert(offset
== (offset
& 0xfffc));
1721 code
[0] |= offset
<< 21;
1722 code
[1] |= offset
>> 11;
1723 code
[1] |= i
->getSrc(s
)->reg
.fileIndex
<< 5;
1727 CodeEmitterGK110::emitSULDGB(const TexInstruction
*i
)
1729 code
[0] = 0x00000002;
1730 code
[1] = 0x30000000 | (i
->subOp
<< 14);
1732 if (i
->src(1).getFile() == FILE_MEMORY_CONST
) {
1733 emitLoadStoreType(i
->dType
, 0x38);
1734 emitCachingMode(i
->cache
, 0x36);
1739 assert(i
->src(1).getFile() == FILE_GPR
);
1740 code
[1] |= 0x49800000;
1742 emitLoadStoreType(i
->dType
, 0x21);
1743 emitSUCachingMode(i
->cache
);
1745 srcId(i
->src(1), 23);
1748 emitSUGType(i
->sType
, 0x34);
1751 defId(i
->def(0), 2); // destination
1752 srcId(i
->src(0), 10); // address
1754 // surface predicate
1755 if (!i
->srcExists(2) || (i
->predSrc
== 2)) {
1756 code
[1] |= 0x7 << 10;
1758 if (i
->src(2).mod
== Modifier(NV50_IR_MOD_NOT
))
1760 srcId(i
->src(2), 32 + 10);
1765 CodeEmitterGK110::emitSUSTGx(const TexInstruction
*i
)
1767 assert(i
->op
== OP_SUSTP
);
1769 code
[0] = 0x00000002;
1770 code
[1] = 0x38000000;
1772 if (i
->src(1).getFile() == FILE_MEMORY_CONST
) {
1773 code
[0] |= i
->subOp
<< 2;
1775 if (i
->op
== OP_SUSTP
)
1776 code
[0] |= i
->tex
.mask
<< 4;
1778 emitSUGType(i
->sType
, 0x8);
1779 emitCachingMode(i
->cache
, 0x36);
1784 assert(i
->src(1).getFile() == FILE_GPR
);
1786 code
[0] |= i
->subOp
<< 23;
1787 code
[1] |= 0x41c00000;
1789 if (i
->op
== OP_SUSTP
)
1790 code
[0] |= i
->tex
.mask
<< 25;
1792 emitSUGType(i
->sType
, 0x1d);
1793 emitSUCachingMode(i
->cache
);
1795 srcId(i
->src(1), 2);
1799 srcId(i
->src(0), 10); // address
1800 srcId(i
->src(3), 42); // values
1802 // surface predicate
1803 if (!i
->srcExists(2) || (i
->predSrc
== 2)) {
1804 code
[1] |= 0x7 << 18;
1806 if (i
->src(2).mod
== Modifier(NV50_IR_MOD_NOT
))
1808 srcId(i
->src(2), 32 + 18);
1813 CodeEmitterGK110::emitSUCLAMPMode(uint16_t subOp
)
1816 switch (subOp
& ~NV50_IR_SUBOP_SUCLAMP_2D
) {
1817 case NV50_IR_SUBOP_SUCLAMP_SD(0, 1): m
= 0; break;
1818 case NV50_IR_SUBOP_SUCLAMP_SD(1, 1): m
= 1; break;
1819 case NV50_IR_SUBOP_SUCLAMP_SD(2, 1): m
= 2; break;
1820 case NV50_IR_SUBOP_SUCLAMP_SD(3, 1): m
= 3; break;
1821 case NV50_IR_SUBOP_SUCLAMP_SD(4, 1): m
= 4; break;
1822 case NV50_IR_SUBOP_SUCLAMP_PL(0, 1): m
= 5; break;
1823 case NV50_IR_SUBOP_SUCLAMP_PL(1, 1): m
= 6; break;
1824 case NV50_IR_SUBOP_SUCLAMP_PL(2, 1): m
= 7; break;
1825 case NV50_IR_SUBOP_SUCLAMP_PL(3, 1): m
= 8; break;
1826 case NV50_IR_SUBOP_SUCLAMP_PL(4, 1): m
= 9; break;
1827 case NV50_IR_SUBOP_SUCLAMP_BL(0, 1): m
= 10; break;
1828 case NV50_IR_SUBOP_SUCLAMP_BL(1, 1): m
= 11; break;
1829 case NV50_IR_SUBOP_SUCLAMP_BL(2, 1): m
= 12; break;
1830 case NV50_IR_SUBOP_SUCLAMP_BL(3, 1): m
= 13; break;
1831 case NV50_IR_SUBOP_SUCLAMP_BL(4, 1): m
= 14; break;
1836 if (subOp
& NV50_IR_SUBOP_SUCLAMP_2D
)
1841 CodeEmitterGK110::emitSUCalc(Instruction
*i
)
1843 ImmediateValue
*imm
= NULL
;
1844 uint64_t opc1
, opc2
;
1846 if (i
->srcExists(2)) {
1847 imm
= i
->getSrc(2)->asImm();
1849 i
->setSrc(2, NULL
); // special case, make emitForm_21 not assert
1853 case OP_SUCLAMP
: opc1
= 0xb00; opc2
= 0x580; break;
1854 case OP_SUBFM
: opc1
= 0xb68; opc2
= 0x1e8; break;
1855 case OP_SUEAU
: opc1
= 0xb6c; opc2
= 0x1ec; break;
1860 emitForm_21(i
, opc2
, opc1
);
1862 if (i
->op
== OP_SUCLAMP
) {
1863 if (i
->dType
== TYPE_S32
)
1865 emitSUCLAMPMode(i
->subOp
);
1868 if (i
->op
== OP_SUBFM
&& i
->subOp
== NV50_IR_SUBOP_SUBFM_3D
)
1871 if (i
->op
!= OP_SUEAU
) {
1872 const uint8_t pos
= i
->op
== OP_SUBFM
? 19 : 16;
1873 if (i
->def(0).getFile() == FILE_PREDICATE
) { // p, #
1874 code
[0] |= 255 << 2;
1875 code
[1] |= i
->getDef(1)->reg
.data
.id
<< pos
;
1877 if (i
->defExists(1)) { // r, p
1878 assert(i
->def(1).getFile() == FILE_PREDICATE
);
1879 code
[1] |= i
->getDef(1)->reg
.data
.id
<< pos
;
1881 code
[1] |= 7 << pos
;
1886 assert(i
->op
== OP_SUCLAMP
);
1888 code
[1] |= (imm
->reg
.data
.u32
& 0x3f) << 10; // sint6
1894 CodeEmitterGK110::emitVectorSubOp(const Instruction
*i
)
1896 switch (NV50_IR_SUBOP_Vn(i
->subOp
)) {
1898 code
[1] |= (i
->subOp
& 0x000f) << 7; // vsrc1
1899 code
[1] |= (i
->subOp
& 0x00e0) >> 6; // vsrc2
1900 code
[1] |= (i
->subOp
& 0x0100) << 13; // vsrc2
1901 code
[1] |= (i
->subOp
& 0x3c00) << 12; // vdst
1910 CodeEmitterGK110::emitVSHL(const Instruction
*i
)
1912 code
[0] = 0x00000002;
1913 code
[1] = 0xb8000000;
1915 assert(NV50_IR_SUBOP_Vn(i
->subOp
) == 0);
1917 if (isSignedType(i
->dType
)) code
[1] |= 1 << 25;
1918 if (isSignedType(i
->sType
)) code
[1] |= 1 << 19;
1923 defId(i
->def(0), 2);
1924 srcId(i
->src(0), 10);
1926 if (i
->getSrc(1)->reg
.file
== FILE_IMMEDIATE
) {
1927 ImmediateValue
*imm
= i
->getSrc(1)->asImm();
1929 code
[0] |= (imm
->reg
.data
.u32
& 0x01ff) << 23;
1930 code
[1] |= (imm
->reg
.data
.u32
& 0xfe00) >> 9;
1932 assert(i
->getSrc(1)->reg
.file
== FILE_GPR
);
1934 srcId(i
->src(1), 23);
1936 srcId(i
->src(2), 42);
1940 if (i
->flagsDef
>= 0)
1945 CodeEmitterGK110::emitAFETCH(const Instruction
*i
)
1947 uint32_t offset
= i
->src(0).get()->reg
.data
.offset
& 0x7ff;
1949 code
[0] = 0x00000002 | (offset
<< 23);
1950 code
[1] = 0x7d000000 | (offset
>> 9);
1952 if (i
->getSrc(0)->reg
.file
== FILE_SHADER_OUTPUT
)
1957 defId(i
->def(0), 2);
1958 srcId(i
->src(0).getIndirect(0), 10);
1962 CodeEmitterGK110::emitPFETCH(const Instruction
*i
)
1964 uint32_t prim
= i
->src(0).get()->reg
.data
.u32
;
1966 code
[0] = 0x00000002 | ((prim
& 0xff) << 23);
1967 code
[1] = 0x7f800000;
1971 const int src1
= (i
->predSrc
== 1) ? 2 : 1; // if predSrc == 1, !srcExists(2)
1973 defId(i
->def(0), 2);
1978 CodeEmitterGK110::emitVFETCH(const Instruction
*i
)
1980 unsigned int size
= typeSizeof(i
->dType
);
1981 uint32_t offset
= i
->src(0).get()->reg
.data
.offset
;
1983 code
[0] = 0x00000002 | (offset
<< 23);
1984 code
[1] = 0x7ec00000 | (offset
>> 9);
1985 code
[1] |= (size
/ 4 - 1) << 18;
1989 if (i
->getSrc(0)->reg
.file
== FILE_SHADER_OUTPUT
)
1990 code
[1] |= 0x8; // yes, TCPs can read from *outputs* of other threads
1994 defId(i
->def(0), 2);
1995 srcId(i
->src(0).getIndirect(0), 10);
1996 srcId(i
->src(0).getIndirect(1), 32 + 10); // vertex address
2000 CodeEmitterGK110::emitEXPORT(const Instruction
*i
)
2002 unsigned int size
= typeSizeof(i
->dType
);
2003 uint32_t offset
= i
->src(0).get()->reg
.data
.offset
;
2005 code
[0] = 0x00000002 | (offset
<< 23);
2006 code
[1] = 0x7f000000 | (offset
>> 9);
2007 code
[1] |= (size
/ 4 - 1) << 18;
2014 assert(i
->src(1).getFile() == FILE_GPR
);
2016 srcId(i
->src(0).getIndirect(0), 10);
2017 srcId(i
->src(0).getIndirect(1), 32 + 10); // vertex base address
2018 srcId(i
->src(1), 2);
2022 CodeEmitterGK110::emitOUT(const Instruction
*i
)
2024 assert(i
->src(0).getFile() == FILE_GPR
);
2026 emitForm_21(i
, 0x1f0, 0xb70);
2028 if (i
->op
== OP_EMIT
)
2030 if (i
->op
== OP_RESTART
|| i
->subOp
== NV50_IR_SUBOP_EMIT_RESTART
)
2035 CodeEmitterGK110::emitInterpMode(const Instruction
*i
)
2037 code
[1] |= (i
->ipa
& 0x3) << 21; // TODO: INTERP_SAMPLEID
2038 code
[1] |= (i
->ipa
& 0xc) << (19 - 2);
2042 interpApply(const FixupEntry
*entry
, uint32_t *code
, const FixupData
& data
)
2044 int ipa
= entry
->ipa
;
2045 int reg
= entry
->reg
;
2046 int loc
= entry
->loc
;
2048 if (data
.flatshade
&&
2049 (ipa
& NV50_IR_INTERP_MODE_MASK
) == NV50_IR_INTERP_SC
) {
2050 ipa
= NV50_IR_INTERP_FLAT
;
2052 } else if (data
.force_persample_interp
&&
2053 (ipa
& NV50_IR_INTERP_SAMPLE_MASK
) == NV50_IR_INTERP_DEFAULT
&&
2054 (ipa
& NV50_IR_INTERP_MODE_MASK
) != NV50_IR_INTERP_FLAT
) {
2055 ipa
|= NV50_IR_INTERP_CENTROID
;
2057 code
[loc
+ 1] &= ~(0xf << 19);
2058 code
[loc
+ 1] |= (ipa
& 0x3) << 21;
2059 code
[loc
+ 1] |= (ipa
& 0xc) << (19 - 2);
2060 code
[loc
+ 0] &= ~(0xff << 23);
2061 code
[loc
+ 0] |= reg
<< 23;
2065 CodeEmitterGK110::emitINTERP(const Instruction
*i
)
2067 const uint32_t base
= i
->getSrc(0)->reg
.data
.offset
;
2069 code
[0] = 0x00000002 | (base
<< 31);
2070 code
[1] = 0x74800000 | (base
>> 1);
2075 if (i
->op
== OP_PINTERP
) {
2076 srcId(i
->src(1), 23);
2077 addInterp(i
->ipa
, SDATA(i
->src(1)).id
, interpApply
);
2079 code
[0] |= 0xff << 23;
2080 addInterp(i
->ipa
, 0xff, interpApply
);
2083 srcId(i
->src(0).getIndirect(0), 10);
2087 defId(i
->def(0), 2);
2089 if (i
->getSampleMode() == NV50_IR_INTERP_OFFSET
)
2090 srcId(i
->src(i
->op
== OP_PINTERP
? 2 : 1), 32 + 10);
2092 code
[1] |= 0xff << 10;
2096 CodeEmitterGK110::emitLoadStoreType(DataType ty
, const int pos
)
2128 assert(!"invalid ld/st type");
2131 code
[pos
/ 32] |= n
<< (pos
% 32);
2135 CodeEmitterGK110::emitCachingMode(CacheMode c
, const int pos
)
2156 assert(!"invalid caching mode");
2159 code
[pos
/ 32] |= n
<< (pos
% 32);
2163 CodeEmitterGK110::emitSTORE(const Instruction
*i
)
2165 int32_t offset
= SDATA(i
->src(0)).offset
;
2167 switch (i
->src(0).getFile()) {
2168 case FILE_MEMORY_GLOBAL
: code
[1] = 0xe0000000; code
[0] = 0x00000000; break;
2169 case FILE_MEMORY_LOCAL
: code
[1] = 0x7a800000; code
[0] = 0x00000002; break;
2170 case FILE_MEMORY_SHARED
:
2171 code
[0] = 0x00000002;
2172 if (i
->subOp
== NV50_IR_SUBOP_STORE_UNLOCKED
)
2173 code
[1] = 0x78400000;
2175 code
[1] = 0x7ac00000;
2178 assert(!"invalid memory file");
2182 if (code
[0] & 0x2) {
2184 emitLoadStoreType(i
->dType
, 0x33);
2185 if (i
->src(0).getFile() == FILE_MEMORY_LOCAL
)
2186 emitCachingMode(i
->cache
, 0x2f);
2188 emitLoadStoreType(i
->dType
, 0x38);
2189 emitCachingMode(i
->cache
, 0x3b);
2191 code
[0] |= offset
<< 23;
2192 code
[1] |= offset
>> 9;
2194 // Unlocked store on shared memory can fail.
2195 if (i
->src(0).getFile() == FILE_MEMORY_SHARED
&&
2196 i
->subOp
== NV50_IR_SUBOP_STORE_UNLOCKED
) {
2197 assert(i
->defExists(0));
2198 defId(i
->def(0), 32 + 16);
2203 srcId(i
->src(1), 2);
2204 srcId(i
->src(0).getIndirect(0), 10);
2205 if (i
->src(0).getFile() == FILE_MEMORY_GLOBAL
&&
2206 i
->src(0).isIndirect(0) &&
2207 i
->getIndirect(0, 0)->reg
.size
== 8)
2212 CodeEmitterGK110::emitLOAD(const Instruction
*i
)
2214 int32_t offset
= SDATA(i
->src(0)).offset
;
2216 switch (i
->src(0).getFile()) {
2217 case FILE_MEMORY_GLOBAL
: code
[1] = 0xc0000000; code
[0] = 0x00000000; break;
2218 case FILE_MEMORY_LOCAL
: code
[1] = 0x7a000000; code
[0] = 0x00000002; break;
2219 case FILE_MEMORY_SHARED
:
2220 code
[0] = 0x00000002;
2221 if (i
->subOp
== NV50_IR_SUBOP_LOAD_LOCKED
)
2222 code
[1] = 0x77400000;
2224 code
[1] = 0x7a400000;
2226 case FILE_MEMORY_CONST
:
2227 if (!i
->src(0).isIndirect(0) && typeSizeof(i
->dType
) == 4) {
2232 code
[0] = 0x00000002;
2233 code
[1] = 0x7c800000 | (i
->src(0).get()->reg
.fileIndex
<< 7);
2234 code
[1] |= i
->subOp
<< 15;
2237 assert(!"invalid memory file");
2241 if (code
[0] & 0x2) {
2243 emitLoadStoreType(i
->dType
, 0x33);
2244 if (i
->src(0).getFile() == FILE_MEMORY_LOCAL
)
2245 emitCachingMode(i
->cache
, 0x2f);
2247 emitLoadStoreType(i
->dType
, 0x38);
2248 emitCachingMode(i
->cache
, 0x3b);
2250 code
[0] |= offset
<< 23;
2251 code
[1] |= offset
>> 9;
2253 // Locked store on shared memory can fail.
2255 if (i
->src(0).getFile() == FILE_MEMORY_SHARED
&&
2256 i
->subOp
== NV50_IR_SUBOP_LOAD_LOCKED
) {
2257 if (i
->def(0).getFile() == FILE_PREDICATE
) { // p, #
2260 } else if (i
->defExists(1)) { // r, p
2263 assert(!"Expected predicate dest for load locked");
2270 defId(i
->def(r
), 2);
2272 code
[0] |= 255 << 2;
2275 defId(i
->def(p
), 32 + 16);
2277 if (i
->getIndirect(0, 0)) {
2278 srcId(i
->src(0).getIndirect(0), 10);
2279 if (i
->getIndirect(0, 0)->reg
.size
== 8)
2282 code
[0] |= 255 << 10;
2287 CodeEmitterGK110::getSRegEncoding(const ValueRef
& ref
)
2289 switch (SDATA(ref
).sv
.sv
) {
2290 case SV_LANEID
: return 0x00;
2291 case SV_PHYSID
: return 0x03;
2292 case SV_VERTEX_COUNT
: return 0x10;
2293 case SV_INVOCATION_ID
: return 0x11;
2294 case SV_YDIR
: return 0x12;
2295 case SV_THREAD_KILL
: return 0x13;
2296 case SV_TID
: return 0x21 + SDATA(ref
).sv
.index
;
2297 case SV_CTAID
: return 0x25 + SDATA(ref
).sv
.index
;
2298 case SV_NTID
: return 0x29 + SDATA(ref
).sv
.index
;
2299 case SV_GRIDID
: return 0x2c;
2300 case SV_NCTAID
: return 0x2d + SDATA(ref
).sv
.index
;
2301 case SV_LBASE
: return 0x34;
2302 case SV_SBASE
: return 0x30;
2303 case SV_LANEMASK_EQ
: return 0x38;
2304 case SV_LANEMASK_LT
: return 0x39;
2305 case SV_LANEMASK_LE
: return 0x3a;
2306 case SV_LANEMASK_GT
: return 0x3b;
2307 case SV_LANEMASK_GE
: return 0x3c;
2308 case SV_CLOCK
: return 0x50 + SDATA(ref
).sv
.index
;
2310 assert(!"no sreg for system value");
2316 CodeEmitterGK110::emitMOV(const Instruction
*i
)
2318 if (i
->def(0).getFile() == FILE_PREDICATE
) {
2319 if (i
->src(0).getFile() == FILE_GPR
) {
2320 // Use ISETP.NE.AND dst, PT, src, RZ, PT
2321 code
[0] = 0x00000002;
2322 code
[1] = 0xdb500000;
2324 code
[0] |= 0x7 << 2;
2325 code
[0] |= 0xff << 23;
2326 code
[1] |= 0x7 << 10;
2327 srcId(i
->src(0), 10);
2329 if (i
->src(0).getFile() == FILE_PREDICATE
) {
2330 // Use PSETP.AND.AND dst, PT, src, PT, PT
2331 code
[0] = 0x00000002;
2332 code
[1] = 0x84800000;
2334 code
[0] |= 0x7 << 2;
2335 code
[1] |= 0x7 << 0;
2336 code
[1] |= 0x7 << 10;
2338 srcId(i
->src(0), 14);
2340 assert(!"Unexpected source for predicate destination");
2344 defId(i
->def(0), 5);
2346 if (i
->src(0).getFile() == FILE_SYSTEM_VALUE
) {
2347 code
[0] = 0x00000002 | (getSRegEncoding(i
->src(0)) << 23);
2348 code
[1] = 0x86400000;
2350 defId(i
->def(0), 2);
2352 if (i
->src(0).getFile() == FILE_IMMEDIATE
) {
2353 code
[0] = 0x00000002 | (i
->lanes
<< 14);
2354 code
[1] = 0x74000000;
2356 defId(i
->def(0), 2);
2357 setImmediate32(i
, 0, Modifier(0));
2359 if (i
->src(0).getFile() == FILE_PREDICATE
) {
2360 code
[0] = 0x00000002;
2361 code
[1] = 0x84401c07;
2363 defId(i
->def(0), 2);
2364 srcId(i
->src(0), 14);
2366 emitForm_C(i
, 0x24c, 2);
2367 code
[1] |= i
->lanes
<< 10;
2372 uses64bitAddress(const Instruction
*ldst
)
2374 return ldst
->src(0).getFile() == FILE_MEMORY_GLOBAL
&&
2375 ldst
->src(0).isIndirect(0) &&
2376 ldst
->getIndirect(0, 0)->reg
.size
== 8;
2380 CodeEmitterGK110::emitATOM(const Instruction
*i
)
2382 const bool hasDst
= i
->defExists(0);
2383 const bool exch
= i
->subOp
== NV50_IR_SUBOP_ATOM_EXCH
;
2385 code
[0] = 0x00000002;
2386 if (i
->subOp
== NV50_IR_SUBOP_ATOM_CAS
)
2387 code
[1] = 0x77800000;
2389 code
[1] = 0x68000000;
2392 case NV50_IR_SUBOP_ATOM_CAS
: break;
2393 case NV50_IR_SUBOP_ATOM_EXCH
: code
[1] |= 0x04000000; break;
2394 default: code
[1] |= i
->subOp
<< 23; break;
2398 case TYPE_U32
: break;
2399 case TYPE_S32
: code
[1] |= 0x00100000; break;
2400 case TYPE_U64
: code
[1] |= 0x00200000; break;
2401 case TYPE_F32
: code
[1] |= 0x00300000; break;
2402 case TYPE_B128
: code
[1] |= 0x00400000; break; /* TODO: U128 */
2403 case TYPE_S64
: code
[1] |= 0x00500000; break;
2404 default: assert(!"unsupported type"); break;
2409 /* TODO: cas: check that src regs line up */
2410 /* TODO: cas: flip bits if $r255 is used */
2411 srcId(i
->src(1), 23);
2414 defId(i
->def(0), 2);
2417 code
[0] |= 255 << 2;
2420 if (hasDst
|| !exch
) {
2421 const int32_t offset
= SDATA(i
->src(0)).offset
;
2422 assert(offset
< 0x80000 && offset
>= -0x80000);
2423 code
[0] |= (offset
& 1) << 31;
2424 code
[1] |= (offset
& 0xffffe) >> 1;
2426 srcAddr32(i
->src(0), 31);
2429 if (i
->getIndirect(0, 0)) {
2430 srcId(i
->getIndirect(0, 0), 10);
2431 if (i
->getIndirect(0, 0)->reg
.size
== 8)
2434 code
[0] |= 255 << 10;
2439 CodeEmitterGK110::emitCCTL(const Instruction
*i
)
2441 int32_t offset
= SDATA(i
->src(0)).offset
;
2443 code
[0] = 0x00000002 | (i
->subOp
<< 2);
2445 if (i
->src(0).getFile() == FILE_MEMORY_GLOBAL
) {
2446 code
[1] = 0x7b000000;
2448 code
[1] = 0x7c000000;
2451 code
[0] |= offset
<< 23;
2452 code
[1] |= offset
>> 9;
2454 if (uses64bitAddress(i
))
2456 srcId(i
->src(0).getIndirect(0), 10);
2462 CodeEmitterGK110::emitInstruction(Instruction
*insn
)
2464 const unsigned int size
= (writeIssueDelays
&& !(codeSize
& 0x3f)) ? 16 : 8;
2466 if (insn
->encSize
!= 8) {
2467 ERROR("skipping unencodable instruction: ");
2471 if (codeSize
+ size
> codeSizeLimit
) {
2472 ERROR("code emitter output buffer too small\n");
2476 if (writeIssueDelays
) {
2477 int id
= (codeSize
& 0x3f) / 8 - 1;
2480 code
[0] = 0x00000000; // cf issue delay "instruction"
2481 code
[1] = 0x08000000;
2485 uint32_t *data
= code
- (id
* 2 + 2);
2488 case 0: data
[0] |= insn
->sched
<< 2; break;
2489 case 1: data
[0] |= insn
->sched
<< 10; break;
2490 case 2: data
[0] |= insn
->sched
<< 18; break;
2491 case 3: data
[0] |= insn
->sched
<< 26; data
[1] |= insn
->sched
>> 6; break;
2492 case 4: data
[1] |= insn
->sched
<< 2; break;
2493 case 5: data
[1] |= insn
->sched
<< 10; break;
2494 case 6: data
[1] |= insn
->sched
<< 18; break;
2501 // assert that instructions with multiple defs don't corrupt registers
2502 for (int d
= 0; insn
->defExists(d
); ++d
)
2503 assert(insn
->asTex() || insn
->def(d
).rep()->reg
.data
.id
>= 0);
2540 if (insn
->dType
== TYPE_F64
)
2542 else if (isFloatType(insn
->dType
))
2548 if (insn
->dType
== TYPE_F64
)
2550 else if (isFloatType(insn
->dType
))
2557 if (insn
->dType
== TYPE_F64
)
2559 else if (isFloatType(insn
->dType
))
2577 emitLogicOp(insn
, 0);
2580 emitLogicOp(insn
, 1);
2583 emitLogicOp(insn
, 2);
2587 if (typeSizeof(insn
->sType
) == 8)
2596 emitSET(insn
->asCmp());
2602 emitSLCT(insn
->asCmp());
2617 if (insn
->def(0).getFile() == FILE_PREDICATE
||
2618 insn
->src(0).getFile() == FILE_PREDICATE
)
2624 emitSFnOp(insn
, 5 + 2 * insn
->subOp
);
2627 emitSFnOp(insn
, 4 + 2 * insn
->subOp
);
2652 emitTEX(insn
->asTex());
2655 emitTXQ(insn
->asTex());
2680 emitQUADOP(insn
, insn
->subOp
, insn
->lanes
);
2683 emitQUADOP(insn
, insn
->src(0).mod
.neg() ? 0x66 : 0x99, 0x4);
2686 emitQUADOP(insn
, insn
->src(0).mod
.neg() ? 0x5a : 0xa5, 0x5);
2726 emitSULDGB(insn
->asTex());
2730 emitSUSTGx(insn
->asTex());
2743 ERROR("operation should have been eliminated");
2749 ERROR("operation should have been lowered\n");
2752 ERROR("unknown op: %u\n", insn
->op
);
2765 CodeEmitterGK110::getMinEncodingSize(const Instruction
*i
) const
2767 // No more short instruction encodings.
2772 CodeEmitterGK110::prepareEmission(Function
*func
)
2774 const Target
*targ
= func
->getProgram()->getTarget();
2776 CodeEmitter::prepareEmission(func
);
2778 if (targ
->hasSWSched
)
2779 calculateSchedDataNVC0(targ
, func
);
2782 CodeEmitterGK110::CodeEmitterGK110(const TargetNVC0
*target
)
2783 : CodeEmitter(target
),
2785 writeIssueDelays(target
->hasSWSched
)
2788 codeSize
= codeSizeLimit
= 0;
2793 TargetNVC0::createCodeEmitterGK110(Program::Type type
)
2795 CodeEmitterGK110
*emit
= new CodeEmitterGK110(this);
2796 emit
->setProgramType(type
);
2800 } // namespace nv50_ir