@@ -46,20 +46,31 @@ std::unique_ptr<llvm::Module> parse_bitcode_file(llvm::StringRef buf, llvm::LLVM
4646 return std::unique_ptr<llvm::Module>(); \
4747 }
4848
49+ #define DECLARE_CPP_INITMOD_LOOKUP_BITS (mod, bits ) \
50+ do { \
51+ if (debug) { \
52+ return get_initmod_##mod##_##bits##_debug (context); \
53+ } else { \
54+ return get_initmod_##mod##_##bits (context); \
55+ } \
56+ } while (0 )
57+
4958#define DECLARE_CPP_INITMOD_LOOKUP (mod ) \
5059 std::unique_ptr<llvm::Module> get_initmod_##mod(llvm::LLVMContext *context, bool bits_64, bool debug) { \
5160 if (bits_64) { \
52- if (debug) { \
53- return get_initmod_##mod##_64_debug (context); \
54- } else { \
55- return get_initmod_##mod##_64 (context); \
56- } \
61+ DECLARE_CPP_INITMOD_LOOKUP_BITS (mod, 64 ); \
62+ } else { \
63+ DECLARE_CPP_INITMOD_LOOKUP_BITS (mod, 32 ); \
64+ } \
65+ }
66+
67+ #define DECLARE_CPP_INITMOD_LOOKUP_64 (mod ) \
68+ std::unique_ptr<llvm::Module> get_initmod_##mod(llvm::LLVMContext *context, bool bits_64, bool debug) { \
69+ if (bits_64) { \
70+ DECLARE_CPP_INITMOD_LOOKUP_BITS (mod, 64 ); \
5771 } else { \
58- if (debug) { \
59- return get_initmod_##mod##_32_debug (context); \
60- } else { \
61- return get_initmod_##mod##_32 (context); \
62- } \
72+ internal_error << " No support for 32-bit initmod: " #mod; \
73+ return nullptr ; /* appease warnings */ \
6374 } \
6475 }
6576
@@ -70,6 +81,11 @@ std::unique_ptr<llvm::Module> parse_bitcode_file(llvm::StringRef buf, llvm::LLVM
7081 DECLARE_INITMOD (mod##_64) \
7182 DECLARE_CPP_INITMOD_LOOKUP (mod)
7283
84+ #define DECLARE_CPP_INITMOD_64 (mod ) \
85+ DECLARE_INITMOD (mod##_64_debug) \
86+ DECLARE_INITMOD (mod##_64) \
87+ DECLARE_CPP_INITMOD_LOOKUP_64 (mod)
88+
7389#define DECLARE_LL_INITMOD (mod ) \
7490 DECLARE_INITMOD (mod##_ll)
7591
@@ -183,18 +199,28 @@ DECLARE_NO_INITMOD(metal_objc_x86)
183199DECLARE_LL_INITMOD (arm)
184200DECLARE_LL_INITMOD(arm_no_neon)
185201DECLARE_CPP_INITMOD(arm_cpu_features)
202+ DECLARE_CPP_INITMOD(linux_arm_cpu_features)
203+ DECLARE_CPP_INITMOD(osx_arm_cpu_features)
186204#else
187205DECLARE_NO_INITMOD (arm)
188206DECLARE_NO_INITMOD(arm_no_neon)
189207DECLARE_NO_INITMOD(arm_cpu_features)
208+ DECLARE_NO_INITMOD(linux_arm_cpu_features)
209+ DECLARE_NO_INITMOD(osx_arm_cpu_features)
190210#endif // WITH_ARM
191211
192212#ifdef WITH_AARCH64
193213DECLARE_LL_INITMOD (aarch64)
194214DECLARE_CPP_INITMOD(aarch64_cpu_features)
215+ DECLARE_CPP_INITMOD(linux_aarch64_cpu_features)
216+ DECLARE_CPP_INITMOD(osx_aarch64_cpu_features)
217+ DECLARE_CPP_INITMOD_64(windows_aarch64_cpu_features_arm)
195218#else
196219DECLARE_NO_INITMOD (aarch64)
197220DECLARE_NO_INITMOD(aarch64_cpu_features)
221+ DECLARE_NO_INITMOD(linux_aarch64_cpu_features)
222+ DECLARE_NO_INITMOD(osx_aarch64_cpu_features)
223+ DECLARE_NO_INITMOD(windows_aarch64_cpu_features_arm)
198224#endif // WITH_AARCH64
199225
200226#ifdef WITH_NVPTX
@@ -1206,9 +1232,23 @@ std::unique_ptr<llvm::Module> get_initial_module_for_target(Target t, llvm::LLVM
12061232 }
12071233 if (t.arch == Target::ARM) {
12081234 if (t.bits == 64 ) {
1209- modules.push_back (get_initmod_aarch64_cpu_features (c, bits_64, debug));
1235+ if (t.os == Target::Android || t.os == Target::Linux) {
1236+ modules.push_back (get_initmod_linux_aarch64_cpu_features (c, bits_64, debug));
1237+ } else if (t.os == Target::OSX || t.os == Target::IOS) {
1238+ modules.push_back (get_initmod_osx_aarch64_cpu_features (c, bits_64, debug));
1239+ } else if (t.os == Target::Windows) {
1240+ modules.push_back (get_initmod_windows_aarch64_cpu_features_arm (c, bits_64, debug));
1241+ } else {
1242+ modules.push_back (get_initmod_aarch64_cpu_features (c, bits_64, debug));
1243+ }
12101244 } else {
1211- modules.push_back (get_initmod_arm_cpu_features (c, bits_64, debug));
1245+ if (t.os == Target::Android || t.os == Target::Linux) {
1246+ modules.push_back (get_initmod_linux_arm_cpu_features (c, bits_64, debug));
1247+ } else if (t.os == Target::OSX || t.os == Target::IOS) {
1248+ modules.push_back (get_initmod_osx_arm_cpu_features (c, bits_64, debug));
1249+ } else {
1250+ modules.push_back (get_initmod_arm_cpu_features (c, bits_64, debug));
1251+ }
12121252 }
12131253 }
12141254 if (t.arch == Target::POWERPC) {
0 commit comments