Skip to content

Commit 6656cec

Browse files
author
Daniel Kroening
authored
Merge pull request #3261 from diffblue/riscv64
add riscv64 architecture
2 parents 191c798 + fe01b87 commit 6656cec

File tree

2 files changed

+61
-28
lines changed

2 files changed

+61
-28
lines changed

src/util/config.cpp

Lines changed: 60 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,32 @@ void configt::ansi_ct::set_arch_spec_mips(const irep_idt &subarch)
399399
}
400400
}
401401

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+
402428
void configt::ansi_ct::set_arch_spec_s390()
403429
{
404430
set_ILP32();
@@ -706,6 +732,8 @@ void configt::set_arch(const irep_idt &arch)
706732
arch=="ppc64" ||
707733
arch=="ppc64le")
708734
ansi_c.set_arch_spec_power(arch);
735+
else if(arch == "riscv64")
736+
ansi_c.set_arch_spec_riscv64();
709737
else if(arch=="sparc" ||
710738
arch=="sparc64")
711739
ansi_c.set_arch_spec_sparc(arch);
@@ -1236,86 +1264,90 @@ std::string configt::object_bits_info()
12361264
")";
12371265
}
12381266

1267+
// clang-format off
12391268
irep_idt configt::this_architecture()
12401269
{
12411270
irep_idt this_arch;
12421271

12431272
// following http://wiki.debian.org/ArchitectureSpecificsMemo
12441273

12451274
#ifdef __alpha__
1246-
this_arch="alpha";
1275+
this_arch = "alpha";
12471276
#elif defined(__armel__)
1248-
this_arch="armel";
1277+
this_arch = "armel";
12491278
#elif defined(__aarch64__)
1250-
this_arch="arm64";
1279+
this_arch = "arm64";
12511280
#elif defined(__arm__)
12521281
#ifdef __ARM_PCS_VFP
1253-
this_arch="armhf"; // variant of arm with hard float
1282+
this_arch = "armhf"; // variant of arm with hard float
12541283
#else
1255-
this_arch="arm";
1284+
this_arch = "arm";
12561285
#endif
12571286
#elif defined(__mipsel__)
12581287
#if _MIPS_SIM==_ABIO32
1259-
this_arch="mipsel";
1288+
this_arch = "mipsel";
12601289
#elif _MIPS_SIM==_ABIN32
1261-
this_arch="mipsn32el";
1290+
this_arch = "mipsn32el";
12621291
#else
1263-
this_arch="mips64el";
1292+
this_arch = "mips64el";
12641293
#endif
12651294
#elif defined(__mips__)
12661295
#if _MIPS_SIM==_ABIO32
1267-
this_arch="mips";
1296+
this_arch = "mips";
12681297
#elif _MIPS_SIM==_ABIN32
1269-
this_arch="mipsn32";
1298+
this_arch = "mipsn32";
12701299
#else
1271-
this_arch="mips64";
1300+
this_arch = "mips64";
12721301
#endif
12731302
#elif defined(__powerpc__)
12741303
#if defined(__ppc64__) || defined(__PPC64__) || \
12751304
defined(__powerpc64__) || defined(__POWERPC64__)
12761305
#ifdef __LITTLE_ENDIAN__
1277-
this_arch="ppc64le";
1306+
this_arch = "ppc64le";
12781307
#else
1279-
this_arch="ppc64";
1308+
this_arch = "ppc64";
12801309
#endif
12811310
#else
1282-
this_arch="powerpc";
1311+
this_arch = "powerpc";
12831312
#endif
1313+
#elif defined(__riscv)
1314+
this_arch = "riscv64";
12841315
#elif defined(__sparc__)
12851316
#ifdef __arch64__
1286-
this_arch="sparc64";
1317+
this_arch = "sparc64";
12871318
#else
1288-
this_arch="sparc";
1319+
this_arch = "sparc";
12891320
#endif
12901321
#elif defined(__ia64__)
1291-
this_arch="ia64";
1322+
this_arch = "ia64";
12921323
#elif defined(__s390x__)
1293-
this_arch="s390x";
1324+
this_arch = "s390x";
12941325
#elif defined(__s390__)
1295-
this_arch="s390";
1326+
this_arch = "s390";
12961327
#elif defined(__x86_64__)
12971328
#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
12991330
#else
1300-
this_arch="x86_64";
1331+
this_arch = "x86_64";
13011332
#endif
13021333
#elif defined(__i386__)
1303-
this_arch="i386";
1334+
this_arch = "i386";
13041335
#elif defined(_WIN64)
1305-
this_arch="x86_64";
1336+
this_arch = "x86_64";
13061337
#elif defined(_WIN32)
1307-
this_arch="i386";
1338+
this_arch = "i386";
13081339
#elif defined(__hppa__)
1309-
this_arch="hppa";
1340+
this_arch = "hppa";
13101341
#elif defined(__sh__)
1311-
this_arch="sh4";
1342+
this_arch = "sh4";
13121343
#else
1313-
// something new and unknown!
1314-
this_arch="unknown";
1344+
// something new and unknown!
1345+
this_arch = "unknown";
13151346
#endif
13161347

13171348
return this_arch;
13181349
}
1350+
// clang-format on
13191351

13201352
void configt::set_classpath(const std::string &cp)
13211353
{

src/util/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class configt
9292
void set_arch_spec_arm(const irep_idt &subarch);
9393
void set_arch_spec_alpha();
9494
void set_arch_spec_mips(const irep_idt &subarch);
95+
void set_arch_spec_riscv64();
9596
void set_arch_spec_s390();
9697
void set_arch_spec_s390x();
9798
void set_arch_spec_sparc(const irep_idt &subarch);

0 commit comments

Comments
 (0)