1d2d19ea51fa3575a8d014a69a9b835c335728817Christoph Bumiller/*
2d2d19ea51fa3575a8d014a69a9b835c335728817Christoph Bumiller * Copyright 2011 Christoph Bumiller
3d2d19ea51fa3575a8d014a69a9b835c335728817Christoph Bumiller *
4d2d19ea51fa3575a8d014a69a9b835c335728817Christoph Bumiller * Permission is hereby granted, free of charge, to any person obtaining a
5d2d19ea51fa3575a8d014a69a9b835c335728817Christoph Bumiller * copy of this software and associated documentation files (the "Software"),
6d2d19ea51fa3575a8d014a69a9b835c335728817Christoph Bumiller * to deal in the Software without restriction, including without limitation
7d2d19ea51fa3575a8d014a69a9b835c335728817Christoph Bumiller * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8d2d19ea51fa3575a8d014a69a9b835c335728817Christoph Bumiller * and/or sell copies of the Software, and to permit persons to whom the
9d2d19ea51fa3575a8d014a69a9b835c335728817Christoph Bumiller * Software is furnished to do so, subject to the following conditions:
10d2d19ea51fa3575a8d014a69a9b835c335728817Christoph Bumiller *
11d2d19ea51fa3575a8d014a69a9b835c335728817Christoph Bumiller * The above copyright notice and this permission notice shall be included in
12d2d19ea51fa3575a8d014a69a9b835c335728817Christoph Bumiller * all copies or substantial portions of the Software.
13d2d19ea51fa3575a8d014a69a9b835c335728817Christoph Bumiller *
14d2d19ea51fa3575a8d014a69a9b835c335728817Christoph Bumiller * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15d2d19ea51fa3575a8d014a69a9b835c335728817Christoph Bumiller * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16d2d19ea51fa3575a8d014a69a9b835c335728817Christoph 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.
21d2d19ea51fa3575a8d014a69a9b835c335728817Christoph Bumiller */
2257594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
2357594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller#ifndef __NV50_IR_TARGET_H__
2457594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller#define __NV50_IR_TARGET_H__
2557594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
265eb7ff1175a644ffe3b0f1a75cb235400355f9fbJohannes Obermayr#include "codegen/nv50_ir.h"
2757594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
2857594065c30feec9376be9b2132659f7d87362eeChristoph Bumillernamespace nv50_ir {
2957594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
3057594065c30feec9376be9b2132659f7d87362eeChristoph Bumillerstruct RelocInfo;
3157594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
3257594065c30feec9376be9b2132659f7d87362eeChristoph Bumillerstruct RelocEntry
3357594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller{
3457594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   enum Type
3557594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   {
3657594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller      TYPE_CODE,
3757594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller      TYPE_BUILTIN,
3857594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller      TYPE_DATA
3957594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   };
4057594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
4157594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   uint32_t data;
4257594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   uint32_t mask;
4357594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   uint32_t offset;
4457594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   int8_t bitPos;
4557594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   Type type;
4657594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
4757594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   inline void apply(uint32_t *binary, const RelocInfo *info) const;
4857594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller};
4957594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
5057594065c30feec9376be9b2132659f7d87362eeChristoph Bumillerstruct RelocInfo
5157594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller{
5257594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   uint32_t codePos;
5357594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   uint32_t libPos;
5457594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   uint32_t dataPos;
5557594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
5657594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   uint32_t count;
5757594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
5857594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   RelocEntry entry[0];
5957594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller};
6057594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
61f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkinstruct FixupData {
62062c6b8e54c14adcc1ec603fad524f38fe058e67Ilia Mirkin   FixupData(bool force, bool flat, uint8_t alphatest) :
63062c6b8e54c14adcc1ec603fad524f38fe058e67Ilia Mirkin      force_persample_interp(force), flatshade(flat), alphatest(alphatest) {}
64f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin   bool force_persample_interp;
65f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin   bool flatshade;
66062c6b8e54c14adcc1ec603fad524f38fe058e67Ilia Mirkin   uint8_t alphatest;
67b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin};
68b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin
69f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkinstruct FixupEntry;
70f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkintypedef void (*FixupApply)(const FixupEntry*, uint32_t*, const FixupData&);
71f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin
72f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkinstruct FixupEntry
73f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin{
74f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin   FixupEntry(FixupApply apply, int ipa, int reg, int loc) :
75f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin      apply(apply), ipa(ipa), reg(reg), loc(loc) {}
76f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin
77f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin   FixupApply apply;
78f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin   union {
79f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin      struct {
80f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin         uint32_t ipa:4; // SC mode used to identify colors
81f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin         uint32_t reg:8; // The reg used for perspective division
82f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin         uint32_t loc:20; // Let's hope we don't have more than 1M-sized shaders
83f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin      };
84f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin      uint32_t val;
85f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin   };
86f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin};
87b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin
88f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkinstruct FixupInfo
89b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin{
90b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin   uint32_t count;
91f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin   FixupEntry entry[0];
92b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin};
93b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin
9457594065c30feec9376be9b2132659f7d87362eeChristoph Bumillerclass CodeEmitter
9557594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller{
9657594065c30feec9376be9b2132659f7d87362eeChristoph Bumillerpublic:
97322bc7ed68ed92233c97168c036d0aa50c11a20eChristoph Bumiller   CodeEmitter(const Target *);
98e264b8ef4138fb874bcf3f82cfd7468ee27768daChristoph Bumiller   virtual ~CodeEmitter() { }
99322bc7ed68ed92233c97168c036d0aa50c11a20eChristoph Bumiller
10057594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   // returns whether the instruction was encodable and written
10157594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   virtual bool emitInstruction(Instruction *) = 0;
10257594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
10357594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   virtual uint32_t getMinEncodingSize(const Instruction *) const = 0;
10457594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
10557594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   void setCodeLocation(void *, uint32_t size);
10657594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   inline void *getCodeLocation() const { return code; }
10757594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   inline uint32_t getCodeSize() const { return codeSize; }
10857594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
10957594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   bool addReloc(RelocEntry::Type, int w, uint32_t data, uint32_t m,
11057594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller                 int s);
11157594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
11257594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   inline void *getRelocInfo() const { return relocInfo; }
11357594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
114f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin   bool addInterp(int ipa, int reg, FixupApply apply);
115f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin   inline void *getFixupInfo() const { return fixupInfo; }
116b75fff70d82474a571c59c2a3a01e4f9f02286a7Ilia Mirkin
117d548d47edf9f05e6dbf9656abc2f8e78d02cb2f6Ben Skeggs   virtual void prepareEmission(Program *);
118322bc7ed68ed92233c97168c036d0aa50c11a20eChristoph Bumiller   virtual void prepareEmission(Function *);
11957594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   virtual void prepareEmission(BasicBlock *);
12057594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
12157594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   void printBinary() const;
12257594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
12357594065c30feec9376be9b2132659f7d87362eeChristoph Bumillerprotected:
124322bc7ed68ed92233c97168c036d0aa50c11a20eChristoph Bumiller   const Target *targ;
125322bc7ed68ed92233c97168c036d0aa50c11a20eChristoph Bumiller
12657594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   uint32_t *code;
12757594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   uint32_t codeSize;
12857594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   uint32_t codeSizeLimit;
12957594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
13057594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   RelocInfo *relocInfo;
131f5fe9030021af830e6c4453f4ad1521cbb697c81Ilia Mirkin   FixupInfo *fixupInfo;
13257594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller};
13357594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
134afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller
135afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumillerenum OpClass
136afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller{
137afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   OPCLASS_MOVE          = 0,
138afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   OPCLASS_LOAD          = 1,
139afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   OPCLASS_STORE         = 2,
140afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   OPCLASS_ARITH         = 3,
141afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   OPCLASS_SHIFT         = 4,
142afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   OPCLASS_SFU           = 5,
143afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   OPCLASS_LOGIC         = 6,
144afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   OPCLASS_COMPARE       = 7,
145afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   OPCLASS_CONVERT       = 8,
146afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   OPCLASS_ATOMIC        = 9,
147afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   OPCLASS_TEXTURE       = 10,
148afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   OPCLASS_SURFACE       = 11,
149afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   OPCLASS_FLOW          = 12,
150afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   OPCLASS_PSEUDO        = 14,
15122b762f9b495b14400f30bd6537f7c5a6d262325Christoph Bumiller   OPCLASS_VECTOR        = 15,
15222b762f9b495b14400f30bd6537f7c5a6d262325Christoph Bumiller   OPCLASS_BITFIELD      = 16,
15322b762f9b495b14400f30bd6537f7c5a6d262325Christoph Bumiller   OPCLASS_CONTROL       = 17,
15422b762f9b495b14400f30bd6537f7c5a6d262325Christoph Bumiller   OPCLASS_OTHER         = 18
155afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller};
156afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller
15757594065c30feec9376be9b2132659f7d87362eeChristoph Bumillerclass Target
15857594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller{
15957594065c30feec9376be9b2132659f7d87362eeChristoph Bumillerpublic:
1607b9475fa652b9df6d599edbea8fa5049fdd995e1Ben Skeggs   Target(bool m, bool j, bool s) : hasJoin(m), joinAnterior(j), hasSWSched(s) { }
161e264b8ef4138fb874bcf3f82cfd7468ee27768daChristoph Bumiller   virtual ~Target() { }
162afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller
16357594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   static Target *create(uint32_t chipset);
16457594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   static void destroy(Target *);
16557594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
16657594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   // 0x50 and 0x84 to 0xaf for nv50
16757594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   // 0xc0 to 0xdf for nvc0
16857594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   inline uint32_t getChipset() const { return chipset; }
16957594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
17057594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   virtual CodeEmitter *getCodeEmitter(Program::Type) = 0;
17157594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
17257594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   // Drivers should upload this so we can use it from all programs.
17357594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   // The address chosen is supplied to the relocation routine.
17457594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   virtual void getBuiltinCode(const uint32_t **code, uint32_t *size) const = 0;
17557594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
17627a51ff9b420909334898785cf194b5998776e88Ilia Mirkin   virtual void parseDriverInfo(const struct nv50_ir_prog_info *info) {
17727a51ff9b420909334898785cf194b5998776e88Ilia Mirkin      threads = info->prop.cp.numThreads;
17811e75fffeb4afc5be0021477f11e5a18a6ff6abfSamuel Pitoiset      if (threads == 0)
17911e75fffeb4afc5be0021477f11e5a18a6ff6abfSamuel Pitoiset         threads = info->target >= NVISA_GK104_CHIPSET ? 1024 : 512;
18027a51ff9b420909334898785cf194b5998776e88Ilia Mirkin   }
181322bc7ed68ed92233c97168c036d0aa50c11a20eChristoph Bumiller
18257594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   virtual bool runLegalizePass(Program *, CGStage stage) const = 0;
18357594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
18457594065c30feec9376be9b2132659f7d87362eeChristoph Bumillerpublic:
18557594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   struct OpInfo
18657594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   {
18757594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller      OpInfo *variants;
18857594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller      operation op;
18957594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller      uint16_t srcTypes;
19057594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller      uint16_t dstTypes;
19157594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller      uint32_t immdBits;
19257594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller      uint8_t srcNr;
19357594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller      uint8_t srcMods[3];
19457594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller      uint8_t dstMods;
1954ea1565bbc49df79d4c39ba5491b0a83c2679a05Ilia Mirkin      uint16_t srcFiles[3];
1964ea1565bbc49df79d4c39ba5491b0a83c2679a05Ilia Mirkin      uint16_t dstFiles;
19757594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller      unsigned int minEncSize  : 4;
19857594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller      unsigned int vector      : 1;
19957594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller      unsigned int predicate   : 1;
20057594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller      unsigned int commutative : 1;
20157594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller      unsigned int pseudo      : 1;
20257594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller      unsigned int flow        : 1;
20357594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller      unsigned int hasDest     : 1;
20457594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller      unsigned int terminator  : 1;
20557594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   };
20657594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
20757594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   inline const OpInfo& getOpInfo(const Instruction *) const;
20857594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   inline const OpInfo& getOpInfo(const operation) const;
20957594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
21057594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   inline DataFile nativeFile(DataFile f) const;
21157594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
21257594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   virtual bool insnCanLoad(const Instruction *insn, int s,
21357594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller                            const Instruction *ld) const = 0;
2140f647bd65bae16c7a2dc7a960c96593ad6ab729cIlia Mirkin   virtual bool insnCanLoadOffset(const Instruction *insn, int s,
21537b67db6ae34fb6586d640a7a1b6232f091dd812Ilia Mirkin                                  int offset) const = 0;
21657594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   virtual bool isOpSupported(operation, DataType) const = 0;
217286abcb51ec2c27970e901ed815a814b3f0bebf6Christoph Bumiller   virtual bool isAccessSupported(DataFile, DataType) const = 0;
21857594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   virtual bool isModSupported(const Instruction *,
21957594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller                               int s, Modifier) const = 0;
22057594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   virtual bool isSatSupported(const Instruction *) const = 0;
22155f9bdb64e1f88c74754c8e090cd2cdbe62bba05Christoph Bumiller   virtual bool isPostMultiplySupported(operation op, float f,
22255f9bdb64e1f88c74754c8e090cd2cdbe62bba05Christoph Bumiller                                        int& e) const { return false; }
22357594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   virtual bool mayPredicate(const Instruction *,
22457594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller                             const Value *) const = 0;
22557594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
226afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   // whether @insn can be issued together with @next (order matters)
227afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   virtual bool canDualIssue(const Instruction *insn,
228afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller                             const Instruction *next) const { return false; }
22957594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   virtual int getLatency(const Instruction *) const { return 1; }
23057594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   virtual int getThroughput(const Instruction *) const { return 1; }
23157594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
23257594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   virtual unsigned int getFileSize(DataFile) const = 0;
23357594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   virtual unsigned int getFileUnit(DataFile) const = 0;
23457594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
23557594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   virtual uint32_t getSVAddress(DataFile, const Symbol *) const = 0;
23657594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
23757594065c30feec9376be9b2132659f7d87362eeChristoph Bumillerpublic:
2387b9475fa652b9df6d599edbea8fa5049fdd995e1Ben Skeggs   const bool hasJoin;      // true if instructions have a join modifier
239afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   const bool joinAnterior; // true if join is executed before the op
240afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   const bool hasSWSched;   // true if code should provide scheduling data
24157594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
242ba6dcb3c2b8f516b120f591144bf6c3751f0e3f9Ilia Mirkin   static const uint8_t operationSrcNr[];
243ba6dcb3c2b8f516b120f591144bf6c3751f0e3f9Ilia Mirkin   static const OpClass operationClass[];
244afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller
245afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   static inline uint8_t getOpSrcNr(operation op)
246afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   {
247afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller      return operationSrcNr[op];
248afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   }
249afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   static inline OpClass getOpClass(operation op)
250afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   {
251afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller      return operationClass[op];
252afcd7b5d1614a8a758ccb4353a9c31a601c9b9b4Christoph Bumiller   }
25357594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
25457594065c30feec9376be9b2132659f7d87362eeChristoph Bumillerprotected:
25557594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   uint32_t chipset;
25627a51ff9b420909334898785cf194b5998776e88Ilia Mirkin   uint32_t threads;
25757594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
25857594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   DataFile nativeFileMap[DATA_FILE_COUNT];
25957594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
26057594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   OpInfo opInfo[OP_LAST + 1];
26157594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller};
26257594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
26357594065c30feec9376be9b2132659f7d87362eeChristoph Bumillerconst Target::OpInfo& Target::getOpInfo(const Instruction *insn) const
26457594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller{
26557594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   return opInfo[MIN2(insn->op, OP_LAST)];
26657594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller}
26757594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
26857594065c30feec9376be9b2132659f7d87362eeChristoph Bumillerconst Target::OpInfo& Target::getOpInfo(const operation op) const
26957594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller{
27057594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   return opInfo[op];
27157594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller}
27257594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
27357594065c30feec9376be9b2132659f7d87362eeChristoph Bumillerinline DataFile Target::nativeFile(DataFile f) const
27457594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller{
27557594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller   return nativeFileMap[f];
27657594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller}
27757594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
27857594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller} // namespace nv50_ir
27957594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller
28057594065c30feec9376be9b2132659f7d87362eeChristoph Bumiller#endif // __NV50_IR_TARGET_H__
281