Skip to content

Commit c76f5ac

Browse files
committed
Reimplement architecture selection
1 parent 4c2fdac commit c76f5ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+6462
-4007
lines changed

bfd/archures.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,6 @@ DESCRIPTION
447447
. bfd_arch_riscv,
448448
.#define bfd_mach_riscv32 132
449449
.#define bfd_mach_riscv64 164
450-
.#define bfd_mach_riscv32_sfpu 1320
451-
.#define bfd_mach_riscv32_sfpu_wormhole 1321
452-
.#define bfd_mach_riscv32_sfpu_blackhole 1322
453450
. bfd_arch_rl78,
454451
.#define bfd_mach_rl78 0x75
455452
. bfd_arch_rx, {* Renesas RX. *}

bfd/bfd-in2.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,9 +1774,6 @@ enum bfd_architecture
17741774
bfd_arch_riscv,
17751775
#define bfd_mach_riscv32 132
17761776
#define bfd_mach_riscv64 164
1777-
#define bfd_mach_riscv32_sfpu 1320
1778-
#define bfd_mach_riscv32_sfpu_wormhole 1321
1779-
#define bfd_mach_riscv32_sfpu_blackhole 1322
17801777
bfd_arch_rl78,
17811778
#define bfd_mach_rl78 0x75
17821779
bfd_arch_rx, /* Renesas RX. */
@@ -7928,7 +7925,6 @@ bool bfd_init_section_compress_status
79287925
bool bfd_compress_section
79297926
(bfd *abfd, asection *section, bfd_byte *uncompressed_buffer);
79307927

7931-
extern int riscv_machine_target;
79327928
#ifdef __cplusplus
79337929
}
79347930
#endif

bfd/cpu-riscv.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ enum
8787
{
8888
I_riscv64,
8989
I_riscv32,
90-
I_riscv32_sfpu_blackhole,
91-
I_riscv32_sfpu_wormhole,
92-
I_riscv32_sfpu
9390
};
9491

9592
#define NN(index) (&arch_info_struct[(index) + 1])
@@ -99,10 +96,7 @@ enum
9996
static const bfd_arch_info_type arch_info_struct[] =
10097
{
10198
N (64, bfd_mach_riscv64, "riscv:rv64", false, NN (I_riscv64)),
102-
N (32, bfd_mach_riscv32, "riscv:rv32", false, NN (I_riscv32)),
103-
N (32, bfd_mach_riscv32_sfpu_blackhole, "riscv:rv32-sfpu-blackhole", false, NN (I_riscv32_sfpu_blackhole)),
104-
N (32, bfd_mach_riscv32_sfpu_wormhole, "riscv:rv32-sfpu-wormhole", false, NN (I_riscv32_sfpu_wormhole)),
105-
N (32, bfd_mach_riscv32_sfpu, "riscv:rv32-sfpu", false, NULL)
99+
N (32, bfd_mach_riscv32, "riscv:rv32", false, NULL),
106100
};
107101

108102
/* The default architecture is riscv:rv64. */

bfd/elf.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6542,17 +6542,7 @@ _bfd_elf_init_file_header (bfd *abfd,
65426542
Such need can generally be supplied by replacing the tests for
65436543
e_machine with the conditions used to determine it. */
65446544
default:
6545-
if (abfd->tdata.elf_obj_data->elf_header->e_machine)
6546-
i_ehdrp->e_machine = abfd->tdata.elf_obj_data->elf_header->e_machine;
6547-
else {
6548-
if (riscv_machine_target != -1 &&
6549-
(riscv_machine_target == EM_RISCV_GRAYSKULL || riscv_machine_target == EM_RISCV_WORMHOLE
6550-
|| riscv_machine_target == EM_RISCV_BLACKHOLE)) {
6551-
i_ehdrp->e_machine = riscv_machine_target;
6552-
} else {
6553-
i_ehdrp->e_machine = bed->elf_machine_code;
6554-
}
6555-
}
6545+
i_ehdrp->e_machine = bed->elf_machine_code;
65566546
}
65576547

65586548
i_ehdrp->e_version = bed->s->ev_current;

bfd/elfnn-riscv.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@
5858
#define ELF_ARCH bfd_arch_riscv
5959
#define ELF_TARGET_ID RISCV_ELF_DATA
6060
#define ELF_MACHINE_CODE EM_RISCV
61-
#define ELF_MACHINE_ALT1 EM_RISCV_GRAYSKULL
62-
#define ELF_MACHINE_ALT2 EM_RISCV_WORMHOLE
63-
#define ELF_MACHINE_ALT3 EM_RISCV_BLACKHOLE
6461
#define ELF_MAXPAGESIZE 0x1000
6562
#define ELF_COMMONPAGESIZE 0x1000
6663

