diff options
Diffstat (limited to 'src/gallium/auxiliary/gallivm')
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_type.c | 25 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_type.h | 4 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.c b/src/gallium/auxiliary/gallivm/lp_bld_type.c index efd159f8869..413e69bedac 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_type.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_type.c @@ -411,3 +411,28 @@ lp_build_context_init(struct lp_build_context *bld, bld->zero = LLVMConstNull(bld->vec_type); bld->one = lp_build_one(gallivm, type); } + + +/** + * Count the number of instructions in a function. + */ +unsigned +lp_build_count_instructions(LLVMValueRef function) +{ + unsigned num_instrs = 0; + LLVMBasicBlockRef block; + + block = LLVMGetFirstBasicBlock(function); + while (block) { + LLVMValueRef instr; + instr = LLVMGetFirstInstruction(block); + while (instr) { + ++num_instrs; + + instr = LLVMGetNextInstruction(instr); + } + block = LLVMGetNextBasicBlock(block); + } + + return num_instrs; +} diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.h b/src/gallium/auxiliary/gallivm/lp_bld_type.h index 5007e83ac5f..f11a190e7cc 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_type.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_type.h @@ -398,4 +398,8 @@ lp_build_context_init(struct lp_build_context *bld, struct lp_type type); +unsigned +lp_build_count_instructions(LLVMValueRef function); + + #endif /* !LP_BLD_TYPE_H */ |