Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2010, The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 17 | #include "runtime/lib/absvdi2.c" |
| 18 | #include "runtime/lib/absvsi2.c" |
| 19 | #include "runtime/lib/addvdi3.c" |
| 20 | #include "runtime/lib/addvsi3.c" |
| 21 | #include "runtime/lib/ashldi3.c" |
| 22 | #ifndef ANDROID |
| 23 | # include "runtime/lib/ashrdi3.c" |
| 24 | #endif |
| 25 | #include "runtime/lib/clzdi2.c" |
| 26 | #include "runtime/lib/clzsi2.c" |
| 27 | #include "runtime/lib/cmpdi2.c" |
| 28 | #include "runtime/lib/ctzdi2.c" |
| 29 | #include "runtime/lib/ctzsi2.c" |
| 30 | #ifndef ANDROID // no complex.h |
| 31 | # include "runtime/lib/divdc3.c" |
| 32 | #endif |
| 33 | #include "runtime/lib/divdi3.c" |
| 34 | #ifndef ANDROID // no complex.h |
| 35 | # include "runtime/lib/divsc3.c" |
| 36 | #endif |
| 37 | #include "runtime/lib/ffsdi2.c" |
| 38 | #include "runtime/lib/fixdfdi.c" |
| 39 | #include "runtime/lib/fixsfdi.c" |
| 40 | #include "runtime/lib/fixunsdfdi.c" |
| 41 | #include "runtime/lib/fixunsdfsi.c" |
| 42 | #include "runtime/lib/fixunssfdi.c" |
| 43 | #include "runtime/lib/fixunssfsi.c" |
| 44 | #include "runtime/lib/floatdidf.c" |
| 45 | #include "runtime/lib/floatdisf.c" |
| 46 | #include "runtime/lib/floatundidf.c" |
| 47 | #include "runtime/lib/floatundisf.c" |
| 48 | #include "runtime/lib/lshrdi3.c" |
| 49 | #include "runtime/lib/moddi3.c" |
| 50 | #ifndef ANDROID // no complex.h |
| 51 | # include "runtime/lib/muldc3.c" |
| 52 | #endif |
| 53 | #include "runtime/lib/muldi3.c" |
| 54 | #ifndef ANDROID // no complex.h |
| 55 | # include "runtime/lib/mulsc3.c" |
| 56 | #endif |
| 57 | #include "runtime/lib/mulvdi3.c" |
| 58 | #include "runtime/lib/mulvsi3.c" |
| 59 | #include "runtime/lib/negdi2.c" |
| 60 | #include "runtime/lib/negvdi2.c" |
| 61 | #include "runtime/lib/negvsi2.c" |
| 62 | #include "runtime/lib/paritydi2.c" |
| 63 | #include "runtime/lib/paritysi2.c" |
| 64 | #include "runtime/lib/popcountdi2.c" |
| 65 | #include "runtime/lib/popcountsi2.c" |
| 66 | #include "runtime/lib/powidf2.c" |
| 67 | #include "runtime/lib/powisf2.c" |
| 68 | #include "runtime/lib/subvdi3.c" |
| 69 | #include "runtime/lib/subvsi3.c" |
| 70 | #include "runtime/lib/ucmpdi2.c" |
| 71 | #include "runtime/lib/udivdi3.c" |
Shih-wei Liao | 210eb40 | 2010-08-26 08:55:40 -0700 | [diff] [blame] | 72 | #include "runtime/lib/udivsi3.c" |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 73 | #include "runtime/lib/udivmoddi4.c" |
| 74 | #include "runtime/lib/umoddi3.c" |
| 75 | #include "runtime/lib/eprintf.c" |
| 76 | |
| 77 | #include <string.h> |
| 78 | #include <stdlib.h> |
Shih-wei Liao | abd1e3d | 2010-04-28 01:47:00 -0700 | [diff] [blame] | 79 | #include <assert.h> |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 80 | |
| 81 | typedef struct { |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 82 | const char *mName; |
| 83 | void *mPtr; |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 84 | } RuntimeFunction; |
| 85 | |
| 86 | #define USE_VFP_RUNTIME 1 |
| 87 | |
| 88 | #if defined(__arm__) |
| 89 | #define DEF_GENERIC_RUNTIME(func) \ |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 90 | extern void *func; |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 91 | #define DEF_VFP_RUNTIME(func) \ |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 92 | extern void *func ## vfp; |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 93 | #define DEF_LLVM_RUNTIME(func) |
Shih-wei Liao | abd1e3d | 2010-04-28 01:47:00 -0700 | [diff] [blame] | 94 | #define DEF_BCC_RUNTIME(func) |
Logan | c439523 | 2010-11-27 18:54:17 +0800 | [diff] [blame^] | 95 | #include "Runtime.def" |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 96 | #endif |
| 97 | |
Shih-wei Liao | abd1e3d | 2010-04-28 01:47:00 -0700 | [diff] [blame] | 98 | static const RuntimeFunction gRuntimes[] = { |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 99 | #if defined(__arm__) |
| 100 | #define DEF_GENERIC_RUNTIME(func) \ |
| 101 | { #func, (void*) &func }, |
| 102 | // TODO: enable only when target support VFP |
| 103 | #define DEF_VFP_RUNTIME(func) \ |
| 104 | { #func, (void*) &func ## vfp }, |
| 105 | #else |
| 106 | // host compiler library must contain generic runtime |
| 107 | #define DEF_GENERIC_RUNTIME(func) |
| 108 | #define DEF_VFP_RUNTIME(func) |
| 109 | #endif |
| 110 | #define DEF_LLVM_RUNTIME(func) \ |
| 111 | { #func, (void*) &func }, |
Shih-wei Liao | abd1e3d | 2010-04-28 01:47:00 -0700 | [diff] [blame] | 112 | #define DEF_BCC_RUNTIME(func) \ |
| 113 | { #func, &func ## _bcc }, |
Logan | c439523 | 2010-11-27 18:54:17 +0800 | [diff] [blame^] | 114 | #include "Runtime.def" |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 115 | }; |
| 116 | |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 117 | static int CompareRuntimeFunction(const void *a, const void *b) { |
| 118 | return strcmp(((const RuntimeFunction*) a)->mName, |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 119 | ((const RuntimeFunction*) b)->mName); |
| 120 | } |
| 121 | |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 122 | void *FindRuntimeFunction(const char *Name) { |
| 123 | // binary search |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 124 | const RuntimeFunction Key = { Name, NULL }; |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 125 | const RuntimeFunction *R = |
| 126 | bsearch(&Key, |
| 127 | gRuntimes, |
| 128 | sizeof(gRuntimes) / sizeof(RuntimeFunction), |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 129 | sizeof(RuntimeFunction), |
| 130 | CompareRuntimeFunction); |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 131 | |
| 132 | return ((R) ? R->mPtr : NULL); |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 133 | } |
Shih-wei Liao | abd1e3d | 2010-04-28 01:47:00 -0700 | [diff] [blame] | 134 | |
| 135 | void VerifyRuntimesTable() { |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 136 | unsigned N = sizeof(gRuntimes) / sizeof(RuntimeFunction), i; |
| 137 | for(i = 0; i < N; i++) { |
| 138 | const char *Name = gRuntimes[i].mName; |
| 139 | int *Ptr = FindRuntimeFunction(Name); |
Shih-wei Liao | abd1e3d | 2010-04-28 01:47:00 -0700 | [diff] [blame] | 140 | |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 141 | if (Ptr != (int*) gRuntimes[i].mPtr) |
| 142 | assert(false && "Table is corrupted (runtime name should be sorted in " |
Logan | c439523 | 2010-11-27 18:54:17 +0800 | [diff] [blame^] | 143 | "Runtime.def)."); |
Shih-wei Liao | abd1e3d | 2010-04-28 01:47:00 -0700 | [diff] [blame] | 144 | } |
| 145 | } |