bfd/elfxx-riscv.c

Lines changed: 17 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,24 +1249,9 @@ static struct riscv_supported_ext riscv_supported_std_zxm_ext[] =
12491249

12501250
static struct riscv_supported_ext riscv_supported_vendor_x_ext[] =
12511251
{
1252-
{NULL, 0, 0, 0, 0}
1253-
};
1254-
1255-
static struct riscv_supported_ext riscv_supported_sfpu_y_ext[] =
1256-
{
1257-
{"y", ISA_SPEC_CLASS_SFPU, 1, 0, 0},
1258-
{NULL, 0, 0, 0, 0}
1259-
};
1260-
1261-
static struct riscv_supported_ext riscv_supported_sfpu_w_ext[] =
1262-
{
1263-
{"w", ISA_SPEC_CLASS_SFPU_WORMHOLE, 1, 0, 0},
1264-
{NULL, 0, 0, 0, 0}
1265-
};
1266-
1267-
static struct riscv_supported_ext riscv_supported_sfpu_l_ext[] =
1268-
{
1269-
{"l", ISA_SPEC_CLASS_SFPU_BLACKHOLE, 1, 0, 0},
1252+
{"xttgs", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
1253+
{"xttwh", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
1254+
{"xttbh", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12701255
{NULL, 0, 0, 0, 0}
12711256
};
12721257

@@ -1277,9 +1262,6 @@ const struct riscv_supported_ext *riscv_all_supported_ext[] =
12771262
riscv_supported_std_s_ext,
12781263
riscv_supported_std_zxm_ext,
12791264
riscv_supported_vendor_x_ext,
1280-
riscv_supported_sfpu_y_ext,
1281-
riscv_supported_sfpu_w_ext,
1282-
riscv_supported_sfpu_l_ext,
12831265
NULL
12841266
};
12851267

@@ -1290,9 +1272,6 @@ enum riscv_prefix_ext_class
12901272
RV_ISA_CLASS_S,
12911273
RV_ISA_CLASS_ZXM,
12921274
RV_ISA_CLASS_X,
1293-
RV_ISA_CLASS_SFPU,
1294-
RV_ISA_CLASS_SFPU_WORMHOLE,
1295-
RV_ISA_CLASS_SFPU_BLACKHOLE,
12961275
RV_ISA_CLASS_UNKNOWN
12971276
};
12981277

@@ -1314,9 +1293,6 @@ static const struct riscv_parse_prefix_config parse_config[] =
13141293
{RV_ISA_CLASS_Z, "z"},
13151294
{RV_ISA_CLASS_S, "s"},
13161295
{RV_ISA_CLASS_X, "x"},
1317-
{RV_ISA_CLASS_SFPU, "y"},
1318-
{RV_ISA_CLASS_SFPU_WORMHOLE, "w"},
1319-
{RV_ISA_CLASS_SFPU_BLACKHOLE, "l"},
13201296
{RV_ISA_CLASS_UNKNOWN, NULL}
13211297
};
13221298

@@ -1370,12 +1346,6 @@ riscv_recognized_prefixed_ext (const char *ext)
13701346
if (strcmp (ext, "x") != 0)
13711347
return true;
13721348
break;
1373-
case RV_ISA_CLASS_SFPU:
1374-
return riscv_known_prefixed_ext (ext, riscv_supported_sfpu_y_ext);
1375-
case RV_ISA_CLASS_SFPU_WORMHOLE:
1376-
return riscv_known_prefixed_ext (ext, riscv_supported_sfpu_w_ext);
1377-
case RV_ISA_CLASS_SFPU_BLACKHOLE:
1378-
return riscv_known_prefixed_ext (ext, riscv_supported_sfpu_l_ext);
13791349
default:
13801350
break;
13811351
}
@@ -1549,9 +1519,7 @@ riscv_get_default_ext_version (enum riscv_spec_class *default_isa_spec,
15491519
case RV_ISA_CLASS_Z: table = riscv_supported_std_z_ext; break;
15501520
case RV_ISA_CLASS_S: table = riscv_supported_std_s_ext; break;
15511521
case RV_ISA_CLASS_X: table = riscv_supported_vendor_x_ext; break;
1552-
case RV_ISA_CLASS_SFPU: table = riscv_supported_sfpu_y_ext; break;
1553-
case RV_ISA_CLASS_SFPU_WORMHOLE: table = riscv_supported_sfpu_w_ext; break;
1554-
case RV_ISA_CLASS_SFPU_BLACKHOLE: table = riscv_supported_sfpu_l_ext; break;
1522+
15551523
default:
15561524
table = riscv_supported_std_ext;
15571525
}
@@ -1571,16 +1539,6 @@ riscv_get_default_ext_version (enum riscv_spec_class *default_isa_spec,
15711539
}
15721540
}
15731541

