2 * Copyright 2011 Christoph Bumiller
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 #include "nv50_ir_util.h"
34 #include "nv50_ir_graph.h"
36 #include "nv50_ir_driver.h"
44 OP_UNION
, // unify a new definition and several source values
45 OP_SPLIT
, // $r0d -> { $r0, $r1 } ($r0d and $r0/$r1 will be coalesced)
46 OP_MERGE
, // opposite of split, e.g. combine 2 32 bit into a 64 bit value
47 OP_CONSTRAINT
, // copy values into consecutive registers
48 OP_MOV
, // simple copy, no modifiers allowed
58 OP_SAD
, // abs(src0 - src1) + src2
69 OP_SAT
, // CLAMP(f32, 0.0, 1.0)
74 OP_SET_AND
, // dst = (src0 CMP src1) & src2
78 OP_SELP
, // dst = src2 ? src0 : src1
79 OP_SLCT
, // dst = (src2 CMP 0) ? src0 : src1
86 OP_EXP
, // exponential (base M_E)
87 OP_LOG
, // natural logarithm
100 OP_BRKPT
, // breakpoint (not related to loops)
101 OP_JOINAT
, // push control flow convergence point
106 OP_VFETCH
, // indirection 0 in attribute space, indirection 1 is vertex base
107 OP_PFETCH
, // fetch base address of vertex src0 (immediate) [+ src1]
111 OP_EMIT
, // emit vertex
112 OP_RESTART
, // restart primitive
114 OP_TXB
, // texture bias
115 OP_TXL
, // texure lod
116 OP_TXF
, // texel fetch
117 OP_TXQ
, // texture size query
118 OP_TXD
, // texture derivatives
119 OP_TXG
, // texture gather
121 OP_SULD
, // surface load
122 OP_SUST
, // surface store
125 OP_RDSV
, // read system value
126 OP_WRSV
, // write system value
127 OP_TEXPREP
, // turn cube map array into 2d array coordinates, TODO: move
131 OP_POPCNT
, // bitcount(src0 & src1)
132 OP_INSBF
, // insert first src1[8:15] bits of src0 into src2 at src1[0:7]
138 // various instruction-specific modifier definitions Instruction::subOp
139 // MOV_FINAL marks a MOV originating from an EXPORT (used for placing TEXBARs)
140 #define NV50_IR_SUBOP_MUL_HIGH 1
141 #define NV50_IR_SUBOP_EMIT_RESTART 1
142 #define NV50_IR_SUBOP_LDC_IL 1
143 #define NV50_IR_SUBOP_LDC_IS 2
144 #define NV50_IR_SUBOP_LDC_ISL 3
145 #define NV50_IR_SUBOP_SHIFT_WRAP 1
146 #define NV50_IR_SUBOP_EMU_PRERET 1
147 #define NV50_IR_SUBOP_TEXBAR(n) n
148 #define NV50_IR_SUBOP_MOV_FINAL 1
159 TYPE_U64
, // 64 bit operations are only lowered after register allocation
171 CC_NEVER
= CC_FL
, // when used with FILE_FLAGS
174 CC_NOT_P
= CC_EQ
, // when used with FILE_PREDICATE
202 ROUND_M
, // towards -inf
203 ROUND_Z
, // towards 0
204 ROUND_P
, // towards +inf
205 ROUND_NI
, // nearest integer
206 ROUND_MI
, // to integer towards -inf
207 ROUND_ZI
, // to integer towards 0
208 ROUND_PI
, // to integer towards +inf
213 CACHE_CA
, // cache at all levels
214 CACHE_WB
= CACHE_CA
, // cache write back
215 CACHE_CG
, // cache at global level
216 CACHE_CS
, // cache streaming
217 CACHE_CV
, // cache as volatile
218 CACHE_WT
= CACHE_CV
// cache write-through
225 FILE_PREDICATE
, // boolean predicate
226 FILE_FLAGS
, // zero/sign/carry/overflow bits
228 LAST_REGISTER_FILE
= FILE_ADDRESS
,
247 TEX_TARGET_1D_SHADOW
,
248 TEX_TARGET_2D_SHADOW
,
249 TEX_TARGET_CUBE_SHADOW
,
252 TEX_TARGET_2D_MS_ARRAY
,
253 TEX_TARGET_CUBE_ARRAY
,
254 TEX_TARGET_1D_ARRAY_SHADOW
,
255 TEX_TARGET_2D_ARRAY_SHADOW
,
257 TEX_TARGET_RECT_SHADOW
,
258 TEX_TARGET_CUBE_ARRAY_SHADOW
,
270 SV_VERTEX_COUNT
, // gl_PatchVerticesIn
303 class CmpInstruction
;
304 class TexInstruction
;
305 class FlowInstruction
;
310 class ImmediateValue
;
315 int8_t fileIndex
; // signed, may be indirect for CONST[]
316 uint8_t size
; // this should match the Instruction type's size
317 DataType type
; // mainly for pretty printing
319 uint64_t u64
; // immediate values
329 int32_t offset
; // offset from 0 (base of address space)
330 int32_t id
; // register id (< 0 if virtual/unassigned, in units <= 4)
338 // precedence: NOT after SAT after NEG after ABS
339 #define NV50_IR_MOD_ABS (1 << 0)
340 #define NV50_IR_MOD_NEG (1 << 1)
341 #define NV50_IR_MOD_SAT (1 << 2)
342 #define NV50_IR_MOD_NOT (1 << 3)
343 #define NV50_IR_MOD_NEG_ABS (NV50_IR_MOD_NEG | NV50_IR_MOD_ABS)
345 #define NV50_IR_INTERP_MODE_MASK 0x3
346 #define NV50_IR_INTERP_LINEAR (0 << 0)
347 #define NV50_IR_INTERP_PERSPECTIVE (1 << 0)
348 #define NV50_IR_INTERP_FLAT (2 << 0)
349 #define NV50_IR_INTERP_SC (3 << 0) // what exactly is that ?
350 #define NV50_IR_INTERP_SAMPLE_MASK 0xc
351 #define NV50_IR_INTERP_DEFAULT (0 << 2)
352 #define NV50_IR_INTERP_CENTROID (1 << 2)
353 #define NV50_IR_INTERP_OFFSET (2 << 2)
354 #define NV50_IR_INTERP_SAMPLEID (3 << 2)
356 // do we really want this to be a class ?
360 Modifier() : bits(0) { }
361 Modifier(unsigned int m
) : bits(m
) { }
362 Modifier(operation op
);
364 // @return new Modifier applying a after b (asserts if unrepresentable)
365 Modifier
operator*(const Modifier
) const;
366 Modifier
operator*=(const Modifier m
) { *this = *this * m
; return *this; }
367 Modifier
operator==(const Modifier m
) const { return m
.bits
== bits
; }
368 Modifier
operator!=(const Modifier m
) const { return m
.bits
!= bits
; }
370 inline Modifier
operator&(const Modifier m
) const { return bits
& m
.bits
; }
371 inline Modifier
operator|(const Modifier m
) const { return bits
| m
.bits
; }
372 inline Modifier
operator^(const Modifier m
) const { return bits
^ m
.bits
; }
374 operation
getOp() const;
376 inline int neg() const { return (bits
& NV50_IR_MOD_NEG
) ? 1 : 0; }
377 inline int abs() const { return (bits
& NV50_IR_MOD_ABS
) ? 1 : 0; }
379 inline operator bool() const { return bits
? true : false; }
381 void applyTo(ImmediateValue
&imm
) const;
383 int print(char *buf
, size_t size
) const;
392 ValueRef(Value
* = NULL
);
393 ValueRef(const ValueRef
&);
396 inline bool exists() const { return value
!= NULL
; }
399 void set(const ValueRef
&);
400 inline Value
*get() const { return value
; }
401 inline Value
*rep() const;
403 inline Instruction
*getInsn() const { return insn
; }
404 inline void setInsn(Instruction
*inst
) { insn
= inst
; }
406 inline bool isIndirect(int dim
) const { return indirect
[dim
] >= 0; }
407 inline const ValueRef
*getIndirect(int dim
) const;
409 inline DataFile
getFile() const;
410 inline unsigned getSize() const;
412 // SSA: return eventual (traverse MOVs) literal value, if it exists
413 bool getImmediate(ImmediateValue
&) const;
417 int8_t indirect
[2]; // >= 0 if relative to lvalue in insn->src(indirect[i])
420 bool usedAsPtr
; // for printing
430 ValueDef(Value
* = NULL
);
431 ValueDef(const ValueDef
&);
434 inline bool exists() const { return value
!= NULL
; }
436 inline Value
*get() const { return value
; }
437 inline Value
*rep() const;
439 bool mayReplace(const ValueRef
&);
440 void replace(const ValueRef
&, bool doSet
); // replace all uses of the old value
442 inline Instruction
*getInsn() const { return insn
; }
443 inline void setInsn(Instruction
*inst
) { insn
= inst
; }
445 inline DataFile
getFile() const;
446 inline unsigned getSize() const;
448 inline void setSSA(LValue
*);
449 inline const LValue
*preSSA() const;
452 Value
*value
; // should make this LValue * ...
453 LValue
*origin
; // pre SSA value
463 virtual Value
*clone(ClonePolicy
<Function
>&) const = 0;
465 virtual int print(char *, size_t, DataType ty
= TYPE_NONE
) const = 0;
467 virtual bool equals(const Value
*, bool strict
= false) const;
468 virtual bool interfers(const Value
*) const;
469 virtual bool isUniform() const { return true; }
471 inline Value
*rep() const { return join
; }
473 inline Instruction
*getUniqueInsn() const;
474 inline Instruction
*getInsn() const; // use when uniqueness is certain
476 inline int refCount() { return uses
.size(); }
478 inline LValue
*asLValue();
479 inline Symbol
*asSym();
480 inline ImmediateValue
*asImm();
481 inline const Symbol
*asSym() const;
482 inline const ImmediateValue
*asImm() const;
484 inline bool inFile(DataFile f
) { return reg
.file
== f
; }
486 static inline Value
*get(Iterator
&);
488 std::list
<ValueRef
*> uses
;
489 std::list
<ValueDef
*> defs
;
490 typedef std::list
<ValueRef
*>::iterator UseIterator
;
491 typedef std::list
<ValueRef
*>::const_iterator UseCIterator
;
492 typedef std::list
<ValueDef
*>::iterator DefIterator
;
493 typedef std::list
<ValueDef
*>::const_iterator DefCIterator
;
498 // TODO: these should be in LValue:
503 class LValue
: public Value
506 LValue(Function
*, DataFile file
);
507 LValue(Function
*, LValue
*);
510 virtual bool isUniform() const;
512 virtual LValue
*clone(ClonePolicy
<Function
>&) const;
514 virtual int print(char *, size_t, DataType ty
= TYPE_NONE
) const;
517 unsigned compMask
: 8; // compound/component mask
518 unsigned compound
: 1; // used by RA, value involved in split/merge
520 unsigned fixedReg
: 1; // set & used by RA, earlier just use (id < 0)
521 unsigned noSpill
: 1; // do not spill (e.g. if spill temporary already)
524 class Symbol
: public Value
527 Symbol(Program
*, DataFile file
= FILE_MEMORY_CONST
, ubyte fileIdx
= 0);
530 virtual Symbol
*clone(ClonePolicy
<Function
>&) const;
532 virtual bool equals(const Value
*that
, bool strict
) const;
534 virtual bool isUniform() const;
536 virtual int print(char *, size_t, DataType ty
= TYPE_NONE
) const;
538 // print with indirect values
539 int print(char *, size_t, Value
*, Value
*, DataType ty
= TYPE_NONE
) const;
541 inline void setFile(DataFile file
, ubyte fileIndex
= 0)
544 reg
.fileIndex
= fileIndex
;
547 inline void setOffset(int32_t offset
);
548 inline void setAddress(Symbol
*base
, int32_t offset
);
549 inline void setSV(SVSemantic sv
, uint32_t idx
= 0);
551 inline const Symbol
*getBase() const { return baseSym
; }
554 Symbol
*baseSym
; // array base for Symbols representing array elements
557 class ImmediateValue
: public Value
561 ImmediateValue(Program
*, uint32_t);
562 ImmediateValue(Program
*, float);
563 ImmediateValue(Program
*, double);
564 // NOTE: not added to program with
565 ImmediateValue(const ImmediateValue
*, DataType ty
);
566 ~ImmediateValue() { };
568 virtual ImmediateValue
*clone(ClonePolicy
<Function
>&) const;
570 virtual bool equals(const Value
*that
, bool strict
) const;
572 // these only work if 'type' is valid (we mostly use untyped literals):
573 bool isInteger(const int ival
) const; // ival is cast to this' type
574 bool isNegative() const;
579 // for constant folding:
580 ImmediateValue
operator+(const ImmediateValue
&) const;
581 ImmediateValue
operator-(const ImmediateValue
&) const;
582 ImmediateValue
operator*(const ImmediateValue
&) const;
583 ImmediateValue
operator/(const ImmediateValue
&) const;
585 ImmediateValue
& operator=(const ImmediateValue
&); // only sets value !
587 bool compare(CondCode cc
, float fval
) const;
589 virtual int print(char *, size_t, DataType ty
= TYPE_NONE
) const;
596 Instruction(Function
*, operation
, DataType
);
597 virtual ~Instruction();
599 virtual Instruction
*clone(ClonePolicy
<Function
>&,
600 Instruction
* = NULL
) const;
602 void setDef(int i
, Value
*);
603 void setSrc(int s
, Value
*);
604 void setSrc(int s
, const ValueRef
&);
605 void swapSources(int a
, int b
);
606 void moveSources(int s
, int delta
); // NOTE: only delta > 0 implemented
607 bool setIndirect(int s
, int dim
, Value
*);
609 inline ValueRef
& src(int s
) { return srcs
[s
]; }
610 inline ValueDef
& def(int s
) { return defs
[s
]; }
611 inline const ValueRef
& src(int s
) const { return srcs
[s
]; }
612 inline const ValueDef
& def(int s
) const { return defs
[s
]; }
614 inline Value
*getDef(int d
) const { return defs
[d
].get(); }
615 inline Value
*getSrc(int s
) const { return srcs
[s
].get(); }
616 inline Value
*getIndirect(int s
, int dim
) const;
618 inline bool defExists(unsigned d
) const
620 return d
< defs
.size() && defs
[d
].exists();
622 inline bool srcExists(unsigned s
) const
624 return s
< srcs
.size() && srcs
[s
].exists();
627 inline bool constrainedDefs() const;
629 bool setPredicate(CondCode ccode
, Value
*);
630 inline Value
*getPredicate() const;
631 bool writesPredicate() const;
632 inline bool isPredicated() const { return predSrc
>= 0; }
634 inline void setFlagsSrc(int s
, Value
*);
635 inline void setFlagsDef(int d
, Value
*);
637 unsigned int defCount() const { return defs
.size(); };
638 unsigned int defCount(unsigned int mask
, bool singleFile
= false) const;
639 unsigned int srcCount() const { return srcs
.size(); };
640 unsigned int srcCount(unsigned int mask
, bool singleFile
= false) const;
642 // save & remove / set indirect[0,1] and predicate source
643 void takeExtraSources(int s
, Value
*[3]);
644 void putExtraSources(int s
, Value
*[3]);
646 inline void setType(DataType type
) { dType
= sType
= type
; }
648 inline void setType(DataType dtype
, DataType stype
)
654 inline bool isPseudo() const { return op
< OP_MOV
; }
657 bool isCommutationLegal(const Instruction
*) const; // must be adjacent !
658 bool isActionEqual(const Instruction
*) const;
659 bool isResultEqual(const Instruction
*) const;
663 inline CmpInstruction
*asCmp();
664 inline TexInstruction
*asTex();
665 inline FlowInstruction
*asFlow();
666 inline const TexInstruction
*asTex() const;
667 inline const CmpInstruction
*asCmp() const;
668 inline const FlowInstruction
*asFlow() const;
674 int serial
; // CFG order
677 DataType dType
; // destination or defining type
678 DataType sType
; // source or secondary type
683 uint8_t subOp
; // quadop, 1 for mul-high, etc.
685 uint8_t sched
; // scheduling data (NOTE: maybe move to separate storage)
687 unsigned encSize
: 4; // encoding size in bytes
688 unsigned saturate
: 1; // to [0.0f, 1.0f]
689 unsigned join
: 1; // converge control flow (use OP_JOIN until end)
690 unsigned fixed
: 1; // prevent dead code elimination
691 unsigned terminator
: 1; // end of basic block
693 unsigned ftz
: 1; // flush denormal to zero
694 unsigned dnz
: 1; // denormals, NaN are zero
695 unsigned ipa
: 4; // interpolation mode
697 unsigned perPatch
: 1;
698 unsigned exit
: 1; // terminate program after insn
700 int8_t postFactor
; // MUL/DIV(if < 0) by 1 << postFactor
709 std::deque
<ValueDef
> defs
; // no gaps !
710 std::deque
<ValueRef
> srcs
; // no gaps !
712 // instruction specific methods:
713 // (don't want to subclass, would need more constructors and memory pools)
715 inline void setInterpolate(unsigned int mode
) { ipa
= mode
; }
717 unsigned int getInterpMode() const { return ipa
& 0x3; }
718 unsigned int getSampleMode() const { return ipa
& 0xc; }
735 class TexInstruction
: public Instruction
741 Target(TexTarget targ
= TEX_TARGET_2D
) : target(targ
) { }
743 const char *getName() const { return descTable
[target
].name
; }
744 unsigned int getArgCount() const { return descTable
[target
].argc
; }
745 unsigned int getDim() const { return descTable
[target
].dim
; }
746 int isArray() const { return descTable
[target
].array
? 1 : 0; }
747 int isCube() const { return descTable
[target
].cube
? 1 : 0; }
748 int isShadow() const { return descTable
[target
].shadow
? 1 : 0; }
750 Target
& operator=(TexTarget targ
)
752 assert(targ
< TEX_TARGET_COUNT
);
757 inline bool operator==(TexTarget targ
) const { return target
== targ
; }
770 static const struct Desc descTable
[TEX_TARGET_COUNT
];
773 enum TexTarget target
;
777 TexInstruction(Function
*, operation
);
778 virtual ~TexInstruction();
780 virtual TexInstruction
*clone(ClonePolicy
<Function
>&,
781 Instruction
* = NULL
) const;
783 inline void setTexture(Target targ
, uint8_t r
, uint8_t s
)
790 inline Value
*getIndirectR() const;
791 inline Value
*getIndirectS() const;
805 bool liveOnly
; // only execute on live pixels of a quad (optimization)
809 int8_t useOffsets
; // 0, 1, or 4 for textureGatherOffsets
819 class CmpInstruction
: public Instruction
822 CmpInstruction(Function
*, operation
);
824 virtual CmpInstruction
*clone(ClonePolicy
<Function
>&,
825 Instruction
* = NULL
) const;
827 void setCondition(CondCode cond
) { setCond
= cond
; }
828 CondCode
getCondition() const { return setCond
; }
834 class FlowInstruction
: public Instruction
837 FlowInstruction(Function
*, operation
, void *target
);
839 virtual FlowInstruction
*clone(ClonePolicy
<Function
>&,
840 Instruction
* = NULL
) const;
843 unsigned allWarp
: 1;
844 unsigned absolute
: 1;
846 unsigned builtin
: 1; // true for calls to emulation code
858 BasicBlock(Function
*);
861 BasicBlock
*clone(ClonePolicy
<Function
>&) const;
863 inline int getId() const { return id
; }
864 inline unsigned int getInsnCount() const { return numInsns
; }
865 inline bool isTerminated() const { return exit
&& exit
->terminator
; }
867 bool dominatedBy(BasicBlock
*bb
);
868 inline bool reachableBy(const BasicBlock
*by
, const BasicBlock
*term
);
870 // returns mask of conditional out blocks
871 // e.g. 3 for IF { .. } ELSE { .. } ENDIF, 1 for IF { .. } ENDIF
872 unsigned int initiatesSimpleConditional() const;
875 Function
*getFunction() const { return func
; }
876 Program
*getProgram() const { return program
; }
878 Instruction
*getEntry() const { return entry
; } // first non-phi instruction
879 Instruction
*getPhi() const { return phi
; }
880 Instruction
*getFirst() const { return phi
? phi
: entry
; }
881 Instruction
*getExit() const { return exit
; }
883 void insertHead(Instruction
*);
884 void insertTail(Instruction
*);
885 void insertBefore(Instruction
*, Instruction
*);
886 void insertAfter(Instruction
*, Instruction
*);
887 void remove(Instruction
*);
888 void permuteAdjacent(Instruction
*, Instruction
*);
890 BasicBlock
*idom() const;
892 // NOTE: currently does not rebuild the dominator tree
893 BasicBlock
*splitBefore(Instruction
*, bool attach
= true);
894 BasicBlock
*splitAfter(Instruction
*, bool attach
= true);
896 DLList
& getDF() { return df
; }
897 DLList::Iterator
iterDF() { return df
.iterator(); }
899 static inline BasicBlock
*get(Iterator
&);
900 static inline BasicBlock
*get(Graph::Node
*);
903 Graph::Node cfg
; // first edge is branch *taken* (the ELSE branch)
912 Instruction
*joinAt
; // for quick reference
914 bool explicitCont
; // loop headers: true if loop contains continue stmts
924 unsigned int numInsns
;
930 void splitCommon(Instruction
*, BasicBlock
*, bool attach
);
936 Function(Program
*, const char *name
, uint32_t label
);
939 static inline Function
*get(Graph::Node
*node
);
941 inline Program
*getProgram() const { return prog
; }
942 inline const char *getName() const { return name
; }
943 inline int getId() const { return id
; }
944 inline uint32_t getLabel() const { return label
; }
947 void printLiveIntervals() const;
948 void printCFGraph(const char *filePath
);
950 bool setEntry(BasicBlock
*);
951 bool setExit(BasicBlock
*);
953 unsigned int orderInstructions(ArrayList
&);
955 inline void add(BasicBlock
*bb
, int& id
) { allBBlocks
.insert(bb
, id
); }
956 inline void add(Instruction
*insn
, int& id
) { allInsns
.insert(insn
, id
); }
957 inline void add(LValue
*lval
, int& id
) { allLValues
.insert(lval
, id
); }
959 inline LValue
*getLValue(int id
);
961 void buildLiveSets();
966 std::deque
<ValueDef
> ins
;
967 std::deque
<ValueRef
> outs
;
968 std::deque
<Value
*> clobbers
;
971 Graph::Node
*cfgExit
;
973 Graph::Node call
; // node in the call graph
975 BasicBlock
**bbArray
; // BBs in emission order
978 unsigned int loopNestingBound
;
986 uint32_t tlsBase
; // base address for l[] space (if no stack pointer is used)
989 ArrayList allBBlocks
;
991 ArrayList allLValues
;
994 void buildLiveSetsPreSSA(BasicBlock
*, const int sequence
);
995 void buildDefSetsPreSSA(BasicBlock
*bb
, const int seq
);
1000 const char *const name
;
1007 CG_STAGE_SSA
, // expected directly before register allocation
1017 TYPE_TESSELLATION_CONTROL
,
1018 TYPE_TESSELLATION_EVAL
,
1024 Program(Type type
, Target
*targ
);
1029 Type
getType() const { return progType
; }
1031 inline void add(Function
*fn
, int& id
) { allFuncs
.insert(fn
, id
); }
1032 inline void del(Function
*fn
, int& id
) { allFuncs
.remove(id
); }
1033 inline void add(Value
*rval
, int& id
) { allRValues
.insert(rval
, id
); }
1035 bool makeFromTGSI(struct nv50_ir_prog_info
*);
1036 bool makeFromSM4(struct nv50_ir_prog_info
*);
1037 bool convertToSSA();
1038 bool optimizeSSA(int level
);
1039 bool optimizePostRA(int level
);
1040 bool registerAllocation();
1041 bool emitBinary(struct nv50_ir_prog_info
*);
1043 const Target
*getTarget() const { return target
; }
1046 void emitSymbolTable(struct nv50_ir_prog_info
*);
1056 ArrayList allRValues
;
1060 uint32_t tlsSize
; // size required for FILE_MEMORY_LOCAL
1064 MemoryPool mem_Instruction
;
1065 MemoryPool mem_CmpInstruction
;
1066 MemoryPool mem_TexInstruction
;
1067 MemoryPool mem_FlowInstruction
;
1068 MemoryPool mem_LValue
;
1069 MemoryPool mem_Symbol
;
1070 MemoryPool mem_ImmediateValue
;
1075 void *targetPriv
; // e.g. to carry information between passes
1077 void releaseInstruction(Instruction
*);
1078 void releaseValue(Value
*);
1081 // TODO: add const version
1085 bool run(Program
*, bool ordered
= false, bool skipPhi
= false);
1086 bool run(Function
*, bool ordered
= false, bool skipPhi
= false);
1089 // return false to continue with next entity on next higher level
1090 virtual bool visit(Function
*) { return true; }
1091 virtual bool visit(BasicBlock
*) { return true; }
1092 virtual bool visit(Instruction
*) { return false; }
1094 bool doRun(Program
*, bool ordered
, bool skipPhi
);
1095 bool doRun(Function
*, bool ordered
, bool skipPhi
);
1103 // =============================================================================
1105 #include "nv50_ir_inlines.h"
1107 } // namespace nv50_ir
1109 #endif // __NV50_IR_H__