From 28c2dcb99b7b7deb26b4066d850ad4ba3705f7f7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 13 Dec 2013 19:42:31 -0800 Subject: [PATCH] Use a non-inlined helper for the simple case of a single provider. This reduces the built size by another 37k. --- src/gen_dispatch.py | 54 +++++++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/src/gen_dispatch.py b/src/gen_dispatch.py index ef2b433..8acd9da 100755 --- a/src/gen_dispatch.py +++ b/src/gen_dispatch.py @@ -535,22 +535,28 @@ class Generator(object): for provider in alias_func.providers.values(): providers.append(provider) - self.outln(' static const enum {0}_provider providers[] = {{'.format(self.target)) - for provider in providers: - self.outln(' {0},'.format(provider.enum)) - self.outln(' {0}_provider_terminator'.format(self.target)) - self.outln(' };') - - self.outln(' static const uint16_t entrypoints[] = {') - for provider in providers: - self.outln(' {0} /* "{1}" */,'.format(self.entrypoint_string_offset[provider.name], provider.name)) - self.outln(' };') - - self.outln(' return {0}_provider_resolver(entrypoint_strings + {1} /* "{2}" */,'.format(self.target, - self.entrypoint_string_offset[func.name], - func.name)) - self.outln(' providers, entrypoints);') - + if len(providers) != 1: + self.outln(' static const enum {0}_provider providers[] = {{'.format(self.target)) + for provider in providers: + self.outln(' {0},'.format(provider.enum)) + self.outln(' {0}_provider_terminator'.format(self.target)) + self.outln(' };') + + self.outln(' static const uint16_t entrypoints[] = {') + for provider in providers: + self.outln(' {0} /* "{1}" */,'.format(self.entrypoint_string_offset[provider.name], provider.name)) + self.outln(' };') + + self.outln(' return {0}_provider_resolver(entrypoint_strings + {1} /* "{2}" */,'.format(self.target, + self.entrypoint_string_offset[func.name], + func.name)) + self.outln(' providers, entrypoints);') + else: + assert(providers[0].name == func.name) + self.outln(' return {0}_single_resolver({1}, {2} /* {3} */);'.format(self.target, + providers[0].enum, + self.entrypoint_string_offset[func.name], + func.name)) self.outln('}') self.outln('') @@ -688,6 +694,22 @@ class Generator(object): self.outln('}') self.outln('') + single_resolver_proto = '{0}_single_resolver(enum {0}_provider provider, uint16_t entrypoint_offset)'.format(self.target) + self.outln('static void *') + self.outln('{0} __attribute__((noinline));'.format(single_resolver_proto)) + self.outln('') + self.outln('static void *') + self.outln('{0}'.format(single_resolver_proto)) + self.outln('{') + self.outln(' enum {0}_provider providers[] = {{'.format(self.target)) + self.outln(' provider,') + self.outln(' {0}_provider_terminator'.format(self.target)) + self.outln(' };') + self.outln(' return {0}_provider_resolver(entrypoint_strings + entrypoint_offset,'.format(self.target)) + self.outln(' providers, &entrypoint_offset);') + self.outln('}') + self.outln('') + def write_source(self, file): self.out_file = open(file, 'w')