maxGPR = -1;
- main = new Function(this, "MAIN");
+ main = new Function(this, "MAIN", ~0);
calls.insert(&main->call);
dbgFlags = 0;
class Function
{
public:
- Function(Program *, const char *name);
+ Function(Program *, const char *name, uint32_t label);
~Function();
static inline Function *get(Graph::Node *node);
inline Program *getProgram() const { return prog; }
inline const char *getName() const { return name; }
inline int getId() const { return id; }
+ inline uint32_t getLabel() const { return label; }
void print();
void printLiveIntervals() const;
void buildDefSetsPreSSA(BasicBlock *bb, const int seq);
private:
+ uint32_t label;
int id;
const char *const name;
Program *prog;
const Target *getTarget() const { return target; }
private:
+ void emitSymbolTable(struct nv50_ir_prog_info *);
+
Type progType;
Target *target;
namespace nv50_ir {
-Function::Function(Program *p, const char *fnName)
+Function::Function(Program *p, const char *fnName, uint32_t label)
: call(this),
+ label(label),
name(fnName),
prog(p)
{
#define NV50_PRIM_PATCHES PIPE_PRIM_MAX
+struct nv50_ir_prog_symbol
+{
+ uint32_t label;
+ uint32_t offset;
+};
+
struct nv50_ir_prog_info
{
uint16_t target; /* chipset (0x50, 0x84, 0xc0, ...) */
uint8_t sourceRep; /* NV50_PROGRAM_IR */
const void *source;
void *relocData;
+ struct nv50_ir_prog_symbol *syms;
+ uint16_t numSyms;
} bin;
struct nv50_ir_varying sv[PIPE_MAX_SHADER_INPUTS];
PRINT(" %sBUILTIN:%i", colour[TXT_BRA], asFlow()->target.builtin);
} else
if (op == OP_CALL && asFlow()->target.fn) {
- PRINT(" %s%s", colour[TXT_BRA], asFlow()->target.fn->getName());
+ PRINT(" %s%s:%i", colour[TXT_BRA],
+ asFlow()->target.fn->getName(),
+ asFlow()->target.fn->getLabel());
} else
if (asFlow()->target.bb)
PRINT(" %sBB:%i", colour[TXT_BRA], asFlow()->target.bb->getId());
bool
PrintPass::visit(Function *fn)
{
- INFO("\n%s:\n", fn->getName());
+ INFO("\n%s:%i\n", fn->getName(), fn->getLabel());
return true;
}
func->binSize += bb->binSize;
}
+void
+Program::emitSymbolTable(struct nv50_ir_prog_info *info)
+{
+ unsigned int n = 0, nMax = allFuncs.getSize();
+
+ info->bin.syms =
+ (struct nv50_ir_prog_symbol *)MALLOC(nMax * sizeof(*info->bin.syms));
+
+ for (ArrayList::Iterator fi = allFuncs.iterator();
+ !fi.end();
+ fi.next(), ++n) {
+ Function *f = (Function *)fi.get();
+ assert(n < nMax);
+
+ info->bin.syms[n].label = f->getLabel();
+ info->bin.syms[n].offset = f->binPos;
+ }
+
+ info->bin.numSyms = n;
+}
+
bool
Program::emitBinary(struct nv50_ir_prog_info *info)
{
}
info->bin.relocData = emit->getRelocInfo();
+ emitSymbolTable(info);
+
delete emit;
return true;
}
NOUVEAU_ERR("shader translation failed: %i\n", ret);
goto out;
}
+ if (info->bin.syms) /* we don't need them yet */
+ FREE(info->bin.syms);
prog->code = info->bin.code;
prog->code_size = info->bin.codeSize;