0009-RISC-V-Support-to-add-implicit-extensions.patch 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. From 0249aa42c5267cdaeeaf5a26dbc2e7e54dd71b96 Mon Sep 17 00:00:00 2001
  2. From: Nelson Chu <nelson.chu@sifive.com>
  3. Date: Fri, 20 Nov 2020 18:05:05 +0800
  4. Subject: [PATCH 09/48] RISC-V: Support to add implicit extensions.
  5. We have to parse and add all arch string extensions at first, and then
  6. start to add their implicit extensions. That means we can always add
  7. arch string extensions at the end of the subset list, but we need to
  8. search the right place to add their implicit extensions. For now we
  9. follow the following rules to add the implicit extensions,
  10. * Add zicsr and zifencei only when the i's version less than 2.1.
  11. * Add d, f and zicsr when q is found.
  12. * Add f and zicsr when d is found.
  13. * Add zicsr when f is found.
  14. Besides, we do not add the implicit extensions if they are already added
  15. in the subset list, or we cannot find their default versions according to
  16. the chosen ISA spec.
  17. bfd/
  18. * elfnn-riscv.c (riscv_merge_std_ext): Updated since
  19. riscv_lookup_subset is changed.
  20. * elfxx-riscv.c (riscv_ext_order): New Array used to compare the
  21. extensions' order quickly.
  22. (riscv_init_ext_order): New function. Init the riscv_ext_order
  23. according to the riscv_supported_std_ext and parse_config[i].class
  24. automatically.
  25. (riscv_compare_subsets): New function. Similar to the strcmp, but
  26. compare the subsets with the specific order.
  27. (riscv_lookup_subset): Return TRUE and set `current` to the subset
  28. if it is found. Otherwise, return FALSE and set `current` to the
  29. place where we should insert the subset.
  30. (riscv_add_implicit_subset): New function. Search the list first,
  31. and then find the right place to add the implicit_subset.
  32. (riscv_parse_add_subset): Since We have to add all arch string
  33. extensions first, and then start to add their implicit extensions.
  34. We can add arch string extensions in order by the original
  35. riscv_add_subset, and then add the implicit subsets by the
  36. riscv_add_implicit_subset. Besides, do not add the implicit
  37. extensions if we failed to find their default versions.
  38. (riscv_parse_std_ext): Updated.
  39. (riscv_parse_add_implicit_subsets): New function. Add all implicit
  40. extensions according to the arch string extensions.
  41. (riscv_parse_subset): Call riscv_init_ext_order and
  42. riscv_parse_add_implicit_subsets, before and after parsing the
  43. arch string. Remove parts of the ISA conflict checking since
  44. the implicit extensions are added.
  45. * elfxx-riscv.h (riscv_lookup_subset): Updated.
  46. gas/
  47. * config/tc-riscv.c (riscv_subset_supports): Updated.
  48. * testsuite/gas/riscv/march-imply-i2p0.d: New testcase. Need to
  49. add the implicit zicsr and zifencei when i's version less than 2.1.
  50. * testsuite/gas/riscv/march-imply-i2p1.d: New testcase.
  51. * testsuite/gas/riscv/march-imply-d.d: Likewise.
  52. * testsuite/gas/riscv/march-imply-f.d: Likewise.
  53. * testsuite/gas/riscv/march-imply-q.d: Likewise.
  54. * testsuite/gas/riscv/march-fail-rv32iq.l: Updated.
  55. * testsuite/gas/riscv/march-fail-rv32id.d: Removed.
  56. * testsuite/gas/riscv/march-fail-rv32id.l: Likewise.
  57. * testsuite/gas/riscv/march-fail-rv64iq.d: Likewise.
  58. * testsuite/gas/riscv/march-fail-rv64iq.l: Likewise.
  59. ---
  60. bfd/elfnn-riscv.c | 21 +-
  61. bfd/elfxx-riscv.c | 267 ++++++++++++++++----
  62. bfd/elfxx-riscv.h | 5 +-
  63. gas/config/tc-riscv.c | 4 +-
  64. gas/testsuite/gas/riscv/march-fail-rv32id.d | 3 -
  65. gas/testsuite/gas/riscv/march-fail-rv32id.l | 2 -
  66. gas/testsuite/gas/riscv/march-fail-rv32iq.l | 1 -
  67. gas/testsuite/gas/riscv/march-fail-rv64iq.d | 3 -
  68. gas/testsuite/gas/riscv/march-fail-rv64iq.l | 2 -
  69. gas/testsuite/gas/riscv/march-imply-d.d | 6 +
  70. gas/testsuite/gas/riscv/march-imply-f.d | 6 +
  71. gas/testsuite/gas/riscv/march-imply-i2p0.d | 6 +
  72. gas/testsuite/gas/riscv/march-imply-i2p1.d | 6 +
  73. gas/testsuite/gas/riscv/march-imply-q.d | 6 +
  74. 14 files changed, 269 insertions(+), 69 deletions(-)
  75. delete mode 100644 gas/testsuite/gas/riscv/march-fail-rv32id.d
  76. delete mode 100644 gas/testsuite/gas/riscv/march-fail-rv32id.l
  77. delete mode 100644 gas/testsuite/gas/riscv/march-fail-rv64iq.d
  78. delete mode 100644 gas/testsuite/gas/riscv/march-fail-rv64iq.l
  79. create mode 100644 gas/testsuite/gas/riscv/march-imply-d.d
  80. create mode 100644 gas/testsuite/gas/riscv/march-imply-f.d
  81. create mode 100644 gas/testsuite/gas/riscv/march-imply-i2p0.d
  82. create mode 100644 gas/testsuite/gas/riscv/march-imply-i2p1.d
  83. create mode 100644 gas/testsuite/gas/riscv/march-imply-q.d
  84. diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
  85. index c08827873c..8524e689ef 100644
  86. --- a/bfd/elfnn-riscv.c
  87. +++ b/bfd/elfnn-riscv.c
  88. @@ -2727,21 +2727,24 @@ riscv_merge_std_ext (bfd *ibfd,
  89. /* Handle standard extension first. */
  90. for (p = standard_exts; *p; ++p)
  91. {
  92. + struct riscv_subset_t *ext_in, *ext_out, *ext_merged;
  93. char find_ext[2] = {*p, '\0'};
  94. - struct riscv_subset_t *find_in =
  95. - riscv_lookup_subset (&in_subsets, find_ext);
  96. - struct riscv_subset_t *find_out =
  97. - riscv_lookup_subset (&out_subsets, find_ext);
  98. + bfd_boolean find_in, find_out;
  99. - if (find_in == NULL && find_out == NULL)
  100. + find_in = riscv_lookup_subset (&in_subsets, find_ext, &ext_in);
  101. + find_out = riscv_lookup_subset (&out_subsets, find_ext, &ext_out);
  102. +
  103. + if (!find_in && !find_out)
  104. continue;
  105. - if (!riscv_version_mismatch (ibfd, find_in, find_out))
  106. + if (find_in
  107. + && find_out
  108. + && !riscv_version_mismatch (ibfd, ext_in, ext_out))
  109. return FALSE;
  110. - struct riscv_subset_t *merged = find_out ? find_out : find_in;
  111. - riscv_add_subset (&merged_subsets, merged->name,
  112. - merged->major_version, merged->minor_version);
  113. + ext_merged = find_out ? ext_out : ext_in;
  114. + riscv_add_subset (&merged_subsets, ext_merged->name,
  115. + ext_merged->major_version, ext_merged->minor_version);
  116. }
  117. /* Skip all standard extensions. */
  118. diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
  119. index 233f4e20d6..38c4de19bd 100644
  120. --- a/bfd/elfxx-riscv.c
  121. +++ b/bfd/elfxx-riscv.c
  122. @@ -1010,22 +1010,75 @@ riscv_elf_add_sub_reloc (bfd *abfd,
  123. return bfd_reloc_ok;
  124. }
  125. -/* Find subset in list, return NULL if not found. */
  126. +/* Array is used to compare the all extensions' order quickly.
  127. -riscv_subset_t *
  128. -riscv_lookup_subset (const riscv_subset_list_t *subset_list,
  129. - const char *subset)
  130. + Zero number means it is a preserved keyword.
  131. + Negative number means it is a prefix keyword (s, h, x, z).
  132. + Positive number means it is a standard extension. */
  133. +
  134. +static int riscv_ext_order[26] = {0};
  135. +
  136. +/* Similar to the strcmp. It returns an integer less than, equal to,
  137. + or greater than zero if `subset2` is found, respectively, to be less
  138. + than, to match, or be greater than `subset1`. */
  139. +
  140. +static int
  141. +riscv_compare_subsets (const char *subset1, const char *subset2)
  142. {
  143. - riscv_subset_t *s;
  144. + int order1 = riscv_ext_order[(*subset1 - 'a')];
  145. + int order2 = riscv_ext_order[(*subset2 - 'a')];
  146. - for (s = subset_list->head; s != NULL; s = s->next)
  147. - if (strcasecmp (s->name, subset) == 0)
  148. - return s;
  149. + /* Compare the standard extension first. */
  150. + if (order1 > 0 && order2 > 0)
  151. + return order1 - order2;
  152. - return NULL;
  153. + if (order1 == order2 && order1 < 0)
  154. + {
  155. + /* Compare the standard addition z extensions. */
  156. + if (*subset1 == 'z')
  157. + {
  158. + order1 = riscv_ext_order[(*++subset1 - 'a')];
  159. + order2 = riscv_ext_order[(*++subset2 - 'a')];
  160. + if (order1 != order2)
  161. + return order1 - order2;
  162. + }
  163. + return strcasecmp (++subset1, ++subset2);
  164. + }
  165. +
  166. + return order2 - order1;
  167. }
  168. -/* Add extension to the subset list. */
  169. +/* Find subset in the list. Return TRUE and set `current` to the subset
  170. + if it is found. Otherwise, return FALSE and set `current` to the place
  171. + where we should insert the subset. However, return FALSE with the NULL
  172. + `current` means we should insert the subset at the head of subset list,
  173. + if needed. */
  174. +
  175. +bfd_boolean
  176. +riscv_lookup_subset (const riscv_subset_list_t *subset_list,
  177. + const char *subset,
  178. + riscv_subset_t **current)
  179. +{
  180. + riscv_subset_t *s, *pre_s = NULL;
  181. +
  182. + for (s = subset_list->head;
  183. + s != NULL;
  184. + pre_s = s, s = s->next)
  185. + {
  186. + int cmp = riscv_compare_subsets (s->name, subset);
  187. + if (cmp == 0)
  188. + {
  189. + *current = s;
  190. + return TRUE;
  191. + }
  192. + else if (cmp > 0)
  193. + break;
  194. + }
  195. + *current = pre_s;
  196. + return FALSE;
  197. +}
  198. +
  199. +/* Add arch string extension to the last of the subset list. */
  200. void
  201. riscv_add_subset (riscv_subset_list_t *subset_list,
  202. @@ -1048,7 +1101,44 @@ riscv_add_subset (riscv_subset_list_t *subset_list,
  203. subset_list->tail = s;
  204. }
  205. -/* Find the default versions for the extension before adding them to
  206. +/* Add the implicit extension to the subset list. Search the
  207. + list first, and then find the right place to add. */
  208. +
  209. +static void
  210. +riscv_add_implicit_subset (riscv_subset_list_t *subset_list,
  211. + const char *subset,
  212. + int major,
  213. + int minor)
  214. +{
  215. + riscv_subset_t *current, *new;
  216. +
  217. + if (riscv_lookup_subset (subset_list, subset, &current))
  218. + return;
  219. +
  220. + new = xmalloc (sizeof *new);
  221. + new->name = xstrdup (subset);
  222. + new->major_version = major;
  223. + new->minor_version = minor;
  224. + new->next = NULL;
  225. +
  226. + if (current != NULL)
  227. + {
  228. + new->next = current->next;
  229. + current->next = new;
  230. + }
  231. + else
  232. + {
  233. + new->next = subset_list->head;
  234. + subset_list->head = new;
  235. + }
  236. +}
  237. +
  238. +/* We have to add all arch string extensions first, and then start to
  239. + add their implicit extensions. The arch string extensions must be
  240. + set in order, so we can add them to the last of the subset list
  241. + directly, without searching.
  242. +
  243. + Find the default versions for the extension before adding them to
  244. the subset list, if their versions are RISCV_UNKNOWN_VERSION.
  245. Afterwards, report errors if we can not find their default versions. */
  246. @@ -1056,7 +1146,8 @@ static void
  247. riscv_parse_add_subset (riscv_parse_subset_t *rps,
  248. const char *subset,
  249. int major,
  250. - int minor)
  251. + int minor,
  252. + bfd_boolean implicit)
  253. {
  254. int major_version = major;
  255. int minor_version = minor;
  256. @@ -1066,8 +1157,9 @@ riscv_parse_add_subset (riscv_parse_subset_t *rps,
  257. && rps->get_default_version != NULL)
  258. rps->get_default_version (subset, &major_version, &minor_version);
  259. - if (major_version == RISCV_UNKNOWN_VERSION
  260. - || minor_version == RISCV_UNKNOWN_VERSION)
  261. + if (!implicit
  262. + && (major_version == RISCV_UNKNOWN_VERSION
  263. + || minor_version == RISCV_UNKNOWN_VERSION))
  264. {
  265. if (subset[0] == 'x')
  266. rps->error_handler
  267. @@ -1080,8 +1172,15 @@ riscv_parse_add_subset (riscv_parse_subset_t *rps,
  268. return;
  269. }
  270. - riscv_add_subset (rps->subset_list, subset,
  271. - major_version, minor_version);
  272. + if (!implicit)
  273. + riscv_add_subset (rps->subset_list, subset,
  274. + major_version, minor_version);
  275. + else if (major_version != RISCV_UNKNOWN_VERSION
  276. + && minor_version != RISCV_UNKNOWN_VERSION)
  277. + /* We only add the implicit extension if it is supported in the
  278. + chosen ISA spec. */
  279. + riscv_add_implicit_subset (rps->subset_list, subset,
  280. + major_version, minor_version);
  281. }
  282. /* Release subset list. */
  283. @@ -1215,7 +1314,7 @@ riscv_parse_std_ext (riscv_parse_subset_t *rps,
  284. &minor_version, TRUE);
  285. riscv_parse_add_subset (rps, "i",
  286. major_version,
  287. - minor_version);
  288. + minor_version, FALSE);
  289. break;
  290. case 'e':
  291. @@ -1224,11 +1323,11 @@ riscv_parse_std_ext (riscv_parse_subset_t *rps,
  292. &minor_version, TRUE);
  293. riscv_parse_add_subset (rps, "e",
  294. major_version,
  295. - minor_version);
  296. + minor_version, FALSE);
  297. /* i-ext must be enabled. */
  298. riscv_parse_add_subset (rps, "i",
  299. RISCV_UNKNOWN_VERSION,
  300. - RISCV_UNKNOWN_VERSION);
  301. + RISCV_UNKNOWN_VERSION, FALSE);
  302. if (*rps->xlen > 32)
  303. {
  304. @@ -1248,13 +1347,13 @@ riscv_parse_std_ext (riscv_parse_subset_t *rps,
  305. /* i-ext must be enabled. */
  306. riscv_parse_add_subset (rps, "i",
  307. RISCV_UNKNOWN_VERSION,
  308. - RISCV_UNKNOWN_VERSION);
  309. + RISCV_UNKNOWN_VERSION, FALSE);
  310. for ( ; *std_exts != 'q'; std_exts++)
  311. {
  312. subset[0] = *std_exts;
  313. riscv_parse_add_subset (rps, subset,
  314. RISCV_UNKNOWN_VERSION,
  315. - RISCV_UNKNOWN_VERSION);
  316. + RISCV_UNKNOWN_VERSION, FALSE);
  317. }
  318. break;
  319. @@ -1301,7 +1400,7 @@ riscv_parse_std_ext (riscv_parse_subset_t *rps,
  320. &minor_version, TRUE);
  321. riscv_parse_add_subset (rps, subset,
  322. major_version,
  323. - minor_version);
  324. + minor_version, FALSE);
  325. }
  326. return p;
  327. @@ -1438,7 +1537,7 @@ riscv_parse_prefixed_ext (riscv_parse_subset_t *rps,
  328. riscv_parse_add_subset (rps, subset,
  329. major_version,
  330. - minor_version);
  331. + minor_version, FALSE);
  332. free (subset);
  333. p += end_of_version - subset;
  334. @@ -1544,6 +1643,92 @@ static const riscv_parse_config_t parse_config[] =
  335. {RV_ISA_CLASS_UNKNOWN, NULL, NULL}
  336. };
  337. +/* Init the riscv_ext_order array. */
  338. +
  339. +static void
  340. +riscv_init_ext_order (void)
  341. +{
  342. + static bfd_boolean inited = FALSE;
  343. + const char *std_base_exts = "eig";
  344. + const char *std_remain_exts = riscv_supported_std_ext ();
  345. + const char *ext;
  346. + unsigned int i;
  347. + int order;
  348. +
  349. + if (inited)
  350. + return;
  351. +
  352. + /* All standard extensions' orders are positive numbers. */
  353. + order = 1;
  354. +
  355. + /* Init the standard base extensions first. */
  356. + for (ext = std_base_exts; *ext; ext++)
  357. + riscv_ext_order[(*ext - 'a')] = order++;
  358. +
  359. + /* Init the standard remaining extensions. */
  360. + for (ext = std_remain_exts; *ext; ext++)
  361. + riscv_ext_order[(*ext - 'a')] = order++;
  362. +
  363. + /* Init the order for prefixed keywords. The orders are
  364. + negative numbers. */
  365. + order = -1;
  366. + for (i = 0; parse_config[i].class != RV_ISA_CLASS_UNKNOWN; i++)
  367. + {
  368. + ext = parse_config[i].prefix;
  369. + riscv_ext_order[(*ext - 'a')] = order--;
  370. + }
  371. +
  372. + inited = TRUE;
  373. +}
  374. +
  375. +/* Add the implicit extensions according to the arch string extensions. */
  376. +
  377. +static void
  378. +riscv_parse_add_implicit_subsets (riscv_parse_subset_t *rps)
  379. +{
  380. + riscv_subset_t *subset = NULL;
  381. +
  382. + /* Add the zicsr and zifencei only when the i's version less than 2.1. */
  383. + if ((riscv_lookup_subset (rps->subset_list, "i", &subset))
  384. + && (subset->major_version < 2
  385. + || (subset->major_version == 2
  386. + && subset->minor_version < 1)))
  387. + {
  388. + riscv_parse_add_subset (rps, "zicsr",
  389. + RISCV_UNKNOWN_VERSION,
  390. + RISCV_UNKNOWN_VERSION, TRUE);
  391. + riscv_parse_add_subset (rps, "zifencei",
  392. + RISCV_UNKNOWN_VERSION,
  393. + RISCV_UNKNOWN_VERSION, TRUE);
  394. + }
  395. +
  396. + if ((riscv_lookup_subset (rps->subset_list, "q", &subset)))
  397. + {
  398. + riscv_parse_add_subset (rps, "d",
  399. + RISCV_UNKNOWN_VERSION,
  400. + RISCV_UNKNOWN_VERSION, TRUE);
  401. + riscv_parse_add_subset (rps, "f",
  402. + RISCV_UNKNOWN_VERSION,
  403. + RISCV_UNKNOWN_VERSION, TRUE);
  404. + riscv_parse_add_subset (rps, "zicsr",
  405. + RISCV_UNKNOWN_VERSION,
  406. + RISCV_UNKNOWN_VERSION, TRUE);
  407. + }
  408. + else if ((riscv_lookup_subset (rps->subset_list, "d", &subset)))
  409. + {
  410. + riscv_parse_add_subset (rps, "f",
  411. + RISCV_UNKNOWN_VERSION,
  412. + RISCV_UNKNOWN_VERSION, TRUE);
  413. + riscv_parse_add_subset (rps, "zicsr",
  414. + RISCV_UNKNOWN_VERSION,
  415. + RISCV_UNKNOWN_VERSION, TRUE);
  416. + }
  417. + else if ((riscv_lookup_subset (rps->subset_list, "f", &subset)))
  418. + riscv_parse_add_subset (rps, "zicsr",
  419. + RISCV_UNKNOWN_VERSION,
  420. + RISCV_UNKNOWN_VERSION, TRUE);
  421. +}
  422. +
  423. /* Function for parsing arch string.
  424. Return Value:
  425. @@ -1557,6 +1742,7 @@ bfd_boolean
  426. riscv_parse_subset (riscv_parse_subset_t *rps,
  427. const char *arch)
  428. {
  429. + riscv_subset_t *subset = NULL;
  430. const char *p;
  431. size_t i;
  432. bfd_boolean no_conflict = TRUE;
  433. @@ -1597,6 +1783,10 @@ riscv_parse_subset (riscv_parse_subset_t *rps,
  434. return FALSE;
  435. }
  436. + /* Init the riscv_ext_order array to compare the order of extensions
  437. + quickly. */
  438. + riscv_init_ext_order ();
  439. +
  440. /* Parsing standard extension. */
  441. p = riscv_parse_std_ext (rps, arch, p);
  442. @@ -1619,42 +1809,27 @@ riscv_parse_subset (riscv_parse_subset_t *rps,
  443. return FALSE;
  444. }
  445. + /* Finally add implicit extensions according to the current
  446. + extensions. */
  447. + riscv_parse_add_implicit_subsets (rps);
  448. +
  449. /* Check the conflicts. */
  450. - if (riscv_lookup_subset (rps->subset_list, "e")
  451. - && riscv_lookup_subset (rps->subset_list, "f"))
  452. + if (riscv_lookup_subset (rps->subset_list, "e", &subset)
  453. + && riscv_lookup_subset (rps->subset_list, "f", &subset))
  454. {
  455. rps->error_handler
  456. (_("-march=%s: rv32e does not support the `f' extension"),
  457. arch);
  458. no_conflict = FALSE;
  459. }
  460. -
  461. - if (riscv_lookup_subset (rps->subset_list, "q") && *rps->xlen < 64)
  462. + if (riscv_lookup_subset (rps->subset_list, "q", &subset)
  463. + && *rps->xlen < 64)
  464. {
  465. rps->error_handler
  466. (_("-march=%s: rv32 does not support the `q' extension"),
  467. arch);
  468. no_conflict = FALSE;
  469. }
  470. -
  471. - if (riscv_lookup_subset (rps->subset_list, "d")
  472. - && !riscv_lookup_subset (rps->subset_list, "f"))
  473. - {
  474. - rps->error_handler
  475. - (_("-march=%s: `d' extension requires `f' extension"),
  476. - arch);
  477. - no_conflict = FALSE;
  478. - }
  479. -
  480. - if (riscv_lookup_subset (rps->subset_list, "q")
  481. - && !riscv_lookup_subset (rps->subset_list, "d"))
  482. - {
  483. - rps->error_handler
  484. - (_("-march=%s: `q' extension requires `d' extension"),
  485. - arch);
  486. - no_conflict = FALSE;
  487. - }
  488. -
  489. return no_conflict;
  490. }
  491. diff --git a/bfd/elfxx-riscv.h b/bfd/elfxx-riscv.h
  492. index 45705ce31c..89d4abb86e 100644
  493. --- a/bfd/elfxx-riscv.h
  494. +++ b/bfd/elfxx-riscv.h
  495. @@ -60,9 +60,10 @@ riscv_add_subset (riscv_subset_list_t *,
  496. const char *,
  497. int, int);
  498. -extern riscv_subset_t *
  499. +extern bfd_boolean
  500. riscv_lookup_subset (const riscv_subset_list_t *,
  501. - const char *);
  502. + const char *,
  503. + riscv_subset_t **);
  504. typedef struct
  505. {
  506. diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
  507. index 24771b0a0b..c21bb719d8 100644
  508. --- a/gas/config/tc-riscv.c
  509. +++ b/gas/config/tc-riscv.c
  510. @@ -210,10 +210,12 @@ static riscv_subset_list_t riscv_subsets;
  511. static bfd_boolean
  512. riscv_subset_supports (const char *feature)
  513. {
  514. + struct riscv_subset_t *subset;
  515. +
  516. if (riscv_opts.rvc && (strcasecmp (feature, "c") == 0))
  517. return TRUE;
  518. - return riscv_lookup_subset (&riscv_subsets, feature) != NULL;
  519. + return riscv_lookup_subset (&riscv_subsets, feature, &subset);
  520. }
  521. static bfd_boolean
  522. diff --git a/gas/testsuite/gas/riscv/march-fail-rv32id.d b/gas/testsuite/gas/riscv/march-fail-rv32id.d
  523. deleted file mode 100644
  524. index de741cbc81..0000000000
  525. --- a/gas/testsuite/gas/riscv/march-fail-rv32id.d
  526. +++ /dev/null
  527. @@ -1,3 +0,0 @@
  528. -#as: -march=rv32id
  529. -#source: empty.s
  530. -#error_output: march-fail-rv32id.l
  531. diff --git a/gas/testsuite/gas/riscv/march-fail-rv32id.l b/gas/testsuite/gas/riscv/march-fail-rv32id.l
  532. deleted file mode 100644
  533. index c5f990cd73..0000000000
  534. --- a/gas/testsuite/gas/riscv/march-fail-rv32id.l
  535. +++ /dev/null
  536. @@ -1,2 +0,0 @@
  537. -.*Assembler messages:
  538. -.*Error: .*`d' extension requires `f' extension
  539. diff --git a/gas/testsuite/gas/riscv/march-fail-rv32iq.l b/gas/testsuite/gas/riscv/march-fail-rv32iq.l
  540. index 8143dd441d..dc201b3d7b 100644
  541. --- a/gas/testsuite/gas/riscv/march-fail-rv32iq.l
  542. +++ b/gas/testsuite/gas/riscv/march-fail-rv32iq.l
  543. @@ -1,3 +1,2 @@
  544. .*Assembler messages:
  545. .*Error: .*rv32 does not support the `q' extension
  546. -.*Error: .*`q' extension requires `d' extension
  547. diff --git a/gas/testsuite/gas/riscv/march-fail-rv64iq.d b/gas/testsuite/gas/riscv/march-fail-rv64iq.d
  548. deleted file mode 100644
  549. index c97a812cb3..0000000000
  550. --- a/gas/testsuite/gas/riscv/march-fail-rv64iq.d
  551. +++ /dev/null
  552. @@ -1,3 +0,0 @@
  553. -#as: -march=rv64iq
  554. -#source: empty.s
  555. -#error_output: march-fail-rv64iq.l
  556. diff --git a/gas/testsuite/gas/riscv/march-fail-rv64iq.l b/gas/testsuite/gas/riscv/march-fail-rv64iq.l
  557. deleted file mode 100644
  558. index 787f46d1ed..0000000000
  559. --- a/gas/testsuite/gas/riscv/march-fail-rv64iq.l
  560. +++ /dev/null
  561. @@ -1,2 +0,0 @@
  562. -.*Assembler messages:
  563. -.*Error: .*`q' extension requires `d' extension
  564. diff --git a/gas/testsuite/gas/riscv/march-imply-d.d b/gas/testsuite/gas/riscv/march-imply-d.d
  565. new file mode 100644
  566. index 0000000000..ce2b47929f
  567. --- /dev/null
  568. +++ b/gas/testsuite/gas/riscv/march-imply-d.d
  569. @@ -0,0 +1,6 @@
  570. +#as: -march=rv32id -march-attr -misa-spec=20191213
  571. +#readelf: -A
  572. +#source: empty.s
  573. +Attribute Section: riscv
  574. +File Attributes
  575. + Tag_RISCV_arch: "rv32i2p1_f2p2_d2p2_zicsr2p0"
  576. diff --git a/gas/testsuite/gas/riscv/march-imply-f.d b/gas/testsuite/gas/riscv/march-imply-f.d
  577. new file mode 100644
  578. index 0000000000..bc372aed0e
  579. --- /dev/null
  580. +++ b/gas/testsuite/gas/riscv/march-imply-f.d
  581. @@ -0,0 +1,6 @@
  582. +#as: -march=rv32if -march-attr -misa-spec=20191213
  583. +#readelf: -A
  584. +#source: empty.s
  585. +Attribute Section: riscv
  586. +File Attributes
  587. + Tag_RISCV_arch: "rv32i2p1_f2p2_zicsr2p0"
  588. diff --git a/gas/testsuite/gas/riscv/march-imply-i2p0.d b/gas/testsuite/gas/riscv/march-imply-i2p0.d
  589. new file mode 100644
  590. index 0000000000..17fcc7aa90
  591. --- /dev/null
  592. +++ b/gas/testsuite/gas/riscv/march-imply-i2p0.d
  593. @@ -0,0 +1,6 @@
  594. +#as: -march=rv32i2p0 -march-attr -misa-spec=20191213
  595. +#readelf: -A
  596. +#source: empty.s
  597. +Attribute Section: riscv
  598. +File Attributes
  599. + Tag_RISCV_arch: "rv32i2p0_zicsr2p0_zifencei2p0"
  600. diff --git a/gas/testsuite/gas/riscv/march-imply-i2p1.d b/gas/testsuite/gas/riscv/march-imply-i2p1.d
  601. new file mode 100644
  602. index 0000000000..0e9a464d61
  603. --- /dev/null
  604. +++ b/gas/testsuite/gas/riscv/march-imply-i2p1.d
  605. @@ -0,0 +1,6 @@
  606. +#as: -march=rv32i -march-attr -misa-spec=20191213
  607. +#readelf: -A
  608. +#source: empty.s
  609. +Attribute Section: riscv
  610. +File Attributes
  611. + Tag_RISCV_arch: "rv32i2p1"
  612. diff --git a/gas/testsuite/gas/riscv/march-imply-q.d b/gas/testsuite/gas/riscv/march-imply-q.d
  613. new file mode 100644
  614. index 0000000000..d631d6f321
  615. --- /dev/null
  616. +++ b/gas/testsuite/gas/riscv/march-imply-q.d
  617. @@ -0,0 +1,6 @@
  618. +#as: -march=rv64iq -march-attr -misa-spec=20191213
  619. +#readelf: -A
  620. +#source: empty.s
  621. +Attribute Section: riscv
  622. +File Attributes
  623. + Tag_RISCV_arch: "rv64i2p1_f2p2_d2p2_q2p2_zicsr2p0"
  624. --
  625. 2.33.0