@@ -399,6 +399,32 @@ void configt::ansi_ct::set_arch_spec_mips(const irep_idt &subarch)
399
399
}
400
400
}
401
401
402
+ void configt::ansi_ct::set_arch_spec_riscv64 ()
403
+ {
404
+ set_LP64 ();
405
+ endianness = endiannesst::IS_LITTLE_ENDIAN;
406
+ long_double_width = 16 * 8 ;
407
+ char_is_unsigned = true ;
408
+ NULL_is_zero = true ;
409
+
410
+ switch (mode)
411
+ {
412
+ case flavourt::GCC:
413
+ defines.push_back (" __riscv" );
414
+ break ;
415
+
416
+ case flavourt::VISUAL_STUDIO:
417
+ case flavourt::CLANG:
418
+ case flavourt::CODEWARRIOR:
419
+ case flavourt::ARM:
420
+ case flavourt::ANSI:
421
+ break ;
422
+
423
+ case flavourt::NONE:
424
+ UNREACHABLE;
425
+ }
426
+ }
427
+
402
428
void configt::ansi_ct::set_arch_spec_s390 ()
403
429
{
404
430
set_ILP32 ();
@@ -706,6 +732,8 @@ void configt::set_arch(const irep_idt &arch)
706
732
arch==" ppc64" ||
707
733
arch==" ppc64le" )
708
734
ansi_c.set_arch_spec_power (arch);
735
+ else if (arch == " riscv64" )
736
+ ansi_c.set_arch_spec_riscv64 ();
709
737
else if (arch==" sparc" ||
710
738
arch==" sparc64" )
711
739
ansi_c.set_arch_spec_sparc (arch);
@@ -1236,86 +1264,90 @@ std::string configt::object_bits_info()
1236
1264
" )" ;
1237
1265
}
1238
1266
1267
+ // clang-format off
1239
1268
irep_idt configt::this_architecture ()
1240
1269
{
1241
1270
irep_idt this_arch;
1242
1271
1243
1272
// following http://wiki.debian.org/ArchitectureSpecificsMemo
1244
1273
1245
1274
#ifdef __alpha__
1246
- this_arch= " alpha" ;
1275
+ this_arch = " alpha" ;
1247
1276
#elif defined(__armel__)
1248
- this_arch= " armel" ;
1277
+ this_arch = " armel" ;
1249
1278
#elif defined(__aarch64__)
1250
- this_arch= " arm64" ;
1279
+ this_arch = " arm64" ;
1251
1280
#elif defined(__arm__)
1252
1281
#ifdef __ARM_PCS_VFP
1253
- this_arch= " armhf" ; // variant of arm with hard float
1282
+ this_arch = " armhf" ; // variant of arm with hard float
1254
1283
#else
1255
- this_arch= " arm" ;
1284
+ this_arch = " arm" ;
1256
1285
#endif
1257
1286
#elif defined(__mipsel__)
1258
1287
#if _MIPS_SIM==_ABIO32
1259
- this_arch= " mipsel" ;
1288
+ this_arch = " mipsel" ;
1260
1289
#elif _MIPS_SIM==_ABIN32
1261
- this_arch= " mipsn32el" ;
1290
+ this_arch = " mipsn32el" ;
1262
1291
#else
1263
- this_arch= " mips64el" ;
1292
+ this_arch = " mips64el" ;
1264
1293
#endif
1265
1294
#elif defined(__mips__)
1266
1295
#if _MIPS_SIM==_ABIO32
1267
- this_arch= " mips" ;
1296
+ this_arch = " mips" ;
1268
1297
#elif _MIPS_SIM==_ABIN32
1269
- this_arch= " mipsn32" ;
1298
+ this_arch = " mipsn32" ;
1270
1299
#else
1271
- this_arch= " mips64" ;
1300
+ this_arch = " mips64" ;
1272
1301
#endif
1273
1302
#elif defined(__powerpc__)
1274
1303
#if defined(__ppc64__) || defined(__PPC64__) || \
1275
1304
defined (__powerpc64__) || defined (__POWERPC64__)
1276
1305
#ifdef __LITTLE_ENDIAN__
1277
- this_arch= " ppc64le" ;
1306
+ this_arch = " ppc64le" ;
1278
1307
#else
1279
- this_arch= " ppc64" ;
1308
+ this_arch = " ppc64" ;
1280
1309
#endif
1281
1310
#else
1282
- this_arch= " powerpc" ;
1311
+ this_arch = " powerpc" ;
1283
1312
#endif
1313
+ #elif defined(__riscv)
1314
+ this_arch = " riscv64" ;
1284
1315
#elif defined(__sparc__)
1285
1316
#ifdef __arch64__
1286
- this_arch= " sparc64" ;
1317
+ this_arch = " sparc64" ;
1287
1318
#else
1288
- this_arch= " sparc" ;
1319
+ this_arch = " sparc" ;
1289
1320
#endif
1290
1321
#elif defined(__ia64__)
1291
- this_arch= " ia64" ;
1322
+ this_arch = " ia64" ;
1292
1323
#elif defined(__s390x__)
1293
- this_arch= " s390x" ;
1324
+ this_arch = " s390x" ;
1294
1325
#elif defined(__s390__)
1295
- this_arch= " s390" ;
1326
+ this_arch = " s390" ;
1296
1327
#elif defined(__x86_64__)
1297
1328
#ifdef __ILP32__
1298
- this_arch= " x32" ; // variant of x86_64 with 32-bit pointers
1329
+ this_arch = " x32" ; // variant of x86_64 with 32-bit pointers
1299
1330
#else
1300
- this_arch= " x86_64" ;
1331
+ this_arch = " x86_64" ;
1301
1332
#endif
1302
1333
#elif defined(__i386__)
1303
- this_arch= " i386" ;
1334
+ this_arch = " i386" ;
1304
1335
#elif defined(_WIN64)
1305
- this_arch= " x86_64" ;
1336
+ this_arch = " x86_64" ;
1306
1337
#elif defined(_WIN32)
1307
- this_arch= " i386" ;
1338
+ this_arch = " i386" ;
1308
1339
#elif defined(__hppa__)
1309
- this_arch= " hppa" ;
1340
+ this_arch = " hppa" ;
1310
1341
#elif defined(__sh__)
1311
- this_arch= " sh4" ;
1342
+ this_arch = " sh4" ;
1312
1343
#else
1313
- // something new and unknown!
1314
- this_arch= " unknown" ;
1344
+ // something new and unknown!
1345
+ this_arch = " unknown" ;
1315
1346
#endif
1316
1347
1317
1348
return this_arch;
1318
1349
}
1350
+ // clang-format on
1319
1351
1320
1352
void configt::set_classpath (const std::string &cp)
1321
1353
{
0 commit comments