{ BFD_RELOC_RISCV_SUB_ULEB128, R_RISCV_SUB_ULEB128 },
};
+struct riscv_profiles
+{
+ const char *profile_name;
+ const char *profile_string;
+};
+
/* Given a BFD reloc type, return a howto structure. */
reloc_howto_type *
{NULL, NULL, NULL}
};
+/* This table records the mapping form RISC-V Profiles into march string. */
+static struct riscv_profiles riscv_profiles_table[] =
+{
+ /* RVI20U only contains the base extension 'i' as mandatory extension. */
+ {"rvi20u64", "rv64i"},
+ {"rvi20u32", "rv32i"},
+
+ /* RVA20U contains the 'i,m,a,f,d,c,zicsr,zicntr,ziccif,ziccrse,ziccamoa,
+ zicclsm,za128rs' as mandatory extensions. */
+ {"rva20u64", "rv64imafdc_zicsr_zicntr_ziccif_ziccrse_ziccamoa"
+ "_zicclsm_za128rs"},
+
+ /* RVA22U contains the 'i,m,a,f,d,c,zicsr,zihintpause,zba,zbb,zbs,zicntr,
+ zihpm,ziccif,ziccrse,ziccamoa, zicclsm,zic64b,za64rs,zicbom,zicbop,zicboz,
+ zfhmin,zkt' as mandatory extensions. */
+ {"rva22u64", "rv64imafdc_zicsr_zicntr_ziccif_ziccrse_ziccamoa"
+ "_zicclsm_zic64b_za64rs_zihintpause_zba_zbb_zbs_zicbom_zicbop"
+ "_zicboz_zfhmin_zkt"},
+
+ /* Currently we do not define S/M mode Profiles. */
+
+ /* Terminate the list. */
+ {NULL, NULL}
+};
+
/* For default_enable field, decide if the extension should
be enbaled by default. */
static const char *
riscv_parse_extensions (riscv_parse_subset_t *rps,
const char *arch,
- const char *p)
+ const char *p,
+ bool profile)
{
- /* First letter must start with i, e or g. */
- if (*p != 'e' && *p != 'i' && *p != 'g')
+ /* First letter must start with i, e, g or a profile. */
+ if (*p != 'e' && *p != 'i' && *p != 'g' && !profile)
{
rps->error_handler
(_("%s: first ISA extension must be `e', `i' or `g'"),
}
}
+static bool
+riscv_find_profiles (riscv_parse_subset_t *rps, const char **pp)
+{
+ const char *p = *pp;
+
+ /* Checking if input string contains a Profiles.
+ There are two cases use Profiles in -march option:
+
+ 1. Only use Profiles in '-march' as input
+ 2. Mixed Profiles with other extensions
+
+ Use '_' to split Profiles and other extensions. */
+
+ for (int i = 0; riscv_profiles_table[i].profile_name != NULL; ++i)
+ {
+ /* Find profile at the begin. */
+ if (startswith (p, riscv_profiles_table[i].profile_name))
+ {
+ /* Handle the profile string. */
+ riscv_parse_subset (rps, riscv_profiles_table[i].profile_string);
+ p += strlen (riscv_profiles_table[i].profile_name);
+ /* Handle string after profiles if exists. If missing underline
+ bewteen profile and other extensions, warn the user but not deal
+ as an error. */
+ if (*p != '\0' && *p != '_')
+ _bfd_error_handler
+ (_("Warning: should use \"_\" to contact Profiles with other "
+ "extensions"));
+ *pp = p;
+ return true;
+ }
+ }
+ /* Not found profile, return directly. */
+ return false;
+}
+
/* Function for parsing ISA string.
Return Value:
}
}
+ bool profile = false;
p = arch;
- if (startswith (p, "rv32"))
+ if (riscv_find_profiles (rps, &p))
+ {
+ /* Check if using Profiles. */
+ profile = true;
+ }
+ else if (startswith (p, "rv32"))
{
*rps->xlen = 32;
p += 4;
string is empty. */
if (strlen (arch))
rps->error_handler (
- _("%s: ISA string must begin with rv32 or rv64"),
+ _("%s: ISA string must begin with rv32, rv64 or Profiles"),
arch);
return false;
}
/* Parse single standard and prefixed extensions. */
- if (riscv_parse_extensions (rps, arch, p) == NULL)
+ if (riscv_parse_extensions (rps, arch, p, profile) == NULL)
return false;
/* Finally add implicit extensions according to the current
@item -fno-pic
Don't generate position-independent code (default)
-@cindex @samp{-march=ISA} option, RISC-V
-@item -march=ISA
-Select the base isa, as specified by ISA. For example -march=rv32ima.
+@cindex @samp{-march=ISA|Profiles|Profiles_ISA} option, RISC-V
+@item -march=ISA|Profiles|Profiles_ISA
+Select the base isa, as specified by ISA or Profiles or Profies_ISA.
+For example @samp{-march=rv32ima} @samp{-march=RVI20U64}
+@samp{-march=RVI20U64_d}.
If this option and the architecture attributes aren't set, then assembler
will check the default configure setting --with-arch=ISA.
for the default version of its base ISA. On the other hand, the architecture
@code{RV32G} has to be presented as @code{RV32I2P0_M2P0_A2P0_F2P0_D2P0} in
which the abbreviation @code{G} is expanded to the @code{IMAFD} combination
-with default versions of the standard extensions.
+with default versions of the standard extensions. All Profiles are expanded
+ to the mandatory extensions it includes then processing. For example,
+@code{RVI20U32} is expanded to @code{RV32I2P0} for processing, which contains
+the mandatory extensions @code{I} as it defined. And you can also combine
+Profiles with ISA use underline, like @code{RVI20U32_D} is expanded to the
+@code{RV32I2P0_F2P0_D2P0}.
@item Tag_RISCV_unaligned_access (6)
Tag_RISCV_unaligned_access is 0 for files that do not allow any unaligned