diff options
author | Eric Anholt <eric@anholt.net> | 2013-12-13 19:42:31 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2013-12-15 20:16:01 -0800 |
commit | 28c2dcb99b7b7deb26b4066d850ad4ba3705f7f7 (patch) | |
tree | 83b4b463aee20e6a19b72341907202e5136bc119 /src | |
parent | c4f582b5329f4c6832a2b111b9db107da0d87a32 (diff) |
Use a non-inlined helper for the simple case of a single provider.
This reduces the built size by another 37k.
Diffstat (limited to 'src')
-rwxr-xr-x | src/gen_dispatch.py | 54 |
1 files 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') |