1574-
bool
1575-
riscv_ext_dont_care_version (const char *subset)
1576-
{
1577-
if (strcmp (subset, "y") == 0
1578-
|| strcmp (subset, "w") == 0
1579-
|| strcmp (subset, "l") == 0)
1580-
return true;
1581-
return false;
1582-
}
1583-
15841542
/* Find the default versions for the extension before adding them to
15851543
the subset list, if their versions are RISCV_UNKNOWN_VERSION.
15861544
Afterwards, report errors if we can not find their default versions. */
@@ -1600,13 +1558,6 @@ riscv_parse_add_subset (riscv_parse_subset_t *rps,
16001558
riscv_get_default_ext_version (rps->isa_spec, subset,
16011559
&major_version, &minor_version);
16021560

1603-
if (riscv_ext_dont_care_version (subset))
1604-
{
1605-
riscv_add_subset (rps->subset_list, subset,
1606-
major_version, minor_version);
1607-
return;
1608-
}
1609-
16101561
/* We don't care the versions of the implicit extensions. */
16111562
if (!implicit
16121563
&& (major_version == RISCV_UNKNOWN_VERSION
@@ -1618,10 +1569,7 @@ riscv_parse_add_subset (riscv_parse_subset_t *rps,
16181569
subset);
16191570
/* Allow old ISA spec can recognize zicsr and zifencei. */
16201571
else if (strcmp (subset, "zicsr") != 0
1621-
&& strcmp (subset, "zifencei") != 0
1622-
&& strcmp (subset, "iy") != 0
1623-
&& strcmp (subset, "iw") != 0
1624-
&& strcmp (subset, "il") != 0)
1572+
&& strcmp (subset, "zifencei") != 0)
16251573
rps->error_handler
16261574
(_("cannot find default versions of the ISA extension `%s'"),
16271575
subset);
@@ -2464,12 +2412,12 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps,
24642412
return riscv_subset_supports (rps, "svinval");
24652413
case INSN_CLASS_H:
24662414
return riscv_subset_supports (rps, "h");
2467-
case INSN_CLASS_I_Y:
2468-
return riscv_subset_supports (rps, "y");
2469-
case INSN_CLASS_I_W:
2470-
return riscv_subset_supports (rps, "w");
2471-
case INSN_CLASS_I_L:
2472-
return riscv_subset_supports (rps, "l");
2415+
case INSN_CLASS_XTTGS:
2416+
return riscv_subset_supports (rps, "xttgs");
2417+
case INSN_CLASS_XTTWH:
2418+
return riscv_subset_supports (rps, "xttwh");
2419+
case INSN_CLASS_XTTBH:
2420+
return riscv_subset_supports (rps, "xttbh");
24732421
default:
24742422
rps->error_handler
24752423
(_("internal: unreachable INSN_CLASS_*"));
@@ -2595,12 +2543,12 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
25952543
return "svinval";
25962544
case INSN_CLASS_H:
25972545
return _("h");
2598-
case INSN_CLASS_I_Y:
2599-
return "y";
2600-
case INSN_CLASS_I_W:
2601-
return "w";
2602-
case INSN_CLASS_I_L:
2603-
return "l";
2546+
case INSN_CLASS_XTTGS:
2547+
return "xttgs";
2548+
case INSN_CLASS_XTTWH:
2549+
return "xttwh";
2550+
case INSN_CLASS_XTTBH:
2551+
return "xttbh";
26042552
default:
26052553
rps->error_handler
26062554
(_("internal: unreachable INSN_CLASS_*"));

bfd/format.c

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -279,71 +279,6 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
279279

280280
cleanup = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
281281

282-
// FIXME: The handling of rhese variants as new machine types is
283-
// wrong. We should be using the _X<name> extension mechanism
284-
285-
// check if input object file machine code is WORMHOLE, GRAYSKULL, BLACKHOLE.
286-
if (abfd->tdata.elf_obj_data && abfd->tdata.elf_obj_data->elf_header
287-
&& abfd->tdata.elf_obj_data->elf_header->e_machine != riscv_machine_target) {
288-
if ((riscv_machine_target == -1
289-
|| riscv_machine_target == EM_RISCV) && // Allow plain RISCV to decay to TT cpu
290-
(abfd->tdata.elf_obj_data->elf_header->e_machine == EM_RISCV_GRAYSKULL ||
291-
abfd->tdata.elf_obj_data->elf_header->e_machine == EM_RISCV_WORMHOLE ||
292-
abfd->tdata.elf_obj_data->elf_header->e_machine == EM_RISCV_BLACKHOLE ||
293-
abfd->tdata.elf_obj_data->elf_header->e_machine == EM_RISCV )) {
294-
riscv_machine_target = abfd->tdata.elf_obj_data->elf_header->e_machine;
295-
} else if (abfd->tdata.elf_obj_data->elf_header->e_machine == EM_RISCV
296-
&& (riscv_machine_target == EM_RISCV_GRAYSKULL
297-
|| riscv_machine_target == EM_RISCV_WORMHOLE
298-
|| riscv_machine_target == EM_RISCV_BLACKHOLE))
299-
; // Allow RISCV to keep
300-
else if (riscv_machine_target == EM_RISCV_GRAYSKULL) {
301-
if (abfd->tdata.elf_obj_data->elf_header->e_machine == EM_RISCV_WORMHOLE) {
302-
_bfd_error_handler(_("%pB: Incorrect machine target. \nCurrent machine target is grayskull "
303-
"but got wormhole object file"), abfd);
304-
xexit (0);
305-
} else if (abfd->tdata.elf_obj_data->elf_header->e_machine == EM_RISCV_BLACKHOLE) {
306-
_bfd_error_handler(_("%pB: Incorrect machine target. \nCurrent machine target is grayskull "
307-
"but got blackhole object file"), abfd);
308-
xexit (0);
309-
}
310-
} else if (riscv_machine_target == EM_RISCV_WORMHOLE) {
311-
if (abfd->tdata.elf_obj_data->elf_header->e_machine == EM_RISCV_GRAYSKULL) {
312-
_bfd_error_handler(_("%pB: Incorrect machine target. \nCurrent machine target is wormhole "
313-
"but got grayskull object file"), abfd);
314-
xexit (0);
315-
} else if (abfd->tdata.elf_obj_data->elf_header->e_machine == EM_RISCV_BLACKHOLE) {
316-
_bfd_error_handler(_("%pB: Incorrect machine target. \nCurrent machine target is wormhole "
317-
"but got blackhole object file"), abfd);
318-
xexit (0);
319-
}
320-
} else if (riscv_machine_target == EM_RISCV_BLACKHOLE) {
321-
if (abfd->tdata.elf_obj_data->elf_header->e_machine == EM_RISCV_GRAYSKULL) {
322-
_bfd_error_handler(_("%pB: Incorrect machine target. \nCurrent machine target is blackhole "
323-
"but got grayskull object file"), abfd);
324-
xexit (0);
325-
} else if (abfd->tdata.elf_obj_data->elf_header->e_machine == EM_RISCV_WORMHOLE) {
326-
_bfd_error_handler(_("%pB: Incorrect machine target. \nCurrent machine target is blackhole "
327-
"but got wormhole object file"), abfd);
328-
xexit (0);
329-
}
330-
} else if (riscv_machine_target == EM_RISCV) {
331-
if (abfd->tdata.elf_obj_data->elf_header->e_machine == EM_RISCV_GRAYSKULL) {
332-
_bfd_error_handler(_("%pB: Incorrect machine target. \nCurrent machine target is riscv "
333-
"but got grayskull object file"), abfd);
334-
xexit (0);
335-
} else if (abfd->tdata.elf_obj_data->elf_header->e_machine == EM_RISCV_WORMHOLE) {
336-
_bfd_error_handler(_("%pB: Incorrect machine target. \nCurrent machine target is riscv "
337-
"but got wormhole object file"), abfd);
338-
xexit (0);
339-
} else if (abfd->tdata.elf_obj_data->elf_header->e_machine == EM_RISCV_BLACKHOLE) {
340-
_bfd_error_handler(_("%pB: Incorrect machine target. \nCurrent machine target is riscv "
341-
"but got blackhole object file"), abfd);
342-
xexit (0);
343-
}
344-
}
345-
}
346-
347282
if (cleanup)
348283
goto ok_ret;
349284

binutils/dwarf.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8707,7 +8707,6 @@ init_dwarf_regnames_by_elf_machine_code (unsigned int e_machine)
87078707
break;
87088708

87098709
case EM_RISCV:
8710-
case EM_RISCV_GRAYSKULL: case EM_RISCV_WORMHOLE: case EM_RISCV_BLACKHOLE:
87118710
init_dwarf_regnames_riscv ();
87128711
break;
87138712

0 commit comments

Comments
 (0)