13433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller/* 23433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller * Copyright 2012 Christoph Bumiller 33433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller * 43433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller * Permission is hereby granted, free of charge, to any person obtaining a 53433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller * copy of this software and associated documentation files (the "Software"), 63433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller * to deal in the Software without restriction, including without limitation 73433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller * the rights to use, copy, modify, merge, publish, distribute, sublicense, 83433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller * and/or sell copies of the Software, and to permit persons to whom the 93433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller * Software is furnished to do so, subject to the following conditions: 103433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller * 113433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller * The above copyright notice and this permission notice shall be included in 123433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller * all copies or substantial portions of the Software. 133433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller * 143433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 153433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 163433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 173d8d5b298a268b119d840bc9bae0ee9e0c9244a9Kenneth Graunke * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 183d8d5b298a268b119d840bc9bae0ee9e0c9244a9Kenneth Graunke * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 193d8d5b298a268b119d840bc9bae0ee9e0c9244a9Kenneth Graunke * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 203d8d5b298a268b119d840bc9bae0ee9e0c9244a9Kenneth Graunke * OTHER DEALINGS IN THE SOFTWARE. 213433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller */ 223433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 235eb7ff1175a644ffe3b0f1a75cb235400355f9fbJohannes Obermayr#include "codegen/nv50_ir_target_nvc0.h" 243433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 253433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller// CodeEmitter for GK110 encoding of the Fermi/Kepler ISA. 263433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 273433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillernamespace nv50_ir { 283433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 293433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillerclass CodeEmitterGK110 : public CodeEmitter 303433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 313433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillerpublic: 323433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller CodeEmitterGK110(const TargetNVC0 *); 333433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 343433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller virtual bool emitInstruction(Instruction *); 353433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller virtual uint32_t getMinEncodingSize(const Instruction *) const; 363433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller virtual void prepareEmission(Function *); 373433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 383433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller inline void setProgramType(Program::Type pType) { progType = pType; } 393433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 403433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillerprivate: 413741b7d844f7357fac984e8c565dedb248947487Christoph Bumiller const TargetNVC0 *targNVC0; 423433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 433433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller Program::Type progType; 443433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 453433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller const bool writeIssueDelays; 463433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 473433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillerprivate: 483433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitForm_21(const Instruction *, uint32_t opc2, uint32_t opc1); 493433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitForm_C(const Instruction *, uint32_t opc, uint8_t ctg); 503433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitForm_L(const Instruction *, uint32_t opc, uint8_t ctg, Modifier); 513433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 523433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitPredicate(const Instruction *); 533433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 543433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void setCAddress14(const ValueRef&); 553433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void setShortImmediate(const Instruction *, const int s); 563433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void setImmediate32(const Instruction *, const int s, Modifier); 571f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset void setSUConst16(const Instruction *, const int s); 583433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 593433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void modNegAbsF32_3b(const Instruction *, const int s); 603433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 613433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitCondCode(CondCode cc, int pos, uint8_t mask); 623433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitInterpMode(const Instruction *); 633433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitLoadStoreType(DataType ty, const int pos); 643433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitCachingMode(CacheMode c, const int pos); 651f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset void emitSUGType(DataType, const int pos); 661f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset void emitSUCachingMode(CacheMode c); 673433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 683433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller inline uint8_t getSRegEncoding(const ValueRef&); 693433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 703433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitRoundMode(RoundMode, const int pos, const int rintPos); 713433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitRoundModeF(RoundMode, const int pos); 723433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitRoundModeI(RoundMode, const int pos); 733433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 743433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitNegAbs12(const Instruction *); 753433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 763433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitNOP(const Instruction *); 773433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 783433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitLOAD(const Instruction *); 793433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitSTORE(const Instruction *); 803433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitMOV(const Instruction *); 817d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin void emitATOM(const Instruction *); 828c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin void emitCCTL(const Instruction *); 833433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 843433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitINTERP(const Instruction *); 859d60793a03e40e1d139b78fce0144cad57438741Ilia Mirkin void emitAFETCH(const Instruction *); 863433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitPFETCH(const Instruction *); 873433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitVFETCH(const Instruction *); 883433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitEXPORT(const Instruction *); 893433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitOUT(const Instruction *); 903433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 913433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitUADD(const Instruction *); 923433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitFADD(const Instruction *); 93493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin void emitDADD(const Instruction *); 943433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitIMUL(const Instruction *); 953433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitFMUL(const Instruction *); 96493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin void emitDMUL(const Instruction *); 973433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitIMAD(const Instruction *); 983433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitISAD(const Instruction *); 9931545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset void emitSHLADD(const Instruction *); 1003433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitFMAD(const Instruction *); 101493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin void emitDMAD(const Instruction *); 102fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset void emitMADSP(const Instruction *i); 1033433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1043433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitNOT(const Instruction *); 1053433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitLogicOp(const Instruction *, uint8_t subOp); 1063433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitPOPC(const Instruction *); 1073433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitINSBF(const Instruction *); 108b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin void emitEXTBF(const Instruction *); 109b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin void emitBFIND(const Instruction *); 110c2ce22ca4641343e9bad446811a882c5c3930419Samuel Pitoiset void emitPERMT(const Instruction *); 1113433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitShift(const Instruction *); 1123433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1133433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitSFnOp(const Instruction *, uint8_t subOp); 1143433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1153433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitCVT(const Instruction *); 1163433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitMINMAX(const Instruction *); 1173433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitPreOp(const Instruction *); 1183433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1193433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitSET(const CmpInstruction *); 1203433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitSLCT(const CmpInstruction *); 1216526225f888a08b301e8c39ec70b4e739081e490Samuel Pitoiset void emitSELP(const Instruction *); 1223433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1233433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitTEXBAR(const Instruction *); 1243433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitTEX(const TexInstruction *); 1253433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitTEXCSAA(const TexInstruction *); 1263433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitTXQ(const TexInstruction *); 1273433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1283433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitQUADOP(const Instruction *, uint8_t qOp, uint8_t laneMask); 1293433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 130af38ef907c89ecb1125bf258cafa0793f79a5eb7Ilia Mirkin void emitPIXLD(const Instruction *); 131af38ef907c89ecb1125bf258cafa0793f79a5eb7Ilia Mirkin 13288818c4cd6de9d8855a9ba3c3a85306d42f5e9d3Ilia Mirkin void emitBAR(const Instruction *); 1337d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin void emitMEMBAR(const Instruction *); 13488818c4cd6de9d8855a9ba3c3a85306d42f5e9d3Ilia Mirkin 1353433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller void emitFlow(const Instruction *); 1363433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 13707ed003faf3199a3e95852e7a34763aeaf76503dSamuel Pitoiset void emitVOTE(const Instruction *); 13807ed003faf3199a3e95852e7a34763aeaf76503dSamuel Pitoiset 1391f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset void emitSULDGB(const TexInstruction *); 1401f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset void emitSUSTGx(const TexInstruction *); 141af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset void emitSUCLAMPMode(uint16_t); 142af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset void emitSUCalc(Instruction *); 1431f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 1442daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset void emitVSHL(const Instruction *); 1452daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset void emitVectorSubOp(const Instruction *); 1462daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset 1473433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller inline void defId(const ValueDef&, const int pos); 1483433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller inline void srcId(const ValueRef&, const int pos); 1493433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller inline void srcId(const ValueRef *, const int pos); 1503433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller inline void srcId(const Instruction *, int s, const int pos); 1513433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1523433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller inline void srcAddr32(const ValueRef&, const int pos); // address / 4 1533433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1543433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller inline bool isLIMM(const ValueRef&, DataType ty, bool mod = false); 1553433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller}; 1563433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1573433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller#define GK110_GPR_ZERO 255 1583433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1593433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller#define NEG_(b, s) \ 1603433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->src(s).mod.neg()) code[(0x##b) / 32] |= 1 << ((0x##b) % 32) 1613433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller#define ABS_(b, s) \ 1623433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->src(s).mod.abs()) code[(0x##b) / 32] |= 1 << ((0x##b) % 32) 1633433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1643433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller#define NOT_(b, s) if (i->src(s).mod & Modifier(NV50_IR_MOD_NOT)) \ 1653433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[(0x##b) / 32] |= 1 << ((0x##b) % 32) 1663433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1673433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller#define FTZ_(b) if (i->ftz) code[(0x##b) / 32] |= 1 << ((0x##b) % 32) 168c74be01e80fcdd7feabc0f27df4aebe66abb626eIlia Mirkin#define DNZ_(b) if (i->dnz) code[(0x##b) / 32] |= 1 << ((0x##b) % 32) 1693433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1703433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller#define SAT_(b) if (i->saturate) code[(0x##b) / 32] |= 1 << ((0x##b) % 32) 1713433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1723433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller#define RND_(b, t) emitRoundMode##t(i->rnd, 0x##b) 1733433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1743433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller#define SDATA(a) ((a).rep()->reg.data) 1753433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller#define DDATA(a) ((a).rep()->reg.data) 1763433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1773433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid CodeEmitterGK110::srcId(const ValueRef& src, const int pos) 1783433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 1793433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[pos / 32] |= (src.get() ? SDATA(src).id : GK110_GPR_ZERO) << (pos % 32); 1803433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 1813433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1823433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid CodeEmitterGK110::srcId(const ValueRef *src, const int pos) 1833433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 1843433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[pos / 32] |= (src ? SDATA(*src).id : GK110_GPR_ZERO) << (pos % 32); 1853433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 1863433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1873433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid CodeEmitterGK110::srcId(const Instruction *insn, int s, int pos) 1883433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 1893433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller int r = insn->srcExists(s) ? SDATA(insn->src(s)).id : GK110_GPR_ZERO; 1903433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[pos / 32] |= r << (pos % 32); 1913433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 1923433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1933433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid CodeEmitterGK110::srcAddr32(const ValueRef& src, const int pos) 1943433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 1953433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[pos / 32] |= (SDATA(src).offset >> 2) << (pos % 32); 1963433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 1973433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1983433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid CodeEmitterGK110::defId(const ValueDef& def, const int pos) 1993433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 2003433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[pos / 32] |= (def.get() ? DDATA(def).id : GK110_GPR_ZERO) << (pos % 32); 2013433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 2023433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 2033433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillerbool CodeEmitterGK110::isLIMM(const ValueRef& ref, DataType ty, bool mod) 2043433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 2053433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller const ImmediateValue *imm = ref.get()->asImm(); 2063433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 2073433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller return imm && (imm->reg.data.u32 & ((ty == TYPE_F32) ? 0xfff : 0xfff00000)); 2083433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 2093433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 2103433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 2113433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitRoundMode(RoundMode rnd, const int pos, const int rintPos) 2123433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 2133433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller bool rint = false; 2143433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller uint8_t n; 2153433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 2163433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (rnd) { 2173433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case ROUND_MI: rint = true; /* fall through */ case ROUND_M: n = 1; break; 2183433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case ROUND_PI: rint = true; /* fall through */ case ROUND_P: n = 2; break; 2193433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case ROUND_ZI: rint = true; /* fall through */ case ROUND_Z: n = 3; break; 2203433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 2213433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller rint = rnd == ROUND_NI; 2223433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller n = 0; 2233433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(rnd == ROUND_N || rnd == ROUND_NI); 2243433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 2253433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 2263433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[pos / 32] |= n << (pos % 32); 2273433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (rint && rintPos >= 0) 2283433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[rintPos / 32] |= 1 << (rintPos % 32); 2293433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 2303433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 2313433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 2323433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitRoundModeF(RoundMode rnd, const int pos) 2333433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 2343433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller uint8_t n; 2353433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 2363433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (rnd) { 2373433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case ROUND_M: n = 1; break; 2383433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case ROUND_P: n = 2; break; 2393433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case ROUND_Z: n = 3; break; 2403433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 2413433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller n = 0; 2423433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(rnd == ROUND_N); 2433433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 2443433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 2453433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[pos / 32] |= n << (pos % 32); 2463433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 2473433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 2483433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 2493433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitRoundModeI(RoundMode rnd, const int pos) 2503433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 2513433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller uint8_t n; 2523433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 2533433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (rnd) { 2543433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case ROUND_MI: n = 1; break; 2553433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case ROUND_PI: n = 2; break; 2563433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case ROUND_ZI: n = 3; break; 2573433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 2583433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller n = 0; 2593433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(rnd == ROUND_NI); 2603433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 2613433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 2623433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[pos / 32] |= n << (pos % 32); 2633433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 2643433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 2653433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid CodeEmitterGK110::emitCondCode(CondCode cc, int pos, uint8_t mask) 2663433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 2673433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller uint8_t n; 2683433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 2693433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (cc) { 2703433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_FL: n = 0x00; break; 2713433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_LT: n = 0x01; break; 2723433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_EQ: n = 0x02; break; 2733433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_LE: n = 0x03; break; 2743433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_GT: n = 0x04; break; 2753433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_NE: n = 0x05; break; 2763433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_GE: n = 0x06; break; 2773433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_LTU: n = 0x09; break; 2783433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_EQU: n = 0x0a; break; 2793433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_LEU: n = 0x0b; break; 2803433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_GTU: n = 0x0c; break; 2813433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_NEU: n = 0x0d; break; 2823433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_GEU: n = 0x0e; break; 2833433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_TR: n = 0x0f; break; 2843433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_NO: n = 0x10; break; 2853433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_NC: n = 0x11; break; 2863433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_NS: n = 0x12; break; 2873433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_NA: n = 0x13; break; 2883433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_A: n = 0x14; break; 2893433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_S: n = 0x15; break; 2903433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_C: n = 0x16; break; 2913433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CC_O: n = 0x17; break; 2923433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 2933433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller n = 0; 2943433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(!"invalid condition code"); 2953433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 2963433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 2973433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[pos / 32] |= (n & mask) << (pos % 32); 2983433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 2993433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 3003433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 3013433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitPredicate(const Instruction *i) 3023433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 3033433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->predSrc >= 0) { 3043433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller srcId(i->src(i->predSrc), 18); 3053433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->cc == CC_NOT_P) 3063433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] |= 8 << 18; // negate 3073433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(i->getPredicate()->reg.file == FILE_PREDICATE); 3083433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 3093433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] |= 7 << 18; 3103433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 3113433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 3123433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 3133433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 3143433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::setCAddress14(const ValueRef& src) 3153433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 3167a673187948b38d2d80aa48d9fc09176fa3547e8Ilia Mirkin const Storage& res = src.get()->asSym()->reg; 3177a673187948b38d2d80aa48d9fc09176fa3547e8Ilia Mirkin const int32_t addr = res.data.offset / 4; 3183433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 3193433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] |= (addr & 0x01ff) << 23; 3203433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= (addr & 0x3e00) >> 9; 3217a673187948b38d2d80aa48d9fc09176fa3547e8Ilia Mirkin code[1] |= res.fileIndex << 5; 3223433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 3233433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 3243433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 3253433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::setShortImmediate(const Instruction *i, const int s) 3263433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 3273433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller const uint32_t u32 = i->getSrc(s)->asImm()->reg.data.u32; 3283433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller const uint64_t u64 = i->getSrc(s)->asImm()->reg.data.u64; 3293433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 3303433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->sType == TYPE_F32) { 3313433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(!(u32 & 0x00000fff)); 3323433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] |= ((u32 & 0x001ff000) >> 12) << 23; 3333433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= ((u32 & 0x7fe00000) >> 21); 3343433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= ((u32 & 0x80000000) >> 4); 3353433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else 3363433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->sType == TYPE_F64) { 3373433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(!(u64 & 0x00000fffffffffffULL)); 3383433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] |= ((u64 & 0x001ff00000000000ULL) >> 44) << 23; 3393433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= ((u64 & 0x7fe0000000000000ULL) >> 53); 3403433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= ((u64 & 0x8000000000000000ULL) >> 36); 3413433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 3423433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert((u32 & 0xfff00000) == 0 || (u32 & 0xfff00000) == 0xfff00000); 3433433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] |= (u32 & 0x001ff) << 23; 3443433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= (u32 & 0x7fe00) >> 9; 3453433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= (u32 & 0x80000) << 8; 3463433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 3473433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 3483433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 3493433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 3503433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::setImmediate32(const Instruction *i, const int s, 3513433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller Modifier mod) 3523433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 3533433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller uint32_t u32 = i->getSrc(s)->asImm()->reg.data.u32; 3543433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 3553433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (mod) { 3563433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller ImmediateValue imm(i->getSrc(s)->asImm(), i->sType); 3573433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller mod.applyTo(imm); 3583433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller u32 = imm.reg.data.u32; 3593433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 3603433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 3613433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] |= u32 << 23; 3623433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= u32 >> 9; 3633433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 3643433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 3653433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 3663433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitForm_L(const Instruction *i, uint32_t opc, uint8_t ctg, 3673433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller Modifier mod) 3683433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 3693433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] = ctg; 3703433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] = opc << 20; 3713433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 3723433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitPredicate(i); 3733433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 3743433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller defId(i->def(0), 2); 3753433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 3763433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller for (int s = 0; s < 3 && i->srcExists(s); ++s) { 3773433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (i->src(s).getFile()) { 3783433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case FILE_GPR: 3793433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller srcId(i->src(s), s ? 42 : 10); 3803433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 3813433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case FILE_IMMEDIATE: 3823433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller setImmediate32(i, s, mod); 3833433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 3843433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 3853433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 3863433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 3873433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 3883433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 3893433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 3903433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 3913433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 3923433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitForm_C(const Instruction *i, uint32_t opc, uint8_t ctg) 3933433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 3943433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] = ctg; 3953433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] = opc << 20; 3963433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 3973433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitPredicate(i); 3983433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 3993433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller defId(i->def(0), 2); 4003433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 4013433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (i->src(0).getFile()) { 4023433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case FILE_MEMORY_CONST: 4033433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= 0x4 << 28; 4043433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller setCAddress14(i->src(0)); 4053433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 4063433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case FILE_GPR: 4073433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= 0xc << 28; 4083433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller srcId(i->src(0), 23); 4093433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 4103433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 4113433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(0); 4123433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 4133433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 4143433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 4153433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 4163433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller// 0x2 for GPR, c[] and 0x1 for short immediate 4173433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 4183433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitForm_21(const Instruction *i, uint32_t opc2, 4193433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller uint32_t opc1) 4203433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 4213433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller const bool imm = i->srcExists(1) && i->src(1).getFile() == FILE_IMMEDIATE; 4223433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 4233433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller int s1 = 23; 4243433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->srcExists(2) && i->src(2).getFile() == FILE_MEMORY_CONST) 4253433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller s1 = 42; 4263433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 4273433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (imm) { 4283433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] = 0x1; 4293433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] = opc1 << 20; 4303433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 4313433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] = 0x2; 4323433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] = (0xc << 28) | (opc2 << 20); 4333433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 4343433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 4353433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitPredicate(i); 4363433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 4373433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller defId(i->def(0), 2); 4383433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 4393433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller for (int s = 0; s < 3 && i->srcExists(s); ++s) { 4403433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (i->src(s).getFile()) { 4413433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case FILE_MEMORY_CONST: 4423433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] &= (s == 2) ? ~(0x4 << 28) : ~(0x8 << 28); 4433433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller setCAddress14(i->src(s)); 4443433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 4453433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case FILE_IMMEDIATE: 4463433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller setShortImmediate(i, s); 4473433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 4483433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case FILE_GPR: 4493433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller srcId(i->src(s), s ? ((s == 2) ? 42 : s1) : 10); 4503433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 4513433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 452e0371e63df173be38a086a5d816eeaf0e8cbe7ebSamuel Pitoiset if (i->op == OP_SELP) { 453e0371e63df173be38a086a5d816eeaf0e8cbe7ebSamuel Pitoiset assert(s == 2 && i->src(s).getFile() == FILE_PREDICATE); 454e0371e63df173be38a086a5d816eeaf0e8cbe7ebSamuel Pitoiset srcId(i->src(s), 42); 455e0371e63df173be38a086a5d816eeaf0e8cbe7ebSamuel Pitoiset } 4563433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller // ignore here, can be predicate or flags, but must not be address 4573433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 4583433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 4593433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 4603433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller // 0x0 = invalid 4613433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller // 0xc = rrr 4623433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller // 0x8 = rrc 4633433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller // 0x4 = rcr 4643433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(imm || (code[1] & (0xc << 28))); 4653433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 4663433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 4673433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillerinline void 4683433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::modNegAbsF32_3b(const Instruction *i, const int s) 4693433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 4703433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->src(s).mod.abs()) code[1] &= ~(1 << 27); 4713433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->src(s).mod.neg()) code[1] ^= (1 << 27); 4723433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 4733433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 4743433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 4753433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitNOP(const Instruction *i) 4763433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 4773433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] = 0x00003c02; 4783433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] = 0x85800000; 4793433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 4803433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i) 4813433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitPredicate(i); 4823433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller else 4833433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] = 0x001c3c02; 4843433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 4853433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 4863433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 4873433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitFMAD(const Instruction *i) 4883433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 4893433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(!isLIMM(i->src(1), TYPE_F32)); 4903433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 4913433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitForm_21(i, 0x0c0, 0x940); 4923433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 4933433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller NEG_(34, 2); 4943433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller SAT_(35); 4953433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller RND_(36, F); 4963433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller FTZ_(38); 497c74be01e80fcdd7feabc0f27df4aebe66abb626eIlia Mirkin DNZ_(39); 4983433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 4993433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller bool neg1 = (i->src(0).mod ^ i->src(1).mod).neg(); 5003433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 5013433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (code[0] & 0x1) { 5023433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (neg1) 5033433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] ^= 1 << 27; 5043433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else 5053433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (neg1) { 5063433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= 1 << 19; 5073433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 5083433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 5093433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 5103433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 511493ad88e1b6598e3827546854b0c8336b42b36a2Ilia MirkinCodeEmitterGK110::emitDMAD(const Instruction *i) 512493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin{ 513493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin assert(!i->saturate); 514493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin assert(!i->ftz); 515493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin 516493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin emitForm_21(i, 0x1b8, 0xb38); 517493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin 518493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin NEG_(34, 2); 519493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin RND_(36, F); 520493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin 521493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin bool neg1 = (i->src(0).mod ^ i->src(1).mod).neg(); 522493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin 523493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin if (code[0] & 0x1) { 524493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin if (neg1) 525493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin code[1] ^= 1 << 27; 526493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin } else 527493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin if (neg1) { 528493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin code[1] |= 1 << 19; 529493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin } 530493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin} 531493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin 532493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkinvoid 533fddd8523d48f456d3fd614179ecd66e46625c774Samuel PitoisetCodeEmitterGK110::emitMADSP(const Instruction *i) 534fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset{ 535fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset emitForm_21(i, 0x140, 0xa40); 536fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset 537fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset if (i->subOp == NV50_IR_SUBOP_MADSP_SD) { 538fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset code[1] |= 0x00c00000; 539fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset } else { 540fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset code[1] |= (i->subOp & 0x00f) << 19; // imadp1 541fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset code[1] |= (i->subOp & 0x0f0) << 20; // imadp2 542fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset code[1] |= (i->subOp & 0x100) << 11; // imadp3 543fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset code[1] |= (i->subOp & 0x200) << 15; // imadp3 544fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset code[1] |= (i->subOp & 0xc00) << 12; // imadp3 545fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset } 546fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset 547fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset if (i->flagsDef >= 0) 548fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset code[1] |= 1 << 18; 549fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset} 550fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset 551fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoisetvoid 5523433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitFMUL(const Instruction *i) 5533433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 5543433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller bool neg = (i->src(0).mod ^ i->src(1).mod).neg(); 5553433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 5563433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(i->postFactor >= -3 && i->postFactor <= 3); 5573433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 5583433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (isLIMM(i->src(1), TYPE_F32)) { 5593433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitForm_L(i, 0x200, 0x2, Modifier(0)); 5603433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 5613433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller FTZ_(38); 562c74be01e80fcdd7feabc0f27df4aebe66abb626eIlia Mirkin DNZ_(39); 5633433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller SAT_(3a); 5643433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (neg) 5653433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] ^= 1 << 22; 5663433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 5673433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(i->postFactor == 0); 5683433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 5693433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitForm_21(i, 0x234, 0xc34); 570c8309cde30fe6829ed5d2eedbda2bd4dbde79418Ilia Mirkin code[1] |= ((i->postFactor > 0) ? 571c8309cde30fe6829ed5d2eedbda2bd4dbde79418Ilia Mirkin (7 - i->postFactor) : (0 - i->postFactor)) << 12; 5723433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 5733433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller RND_(2a, F); 5743433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller FTZ_(2f); 575c74be01e80fcdd7feabc0f27df4aebe66abb626eIlia Mirkin DNZ_(30); 5763433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller SAT_(35); 5773433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 5783433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (code[0] & 0x1) { 5793433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (neg) 5803433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] ^= 1 << 27; 5813433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else 5823433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (neg) { 5833433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= 1 << 19; 5843433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 5853433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 5863433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 5873433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 5883433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 589493ad88e1b6598e3827546854b0c8336b42b36a2Ilia MirkinCodeEmitterGK110::emitDMUL(const Instruction *i) 590493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin{ 591493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin bool neg = (i->src(0).mod ^ i->src(1).mod).neg(); 592493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin 593493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin assert(!i->postFactor); 594493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin assert(!i->saturate); 595493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin assert(!i->ftz); 596493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin assert(!i->dnz); 597493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin 598493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin emitForm_21(i, 0x240, 0xc40); 599493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin 600493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin RND_(2a, F); 601493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin 602493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin if (code[0] & 0x1) { 603493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin if (neg) 604493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin code[1] ^= 1 << 27; 605493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin } else 606493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin if (neg) { 607493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin code[1] |= 1 << 19; 608493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin } 609493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin} 610493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin 611493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkinvoid 6123433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitIMUL(const Instruction *i) 6133433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 6143433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(!i->src(0).mod.neg() && !i->src(1).mod.neg()); 6153433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(!i->src(0).mod.abs() && !i->src(1).mod.abs()); 6163433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 617d30768025a2283d4cc57930b784798bf278969daSamuel Pitoiset if (i->src(1).getFile() == FILE_IMMEDIATE) { 6183433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitForm_L(i, 0x280, 2, Modifier(0)); 6193433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 620db072d20867426958153279575dfdc2049b5f595Ilia Mirkin if (i->subOp == NV50_IR_SUBOP_MUL_HIGH) 621db072d20867426958153279575dfdc2049b5f595Ilia Mirkin code[1] |= 1 << 24; 6223433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->sType == TYPE_S32) 6233433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= 3 << 25; 6243433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 6253433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitForm_21(i, 0x21c, 0xc1c); 6263433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 6273433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->subOp == NV50_IR_SUBOP_MUL_HIGH) 6283433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= 1 << 10; 6293433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->sType == TYPE_S32) 6303433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= 3 << 11; 6313433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 6323433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 6333433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 6343433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 6353433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitFADD(const Instruction *i) 6363433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 6373433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (isLIMM(i->src(1), TYPE_F32)) { 6383433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(i->rnd == ROUND_N); 6393433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(!i->saturate); 6403433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 6413c40be2615872b9f9c95f6b551b37498561273d2Ilia Mirkin Modifier mod = i->src(1).mod ^ 6423c40be2615872b9f9c95f6b551b37498561273d2Ilia Mirkin Modifier(i->op == OP_SUB ? NV50_IR_MOD_NEG : 0); 6433c40be2615872b9f9c95f6b551b37498561273d2Ilia Mirkin 6443c40be2615872b9f9c95f6b551b37498561273d2Ilia Mirkin emitForm_L(i, 0x400, 0, mod); 6453433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 6463433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller FTZ_(3a); 6473433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller NEG_(3b, 0); 6483433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller ABS_(39, 0); 6493433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 6503433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitForm_21(i, 0x22c, 0xc2c); 6513433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 6523433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller FTZ_(2f); 6533433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller RND_(2a, F); 6543433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller ABS_(31, 0); 6553433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller NEG_(33, 0); 6564a3a71a183eba60539ca3c556938344bcf180d70Ilia Mirkin SAT_(35); 6573433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 6583433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (code[0] & 0x1) { 6593433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller modNegAbsF32_3b(i, 1); 6603c40be2615872b9f9c95f6b551b37498561273d2Ilia Mirkin if (i->op == OP_SUB) code[1] ^= 1 << 27; 6613433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 6623433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller ABS_(34, 1); 6633433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller NEG_(30, 1); 6643c40be2615872b9f9c95f6b551b37498561273d2Ilia Mirkin if (i->op == OP_SUB) code[1] ^= 1 << 16; 6653433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 6663433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 6673433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 6683433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 6693433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 670493ad88e1b6598e3827546854b0c8336b42b36a2Ilia MirkinCodeEmitterGK110::emitDADD(const Instruction *i) 671493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin{ 672493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin assert(!i->saturate); 673493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin assert(!i->ftz); 674493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin 675493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin emitForm_21(i, 0x238, 0xc38); 676493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin RND_(2a, F); 677493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin ABS_(31, 0); 678493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin NEG_(33, 0); 679493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin if (code[0] & 0x1) { 680493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin modNegAbsF32_3b(i, 1); 681493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin if (i->op == OP_SUB) code[1] ^= 1 << 27; 682493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin } else { 683493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin NEG_(30, 1); 684493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin ABS_(34, 1); 685493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin if (i->op == OP_SUB) code[1] ^= 1 << 16; 686493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin } 687493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin} 688493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin 689493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkinvoid 6903433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitUADD(const Instruction *i) 6913433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 6923433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller uint8_t addOp = (i->src(0).mod.neg() << 1) | i->src(1).mod.neg(); 6933433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 6943433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->op == OP_SUB) 6953433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller addOp ^= 1; 6963433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 6973433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(!i->src(0).mod.abs() && !i->src(1).mod.abs()); 6983433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 6993433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (isLIMM(i->src(1), TYPE_S32)) { 7003433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitForm_L(i, 0x400, 1, Modifier((addOp & 1) ? NV50_IR_MOD_NEG : 0)); 7013433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 7023433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (addOp & 2) 7033433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= 1 << 27; 7043433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 7053433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(!i->defExists(1)); 7063433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(i->flagsSrc < 0); 7073433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 7083433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller SAT_(39); 7093433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 7103433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitForm_21(i, 0x208, 0xc08); 7113433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 7123433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(addOp != 3); // would be add-plus-one 7133433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 7143433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= addOp << 19; 7153433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 7163433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->defExists(1)) 7173433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= 1 << 18; // write carry 7183433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->flagsSrc >= 0) 7193433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= 1 << 14; // add carry 7203433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 7213433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller SAT_(35); 7223433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 7233433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 7243433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 7253433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 7263433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitIMAD(const Instruction *i) 7273433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 7283433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller uint8_t addOp = 72984e946380b2d5ddc62a107b667be39abf1932704Samuel Pitoiset i->src(2).mod.neg() | ((i->src(0).mod.neg() ^ i->src(1).mod.neg()) << 1); 7303433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 7313433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitForm_21(i, 0x100, 0xa00); 7323433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 7333433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(addOp != 3); 7343433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= addOp << 26; 7353433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 7363433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->sType == TYPE_S32) 7373433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= (1 << 19) | (1 << 24); 7383433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 7391d708aacb7631833b0f04e704481854428f60ba3Ilia Mirkin if (i->subOp == NV50_IR_SUBOP_MUL_HIGH) 7401d708aacb7631833b0f04e704481854428f60ba3Ilia Mirkin code[1] |= 1 << 25; 741c0b66d96d77b646282f7e732c4c25761431336c3Ilia Mirkin 742c0b66d96d77b646282f7e732c4c25761431336c3Ilia Mirkin if (i->flagsDef >= 0) code[1] |= 1 << 18; 743c0b66d96d77b646282f7e732c4c25761431336c3Ilia Mirkin if (i->flagsSrc >= 0) code[1] |= 1 << 20; 744c0b66d96d77b646282f7e732c4c25761431336c3Ilia Mirkin 7451d708aacb7631833b0f04e704481854428f60ba3Ilia Mirkin SAT_(35); 7463433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 7473433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 7483433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 7493433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitISAD(const Instruction *i) 7503433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 7513433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(i->dType == TYPE_S32 || i->dType == TYPE_U32); 7523433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 753ed1b9e5721f6c7a74e042eadb31fc5dcb2fc3552Ilia Mirkin emitForm_21(i, 0x1f4, 0xb74); 7543433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 7553433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->dType == TYPE_S32) 7563433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= 1 << 19; 7573433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 7583433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 7593433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 76031545b64b80aa939a693723e07f06fe45160ae62Samuel PitoisetCodeEmitterGK110::emitSHLADD(const Instruction *i) 76131545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset{ 7621ec7227d44dceae8de7b93f846bbd33d66007909Samuel Pitoiset uint8_t addOp = (i->src(0).mod.neg() << 1) | i->src(2).mod.neg(); 76331545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset const ImmediateValue *imm = i->src(1).get()->asImm(); 76431545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset assert(imm); 76531545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset 76631545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset if (i->src(2).getFile() == FILE_IMMEDIATE) { 76731545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset code[0] = 0x1; 76831545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset code[1] = 0xc0c << 20; 76931545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset } else { 77031545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset code[0] = 0x2; 77131545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset code[1] = 0x20c << 20; 77231545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset } 77331545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset code[1] |= addOp << 19; 77431545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset 77531545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset emitPredicate(i); 77631545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset 77731545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset defId(i->def(0), 2); 77831545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset srcId(i->src(0), 10); 77931545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset 78031545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset if (i->flagsDef >= 0) 78131545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset code[1] |= 1 << 18; 78231545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset 78331545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset assert(!(imm->reg.data.u32 & 0xffffffe0)); 78431545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset code[1] |= imm->reg.data.u32 << 10; 78531545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset 78631545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset switch (i->src(2).getFile()) { 78731545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset case FILE_GPR: 78831545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset assert(code[0] & 0x2); 78931545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset code[1] |= 0xc << 28; 79031545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset srcId(i->src(2), 23); 79131545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset break; 79231545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset case FILE_MEMORY_CONST: 79331545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset assert(code[0] & 0x2); 79431545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset code[1] |= 0x4 << 28; 79531545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset setCAddress14(i->src(2)); 79631545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset break; 79731545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset case FILE_IMMEDIATE: 79831545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset assert(code[0] & 0x1); 79931545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset setShortImmediate(i, 2); 80031545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset break; 80131545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset default: 80231545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset assert(!"bad src2 file"); 80331545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset break; 80431545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset } 80531545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset} 80631545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset 80731545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoisetvoid 8083433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitNOT(const Instruction *i) 8093433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 8103433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] = 0x0003fc02; // logop(mov2) dst, 0, not src 8113433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] = 0x22003800; 8123433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 8133433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitPredicate(i); 8143433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 8153433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller defId(i->def(0), 2); 8163433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 8173433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (i->src(0).getFile()) { 8183433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case FILE_GPR: 8193433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= 0xc << 28; 8203433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller srcId(i->src(0), 23); 8213433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 8223433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case FILE_MEMORY_CONST: 8233433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= 0x4 << 28; 824d8b4f5fcca2ce299b8ef248b6f57896c7b85d18cSamuel Pitoiset setCAddress14(i->src(0)); 8253433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 8263433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 8273433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(0); 8283433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 8293433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 8303433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 8313433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 8323433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 8333433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitLogicOp(const Instruction *i, uint8_t subOp) 8343433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 835c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset if (i->def(0).getFile() == FILE_PREDICATE) { 836c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset code[0] = 0x00000002 | (subOp << 27); 837c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset code[1] = 0x84800000; 838c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset 839c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset emitPredicate(i); 840c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset 841c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset defId(i->def(0), 5); 842c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset srcId(i->src(0), 14); 843c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset if (i->src(0).mod == Modifier(NV50_IR_MOD_NOT)) code[0] |= 1 << 17; 844c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset srcId(i->src(1), 32); 845c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset if (i->src(1).mod == Modifier(NV50_IR_MOD_NOT)) code[1] |= 1 << 3; 846c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset 847c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset if (i->defExists(1)) { 848c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset defId(i->def(1), 2); 849c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset } else { 850c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset code[0] |= 7 << 2; 851c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset } 852c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset // (a OP b) OP c 853c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset if (i->predSrc != 2 && i->srcExists(2)) { 854c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset code[1] |= subOp << 16; 855c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset srcId(i->src(2), 42); 856c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset if (i->src(2).mod == Modifier(NV50_IR_MOD_NOT)) code[1] |= 1 << 13; 857c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset } else { 858c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset code[1] |= 7 << 10; 859c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset } 860c62b1b92f7da2563511581a2a74048334585da27Samuel Pitoiset } else 8613433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (isLIMM(i->src(1), TYPE_S32)) { 8623433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitForm_L(i, 0x200, 0, i->src(1).mod); 8633433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= subOp << 24; 864d8e0d1e882e40b0da0237ef6e9b4ef21b7a3b3bfIlia Mirkin NOT_(3a, 0); 8653433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 8663433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitForm_21(i, 0x220, 0xc20); 8673433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= subOp << 12; 868d8e0d1e882e40b0da0237ef6e9b4ef21b7a3b3bfIlia Mirkin NOT_(2a, 0); 8693433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller NOT_(2b, 1); 8703433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 8713433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 8723433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 8733433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 8743433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitPOPC(const Instruction *i) 8753433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 8763433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(!isLIMM(i->src(1), TYPE_S32, true)); 8773433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 8783433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitForm_21(i, 0x204, 0xc04); 8793433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 8803433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller NOT_(2a, 0); 8813433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (!(code[0] & 0x1)) 8823433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller NOT_(2b, 1); 8833433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 8843433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 8853433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 8863433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitINSBF(const Instruction *i) 8873433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 8883433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitForm_21(i, 0x1f8, 0xb78); 8893433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 8903433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 8913433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 892b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia MirkinCodeEmitterGK110::emitEXTBF(const Instruction *i) 893b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin{ 894b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin emitForm_21(i, 0x600, 0xc00); 895b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin 896b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin if (i->dType == TYPE_S32) 897b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin code[1] |= 0x80000; 898b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin if (i->subOp == NV50_IR_SUBOP_EXTBF_REV) 899b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin code[1] |= 0x800; 900b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin} 901b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin 902b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkinvoid 903b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia MirkinCodeEmitterGK110::emitBFIND(const Instruction *i) 904b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin{ 905bd7dd3ed06ea9e88a9f6e18f45338bd99fde86f1Ilia Mirkin emitForm_C(i, 0x218, 0x2); 906b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin 907b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin if (i->dType == TYPE_S32) 908b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin code[1] |= 0x80000; 909b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin if (i->src(0).mod == Modifier(NV50_IR_MOD_NOT)) 910b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin code[1] |= 0x800; 911b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin if (i->subOp == NV50_IR_SUBOP_BFIND_SAMT) 912b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin code[1] |= 0x1000; 913b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin} 914b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin 915b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkinvoid 916c2ce22ca4641343e9bad446811a882c5c3930419Samuel PitoisetCodeEmitterGK110::emitPERMT(const Instruction *i) 917c2ce22ca4641343e9bad446811a882c5c3930419Samuel Pitoiset{ 918c2ce22ca4641343e9bad446811a882c5c3930419Samuel Pitoiset emitForm_21(i, 0x1e0, 0xb60); 919c2ce22ca4641343e9bad446811a882c5c3930419Samuel Pitoiset 920c2ce22ca4641343e9bad446811a882c5c3930419Samuel Pitoiset code[1] |= i->subOp << 19; 921c2ce22ca4641343e9bad446811a882c5c3930419Samuel Pitoiset} 922c2ce22ca4641343e9bad446811a882c5c3930419Samuel Pitoiset 923c2ce22ca4641343e9bad446811a882c5c3930419Samuel Pitoisetvoid 9243433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitShift(const Instruction *i) 9253433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 9263433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->op == OP_SHR) { 927b56e50b8afbb386bcf30f9a4f07981a123dba1c1Ilia Mirkin emitForm_21(i, 0x214, 0xc14); 928b56e50b8afbb386bcf30f9a4f07981a123dba1c1Ilia Mirkin if (isSignedType(i->dType)) 929b56e50b8afbb386bcf30f9a4f07981a123dba1c1Ilia Mirkin code[1] |= 1 << 19; 9303433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 931b56e50b8afbb386bcf30f9a4f07981a123dba1c1Ilia Mirkin emitForm_21(i, 0x224, 0xc24); 9323433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 9333433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 934b56e50b8afbb386bcf30f9a4f07981a123dba1c1Ilia Mirkin if (i->subOp == NV50_IR_SUBOP_SHIFT_WRAP) 935b56e50b8afbb386bcf30f9a4f07981a123dba1c1Ilia Mirkin code[1] |= 1 << 10; 9363433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 9373433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 9383433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 9393433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitPreOp(const Instruction *i) 9403433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 94172310869f02edce3d2b896659b45e2f882e05bbfIlia Mirkin emitForm_C(i, 0x248, 0x2); 9423433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 9433433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->op == OP_PREEX2) 9443433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= 1 << 10; 9453433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 9463433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller NEG_(30, 0); 9473433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller ABS_(34, 0); 9483433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 9493433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 9503433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 9513433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitSFnOp(const Instruction *i, uint8_t subOp) 9523433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 9533433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] = 0x00000002 | (subOp << 23); 9543433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] = 0x84000000; 9553433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 9563433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitPredicate(i); 9573433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 9583433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller defId(i->def(0), 2); 9593433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller srcId(i->src(0), 10); 9603433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 9613433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller NEG_(33, 0); 9623433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller ABS_(31, 0); 963ce75a3e8d36e85214e98194ca212504282df47f9Ilia Mirkin SAT_(35); 9643433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 9653433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 9663433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 9673433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitMINMAX(const Instruction *i) 9683433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 9693433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller uint32_t op2, op1; 9703433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 9713433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (i->dType) { 9723433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case TYPE_U32: 9733433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case TYPE_S32: 9743433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller op2 = 0x210; 9753433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller op1 = 0xc10; 9763433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 9773433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case TYPE_F32: 9783433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller op2 = 0x230; 9793433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller op1 = 0xc30; 9803433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 9813433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case TYPE_F64: 9823433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller op2 = 0x228; 9833433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller op1 = 0xc28; 9843433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 9853433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 9863433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(0); 9873433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller op2 = 0; 9883433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller op1 = 0; 9893433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 9903433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 9913433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitForm_21(i, op2, op1); 9923433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 9933433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->dType == TYPE_S32) 9943433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= 1 << 19; 9953433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= (i->op == OP_MIN) ? 0x1c00 : 0x3c00; // [!]pt 9963433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 9973433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller FTZ_(2f); 9983433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller ABS_(31, 0); 9993433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller NEG_(33, 0); 10003433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (code[0] & 0x1) { 10013433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller modNegAbsF32_3b(i, 1); 10023433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 10033433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller ABS_(34, 1); 10043433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller NEG_(30, 1); 10053433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 10063433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 10073433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 10083433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 10093433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitCVT(const Instruction *i) 10103433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 10113433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller const bool f2f = isFloatType(i->dType) && isFloatType(i->sType); 10123433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller const bool f2i = !isFloatType(i->dType) && isFloatType(i->sType); 10133433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller const bool i2f = isFloatType(i->dType) && !isFloatType(i->sType); 10143433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 10153433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller bool sat = i->saturate; 10163433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller bool abs = i->src(0).mod.abs(); 10173433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller bool neg = i->src(0).mod.neg(); 10183433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 10193433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller RoundMode rnd = i->rnd; 10203433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 10213433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (i->op) { 10223433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_CEIL: rnd = f2f ? ROUND_PI : ROUND_P; break; 10233433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_FLOOR: rnd = f2f ? ROUND_MI : ROUND_M; break; 10243433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_TRUNC: rnd = f2f ? ROUND_ZI : ROUND_Z; break; 10253433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_SAT: sat = true; break; 10263433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_NEG: neg = !neg; break; 10273433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_ABS: abs = true; neg = false; break; 10283433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 10293433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 10303433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 10313433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 103218d97a8df776863c89c52294055160a17fc0f9e6Ilia Mirkin DataType dType; 103318d97a8df776863c89c52294055160a17fc0f9e6Ilia Mirkin 103418d97a8df776863c89c52294055160a17fc0f9e6Ilia Mirkin if (i->op == OP_NEG && i->dType == TYPE_U32) 103518d97a8df776863c89c52294055160a17fc0f9e6Ilia Mirkin dType = TYPE_S32; 103618d97a8df776863c89c52294055160a17fc0f9e6Ilia Mirkin else 103718d97a8df776863c89c52294055160a17fc0f9e6Ilia Mirkin dType = i->dType; 103818d97a8df776863c89c52294055160a17fc0f9e6Ilia Mirkin 103918d97a8df776863c89c52294055160a17fc0f9e6Ilia Mirkin 10403433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller uint32_t op; 10413433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 10423433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (f2f) op = 0x254; 10433433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller else if (f2i) op = 0x258; 10443433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller else if (i2f) op = 0x25c; 10453433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller else op = 0x260; 10463433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 10473433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitForm_C(i, op, 0x2); 10483433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 10493433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller FTZ_(2f); 10503433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (neg) code[1] |= 1 << 16; 10513433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (abs) code[1] |= 1 << 20; 10523433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (sat) code[1] |= 1 << 21; 10533433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 10543433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitRoundMode(rnd, 32 + 10, f2f ? (32 + 13) : -1); 10553433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 105618d97a8df776863c89c52294055160a17fc0f9e6Ilia Mirkin code[0] |= typeSizeofLog2(dType) << 10; 10573433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] |= typeSizeofLog2(i->sType) << 12; 105863cb85e567ad1025ee990b38f43c2f1ef811821bIlia Mirkin code[1] |= i->subOp << 12; 10593433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 106018d97a8df776863c89c52294055160a17fc0f9e6Ilia Mirkin if (isSignedIntType(dType)) 10613433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] |= 0x4000; 10623433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (isSignedIntType(i->sType)) 10633433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] |= 0x8000; 10643433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 10653433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 10663433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 10673433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitSET(const CmpInstruction *i) 10683433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 10693433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller uint16_t op1, op2; 10703433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 10713433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->def(0).getFile() == FILE_PREDICATE) { 10723433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (i->sType) { 10733433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case TYPE_F32: op2 = 0x1d8; op1 = 0xb58; break; 10743433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case TYPE_F64: op2 = 0x1c0; op1 = 0xb40; break; 10753433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 10763433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller op2 = 0x1b0; 10773433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller op1 = 0xb30; 10783433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 10793433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 10803433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitForm_21(i, op2, op1); 10813433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 10823433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller NEG_(2e, 0); 10833433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller ABS_(9, 0); 10843433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (!(code[0] & 0x1)) { 10853433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller NEG_(8, 1); 10863433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller ABS_(2f, 1); 10873433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 10883433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller modNegAbsF32_3b(i, 1); 10893433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 10903433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller FTZ_(32); 10913433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 10923433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller // normal DST field is negated predicate result 10933433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] = (code[0] & ~0xfc) | ((code[0] << 3) & 0xe0); 10943433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->defExists(1)) 10953433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller defId(i->def(1), 2); 1096e5ad19a46e87ed22943d7f6ad046f974fd5977e1Ilia Mirkin else 1097e5ad19a46e87ed22943d7f6ad046f974fd5977e1Ilia Mirkin code[0] |= 0x1c; 10983433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 10993433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (i->sType) { 1100515ac907e68ae1485bd9c65d7351dfb3c3d1e33fIlia Mirkin case TYPE_F32: op2 = 0x000; op1 = 0x800; break; 11013433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case TYPE_F64: op2 = 0x080; op1 = 0x900; break; 11023433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 11033433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller op2 = 0x1a8; 11043433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller op1 = 0xb28; 11053433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 11063433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 11073433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitForm_21(i, op2, op1); 11083433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 11093433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller NEG_(2e, 0); 11103433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller ABS_(39, 0); 11113433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (!(code[0] & 0x1)) { 11123433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller NEG_(38, 1); 11133433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller ABS_(2f, 1); 11143433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 11153433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller modNegAbsF32_3b(i, 1); 11163433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 11173433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller FTZ_(3a); 1118e7047f2917c6bcc714fc6a350ea74e45b0760a77Ilia Mirkin 1119e5ad19a46e87ed22943d7f6ad046f974fd5977e1Ilia Mirkin if (i->dType == TYPE_F32) { 1120e5ad19a46e87ed22943d7f6ad046f974fd5977e1Ilia Mirkin if (isFloatType(i->sType)) 1121e5ad19a46e87ed22943d7f6ad046f974fd5977e1Ilia Mirkin code[1] |= 1 << 23; 1122e5ad19a46e87ed22943d7f6ad046f974fd5977e1Ilia Mirkin else 1123e5ad19a46e87ed22943d7f6ad046f974fd5977e1Ilia Mirkin code[1] |= 1 << 15; 1124e5ad19a46e87ed22943d7f6ad046f974fd5977e1Ilia Mirkin } 11253433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 11263433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->sType == TYPE_S32) 11273433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= 1 << 19; 11283433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 11293433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->op != OP_SET) { 11303433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (i->op) { 11313433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_SET_AND: code[1] |= 0x0 << 16; break; 11323433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_SET_OR: code[1] |= 0x1 << 16; break; 11333433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_SET_XOR: code[1] |= 0x2 << 16; break; 11343433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 11353433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(0); 11363433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 11373433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 11383433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller srcId(i->src(2), 0x2a); 11393433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 11403433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= 0x7 << 10; 11413433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 11423433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitCondCode(i->setCond, 11433433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller isFloatType(i->sType) ? 0x33 : 0x34, 11443433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller isFloatType(i->sType) ? 0xf : 0x7); 11453433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 11463433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 11473433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 11483433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitSLCT(const CmpInstruction *i) 11493433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 11503433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller CondCode cc = i->setCond; 11513433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->src(2).mod.neg()) 11523433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller cc = reverseCondCode(cc); 11533433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 11543433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->dType == TYPE_F32) { 11553433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitForm_21(i, 0x1d0, 0xb50); 11563433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller FTZ_(32); 11573433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitCondCode(cc, 0x33, 0xf); 11583433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 11599fef8b3d811000146b989a101ad0e26ae6530fe4Ilia Mirkin emitForm_21(i, 0x1a0, 0xb20); 11603433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitCondCode(cc, 0x34, 0x7); 11613433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 11623433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 11633433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1164ba3f0b6d5920165c735d51500544da8c29b09060Ilia Mirkinstatic void 1165ba3f0b6d5920165c735d51500544da8c29b09060Ilia MirkinselpFlip(const FixupEntry *entry, uint32_t *code, const FixupData& data) 1166ba3f0b6d5920165c735d51500544da8c29b09060Ilia Mirkin{ 1167ba3f0b6d5920165c735d51500544da8c29b09060Ilia Mirkin int loc = entry->loc; 1168ba3f0b6d5920165c735d51500544da8c29b09060Ilia Mirkin if (data.force_persample_interp) 1169ba3f0b6d5920165c735d51500544da8c29b09060Ilia Mirkin code[loc + 1] |= 1 << 13; 1170ba3f0b6d5920165c735d51500544da8c29b09060Ilia Mirkin else 1171ba3f0b6d5920165c735d51500544da8c29b09060Ilia Mirkin code[loc + 1] &= ~(1 << 13); 1172ba3f0b6d5920165c735d51500544da8c29b09060Ilia Mirkin} 1173ba3f0b6d5920165c735d51500544da8c29b09060Ilia Mirkin 11746526225f888a08b301e8c39ec70b4e739081e490Samuel Pitoisetvoid CodeEmitterGK110::emitSELP(const Instruction *i) 11753433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 11763433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitForm_21(i, 0x250, 0x050); 11773433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 11786526225f888a08b301e8c39ec70b4e739081e490Samuel Pitoiset if (i->src(2).mod & Modifier(NV50_IR_MOD_NOT)) 11793433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= 1 << 13; 1180ba3f0b6d5920165c735d51500544da8c29b09060Ilia Mirkin 1181ba3f0b6d5920165c735d51500544da8c29b09060Ilia Mirkin if (i->subOp == 1) { 1182ba3f0b6d5920165c735d51500544da8c29b09060Ilia Mirkin addInterp(0, 0, selpFlip); 1183ba3f0b6d5920165c735d51500544da8c29b09060Ilia Mirkin } 11843433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 11853433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 11863433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid CodeEmitterGK110::emitTEXBAR(const Instruction *i) 11873433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 118873eec47ef81954f7c2bf7c8bf03b300d11d05b82Ilia Mirkin code[0] = 0x0000003e | (i->subOp << 23); 11893433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] = 0x77000000; 11903433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 11913433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitPredicate(i); 11923433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 11933433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 11943433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid CodeEmitterGK110::emitTEXCSAA(const TexInstruction *i) 11953433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 119608505549ab938a6650024aab68f7713989c5c6feIlia Mirkin code[0] = 0x00000002; 119708505549ab938a6650024aab68f7713989c5c6feIlia Mirkin code[1] = 0x76c00000; 119808505549ab938a6650024aab68f7713989c5c6feIlia Mirkin 1199ece734b3c195c870bbda342edf1807ca436bf83aIlia Mirkin code[1] |= i->tex.r << 9; 120008505549ab938a6650024aab68f7713989c5c6feIlia Mirkin // code[1] |= i->tex.s << (9 + 8); 120108505549ab938a6650024aab68f7713989c5c6feIlia Mirkin 120208505549ab938a6650024aab68f7713989c5c6feIlia Mirkin if (i->tex.liveOnly) 120308505549ab938a6650024aab68f7713989c5c6feIlia Mirkin code[0] |= 0x80000000; 120408505549ab938a6650024aab68f7713989c5c6feIlia Mirkin 120508505549ab938a6650024aab68f7713989c5c6feIlia Mirkin defId(i->def(0), 2); 120608505549ab938a6650024aab68f7713989c5c6feIlia Mirkin srcId(i->src(0), 10); 12073433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 12083433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 12093433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillerstatic inline bool 12103433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerisNextIndependentTex(const TexInstruction *i) 12113433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 12123433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (!i->next || !isTextureOp(i->next->op)) 12133433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller return false; 12143433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->getDef(0)->interfers(i->next->getSrc(0))) 12153433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller return false; 12163433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller return !i->next->srcExists(1) || !i->getDef(0)->interfers(i->next->getSrc(1)); 12173433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 12183433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 12193433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 12203433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitTEX(const TexInstruction *i) 12213433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 12223433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller const bool ind = i->tex.rIndirectSrc >= 0; 12233433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 12243433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (ind) { 12253433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] = 0x00000002; 12263433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (i->op) { 12273433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_TXD: 12283433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] = 0x7e000000; 12293433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 1230423f64e83ab5b1ea7de475ae80300a8408522743Ilia Mirkin case OP_TXLQ: 1231423f64e83ab5b1ea7de475ae80300a8408522743Ilia Mirkin code[1] = 0x7e800000; 1232423f64e83ab5b1ea7de475ae80300a8408522743Ilia Mirkin break; 1233cb3dcb14300613a7628941ff4ba1ad4c52e9772bIlia Mirkin case OP_TXF: 1234cb3dcb14300613a7628941ff4ba1ad4c52e9772bIlia Mirkin code[1] = 0x78000000; 1235cb3dcb14300613a7628941ff4ba1ad4c52e9772bIlia Mirkin break; 1236f6579e4b17a6010fadb464b5179dea5779c74968Ilia Mirkin case OP_TXG: 1237f6579e4b17a6010fadb464b5179dea5779c74968Ilia Mirkin code[1] = 0x7dc00000; 1238f6579e4b17a6010fadb464b5179dea5779c74968Ilia Mirkin break; 12393433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 12403433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] = 0x7d800000; 12413433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 12423433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 12433433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 12443433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (i->op) { 12453433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_TXD: 12463433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] = 0x00000002; 12473433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] = 0x76000000; 1248ece734b3c195c870bbda342edf1807ca436bf83aIlia Mirkin code[1] |= i->tex.r << 9; 12493433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 1250423f64e83ab5b1ea7de475ae80300a8408522743Ilia Mirkin case OP_TXLQ: 1251423f64e83ab5b1ea7de475ae80300a8408522743Ilia Mirkin code[0] = 0x00000002; 1252423f64e83ab5b1ea7de475ae80300a8408522743Ilia Mirkin code[1] = 0x76800000; 1253423f64e83ab5b1ea7de475ae80300a8408522743Ilia Mirkin code[1] |= i->tex.r << 9; 1254423f64e83ab5b1ea7de475ae80300a8408522743Ilia Mirkin break; 1255cb3dcb14300613a7628941ff4ba1ad4c52e9772bIlia Mirkin case OP_TXF: 1256cb3dcb14300613a7628941ff4ba1ad4c52e9772bIlia Mirkin code[0] = 0x00000002; 1257cb3dcb14300613a7628941ff4ba1ad4c52e9772bIlia Mirkin code[1] = 0x70000000; 1258ece734b3c195c870bbda342edf1807ca436bf83aIlia Mirkin code[1] |= i->tex.r << 13; 1259cb3dcb14300613a7628941ff4ba1ad4c52e9772bIlia Mirkin break; 1260f6579e4b17a6010fadb464b5179dea5779c74968Ilia Mirkin case OP_TXG: 1261f6579e4b17a6010fadb464b5179dea5779c74968Ilia Mirkin code[0] = 0x00000001; 1262f6579e4b17a6010fadb464b5179dea5779c74968Ilia Mirkin code[1] = 0x70000000; 1263f6579e4b17a6010fadb464b5179dea5779c74968Ilia Mirkin code[1] |= i->tex.r << 15; 1264f6579e4b17a6010fadb464b5179dea5779c74968Ilia Mirkin break; 12653433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 12663433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] = 0x00000001; 12673433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] = 0x60000000; 1268ece734b3c195c870bbda342edf1807ca436bf83aIlia Mirkin code[1] |= i->tex.r << 15; 12693433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 12703433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 12713433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 12723433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 12733433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= isNextIndependentTex(i) ? 0x1 : 0x2; // t : p mode 12743433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1275cb3dcb14300613a7628941ff4ba1ad4c52e9772bIlia Mirkin if (i->tex.liveOnly) 1276cb3dcb14300613a7628941ff4ba1ad4c52e9772bIlia Mirkin code[0] |= 0x80000000; 12773433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 12783433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (i->op) { 12793433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_TEX: break; 12803433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_TXB: code[1] |= 0x2000; break; 12813433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_TXL: code[1] |= 0x3000; break; 1282cb3dcb14300613a7628941ff4ba1ad4c52e9772bIlia Mirkin case OP_TXF: break; 1283f6579e4b17a6010fadb464b5179dea5779c74968Ilia Mirkin case OP_TXG: break; 12843433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_TXD: break; 1285423f64e83ab5b1ea7de475ae80300a8408522743Ilia Mirkin case OP_TXLQ: break; 12863433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 12873433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(!"invalid texture op"); 12883433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 12893433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 1290cb3dcb14300613a7628941ff4ba1ad4c52e9772bIlia Mirkin 12913433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->op == OP_TXF) { 12923433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (!i->tex.levelZero) 1293cb3dcb14300613a7628941ff4ba1ad4c52e9772bIlia Mirkin code[1] |= 0x1000; 1294cb3dcb14300613a7628941ff4ba1ad4c52e9772bIlia Mirkin } else 12953433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->tex.levelZero) { 12963433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= 0x1000; 12973433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 12983433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1299563083ef576141f39af36426418fc2dbf2d98a3fIlia Mirkin if (i->op != OP_TXD && i->tex.derivAll) 1300563083ef576141f39af36426418fc2dbf2d98a3fIlia Mirkin code[1] |= 0x200; 13013433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 13023433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitPredicate(i); 13033433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 13043433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= i->tex.mask << 2; 13053433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 13063433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller const int src1 = (i->predSrc == 1) ? 2 : 1; // if predSrc == 1, !srcExists(2) 13073433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 13083433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller defId(i->def(0), 2); 13093433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller srcId(i->src(0), 10); 13103433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller srcId(i, src1, 23); 13113433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1312f6579e4b17a6010fadb464b5179dea5779c74968Ilia Mirkin if (i->op == OP_TXG) code[1] |= i->tex.gatherComp << 13; 13133433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 13143433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller // texture target: 13153433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= (i->tex.target.isCube() ? 3 : (i->tex.target.getDim() - 1)) << 7; 13163433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->tex.target.isArray()) 13173433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= 0x40; 1318cb3dcb14300613a7628941ff4ba1ad4c52e9772bIlia Mirkin if (i->tex.target.isShadow()) 1319cb3dcb14300613a7628941ff4ba1ad4c52e9772bIlia Mirkin code[1] |= 0x400; 1320cb3dcb14300613a7628941ff4ba1ad4c52e9772bIlia Mirkin if (i->tex.target == TEX_TARGET_2D_MS || 1321cb3dcb14300613a7628941ff4ba1ad4c52e9772bIlia Mirkin i->tex.target == TEX_TARGET_2D_MS_ARRAY) 1322cb3dcb14300613a7628941ff4ba1ad4c52e9772bIlia Mirkin code[1] |= 0x800; 13233433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 13243433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->srcExists(src1) && i->src(src1).getFile() == FILE_IMMEDIATE) { 13253433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller // ? 13263433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 13273433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1328f3aa999383074d666d6e3f3506e66b0c937904caIlia Mirkin if (i->tex.useOffsets == 1) { 1329563083ef576141f39af36426418fc2dbf2d98a3fIlia Mirkin switch (i->op) { 1330563083ef576141f39af36426418fc2dbf2d98a3fIlia Mirkin case OP_TXF: code[1] |= 0x200; break; 133158030a8f99d94d6c1bab02ef113d93c6c2636216Ilia Mirkin case OP_TXD: code[1] |= 0x00400000; break; 1332563083ef576141f39af36426418fc2dbf2d98a3fIlia Mirkin default: code[1] |= 0x800; break; 1333563083ef576141f39af36426418fc2dbf2d98a3fIlia Mirkin } 1334563083ef576141f39af36426418fc2dbf2d98a3fIlia Mirkin } 1335f3aa999383074d666d6e3f3506e66b0c937904caIlia Mirkin if (i->tex.useOffsets == 4) 1336f3aa999383074d666d6e3f3506e66b0c937904caIlia Mirkin code[1] |= 0x1000; 13373433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 13383433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 13393433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 13403433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitTXQ(const TexInstruction *i) 13413433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 134276554d2d1f3e017370a7ef1b3ea511f83cd83573Ilia Mirkin code[0] = 0x00000002; 134376554d2d1f3e017370a7ef1b3ea511f83cd83573Ilia Mirkin code[1] = 0x75400001; 134476554d2d1f3e017370a7ef1b3ea511f83cd83573Ilia Mirkin 134576554d2d1f3e017370a7ef1b3ea511f83cd83573Ilia Mirkin switch (i->tex.query) { 134676554d2d1f3e017370a7ef1b3ea511f83cd83573Ilia Mirkin case TXQ_DIMS: code[0] |= 0x01 << 25; break; 134776554d2d1f3e017370a7ef1b3ea511f83cd83573Ilia Mirkin case TXQ_TYPE: code[0] |= 0x02 << 25; break; 134876554d2d1f3e017370a7ef1b3ea511f83cd83573Ilia Mirkin case TXQ_SAMPLE_POSITION: code[0] |= 0x05 << 25; break; 134976554d2d1f3e017370a7ef1b3ea511f83cd83573Ilia Mirkin case TXQ_FILTER: code[0] |= 0x10 << 25; break; 135076554d2d1f3e017370a7ef1b3ea511f83cd83573Ilia Mirkin case TXQ_LOD: code[0] |= 0x12 << 25; break; 135176554d2d1f3e017370a7ef1b3ea511f83cd83573Ilia Mirkin case TXQ_BORDER_COLOUR: code[0] |= 0x16 << 25; break; 135276554d2d1f3e017370a7ef1b3ea511f83cd83573Ilia Mirkin default: 135376554d2d1f3e017370a7ef1b3ea511f83cd83573Ilia Mirkin assert(!"invalid texture query"); 135476554d2d1f3e017370a7ef1b3ea511f83cd83573Ilia Mirkin break; 135576554d2d1f3e017370a7ef1b3ea511f83cd83573Ilia Mirkin } 135676554d2d1f3e017370a7ef1b3ea511f83cd83573Ilia Mirkin 1357ece734b3c195c870bbda342edf1807ca436bf83aIlia Mirkin code[1] |= i->tex.mask << 2; 1358ece734b3c195c870bbda342edf1807ca436bf83aIlia Mirkin code[1] |= i->tex.r << 9; 1359ece734b3c195c870bbda342edf1807ca436bf83aIlia Mirkin if (/*i->tex.sIndirectSrc >= 0 || */i->tex.rIndirectSrc >= 0) 1360ece734b3c195c870bbda342edf1807ca436bf83aIlia Mirkin code[1] |= 0x08000000; 136176554d2d1f3e017370a7ef1b3ea511f83cd83573Ilia Mirkin 136276554d2d1f3e017370a7ef1b3ea511f83cd83573Ilia Mirkin defId(i->def(0), 2); 136376554d2d1f3e017370a7ef1b3ea511f83cd83573Ilia Mirkin srcId(i->src(0), 10); 136476554d2d1f3e017370a7ef1b3ea511f83cd83573Ilia Mirkin 136576554d2d1f3e017370a7ef1b3ea511f83cd83573Ilia Mirkin emitPredicate(i); 13663433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 13673433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 13683433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 13693433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitQUADOP(const Instruction *i, uint8_t qOp, uint8_t laneMask) 13703433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 137161e978524a0e5de4f8570b44bcb9b907a9187684Ilia Mirkin code[0] = 0x00000002 | ((qOp & 1) << 31); 137261e978524a0e5de4f8570b44bcb9b907a9187684Ilia Mirkin code[1] = 0x7fc00200 | (qOp >> 1) | (laneMask << 12); // dall 13734bb14aca293b12cbe4f2352fb11c20091876c1cfIlia Mirkin 13744bb14aca293b12cbe4f2352fb11c20091876c1cfIlia Mirkin defId(i->def(0), 2); 13754bb14aca293b12cbe4f2352fb11c20091876c1cfIlia Mirkin srcId(i->src(0), 10); 1376ca23c8081f1f9f709df7a63b9e6de379c0b8df44Ilia Mirkin srcId((i->srcExists(1) && i->predSrc != 1) ? i->src(1) : i->src(0), 23); 13774bb14aca293b12cbe4f2352fb11c20091876c1cfIlia Mirkin 13784bb14aca293b12cbe4f2352fb11c20091876c1cfIlia Mirkin emitPredicate(i); 13793433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 13803433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 13813433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 1382af38ef907c89ecb1125bf258cafa0793f79a5eb7Ilia MirkinCodeEmitterGK110::emitPIXLD(const Instruction *i) 1383af38ef907c89ecb1125bf258cafa0793f79a5eb7Ilia Mirkin{ 1384af38ef907c89ecb1125bf258cafa0793f79a5eb7Ilia Mirkin emitForm_L(i, 0x7f4, 2, Modifier(0)); 1385af38ef907c89ecb1125bf258cafa0793f79a5eb7Ilia Mirkin code[1] |= i->subOp << 2; 1386af38ef907c89ecb1125bf258cafa0793f79a5eb7Ilia Mirkin code[1] |= 0x00070000; 1387af38ef907c89ecb1125bf258cafa0793f79a5eb7Ilia Mirkin} 1388af38ef907c89ecb1125bf258cafa0793f79a5eb7Ilia Mirkin 1389af38ef907c89ecb1125bf258cafa0793f79a5eb7Ilia Mirkinvoid 139088818c4cd6de9d8855a9ba3c3a85306d42f5e9d3Ilia MirkinCodeEmitterGK110::emitBAR(const Instruction *i) 139188818c4cd6de9d8855a9ba3c3a85306d42f5e9d3Ilia Mirkin{ 13929f23007a7a56d576c8f20b76583ca2416e94a75dIlia Mirkin code[0] = 0x00000002; 13939f23007a7a56d576c8f20b76583ca2416e94a75dIlia Mirkin code[1] = 0x85400000; 13949f23007a7a56d576c8f20b76583ca2416e94a75dIlia Mirkin 13959f23007a7a56d576c8f20b76583ca2416e94a75dIlia Mirkin switch (i->subOp) { 13969f23007a7a56d576c8f20b76583ca2416e94a75dIlia Mirkin case NV50_IR_SUBOP_BAR_ARRIVE: code[1] |= 0x08; break; 13979f23007a7a56d576c8f20b76583ca2416e94a75dIlia Mirkin case NV50_IR_SUBOP_BAR_RED_AND: code[1] |= 0x50; break; 13989f23007a7a56d576c8f20b76583ca2416e94a75dIlia Mirkin case NV50_IR_SUBOP_BAR_RED_OR: code[1] |= 0x90; break; 13999f23007a7a56d576c8f20b76583ca2416e94a75dIlia Mirkin case NV50_IR_SUBOP_BAR_RED_POPC: code[1] |= 0x10; break; 14009f23007a7a56d576c8f20b76583ca2416e94a75dIlia Mirkin default: 14019f23007a7a56d576c8f20b76583ca2416e94a75dIlia Mirkin assert(i->subOp == NV50_IR_SUBOP_BAR_SYNC); 14029f23007a7a56d576c8f20b76583ca2416e94a75dIlia Mirkin break; 14039f23007a7a56d576c8f20b76583ca2416e94a75dIlia Mirkin } 14049f23007a7a56d576c8f20b76583ca2416e94a75dIlia Mirkin 14059f23007a7a56d576c8f20b76583ca2416e94a75dIlia Mirkin emitPredicate(i); 14069f23007a7a56d576c8f20b76583ca2416e94a75dIlia Mirkin 1407f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset // barrier id 1408f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset if (i->src(0).getFile() == FILE_GPR) { 1409f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset srcId(i->src(0), 10); 1410f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset } else { 1411f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset ImmediateValue *imm = i->getSrc(0)->asImm(); 1412f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset assert(imm); 1413f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset code[0] |= imm->reg.data.u32 << 10; 1414f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset code[1] |= 0x8000; 1415f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset } 1416f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset 1417f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset // thread count 1418f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset if (i->src(1).getFile() == FILE_GPR) { 1419f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset srcId(i->src(1), 23); 1420f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset } else { 1421f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset ImmediateValue *imm = i->getSrc(0)->asImm(); 1422f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset assert(imm); 1423f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset assert(imm->reg.data.u32 <= 0xfff); 1424f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset code[0] |= imm->reg.data.u32 << 23; 1425f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset code[1] |= imm->reg.data.u32 >> 9; 1426f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset code[1] |= 0x4000; 1427f4d2d491522aea8c7de46311c3f5e9c588307dd2Samuel Pitoiset } 14288a109c0375ba1faa987329ab6355f7bcb497bd78Samuel Pitoiset 14298a109c0375ba1faa987329ab6355f7bcb497bd78Samuel Pitoiset if (i->srcExists(2) && (i->predSrc != 2)) { 14308a109c0375ba1faa987329ab6355f7bcb497bd78Samuel Pitoiset srcId(i->src(2), 32 + 10); 14318a109c0375ba1faa987329ab6355f7bcb497bd78Samuel Pitoiset if (i->src(2).mod == Modifier(NV50_IR_MOD_NOT)) 14328a109c0375ba1faa987329ab6355f7bcb497bd78Samuel Pitoiset code[1] |= 1 << 13; 14338a109c0375ba1faa987329ab6355f7bcb497bd78Samuel Pitoiset } else { 14348a109c0375ba1faa987329ab6355f7bcb497bd78Samuel Pitoiset code[1] |= 7 << 10; 14358a109c0375ba1faa987329ab6355f7bcb497bd78Samuel Pitoiset } 143688818c4cd6de9d8855a9ba3c3a85306d42f5e9d3Ilia Mirkin} 143788818c4cd6de9d8855a9ba3c3a85306d42f5e9d3Ilia Mirkin 14387d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkinvoid CodeEmitterGK110::emitMEMBAR(const Instruction *i) 14397d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin{ 14407d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin code[0] = 0x00000002 | NV50_IR_SUBOP_MEMBAR_SCOPE(i->subOp) << 8; 14417d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin code[1] = 0x7cc00000; 14427d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin 14437d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin emitPredicate(i); 14447d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin} 14457d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin 144688818c4cd6de9d8855a9ba3c3a85306d42f5e9d3Ilia Mirkinvoid 14473433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitFlow(const Instruction *i) 14483433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 14493433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller const FlowInstruction *f = i->asFlow(); 14503433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 14513433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller unsigned mask; // bit 0: predicate, bit 1: target 14523433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 14533433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] = 0x00000000; 14543433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 14553433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (i->op) { 14563433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_BRA: 1457ce75a3e8d36e85214e98194ca212504282df47f9Ilia Mirkin code[1] = f->absolute ? 0x10800000 : 0x12000000; 1458ce75a3e8d36e85214e98194ca212504282df47f9Ilia Mirkin if (i->srcExists(0) && i->src(0).getFile() == FILE_MEMORY_CONST) 1459ce75a3e8d36e85214e98194ca212504282df47f9Ilia Mirkin code[0] |= 0x80; 14603433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller mask = 3; 14613433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 14623433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_CALL: 1463ce75a3e8d36e85214e98194ca212504282df47f9Ilia Mirkin code[1] = f->absolute ? 0x11000000 : 0x13000000; 1464ce75a3e8d36e85214e98194ca212504282df47f9Ilia Mirkin if (i->srcExists(0) && i->src(0).getFile() == FILE_MEMORY_CONST) 1465ce75a3e8d36e85214e98194ca212504282df47f9Ilia Mirkin code[0] |= 0x80; 14663433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller mask = 2; 14673433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 14683433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 14693433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_EXIT: code[1] = 0x18000000; mask = 1; break; 14703433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_RET: code[1] = 0x19000000; mask = 1; break; 1471ce75a3e8d36e85214e98194ca212504282df47f9Ilia Mirkin case OP_DISCARD: code[1] = 0x19800000; mask = 1; break; 1472ce75a3e8d36e85214e98194ca212504282df47f9Ilia Mirkin case OP_BREAK: code[1] = 0x1a000000; mask = 1; break; 1473ce75a3e8d36e85214e98194ca212504282df47f9Ilia Mirkin case OP_CONT: code[1] = 0x1a800000; mask = 1; break; 14743433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 14753433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_JOINAT: code[1] = 0x14800000; mask = 2; break; 1476ce75a3e8d36e85214e98194ca212504282df47f9Ilia Mirkin case OP_PREBREAK: code[1] = 0x15000000; mask = 2; break; 1477ce75a3e8d36e85214e98194ca212504282df47f9Ilia Mirkin case OP_PRECONT: code[1] = 0x15800000; mask = 2; break; 1478ce75a3e8d36e85214e98194ca212504282df47f9Ilia Mirkin case OP_PRERET: code[1] = 0x13800000; mask = 2; break; 14793433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 14806e046508a17b7eee24285e94f144a42ded3ebcdcIlia Mirkin case OP_QUADON: code[1] = 0x1b800000; mask = 0; break; 1481ce75a3e8d36e85214e98194ca212504282df47f9Ilia Mirkin case OP_QUADPOP: code[1] = 0x1c000000; mask = 0; break; 1482ce75a3e8d36e85214e98194ca212504282df47f9Ilia Mirkin case OP_BRKPT: code[1] = 0x00000000; mask = 0; break; 14833433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 14843433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(!"invalid flow operation"); 14853433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller return; 14863433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 14873433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 14883433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (mask & 1) { 14893433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitPredicate(i); 14903433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->flagsSrc < 0) 14913433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] |= 0x3c; 14923433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 14933433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 14943433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (!f) 14953433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller return; 14963433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 14973433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (f->allWarp) 1498ce75a3e8d36e85214e98194ca212504282df47f9Ilia Mirkin code[0] |= 1 << 9; 14993433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (f->limit) 1500ce75a3e8d36e85214e98194ca212504282df47f9Ilia Mirkin code[0] |= 1 << 8; 15013433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 15023433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (f->op == OP_CALL) { 15033433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (f->builtin) { 15043433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(f->absolute); 15053741b7d844f7357fac984e8c565dedb248947487Christoph Bumiller uint32_t pcAbs = targNVC0->getBuiltinOffset(f->target.builtin); 15063433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller addReloc(RelocEntry::TYPE_BUILTIN, 0, pcAbs, 0xff800000, 23); 15073433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller addReloc(RelocEntry::TYPE_BUILTIN, 1, pcAbs, 0x007fffff, -9); 15083433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 15093433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(!f->absolute); 15103433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller int32_t pcRel = f->target.fn->binPos - (codeSize + 8); 15113433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] |= (pcRel & 0x1ff) << 23; 15123433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= (pcRel >> 9) & 0x7fff; 15133433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 15143433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else 15153433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (mask & 2) { 15163433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller int32_t pcRel = f->target.bb->binPos - (codeSize + 8); 15170ec6b8ea8ce0929ecacf6edc8db198b7b9604f18Ilia Mirkin if (writeIssueDelays && !(f->target.bb->binPos & 0x3f)) 15180ec6b8ea8ce0929ecacf6edc8db198b7b9604f18Ilia Mirkin pcRel += 8; 15193433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller // currently we don't want absolute branches 15203433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(!f->absolute); 15213433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] |= (pcRel & 0x1ff) << 23; 15223433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= (pcRel >> 9) & 0x7fff; 15233433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 15243433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 15253433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 15263433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 152707ed003faf3199a3e95852e7a34763aeaf76503dSamuel PitoisetCodeEmitterGK110::emitVOTE(const Instruction *i) 152807ed003faf3199a3e95852e7a34763aeaf76503dSamuel Pitoiset{ 1529704bc0f0e98f3bbdef33cad12646d4e1bf01e8aaIlia Mirkin assert(i->src(0).getFile() == FILE_PREDICATE); 153007ed003faf3199a3e95852e7a34763aeaf76503dSamuel Pitoiset 153107ed003faf3199a3e95852e7a34763aeaf76503dSamuel Pitoiset code[0] = 0x00000002; 153207ed003faf3199a3e95852e7a34763aeaf76503dSamuel Pitoiset code[1] = 0x86c00000 | (i->subOp << 19); 153307ed003faf3199a3e95852e7a34763aeaf76503dSamuel Pitoiset 153407ed003faf3199a3e95852e7a34763aeaf76503dSamuel Pitoiset emitPredicate(i); 153507ed003faf3199a3e95852e7a34763aeaf76503dSamuel Pitoiset 1536704bc0f0e98f3bbdef33cad12646d4e1bf01e8aaIlia Mirkin unsigned rp = 0; 1537704bc0f0e98f3bbdef33cad12646d4e1bf01e8aaIlia Mirkin for (int d = 0; i->defExists(d); d++) { 1538704bc0f0e98f3bbdef33cad12646d4e1bf01e8aaIlia Mirkin if (i->def(d).getFile() == FILE_PREDICATE) { 1539704bc0f0e98f3bbdef33cad12646d4e1bf01e8aaIlia Mirkin assert(!(rp & 2)); 1540704bc0f0e98f3bbdef33cad12646d4e1bf01e8aaIlia Mirkin rp |= 2; 1541704bc0f0e98f3bbdef33cad12646d4e1bf01e8aaIlia Mirkin defId(i->def(d), 48); 1542704bc0f0e98f3bbdef33cad12646d4e1bf01e8aaIlia Mirkin } else if (i->def(d).getFile() == FILE_GPR) { 1543704bc0f0e98f3bbdef33cad12646d4e1bf01e8aaIlia Mirkin assert(!(rp & 1)); 1544704bc0f0e98f3bbdef33cad12646d4e1bf01e8aaIlia Mirkin rp |= 1; 1545704bc0f0e98f3bbdef33cad12646d4e1bf01e8aaIlia Mirkin defId(i->def(d), 2); 1546704bc0f0e98f3bbdef33cad12646d4e1bf01e8aaIlia Mirkin } else { 1547704bc0f0e98f3bbdef33cad12646d4e1bf01e8aaIlia Mirkin assert(!"Unhandled def"); 1548704bc0f0e98f3bbdef33cad12646d4e1bf01e8aaIlia Mirkin } 1549704bc0f0e98f3bbdef33cad12646d4e1bf01e8aaIlia Mirkin } 1550704bc0f0e98f3bbdef33cad12646d4e1bf01e8aaIlia Mirkin if (!(rp & 1)) 1551704bc0f0e98f3bbdef33cad12646d4e1bf01e8aaIlia Mirkin code[0] |= 255 << 2; 1552704bc0f0e98f3bbdef33cad12646d4e1bf01e8aaIlia Mirkin if (!(rp & 2)) 1553704bc0f0e98f3bbdef33cad12646d4e1bf01e8aaIlia Mirkin code[1] |= 7 << 16; 155407ed003faf3199a3e95852e7a34763aeaf76503dSamuel Pitoiset if (i->src(0).mod == Modifier(NV50_IR_MOD_NOT)) 1555b94a46aa8e34de790724bbc0f823fd56555d0cdcSamuel Pitoiset code[1] |= 1 << 13; 155607ed003faf3199a3e95852e7a34763aeaf76503dSamuel Pitoiset srcId(i->src(0), 42); 155707ed003faf3199a3e95852e7a34763aeaf76503dSamuel Pitoiset} 155807ed003faf3199a3e95852e7a34763aeaf76503dSamuel Pitoiset 155907ed003faf3199a3e95852e7a34763aeaf76503dSamuel Pitoisetvoid 15601f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel PitoisetCodeEmitterGK110::emitSUGType(DataType ty, const int pos) 15611f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset{ 15621f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset uint8_t n = 0; 15631f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 15641f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset switch (ty) { 15651f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset case TYPE_S32: n = 1; break; 15661f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset case TYPE_U8: n = 2; break; 15671f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset case TYPE_S8: n = 3; break; 15681f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset default: 15691f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset assert(ty == TYPE_U32); 15701f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset break; 15711f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset } 15721f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset code[pos / 32] |= n << (pos % 32); 15731f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset} 15741f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 15751f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoisetvoid 15761f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel PitoisetCodeEmitterGK110::emitSUCachingMode(CacheMode c) 15771f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset{ 15781f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset uint8_t n = 0; 15791f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 15801f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset switch (c) { 15811f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset case CACHE_CA: 15821f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset// case CACHE_WB: 15831f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset n = 0; 15841f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset break; 15851f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset case CACHE_CG: 15861f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset n = 1; 15871f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset break; 15881f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset case CACHE_CS: 15891f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset n = 2; 15901f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset break; 15911f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset case CACHE_CV: 15921f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset// case CACHE_WT: 15931f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset n = 3; 15941f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset break; 15951f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset default: 15961f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset assert(!"invalid caching mode"); 15971f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset break; 15981f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset } 15991f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset code[0] |= (n & 1) << 31; 16001f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset code[1] |= (n & 2) >> 1; 16011f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset} 16021f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16031f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoisetvoid 16041f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel PitoisetCodeEmitterGK110::setSUConst16(const Instruction *i, const int s) 16051f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset{ 16061f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset const uint32_t offset = i->getSrc(s)->reg.data.offset; 16071f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16081f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset assert(offset == (offset & 0xfffc)); 16091f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16101f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset code[0] |= offset << 21; 16111f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset code[1] |= offset >> 11; 16121f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset code[1] |= i->getSrc(s)->reg.fileIndex << 5; 16131f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset} 16141f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16151f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoisetvoid 16161f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel PitoisetCodeEmitterGK110::emitSULDGB(const TexInstruction *i) 16171f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset{ 16181f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset code[0] = 0x00000002; 16191f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset code[1] = 0x30000000 | (i->subOp << 14); 16201f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16211f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset if (i->src(1).getFile() == FILE_MEMORY_CONST) { 16221f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset emitLoadStoreType(i->dType, 0x38); 16231f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset emitCachingMode(i->cache, 0x36); 16241f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16251f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset // format 16261f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset setSUConst16(i, 1); 16271f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset } else { 16281f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset assert(i->src(1).getFile() == FILE_GPR); 16291f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset code[1] |= 0x49800000; 16301f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16311f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset emitLoadStoreType(i->dType, 0x21); 16321f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset emitSUCachingMode(i->cache); 16331f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16341f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset srcId(i->src(1), 23); 16351f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset } 16361f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16371f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset emitSUGType(i->sType, 0x34); 16381f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16391f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset emitPredicate(i); 16401f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset defId(i->def(0), 2); // destination 16411f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset srcId(i->src(0), 10); // address 16421f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16431f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset // surface predicate 16441f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset if (!i->srcExists(2) || (i->predSrc == 2)) { 16451f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset code[1] |= 0x7 << 10; 16461f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset } else { 16471f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset if (i->src(2).mod == Modifier(NV50_IR_MOD_NOT)) 16481f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset code[1] |= 1 << 13; 16491f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset srcId(i->src(2), 32 + 10); 16501f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset } 16511f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset} 16521f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16531f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoisetvoid 16541f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel PitoisetCodeEmitterGK110::emitSUSTGx(const TexInstruction *i) 16551f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset{ 16561f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset assert(i->op == OP_SUSTP); 16571f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16581f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset code[0] = 0x00000002; 16591f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset code[1] = 0x38000000; 16601f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16611f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset if (i->src(1).getFile() == FILE_MEMORY_CONST) { 16621f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset code[0] |= i->subOp << 2; 16631f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16641f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset if (i->op == OP_SUSTP) 16651f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset code[0] |= i->tex.mask << 4; 16661f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16671f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset emitSUGType(i->sType, 0x8); 16681f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset emitCachingMode(i->cache, 0x36); 16691f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16701f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset // format 16711f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset setSUConst16(i, 1); 16721f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset } else { 16731f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset assert(i->src(1).getFile() == FILE_GPR); 16741f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16751f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset code[0] |= i->subOp << 23; 16761f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset code[1] |= 0x41c00000; 16771f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16781f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset if (i->op == OP_SUSTP) 16791f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset code[0] |= i->tex.mask << 25; 16801f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16811f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset emitSUGType(i->sType, 0x1d); 16821f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset emitSUCachingMode(i->cache); 16831f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16841f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset srcId(i->src(1), 2); 16851f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset } 16861f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16871f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset emitPredicate(i); 16881f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset srcId(i->src(0), 10); // address 16891f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset srcId(i->src(3), 42); // values 16901f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 16911f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset // surface predicate 16921f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset if (!i->srcExists(2) || (i->predSrc == 2)) { 16931f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset code[1] |= 0x7 << 18; 16941f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset } else { 16951f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset if (i->src(2).mod == Modifier(NV50_IR_MOD_NOT)) 16961f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset code[1] |= 1 << 21; 16971f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset srcId(i->src(2), 32 + 18); 16981f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset } 16991f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset} 17001f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset 17011f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoisetvoid 1702af5925209d730f917431b603b031085c7c96c773Samuel PitoisetCodeEmitterGK110::emitSUCLAMPMode(uint16_t subOp) 1703af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset{ 1704af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset uint8_t m; 1705af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset switch (subOp & ~NV50_IR_SUBOP_SUCLAMP_2D) { 1706af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case NV50_IR_SUBOP_SUCLAMP_SD(0, 1): m = 0; break; 1707af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case NV50_IR_SUBOP_SUCLAMP_SD(1, 1): m = 1; break; 1708af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case NV50_IR_SUBOP_SUCLAMP_SD(2, 1): m = 2; break; 1709af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case NV50_IR_SUBOP_SUCLAMP_SD(3, 1): m = 3; break; 1710af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case NV50_IR_SUBOP_SUCLAMP_SD(4, 1): m = 4; break; 1711af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case NV50_IR_SUBOP_SUCLAMP_PL(0, 1): m = 5; break; 1712af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case NV50_IR_SUBOP_SUCLAMP_PL(1, 1): m = 6; break; 1713af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case NV50_IR_SUBOP_SUCLAMP_PL(2, 1): m = 7; break; 1714af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case NV50_IR_SUBOP_SUCLAMP_PL(3, 1): m = 8; break; 1715af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case NV50_IR_SUBOP_SUCLAMP_PL(4, 1): m = 9; break; 1716af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case NV50_IR_SUBOP_SUCLAMP_BL(0, 1): m = 10; break; 1717af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case NV50_IR_SUBOP_SUCLAMP_BL(1, 1): m = 11; break; 1718af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case NV50_IR_SUBOP_SUCLAMP_BL(2, 1): m = 12; break; 1719af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case NV50_IR_SUBOP_SUCLAMP_BL(3, 1): m = 13; break; 1720af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case NV50_IR_SUBOP_SUCLAMP_BL(4, 1): m = 14; break; 1721af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset default: 1722af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset return; 1723af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset } 1724af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset code[1] |= m << 20; 1725af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset if (subOp & NV50_IR_SUBOP_SUCLAMP_2D) 1726af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset code[1] |= 1 << 24; 1727af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset} 1728af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset 1729af5925209d730f917431b603b031085c7c96c773Samuel Pitoisetvoid 1730af5925209d730f917431b603b031085c7c96c773Samuel PitoisetCodeEmitterGK110::emitSUCalc(Instruction *i) 1731af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset{ 1732af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset ImmediateValue *imm = NULL; 1733af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset uint64_t opc1, opc2; 1734af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset 1735af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset if (i->srcExists(2)) { 1736af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset imm = i->getSrc(2)->asImm(); 1737af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset if (imm) 1738af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset i->setSrc(2, NULL); // special case, make emitForm_21 not assert 1739af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset } 1740af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset 1741af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset switch (i->op) { 1742af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case OP_SUCLAMP: opc1 = 0xb00; opc2 = 0x580; break; 1743af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case OP_SUBFM: opc1 = 0xb68; opc2 = 0x1e8; break; 1744af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case OP_SUEAU: opc1 = 0xb6c; opc2 = 0x1ec; break; 1745af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset default: 1746af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset assert(0); 1747af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset return; 1748af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset } 1749af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset emitForm_21(i, opc2, opc1); 1750af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset 1751af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset if (i->op == OP_SUCLAMP) { 1752af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset if (i->dType == TYPE_S32) 1753af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset code[1] |= 1 << 19; 1754af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset emitSUCLAMPMode(i->subOp); 1755af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset } 1756af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset 1757af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset if (i->op == OP_SUBFM && i->subOp == NV50_IR_SUBOP_SUBFM_3D) 1758af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset code[1] |= 1 << 18; 1759af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset 1760af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset if (i->op != OP_SUEAU) { 1761af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset const uint8_t pos = i->op == OP_SUBFM ? 19 : 16; 1762af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset if (i->def(0).getFile() == FILE_PREDICATE) { // p, # 1763af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset code[0] |= 255 << 2; 1764af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset code[1] |= i->getDef(1)->reg.data.id << pos; 1765af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset } else 1766af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset if (i->defExists(1)) { // r, p 1767af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset assert(i->def(1).getFile() == FILE_PREDICATE); 1768af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset code[1] |= i->getDef(1)->reg.data.id << pos; 1769af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset } else { // r, # 1770af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset code[1] |= 7 << pos; 1771af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset } 1772af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset } 1773af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset 1774af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset if (imm) { 1775af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset assert(i->op == OP_SUCLAMP); 1776af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset i->setSrc(2, imm); 1777af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset code[1] |= (imm->reg.data.u32 & 0x3f) << 10; // sint6 1778af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset } 1779af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset} 1780af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset 17812daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset 17822daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoisetvoid 17832daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel PitoisetCodeEmitterGK110::emitVectorSubOp(const Instruction *i) 17842daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset{ 17852daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset switch (NV50_IR_SUBOP_Vn(i->subOp)) { 17862daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset case 0: 17872daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset code[1] |= (i->subOp & 0x000f) << 7; // vsrc1 17882daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset code[1] |= (i->subOp & 0x00e0) >> 6; // vsrc2 17892daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset code[1] |= (i->subOp & 0x0100) << 13; // vsrc2 17902daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset code[1] |= (i->subOp & 0x3c00) << 12; // vdst 17912daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset break; 17922daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset default: 17932daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset assert(0); 17942daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset break; 17952daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset } 17962daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset} 17972daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset 17982daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoisetvoid 17992daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel PitoisetCodeEmitterGK110::emitVSHL(const Instruction *i) 18002daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset{ 18012daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset code[0] = 0x00000002; 18022daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset code[1] = 0xb8000000; 18032daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset 18042daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset assert(NV50_IR_SUBOP_Vn(i->subOp) == 0); 18052daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset 18062daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset if (isSignedType(i->dType)) code[1] |= 1 << 25; 18072daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset if (isSignedType(i->sType)) code[1] |= 1 << 19; 18082daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset 18092daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset emitVectorSubOp(i); 18102daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset 18112daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset emitPredicate(i); 18122daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset defId(i->def(0), 2); 18132daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset srcId(i->src(0), 10); 18142daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset 18152daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset if (i->getSrc(1)->reg.file == FILE_IMMEDIATE) { 18162daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset ImmediateValue *imm = i->getSrc(1)->asImm(); 18172daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset assert(imm); 18182daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset code[0] |= (imm->reg.data.u32 & 0x01ff) << 23; 18192daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset code[1] |= (imm->reg.data.u32 & 0xfe00) >> 9; 18202daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset } else { 18212daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset assert(i->getSrc(1)->reg.file == FILE_GPR); 18222daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset code[1] |= 1 << 21; 18232daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset srcId(i->src(1), 23); 18242daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset } 18252daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset srcId(i->src(2), 42); 18262daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset 18272daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset if (i->saturate) 18282daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset code[0] |= 1 << 22; 18292daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset if (i->flagsDef >= 0) 18302daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset code[1] |= 1 << 18; 18312daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset} 18322daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset 1833af5925209d730f917431b603b031085c7c96c773Samuel Pitoisetvoid 18349d60793a03e40e1d139b78fce0144cad57438741Ilia MirkinCodeEmitterGK110::emitAFETCH(const Instruction *i) 18359d60793a03e40e1d139b78fce0144cad57438741Ilia Mirkin{ 18369d60793a03e40e1d139b78fce0144cad57438741Ilia Mirkin uint32_t offset = i->src(0).get()->reg.data.offset & 0x7ff; 18379d60793a03e40e1d139b78fce0144cad57438741Ilia Mirkin 18389d60793a03e40e1d139b78fce0144cad57438741Ilia Mirkin code[0] = 0x00000002 | (offset << 23); 18399d60793a03e40e1d139b78fce0144cad57438741Ilia Mirkin code[1] = 0x7d000000 | (offset >> 9); 18409d60793a03e40e1d139b78fce0144cad57438741Ilia Mirkin 18419d60793a03e40e1d139b78fce0144cad57438741Ilia Mirkin if (i->getSrc(0)->reg.file == FILE_SHADER_OUTPUT) 18429d60793a03e40e1d139b78fce0144cad57438741Ilia Mirkin code[1] |= 0x8; 18439d60793a03e40e1d139b78fce0144cad57438741Ilia Mirkin 18449d60793a03e40e1d139b78fce0144cad57438741Ilia Mirkin emitPredicate(i); 18459d60793a03e40e1d139b78fce0144cad57438741Ilia Mirkin 18469d60793a03e40e1d139b78fce0144cad57438741Ilia Mirkin defId(i->def(0), 2); 18479d60793a03e40e1d139b78fce0144cad57438741Ilia Mirkin srcId(i->src(0).getIndirect(0), 10); 18489d60793a03e40e1d139b78fce0144cad57438741Ilia Mirkin} 18499d60793a03e40e1d139b78fce0144cad57438741Ilia Mirkin 18509d60793a03e40e1d139b78fce0144cad57438741Ilia Mirkinvoid 18513433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitPFETCH(const Instruction *i) 18523433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 1853c17f7247ec5b7acf44e462accf5b5124fb713772Ilia Mirkin uint32_t prim = i->src(0).get()->reg.data.u32; 1854c17f7247ec5b7acf44e462accf5b5124fb713772Ilia Mirkin 1855c17f7247ec5b7acf44e462accf5b5124fb713772Ilia Mirkin code[0] = 0x00000002 | ((prim & 0xff) << 23); 1856c17f7247ec5b7acf44e462accf5b5124fb713772Ilia Mirkin code[1] = 0x7f800000; 1857c17f7247ec5b7acf44e462accf5b5124fb713772Ilia Mirkin 1858c17f7247ec5b7acf44e462accf5b5124fb713772Ilia Mirkin emitPredicate(i); 1859c17f7247ec5b7acf44e462accf5b5124fb713772Ilia Mirkin 1860a9d08a250ada5fbd4e3f78f8e4119ec295d692cfIlia Mirkin const int src1 = (i->predSrc == 1) ? 2 : 1; // if predSrc == 1, !srcExists(2) 1861a9d08a250ada5fbd4e3f78f8e4119ec295d692cfIlia Mirkin 1862c17f7247ec5b7acf44e462accf5b5124fb713772Ilia Mirkin defId(i->def(0), 2); 186333f0d1138d6ffa4596d3deda68fa5ba9a3d7cf86Ilia Mirkin srcId(i, src1, 10); 18643433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 18653433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 18663433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 18673433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitVFETCH(const Instruction *i) 18683433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 186934bf5e27c6d798bcaa63c7541ecea1d3e99fdd3bIlia Mirkin unsigned int size = typeSizeof(i->dType); 1870c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs uint32_t offset = i->src(0).get()->reg.data.offset; 1871c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs 1872c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs code[0] = 0x00000002 | (offset << 23); 1873c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs code[1] = 0x7ec00000 | (offset >> 9); 187434bf5e27c6d798bcaa63c7541ecea1d3e99fdd3bIlia Mirkin code[1] |= (size / 4 - 1) << 18; 1875c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs 1876c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs if (i->perPatch) 187789e0b08794a56e2ef78e8573a8c11e0cc4589f9eIlia Mirkin code[1] |= 0x4; 1878c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs if (i->getSrc(0)->reg.file == FILE_SHADER_OUTPUT) 187989e0b08794a56e2ef78e8573a8c11e0cc4589f9eIlia Mirkin code[1] |= 0x8; // yes, TCPs can read from *outputs* of other threads 1880c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs 1881c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs emitPredicate(i); 1882c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs 1883c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs defId(i->def(0), 2); 1884c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs srcId(i->src(0).getIndirect(0), 10); 1885c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs srcId(i->src(0).getIndirect(1), 32 + 10); // vertex address 18863433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 18873433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 18883433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 18893433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitEXPORT(const Instruction *i) 18903433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 189134bf5e27c6d798bcaa63c7541ecea1d3e99fdd3bIlia Mirkin unsigned int size = typeSizeof(i->dType); 1892c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs uint32_t offset = i->src(0).get()->reg.data.offset; 1893c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs 1894c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs code[0] = 0x00000002 | (offset << 23); 1895c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs code[1] = 0x7f000000 | (offset >> 9); 189634bf5e27c6d798bcaa63c7541ecea1d3e99fdd3bIlia Mirkin code[1] |= (size / 4 - 1) << 18; 1897c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs 1898c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs if (i->perPatch) 189989e0b08794a56e2ef78e8573a8c11e0cc4589f9eIlia Mirkin code[1] |= 0x4; 1900c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs 1901c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs emitPredicate(i); 1902c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs 1903c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs assert(i->src(1).getFile() == FILE_GPR); 1904c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs 1905c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs srcId(i->src(0).getIndirect(0), 10); 1906c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs srcId(i->src(0).getIndirect(1), 32 + 10); // vertex base address 1907c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs srcId(i->src(1), 2); 19083433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 19093433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 19103433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 19113433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitOUT(const Instruction *i) 19123433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 191315b1f420d04e2fbff8e1ed4a863239e8ddf602deIlia Mirkin assert(i->src(0).getFile() == FILE_GPR); 191415b1f420d04e2fbff8e1ed4a863239e8ddf602deIlia Mirkin 191515b1f420d04e2fbff8e1ed4a863239e8ddf602deIlia Mirkin emitForm_21(i, 0x1f0, 0xb70); 191615b1f420d04e2fbff8e1ed4a863239e8ddf602deIlia Mirkin 191715b1f420d04e2fbff8e1ed4a863239e8ddf602deIlia Mirkin if (i->op == OP_EMIT) 191815b1f420d04e2fbff8e1ed4a863239e8ddf602deIlia Mirkin code[1] |= 1 << 10; 191915b1f420d04e2fbff8e1ed4a863239e8ddf602deIlia Mirkin if (i->op == OP_RESTART || i->subOp == NV50_IR_SUBOP_EMIT_RESTART) 192015b1f420d04e2fbff8e1ed4a863239e8ddf602deIlia Mirkin code[1] |= 1 << 11; 19213433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 19223433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 19233433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 19243433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitInterpMode(const Instruction *i) 19253433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 1926d588a4919b732246b7aa26685ef65545929a4f7bIlia Mirkin code[1] |= (i->ipa & 0x3) << 21; // TODO: INTERP_SAMPLEID 1927d588a4919b732246b7aa26685ef65545929a4f7bIlia Mirkin code[1] |= (i->ipa & 0xc) << (19 - 2); 19283433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 19293433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 1930b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkinstatic void 1931f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia MirkininterpApply(const FixupEntry *entry, uint32_t *code, const FixupData& data) 1932b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin{ 1933b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin int ipa = entry->ipa; 1934b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin int reg = entry->reg; 1935b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin int loc = entry->loc; 1936b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin 1937f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin if (data.flatshade && 1938b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin (ipa & NV50_IR_INTERP_MODE_MASK) == NV50_IR_INTERP_SC) { 1939b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin ipa = NV50_IR_INTERP_FLAT; 1940b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin reg = 0xff; 1941f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin } else if (data.force_persample_interp && 1942b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin (ipa & NV50_IR_INTERP_SAMPLE_MASK) == NV50_IR_INTERP_DEFAULT && 1943b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin (ipa & NV50_IR_INTERP_MODE_MASK) != NV50_IR_INTERP_FLAT) { 1944b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin ipa |= NV50_IR_INTERP_CENTROID; 1945b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin } 1946b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin code[loc + 1] &= ~(0xf << 19); 1947b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin code[loc + 1] |= (ipa & 0x3) << 21; 1948b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin code[loc + 1] |= (ipa & 0xc) << (19 - 2); 1949b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin code[loc + 0] &= ~(0xff << 23); 1950b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin code[loc + 0] |= reg << 23; 1951b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin} 1952b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin 19533433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 19543433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitINTERP(const Instruction *i) 19553433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 1956c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs const uint32_t base = i->getSrc(0)->reg.data.offset; 1957c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs 1958c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs code[0] = 0x00000002 | (base << 31); 1959c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs code[1] = 0x74800000 | (base >> 1); 1960c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs 1961c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs if (i->saturate) 1962c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs code[1] |= 1 << 18; 1963c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs 1964b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin if (i->op == OP_PINTERP) { 1965c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs srcId(i->src(1), 23); 1966b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin addInterp(i->ipa, SDATA(i->src(1)).id, interpApply); 1967b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin } else { 1968c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs code[0] |= 0xff << 23; 1969b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin addInterp(i->ipa, 0xff, interpApply); 1970b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin } 1971c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs 1972c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs srcId(i->src(0).getIndirect(0), 10); 1973c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs emitInterpMode(i); 1974c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs 1975c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs emitPredicate(i); 1976c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs defId(i->def(0), 2); 1977c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs 1978c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs if (i->getSampleMode() == NV50_IR_INTERP_OFFSET) 1979c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs srcId(i->src(i->op == OP_PINTERP ? 2 : 1), 32 + 10); 1980c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs else 1981c29c6b2b2e65f73c75c70daae1d2d32e53964120Ben Skeggs code[1] |= 0xff << 10; 19823433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 19833433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 19843433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 19853433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitLoadStoreType(DataType ty, const int pos) 19863433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 19873433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller uint8_t n; 19883433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 19893433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (ty) { 19903433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case TYPE_U8: 19913433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller n = 0; 19923433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 19933433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case TYPE_S8: 19943433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller n = 1; 19953433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 19963433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case TYPE_U16: 19973433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller n = 2; 19983433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 19993433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case TYPE_S16: 20003433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller n = 3; 20013433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 20023433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case TYPE_F32: 20033433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case TYPE_U32: 20043433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case TYPE_S32: 20053433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller n = 4; 20063433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 20073433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case TYPE_F64: 20083433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case TYPE_U64: 20093433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case TYPE_S64: 20103433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller n = 5; 20113433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 20123433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case TYPE_B128: 20133433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller n = 6; 20143433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 20153433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 20163433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller n = 0; 20173433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(!"invalid ld/st type"); 20183433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 20193433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 20203433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[pos / 32] |= n << (pos % 32); 20213433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 20223433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 20233433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 20243433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitCachingMode(CacheMode c, const int pos) 20253433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 20263433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller uint8_t n; 20273433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 20283433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (c) { 20293433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CACHE_CA: 20303433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller// case CACHE_WB: 20313433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller n = 0; 20323433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 20333433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CACHE_CG: 20343433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller n = 1; 20353433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 20363433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CACHE_CS: 20373433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller n = 2; 20383433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 20393433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case CACHE_CV: 20403433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller// case CACHE_WT: 20413433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller n = 3; 20423433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 20433433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 20443433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller n = 0; 20453433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(!"invalid caching mode"); 20463433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 20473433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 20483433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[pos / 32] |= n << (pos % 32); 20493433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 20503433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 20513433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 20523433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitSTORE(const Instruction *i) 20533433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 20543433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller int32_t offset = SDATA(i->src(0)).offset; 20553433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 20563433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (i->src(0).getFile()) { 20573433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case FILE_MEMORY_GLOBAL: code[1] = 0xe0000000; code[0] = 0x00000000; break; 20583433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case FILE_MEMORY_LOCAL: code[1] = 0x7a800000; code[0] = 0x00000002; break; 2059b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset case FILE_MEMORY_SHARED: 2060b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset code[0] = 0x00000002; 2061b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset if (i->subOp == NV50_IR_SUBOP_STORE_UNLOCKED) 2062b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset code[1] = 0x78400000; 2063b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset else 2064b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset code[1] = 0x7ac00000; 2065b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset break; 20663433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 20673433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(!"invalid memory file"); 20683433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 20693433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 20703433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 20713433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (code[0] & 0x2) { 207271e315475c780311fea205ab8c9a898a67da683bHans de Goede offset &= 0xffffff; 20733433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitLoadStoreType(i->dType, 0x33); 20743433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->src(0).getFile() == FILE_MEMORY_LOCAL) 20753433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitCachingMode(i->cache, 0x2f); 20763433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 20773433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitLoadStoreType(i->dType, 0x38); 20783433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitCachingMode(i->cache, 0x3b); 20793433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 20803433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] |= offset << 23; 20813433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= offset >> 9; 20823433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 2083b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset // Unlocked store on shared memory can fail. 2084b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset if (i->src(0).getFile() == FILE_MEMORY_SHARED && 2085b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset i->subOp == NV50_IR_SUBOP_STORE_UNLOCKED) { 2086b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset assert(i->defExists(0)); 2087b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset defId(i->def(0), 32 + 16); 2088b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset } 2089b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset 20903433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitPredicate(i); 20913433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 20923433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller srcId(i->src(1), 2); 20933433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller srcId(i->src(0).getIndirect(0), 10); 20942e533ab74be1f997ddfaaf01798e7e3018138ac2Ilia Mirkin if (i->src(0).getFile() == FILE_MEMORY_GLOBAL && 20952e533ab74be1f997ddfaaf01798e7e3018138ac2Ilia Mirkin i->src(0).isIndirect(0) && 20962e533ab74be1f997ddfaaf01798e7e3018138ac2Ilia Mirkin i->getIndirect(0, 0)->reg.size == 8) 20972e533ab74be1f997ddfaaf01798e7e3018138ac2Ilia Mirkin code[1] |= 1 << 23; 20983433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 20993433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 21003433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 21013433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitLOAD(const Instruction *i) 21023433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 21033433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller int32_t offset = SDATA(i->src(0)).offset; 21043433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 21053433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (i->src(0).getFile()) { 21063433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case FILE_MEMORY_GLOBAL: code[1] = 0xc0000000; code[0] = 0x00000000; break; 21073433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case FILE_MEMORY_LOCAL: code[1] = 0x7a000000; code[0] = 0x00000002; break; 2108b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset case FILE_MEMORY_SHARED: 2109b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset code[0] = 0x00000002; 2110b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset if (i->subOp == NV50_IR_SUBOP_LOAD_LOCKED) 2111b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset code[1] = 0x77400000; 2112b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset else 2113b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset code[1] = 0x7a400000; 2114b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset break; 21153433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case FILE_MEMORY_CONST: 21163433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (!i->src(0).isIndirect(0) && typeSizeof(i->dType) == 4) { 21173433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitMOV(i); 21183433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller return; 21193433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 21203433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller offset &= 0xffff; 21213433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] = 0x00000002; 21223433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] = 0x7c800000 | (i->src(0).get()->reg.fileIndex << 7); 2123fc3d5fe01d120e9559e45223379e8285ae62b7b8Ilia Mirkin code[1] |= i->subOp << 15; 21243433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 21253433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 21263433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(!"invalid memory file"); 21273433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 21283433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 21293433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 21303433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (code[0] & 0x2) { 21313433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller offset &= 0xffffff; 21323433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitLoadStoreType(i->dType, 0x33); 21333433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->src(0).getFile() == FILE_MEMORY_LOCAL) 21343433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitCachingMode(i->cache, 0x2f); 21353433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 21363433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitLoadStoreType(i->dType, 0x38); 21373433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitCachingMode(i->cache, 0x3b); 21383433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 21393433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] |= offset << 23; 21403433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= offset >> 9; 21413433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 2142b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset // Locked store on shared memory can fail. 2143df2881381ac67c42aa8ec9e0ed28f21a1d253785Ilia Mirkin int r = 0, p = -1; 2144b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset if (i->src(0).getFile() == FILE_MEMORY_SHARED && 2145b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset i->subOp == NV50_IR_SUBOP_LOAD_LOCKED) { 2146df2881381ac67c42aa8ec9e0ed28f21a1d253785Ilia Mirkin if (i->def(0).getFile() == FILE_PREDICATE) { // p, # 2147df2881381ac67c42aa8ec9e0ed28f21a1d253785Ilia Mirkin r = -1; 2148df2881381ac67c42aa8ec9e0ed28f21a1d253785Ilia Mirkin p = 0; 2149df2881381ac67c42aa8ec9e0ed28f21a1d253785Ilia Mirkin } else if (i->defExists(1)) { // r, p 2150df2881381ac67c42aa8ec9e0ed28f21a1d253785Ilia Mirkin p = 1; 2151df2881381ac67c42aa8ec9e0ed28f21a1d253785Ilia Mirkin } else { 2152df2881381ac67c42aa8ec9e0ed28f21a1d253785Ilia Mirkin assert(!"Expected predicate dest for load locked"); 2153df2881381ac67c42aa8ec9e0ed28f21a1d253785Ilia Mirkin } 2154b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset } 2155b3efa0a59e02e20ccd9ed51c6e503d020f619043Samuel Pitoiset 21563433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitPredicate(i); 21573433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 2158df2881381ac67c42aa8ec9e0ed28f21a1d253785Ilia Mirkin if (r >= 0) 2159df2881381ac67c42aa8ec9e0ed28f21a1d253785Ilia Mirkin defId(i->def(r), 2); 2160df2881381ac67c42aa8ec9e0ed28f21a1d253785Ilia Mirkin else 2161df2881381ac67c42aa8ec9e0ed28f21a1d253785Ilia Mirkin code[0] |= 255 << 2; 2162df2881381ac67c42aa8ec9e0ed28f21a1d253785Ilia Mirkin 2163df2881381ac67c42aa8ec9e0ed28f21a1d253785Ilia Mirkin if (p >= 0) 2164df2881381ac67c42aa8ec9e0ed28f21a1d253785Ilia Mirkin defId(i->def(p), 32 + 16); 2165df2881381ac67c42aa8ec9e0ed28f21a1d253785Ilia Mirkin 21667d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin if (i->getIndirect(0, 0)) { 21677d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin srcId(i->src(0).getIndirect(0), 10); 21687d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin if (i->getIndirect(0, 0)->reg.size == 8) 21697d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin code[1] |= 1 << 23; 21707d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin } else { 21717d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin code[0] |= 255 << 10; 21727d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin } 21733433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 21743433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 21753433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumilleruint8_t 21763433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::getSRegEncoding(const ValueRef& ref) 21773433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 21783433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (SDATA(ref).sv.sv) { 21793433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case SV_LANEID: return 0x00; 21803433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case SV_PHYSID: return 0x03; 21813433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case SV_VERTEX_COUNT: return 0x10; 21823433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case SV_INVOCATION_ID: return 0x11; 21833433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case SV_YDIR: return 0x12; 218439f51ec96f00f601b9c4d4e321dacb3af9dc866fIlia Mirkin case SV_THREAD_KILL: return 0x13; 21853433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case SV_TID: return 0x21 + SDATA(ref).sv.index; 21863433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case SV_CTAID: return 0x25 + SDATA(ref).sv.index; 21873433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case SV_NTID: return 0x29 + SDATA(ref).sv.index; 21883433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case SV_GRIDID: return 0x2c; 21893433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case SV_NCTAID: return 0x2d + SDATA(ref).sv.index; 21903433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case SV_LBASE: return 0x34; 21913433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case SV_SBASE: return 0x30; 21923433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case SV_CLOCK: return 0x50 + SDATA(ref).sv.index; 21933433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 21943433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(!"no sreg for system value"); 21953433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller return 0; 21963433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 21973433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 21983433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 21993433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 22003433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitMOV(const Instruction *i) 22013433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 2202c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin if (i->def(0).getFile() == FILE_PREDICATE) { 2203c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin if (i->src(0).getFile() == FILE_GPR) { 2204c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin // Use ISETP.NE.AND dst, PT, src, RZ, PT 2205c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin code[0] = 0x00000002; 2206c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin code[1] = 0xdb500000; 2207c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin 2208c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin code[0] |= 0x7 << 2; 2209c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin code[0] |= 0xff << 23; 2210c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin code[1] |= 0x7 << 10; 2211c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin srcId(i->src(0), 10); 2212c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin } else 2213c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin if (i->src(0).getFile() == FILE_PREDICATE) { 2214c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin // Use PSETP.AND.AND dst, PT, src, PT, PT 2215c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin code[0] = 0x00000002; 2216c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin code[1] = 0x84800000; 2217c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin 2218c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin code[0] |= 0x7 << 2; 2219c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin code[1] |= 0x7 << 0; 2220c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin code[1] |= 0x7 << 10; 2221c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin 2222c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin srcId(i->src(0), 14); 2223c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin } else { 2224c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin assert(!"Unexpected source for predicate destination"); 2225c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin emitNOP(i); 2226c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin } 2227c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin emitPredicate(i); 2228c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin defId(i->def(0), 5); 2229c7731a07408c5d4169625d4a78962d2887419080Ilia Mirkin } else 22303433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->src(0).getFile() == FILE_SYSTEM_VALUE) { 22313433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] = 0x00000002 | (getSRegEncoding(i->src(0)) << 23); 22323433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] = 0x86400000; 22333433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitPredicate(i); 22343433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller defId(i->def(0), 2); 22353433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else 22363433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->src(0).getFile() == FILE_IMMEDIATE) { 22373433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] = 0x00000002 | (i->lanes << 14); 22383433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] = 0x74000000; 22393433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitPredicate(i); 22403433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller defId(i->def(0), 2); 22413433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller setImmediate32(i, 0, Modifier(0)); 22423433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else 22433433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (i->src(0).getFile() == FILE_PREDICATE) { 224467cb8a69960b37a2cfad2a7bc62b8db6aa7558bbIlia Mirkin code[0] = 0x00000002; 224567cb8a69960b37a2cfad2a7bc62b8db6aa7558bbIlia Mirkin code[1] = 0x84401c07; 224667cb8a69960b37a2cfad2a7bc62b8db6aa7558bbIlia Mirkin emitPredicate(i); 224767cb8a69960b37a2cfad2a7bc62b8db6aa7558bbIlia Mirkin defId(i->def(0), 2); 224867cb8a69960b37a2cfad2a7bc62b8db6aa7558bbIlia Mirkin srcId(i->src(0), 14); 22493433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else { 22503433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitForm_C(i, 0x24c, 2); 22513433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] |= i->lanes << 10; 22523433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 22533433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 22543433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 22558c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkinstatic inline bool 22568c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkinuses64bitAddress(const Instruction *ldst) 22578c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin{ 22588c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin return ldst->src(0).getFile() == FILE_MEMORY_GLOBAL && 22598c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin ldst->src(0).isIndirect(0) && 22608c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin ldst->getIndirect(0, 0)->reg.size == 8; 22618c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin} 22628c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin 22637d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkinvoid 22647d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia MirkinCodeEmitterGK110::emitATOM(const Instruction *i) 22658482763d35d8bbf596a7cce84bb53f4b73d5fa6fSamuel Pitoiset{ 226617a37c78fc16505f717a44aa22551285d1cd8c9eSamuel Pitoiset const bool hasDst = i->defExists(0); 226717a37c78fc16505f717a44aa22551285d1cd8c9eSamuel Pitoiset const bool exch = i->subOp == NV50_IR_SUBOP_ATOM_EXCH; 226817a37c78fc16505f717a44aa22551285d1cd8c9eSamuel Pitoiset 22697d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin code[0] = 0x00000002; 22707d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin if (i->subOp == NV50_IR_SUBOP_ATOM_CAS) 22717d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin code[1] = 0x77800000; 22727d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin else 22737d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin code[1] = 0x68000000; 22747d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin 22757d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin switch (i->subOp) { 22767d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin case NV50_IR_SUBOP_ATOM_CAS: break; 22777d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin case NV50_IR_SUBOP_ATOM_EXCH: code[1] |= 0x04000000; break; 22787d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin default: code[1] |= i->subOp << 23; break; 22797d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin } 22807d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin 22817d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin switch (i->dType) { 22827d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin case TYPE_U32: break; 22837d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin case TYPE_S32: code[1] |= 0x00100000; break; 22847d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin case TYPE_U64: code[1] |= 0x00200000; break; 22857d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin case TYPE_F32: code[1] |= 0x00300000; break; 22867d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin case TYPE_B128: code[1] |= 0x00400000; break; /* TODO: U128 */ 22877d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin case TYPE_S64: code[1] |= 0x00500000; break; 22887d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin default: assert(!"unsupported type"); break; 22897d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin } 22908482763d35d8bbf596a7cce84bb53f4b73d5fa6fSamuel Pitoiset 22918482763d35d8bbf596a7cce84bb53f4b73d5fa6fSamuel Pitoiset emitPredicate(i); 22927d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin 22937d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin /* TODO: cas: check that src regs line up */ 22947d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin /* TODO: cas: flip bits if $r255 is used */ 22957d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin srcId(i->src(1), 23); 22967d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin 229717a37c78fc16505f717a44aa22551285d1cd8c9eSamuel Pitoiset if (hasDst) { 22987d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin defId(i->def(0), 2); 229917a37c78fc16505f717a44aa22551285d1cd8c9eSamuel Pitoiset } else 230017a37c78fc16505f717a44aa22551285d1cd8c9eSamuel Pitoiset if (!exch) { 23017d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin code[0] |= 255 << 2; 230217a37c78fc16505f717a44aa22551285d1cd8c9eSamuel Pitoiset } 23037d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin 230417a37c78fc16505f717a44aa22551285d1cd8c9eSamuel Pitoiset if (hasDst || !exch) { 230517a37c78fc16505f717a44aa22551285d1cd8c9eSamuel Pitoiset const int32_t offset = SDATA(i->src(0)).offset; 230617a37c78fc16505f717a44aa22551285d1cd8c9eSamuel Pitoiset assert(offset < 0x80000 && offset >= -0x80000); 230717a37c78fc16505f717a44aa22551285d1cd8c9eSamuel Pitoiset code[0] |= (offset & 1) << 31; 230817a37c78fc16505f717a44aa22551285d1cd8c9eSamuel Pitoiset code[1] |= (offset & 0xffffe) >> 1; 230917a37c78fc16505f717a44aa22551285d1cd8c9eSamuel Pitoiset } else { 231017a37c78fc16505f717a44aa22551285d1cd8c9eSamuel Pitoiset srcAddr32(i->src(0), 31); 231117a37c78fc16505f717a44aa22551285d1cd8c9eSamuel Pitoiset } 23127d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin 23137d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin if (i->getIndirect(0, 0)) { 23147d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin srcId(i->getIndirect(0, 0), 10); 23157d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin if (i->getIndirect(0, 0)->reg.size == 8) 23167d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin code[1] |= 1 << 19; 23177d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin } else { 23187d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin code[0] |= 255 << 10; 23197d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin } 23208482763d35d8bbf596a7cce84bb53f4b73d5fa6fSamuel Pitoiset} 23218482763d35d8bbf596a7cce84bb53f4b73d5fa6fSamuel Pitoiset 23228c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkinvoid 23238c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia MirkinCodeEmitterGK110::emitCCTL(const Instruction *i) 23248c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin{ 23258c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin int32_t offset = SDATA(i->src(0)).offset; 23268c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin 23278c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin code[0] = 0x00000002 | (i->subOp << 2); 23288c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin 23298c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin if (i->src(0).getFile() == FILE_MEMORY_GLOBAL) { 23308c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin code[1] = 0x7b000000; 23318c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin } else { 23328c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin code[1] = 0x7c000000; 23338c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin offset &= 0xffffff; 23348c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin } 23358c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin code[0] |= offset << 23; 23368c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin code[1] |= offset >> 9; 23378c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin 23388c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin if (uses64bitAddress(i)) 23398c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin code[1] |= 1 << 23; 23408c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin srcId(i->src(0).getIndirect(0), 10); 23418c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin 23428c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin emitPredicate(i); 23438c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin} 23448c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin 23453433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillerbool 23463433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::emitInstruction(Instruction *insn) 23473433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 23483433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller const unsigned int size = (writeIssueDelays && !(codeSize & 0x3f)) ? 16 : 8; 23493433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 23503433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (insn->encSize != 8) { 23513433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller ERROR("skipping unencodable instruction: "); 23523433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller insn->print(); 23533433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller return false; 23543433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } else 23553433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (codeSize + size > codeSizeLimit) { 23563433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller ERROR("code emitter output buffer too small\n"); 23573433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller return false; 23583433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 23593433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 23603433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (writeIssueDelays) { 23613433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller int id = (codeSize & 0x3f) / 8 - 1; 23623433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (id < 0) { 23633433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller id += 1; 23643433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] = 0x00000000; // cf issue delay "instruction" 23653433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[1] = 0x08000000; 23663433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code += 2; 23673433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller codeSize += 8; 23683433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 23693433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller uint32_t *data = code - (id * 2 + 2); 23703433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 23713433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (id) { 23723433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case 0: data[0] |= insn->sched << 2; break; 23733433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case 1: data[0] |= insn->sched << 10; break; 23743433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case 2: data[0] |= insn->sched << 18; break; 23753433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case 3: data[0] |= insn->sched << 26; data[1] |= insn->sched >> 6; break; 23761b68009466dd2ac6a8d8827ef47ba9bdf0c58501Ilia Mirkin case 4: data[1] |= insn->sched << 2; break; 23773433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case 5: data[1] |= insn->sched << 10; break; 23783433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case 6: data[1] |= insn->sched << 18; break; 23793433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 23803433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(0); 23813433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 23823433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 23833433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 23843433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 23853433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller // assert that instructions with multiple defs don't corrupt registers 23863433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller for (int d = 0; insn->defExists(d); ++d) 23873433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller assert(insn->asTex() || insn->def(d).rep()->reg.data.id >= 0); 23883433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 23893433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller switch (insn->op) { 23903433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_MOV: 23913433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_RDSV: 23923433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitMOV(insn); 23933433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 23943433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_NOP: 23953433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 23963433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_LOAD: 23973433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitLOAD(insn); 23983433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 23993433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_STORE: 24003433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitSTORE(insn); 24013433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 24023433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_LINTERP: 24033433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_PINTERP: 24043433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitINTERP(insn); 24053433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 24063433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_VFETCH: 24073433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitVFETCH(insn); 24083433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 24093433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_EXPORT: 24103433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitEXPORT(insn); 24113433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 24129d60793a03e40e1d139b78fce0144cad57438741Ilia Mirkin case OP_AFETCH: 24139d60793a03e40e1d139b78fce0144cad57438741Ilia Mirkin emitAFETCH(insn); 24149d60793a03e40e1d139b78fce0144cad57438741Ilia Mirkin break; 24153433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_PFETCH: 24163433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitPFETCH(insn); 24173433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 24183433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_EMIT: 24193433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_RESTART: 24203433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitOUT(insn); 24213433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 24223433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_ADD: 24233433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_SUB: 2424493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin if (insn->dType == TYPE_F64) 2425493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin emitDADD(insn); 2426493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin else if (isFloatType(insn->dType)) 24273433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitFADD(insn); 24283433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller else 24293433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitUADD(insn); 24303433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 24313433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_MUL: 2432493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin if (insn->dType == TYPE_F64) 2433493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin emitDMUL(insn); 2434493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin else if (isFloatType(insn->dType)) 24353433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitFMUL(insn); 24363433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller else 24373433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitIMUL(insn); 24383433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 24393433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_MAD: 24403433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_FMA: 2441493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin if (insn->dType == TYPE_F64) 2442493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin emitDMAD(insn); 2443493ad88e1b6598e3827546854b0c8336b42b36a2Ilia Mirkin else if (isFloatType(insn->dType)) 24443433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitFMAD(insn); 24453433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller else 24463433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitIMAD(insn); 24473433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 2448fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset case OP_MADSP: 2449fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset emitMADSP(insn); 2450fddd8523d48f456d3fd614179ecd66e46625c774Samuel Pitoiset break; 24513433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_SAD: 24523433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitISAD(insn); 24533433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 245431545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset case OP_SHLADD: 245531545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset emitSHLADD(insn); 245631545b64b80aa939a693723e07f06fe45160ae62Samuel Pitoiset break; 24573433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_NOT: 24583433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitNOT(insn); 24593433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 24603433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_AND: 24613433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitLogicOp(insn, 0); 24623433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 24633433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_OR: 24643433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitLogicOp(insn, 1); 24653433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 24663433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_XOR: 24673433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitLogicOp(insn, 2); 24683433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 24693433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_SHL: 24703433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_SHR: 24713433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitShift(insn); 24723433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 24733433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_SET: 24743433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_SET_AND: 24753433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_SET_OR: 24763433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_SET_XOR: 24773433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitSET(insn->asCmp()); 24783433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 24793433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_SELP: 24806526225f888a08b301e8c39ec70b4e739081e490Samuel Pitoiset emitSELP(insn); 24813433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 24823433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_SLCT: 24833433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitSLCT(insn->asCmp()); 24843433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 24853433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_MIN: 24863433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_MAX: 24873433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitMINMAX(insn); 24883433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 24893433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_ABS: 24903433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_NEG: 24913433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_CEIL: 24923433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_FLOOR: 24933433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_TRUNC: 24943433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_SAT: 24953433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitCVT(insn); 24963433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 24971a0fde1f52c59e0dbada03f387c8e25d9475ebbeIlia Mirkin case OP_CVT: 24981a0fde1f52c59e0dbada03f387c8e25d9475ebbeIlia Mirkin if (insn->def(0).getFile() == FILE_PREDICATE || 24991a0fde1f52c59e0dbada03f387c8e25d9475ebbeIlia Mirkin insn->src(0).getFile() == FILE_PREDICATE) 25001a0fde1f52c59e0dbada03f387c8e25d9475ebbeIlia Mirkin emitMOV(insn); 25011a0fde1f52c59e0dbada03f387c8e25d9475ebbeIlia Mirkin else 25021a0fde1f52c59e0dbada03f387c8e25d9475ebbeIlia Mirkin emitCVT(insn); 25031a0fde1f52c59e0dbada03f387c8e25d9475ebbeIlia Mirkin break; 25043433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_RSQ: 2505b87b498b88c51fb8c80901b8f581331d3fbcd972Ilia Mirkin emitSFnOp(insn, 5 + 2 * insn->subOp); 25063433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 25073433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_RCP: 2508b87b498b88c51fb8c80901b8f581331d3fbcd972Ilia Mirkin emitSFnOp(insn, 4 + 2 * insn->subOp); 25093433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 25103433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_LG2: 25113433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitSFnOp(insn, 3); 25123433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 25133433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_EX2: 25143433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitSFnOp(insn, 2); 25153433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 25163433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_SIN: 25173433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitSFnOp(insn, 1); 25183433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 25193433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_COS: 25203433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitSFnOp(insn, 0); 25213433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 25223433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_PRESIN: 25233433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_PREEX2: 25243433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitPreOp(insn); 25253433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 25263433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_TEX: 25273433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_TXB: 25283433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_TXL: 25293433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_TXD: 25303433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_TXF: 2531f6579e4b17a6010fadb464b5179dea5779c74968Ilia Mirkin case OP_TXG: 2532423f64e83ab5b1ea7de475ae80300a8408522743Ilia Mirkin case OP_TXLQ: 25333433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitTEX(insn->asTex()); 25343433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 25353433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_TXQ: 25363433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitTXQ(insn->asTex()); 25373433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 25383433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_TEXBAR: 25393433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitTEXBAR(insn); 25403433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 2541af38ef907c89ecb1125bf258cafa0793f79a5eb7Ilia Mirkin case OP_PIXLD: 2542af38ef907c89ecb1125bf258cafa0793f79a5eb7Ilia Mirkin emitPIXLD(insn); 2543af38ef907c89ecb1125bf258cafa0793f79a5eb7Ilia Mirkin break; 25443433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_BRA: 25453433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_CALL: 25463433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_PRERET: 25473433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_RET: 25483433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_DISCARD: 25493433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_EXIT: 25503433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_PRECONT: 25513433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_CONT: 25523433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_PREBREAK: 25533433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_BREAK: 25543433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_JOINAT: 25553433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_BRKPT: 25563433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_QUADON: 25573433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_QUADPOP: 25583433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitFlow(insn); 25593433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 25603433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_QUADOP: 25613433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitQUADOP(insn, insn->subOp, insn->lanes); 25623433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 25633433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_DFDX: 25643433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitQUADOP(insn, insn->src(0).mod.neg() ? 0x66 : 0x99, 0x4); 25653433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 25663433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_DFDY: 25673433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitQUADOP(insn, insn->src(0).mod.neg() ? 0x5a : 0xa5, 0x5); 25683433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 25693433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_POPCNT: 25703433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitPOPC(insn); 25713433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 2572b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin case OP_INSBF: 2573b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin emitINSBF(insn); 2574b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin break; 2575b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin case OP_EXTBF: 2576b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin emitEXTBF(insn); 2577b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin break; 2578b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin case OP_BFIND: 2579b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin emitBFIND(insn); 2580b4b20d42f6a8cd5aec3ba529a0b8d6ea22e73305Ilia Mirkin break; 2581c2ce22ca4641343e9bad446811a882c5c3930419Samuel Pitoiset case OP_PERMT: 2582c2ce22ca4641343e9bad446811a882c5c3930419Samuel Pitoiset emitPERMT(insn); 2583c2ce22ca4641343e9bad446811a882c5c3930419Samuel Pitoiset break; 25843433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_JOIN: 25853433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emitNOP(insn); 25863433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller insn->join = 1; 25873433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller break; 258888818c4cd6de9d8855a9ba3c3a85306d42f5e9d3Ilia Mirkin case OP_BAR: 258988818c4cd6de9d8855a9ba3c3a85306d42f5e9d3Ilia Mirkin emitBAR(insn); 259088818c4cd6de9d8855a9ba3c3a85306d42f5e9d3Ilia Mirkin break; 25918482763d35d8bbf596a7cce84bb53f4b73d5fa6fSamuel Pitoiset case OP_MEMBAR: 25928482763d35d8bbf596a7cce84bb53f4b73d5fa6fSamuel Pitoiset emitMEMBAR(insn); 25938482763d35d8bbf596a7cce84bb53f4b73d5fa6fSamuel Pitoiset break; 25947d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin case OP_ATOM: 25957d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin emitATOM(insn); 25967d9a97d6beee8878ac57448af8c41b8af3f189b1Ilia Mirkin break; 25978c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin case OP_CCTL: 25988c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin emitCCTL(insn); 25998c2dfe05c5db9946d2d30546920e98bcfb8e3eb9Ilia Mirkin break; 260007ed003faf3199a3e95852e7a34763aeaf76503dSamuel Pitoiset case OP_VOTE: 260107ed003faf3199a3e95852e7a34763aeaf76503dSamuel Pitoiset emitVOTE(insn); 260207ed003faf3199a3e95852e7a34763aeaf76503dSamuel Pitoiset break; 26031f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset case OP_SULDB: 26041f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset emitSULDGB(insn->asTex()); 26051f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset break; 26061f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset case OP_SUSTB: 26071f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset case OP_SUSTP: 26081f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset emitSUSTGx(insn->asTex()); 26091f8900a8e0c344c17dafd9ab57c7fb24c0eec588Samuel Pitoiset break; 2610af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case OP_SUBFM: 2611af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case OP_SUCLAMP: 2612af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset case OP_SUEAU: 2613af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset emitSUCalc(insn); 2614af5925209d730f917431b603b031085c7c96c773Samuel Pitoiset break; 26152daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset case OP_VSHL: 26162daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset emitVSHL(insn); 26172daaa5d657910239833dc796dc1ac6f4b168e3dfSamuel Pitoiset break; 26183433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_PHI: 26193433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_UNION: 26203433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_CONSTRAINT: 26213433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller ERROR("operation should have been eliminated"); 26223433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller return false; 26233433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_EXP: 26243433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_LOG: 26253433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_SQRT: 26263433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller case OP_POW: 26273433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller ERROR("operation should have been lowered\n"); 26283433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller return false; 26293433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller default: 2630b8c524ff88499f64c94f1d1c41671107f98f991aSamuel Pitoiset ERROR("unknown op: %u\n", insn->op); 26313433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller return false; 26323433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller } 26333433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 26343433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (insn->join) 26353433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code[0] |= 1 << 22; 26363433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 26373433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code += 2; 26383433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller codeSize += 8; 26393433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller return true; 26403433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 26413433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 26423433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumilleruint32_t 26433433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::getMinEncodingSize(const Instruction *i) const 26443433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 26453433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller // No more short instruction encodings. 26463433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller return 8; 26473433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 26483433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 26493433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumillervoid 26503433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::prepareEmission(Function *func) 26513433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 26523433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller const Target *targ = func->getProgram()->getTarget(); 26533433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 26543433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller CodeEmitter::prepareEmission(func); 26553433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 26563433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller if (targ->hasSWSched) 26573433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller calculateSchedDataNVC0(targ, func); 26583433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 26593433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 26603433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitterGK110::CodeEmitterGK110(const TargetNVC0 *target) 26613433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller : CodeEmitter(target), 26623741b7d844f7357fac984e8c565dedb248947487Christoph Bumiller targNVC0(target), 26633433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller writeIssueDelays(target->hasSWSched) 26643433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 26653433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller code = NULL; 26663433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller codeSize = codeSizeLimit = 0; 26673433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller relocInfo = NULL; 26683433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 26693433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 26703433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerCodeEmitter * 26713433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph BumillerTargetNVC0::createCodeEmitterGK110(Program::Type type) 26723433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller{ 26733433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller CodeEmitterGK110 *emit = new CodeEmitterGK110(this); 26743433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller emit->setProgramType(type); 26753433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller return emit; 26763433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} 26773433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller 26783433471e8b46dd9dd042a00f88ef9ad011a94aacChristoph Bumiller} // namespace nv50_ir 2679