diff options
author | Francisco Jerez <[email protected]> | 2012-04-06 18:50:56 +0200 |
---|---|---|
committer | Christoph Bumiller <[email protected]> | 2012-04-14 21:54:01 +0200 |
commit | 98116cc3dc3fc2cd84990cc2c968f05fe2978b4a (patch) | |
tree | 18d3e6131de5ee0721c1ab38ee1e350a6da775b3 /src/gallium | |
parent | 5e4b2a1a47ca9a173f6419ed2f12c9fba80e757c (diff) |
nv50/ir: Build a "symbol" table with the binary offsets of each function.
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/nv50/codegen/nv50_ir.cpp | 2 | ||||
-rw-r--r-- | src/gallium/drivers/nv50/codegen/nv50_ir.h | 6 | ||||
-rw-r--r-- | src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp | 3 | ||||
-rw-r--r-- | src/gallium/drivers/nv50/codegen/nv50_ir_driver.h | 8 | ||||
-rw-r--r-- | src/gallium/drivers/nv50/codegen/nv50_ir_print.cpp | 6 | ||||
-rw-r--r-- | src/gallium/drivers/nv50/codegen/nv50_ir_target.cpp | 23 | ||||
-rw-r--r-- | src/gallium/drivers/nvc0/nvc0_program.c | 2 |
7 files changed, 45 insertions, 5 deletions
diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir.cpp index 357d6d9e2cc..e3d2417c93f 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir.cpp +++ b/src/gallium/drivers/nv50/codegen/nv50_ir.cpp @@ -976,7 +976,7 @@ Program::Program(Type type, Target *arch) maxGPR = -1; - main = new Function(this, "MAIN"); + main = new Function(this, "MAIN", ~0); calls.insert(&main->call); dbgFlags = 0; diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir.h b/src/gallium/drivers/nv50/codegen/nv50_ir.h index 25e729eb5d4..b582a468b31 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir.h +++ b/src/gallium/drivers/nv50/codegen/nv50_ir.h @@ -916,7 +916,7 @@ private: class Function { public: - Function(Program *, const char *name); + Function(Program *, const char *name, uint32_t label); ~Function(); static inline Function *get(Graph::Node *node); @@ -924,6 +924,7 @@ public: 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; @@ -968,6 +969,7 @@ private: void buildDefSetsPreSSA(BasicBlock *bb, const int seq); private: + uint32_t label; int id; const char *const name; Program *prog; @@ -1015,6 +1017,8 @@ public: const Target *getTarget() const { return target; } private: + void emitSymbolTable(struct nv50_ir_prog_info *); + Type progType; Target *target; diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp index 8854247db8b..6515ba7e0c9 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp +++ b/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp @@ -24,8 +24,9 @@ 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) { diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_driver.h b/src/gallium/drivers/nv50/codegen/nv50_ir_driver.h index 84a514091c6..ae733a1a924 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir_driver.h +++ b/src/gallium/drivers/nv50/codegen/nv50_ir_driver.h @@ -87,6 +87,12 @@ struct nv50_ir_varying #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, ...) */ @@ -105,6 +111,8 @@ struct nv50_ir_prog_info 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]; diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_print.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_print.cpp index acb5be58801..a831145ef5d 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir_print.cpp +++ b/src/gallium/drivers/nv50/codegen/nv50_ir_print.cpp @@ -431,7 +431,9 @@ void Instruction::print() const 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()); @@ -508,7 +510,7 @@ private: bool PrintPass::visit(Function *fn) { - INFO("\n%s:\n", fn->getName()); + INFO("\n%s:%i\n", fn->getName(), fn->getLabel()); return true; } diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_target.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_target.cpp index c8529a3d395..598e0d26384 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir_target.cpp +++ b/src/gallium/drivers/nv50/codegen/nv50_ir_target.cpp @@ -208,6 +208,27 @@ CodeEmitter::prepareEmission(BasicBlock *bb) 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) { @@ -238,6 +259,8 @@ Program::emitBinary(struct nv50_ir_prog_info *info) } info->bin.relocData = emit->getRelocInfo(); + emitSymbolTable(info); + delete emit; return true; } diff --git a/src/gallium/drivers/nvc0/nvc0_program.c b/src/gallium/drivers/nvc0/nvc0_program.c index e867461fb2e..50a853abed9 100644 --- a/src/gallium/drivers/nvc0/nvc0_program.c +++ b/src/gallium/drivers/nvc0/nvc0_program.c @@ -568,6 +568,8 @@ nvc0_program_translate(struct nvc0_program *prog) 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; |