RISC-V: Indent and GNU coding standards tidy, also aligned the code.

bfd/
    * elfnn-riscv.c: Indent, labels and GNU coding standards tidy,
    also aligned the code.
gas/
    * config/tc-riscv.c: Indent and GNU coding standards tidy,
    also aligned the code.
    * config/tc-riscv.h: Likewise.
include/
    * opcode/riscv.h: Indent and GNU coding standards tidy,
    also aligned the code.
opcodes/
    * riscv-opc.c (riscv_gpr_names_abi): Aligned the code.
    (riscv_fpr_names_abi): Likewise.
    (riscv_opcodes): Likewise.
    (riscv_insn_types): Likewise.
This commit is contained in:
Nelson Chu 2021-01-15 09:36:51 +08:00
parent b800637e76
commit 1942a04836
9 changed files with 923 additions and 901 deletions

View File

@ -1,3 +1,8 @@
2021-01-15 Nelson Chu <nelson.chu@sifive.com>
* elfnn-riscv.c: Indent, labels and GNU coding standards tidy,
also aligned the code.
2021-01-15 Nelson Chu <nelson.chu@sifive.com>
* elfnn-riscv.c (riscv_merge_attributes): Fix typos of messages.

View File

@ -69,16 +69,16 @@ struct riscv_elf_link_hash_entry
{
struct elf_link_hash_entry elf;
#define GOT_UNKNOWN 0
#define GOT_NORMAL 1
#define GOT_TLS_GD 2
#define GOT_TLS_IE 4
#define GOT_TLS_LE 8
#define GOT_UNKNOWN 0
#define GOT_NORMAL 1
#define GOT_TLS_GD 2
#define GOT_TLS_IE 4
#define GOT_TLS_LE 8
char tls_type;
};
#define riscv_elf_hash_entry(ent) \
((struct riscv_elf_link_hash_entry *)(ent))
((struct riscv_elf_link_hash_entry *) (ent))
struct _bfd_riscv_elf_obj_tdata
{
@ -1738,14 +1738,14 @@ typedef struct
typedef struct riscv_pcrel_lo_reloc
{
asection * input_section;
struct bfd_link_info * info;
reloc_howto_type * howto;
const Elf_Internal_Rela * reloc;
bfd_vma addr;
const char * name;
bfd_byte * contents;
struct riscv_pcrel_lo_reloc * next;
asection *input_section;
struct bfd_link_info *info;
reloc_howto_type *howto;
const Elf_Internal_Rela *reloc;
bfd_vma addr;
const char *name;
bfd_byte *contents;
struct riscv_pcrel_lo_reloc *next;
} riscv_pcrel_lo_reloc;
typedef struct
@ -1771,7 +1771,6 @@ riscv_pcrel_reloc_eq (const void *entry1, const void *entry2)
static bfd_boolean
riscv_init_pcrel_relocs (riscv_pcrel_relocs *p)
{
p->lo_relocs = NULL;
p->hi_relocs = htab_create (1024, riscv_pcrel_reloc_hash,
riscv_pcrel_reloc_eq, free);
@ -1824,11 +1823,11 @@ riscv_zero_pcrel_hi_reloc (Elf_Internal_Rela *rel,
if (ARCH_SIZE > 32 && !VALID_UTYPE_IMM (RISCV_CONST_HIGH_PART (addr)))
return FALSE;
rel->r_info = ELFNN_R_INFO(addr, R_RISCV_HI20);
rel->r_info = ELFNN_R_INFO (addr, R_RISCV_HI20);
bfd_vma insn = riscv_get_insn(howto->bitsize, contents + rel->r_offset);
bfd_vma insn = riscv_get_insn (howto->bitsize, contents + rel->r_offset);
insn = (insn & ~MASK_AUIPC) | MATCH_LUI;
riscv_put_insn(howto->bitsize, insn, contents + rel->r_offset);
riscv_put_insn (howto->bitsize, insn, contents + rel->r_offset);
return TRUE;
}
@ -1882,7 +1881,7 @@ riscv_resolve_pcrel_lo_relocs (riscv_pcrel_relocs *p)
riscv_pcrel_hi_reloc *entry = htab_find (p->hi_relocs, &search);
if (entry == NULL
/* Check for overflow into bit 11 when adding reloc addend. */
|| (! (entry->value & 0x800)
|| (!(entry->value & 0x800)
&& ((entry->value + r->reloc->r_addend) & 0x800)))
{
char *string = (entry == NULL
@ -2236,7 +2235,7 @@ riscv_elf_relocate_section (bfd *output_bfd,
goto do_relocation;
default:
bad_ifunc_reloc:
bad_ifunc_reloc:
if (h->root.root.string)
name = h->root.root.string;
else
@ -2254,7 +2253,7 @@ riscv_elf_relocate_section (bfd *output_bfd,
}
}
skip_ifunc:
skip_ifunc:
if (h != NULL)
name = h->root.root.string;
else
@ -2538,7 +2537,7 @@ riscv_elf_relocate_section (bfd *output_bfd,
|| (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
&& !resolved_to_zero)
|| h->root.type != bfd_link_hash_undefweak)
&& (! howto->pc_relative
&& (!howto->pc_relative
|| !SYMBOL_CALLS_LOCAL (info, h)))
|| (!bfd_link_pic (info)
&& h != NULL
@ -2656,14 +2655,14 @@ riscv_elf_relocate_section (bfd *output_bfd,
BFD_ASSERT (! unresolved_reloc);
bfd_put_NN (output_bfd,
dtpoff (info, relocation),
(htab->elf.sgot->contents + off +
RISCV_ELF_WORD_BYTES));
(htab->elf.sgot->contents
+ off + RISCV_ELF_WORD_BYTES));
}
else
{
bfd_put_NN (output_bfd, 0,
(htab->elf.sgot->contents + off +
RISCV_ELF_WORD_BYTES));
(htab->elf.sgot->contents
+ off + RISCV_ELF_WORD_BYTES));
outrel.r_info = ELFNN_R_INFO (indx, R_RISCV_TLS_DTPRELNN);
outrel.r_offset += RISCV_ELF_WORD_BYTES;
riscv_elf_append_rela (output_bfd, htab->elf.srelgot, &outrel);
@ -2680,8 +2679,8 @@ riscv_elf_relocate_section (bfd *output_bfd,
htab->elf.sgot->contents + off);
bfd_put_NN (output_bfd,
dtpoff (info, relocation),
(htab->elf.sgot->contents + off +
RISCV_ELF_WORD_BYTES));
(htab->elf.sgot->contents
+ off + RISCV_ELF_WORD_BYTES));
}
}
@ -2692,7 +2691,7 @@ riscv_elf_relocate_section (bfd *output_bfd,
bfd_put_NN (output_bfd, 0,
htab->elf.sgot->contents + off + ie_off);
outrel.r_offset = sec_addr (htab->elf.sgot)
+ off + ie_off;
+ off + ie_off;
outrel.r_addend = 0;
if (indx == 0)
outrel.r_addend = tpoff (info, relocation);
@ -2999,7 +2998,7 @@ riscv_elf_finish_dynamic_symbol (bfd *output_bfd,
else
{
/* Generate R_RISCV_NN. */
BFD_ASSERT((h->got.offset & 1) == 0);
BFD_ASSERT ((h->got.offset & 1) == 0);
BFD_ASSERT (h->dynindx != -1);
rela.r_info = ELFNN_R_INFO (h->dynindx, R_RISCV_NN);
rela.r_addend = 0;
@ -3008,7 +3007,7 @@ riscv_elf_finish_dynamic_symbol (bfd *output_bfd,
else if (bfd_link_pic (info))
{
/* Generate R_RISCV_NN. */
BFD_ASSERT((h->got.offset & 1) == 0);
BFD_ASSERT ((h->got.offset & 1) == 0);
BFD_ASSERT (h->dynindx != -1);
rela.r_info = ELFNN_R_INFO (h->dynindx, R_RISCV_NN);
rela.r_addend = 0;
@ -3040,7 +3039,7 @@ riscv_elf_finish_dynamic_symbol (bfd *output_bfd,
or a pie link, or the symbol was forced to be local because
of a version file. The entry in the global offset table will
already have been initialized in the relocate_section function. */
BFD_ASSERT((h->got.offset & 1) != 0);
BFD_ASSERT ((h->got.offset & 1) != 0);
asection *sec = h->root.u.def.section;
rela.r_info = ELFNN_R_INFO (0, R_RISCV_RELATIVE);
rela.r_addend = (h->root.u.def.value
@ -3049,7 +3048,7 @@ riscv_elf_finish_dynamic_symbol (bfd *output_bfd,
}
else
{
BFD_ASSERT((h->got.offset & 1) == 0);
BFD_ASSERT ((h->got.offset & 1) == 0);
BFD_ASSERT (h->dynindx != -1);
rela.r_info = ELFNN_R_INFO (h->dynindx, R_RISCV_NN);
rela.r_addend = 0;
@ -3499,18 +3498,18 @@ riscv_merge_multi_letter_ext (bfd *ibfd,
}
}
if (in || out) {
/* If we're here, either `in' or `out' is running longer than
the other. So, we need to append the corresponding tail. */
tail = in ? in : out;
while (tail)
{
riscv_add_subset (&merged_subsets, tail->name, tail->major_version,
tail->minor_version);
tail = tail->next;
}
}
if (in || out)
{
/* If we're here, either `in' or `out' is running longer than
the other. So, we need to append the corresponding tail. */
tail = in ? in : out;
while (tail)
{
riscv_add_subset (&merged_subsets, tail->name, tail->major_version,
tail->minor_version);
tail = tail->next;
}
}
return TRUE;
}
@ -4025,14 +4024,14 @@ riscv_free_pcgp_relocs (riscv_pcgp_relocs *p,
riscv_pcgp_hi_reloc *c;
riscv_pcgp_lo_reloc *l;
for (c = p->hi; c != NULL;)
for (c = p->hi; c != NULL; )
{
riscv_pcgp_hi_reloc *next = c->next;
free (c);
c = next;
}
for (l = p->lo; l != NULL;)
for (l = p->lo; l != NULL; )
{
riscv_pcgp_lo_reloc *next = l->next;
free (l);
@ -4050,7 +4049,7 @@ riscv_record_pcgp_hi_reloc (riscv_pcgp_relocs *p, bfd_vma hi_sec_off,
unsigned hi_sym, asection *sym_sec,
bfd_boolean undefined_weak)
{
riscv_pcgp_hi_reloc *new = bfd_malloc (sizeof(*new));
riscv_pcgp_hi_reloc *new = bfd_malloc (sizeof (*new));
if (!new)
return FALSE;
new->hi_sec_off = hi_sec_off;
@ -4068,7 +4067,7 @@ riscv_record_pcgp_hi_reloc (riscv_pcgp_relocs *p, bfd_vma hi_sec_off,
This is used by a lo part reloc to find the corresponding hi part reloc. */
static riscv_pcgp_hi_reloc *
riscv_find_pcgp_hi_reloc(riscv_pcgp_relocs *p, bfd_vma hi_sec_off)
riscv_find_pcgp_hi_reloc (riscv_pcgp_relocs *p, bfd_vma hi_sec_off)
{
riscv_pcgp_hi_reloc *c;
@ -4084,7 +4083,7 @@ riscv_find_pcgp_hi_reloc(riscv_pcgp_relocs *p, bfd_vma hi_sec_off)
static bfd_boolean
riscv_record_pcgp_lo_reloc (riscv_pcgp_relocs *p, bfd_vma hi_sec_off)
{
riscv_pcgp_lo_reloc *new = bfd_malloc (sizeof(*new));
riscv_pcgp_lo_reloc *new = bfd_malloc (sizeof (*new));
if (!new)
return FALSE;
new->hi_sec_off = hi_sec_off;
@ -4129,7 +4128,7 @@ _bfd_riscv_relax_call (bfd *abfd, asection *sec, asection *sym_sec,
{
bfd_byte *contents = elf_section_data (sec)->this_hdr.contents;
bfd_vma foff = symval - (sec_addr (sec) + rel->r_offset);
bfd_boolean near_zero = (symval + RISCV_IMM_REACH/2) < RISCV_IMM_REACH;
bfd_boolean near_zero = (symval + RISCV_IMM_REACH / 2) < RISCV_IMM_REACH;
bfd_vma auipc, jalr;
int rd, r_type, len = 4, rvc = elf_elfheader (abfd)->e_flags & EF_RISCV_RVC;
@ -4424,17 +4423,17 @@ _bfd_riscv_relax_align (bfd *abfd, asection *sec,
/* Relax PC-relative references to GP-relative references. */
static bfd_boolean
_bfd_riscv_relax_pc (bfd *abfd ATTRIBUTE_UNUSED,
asection *sec,
asection *sym_sec,
struct bfd_link_info *link_info,
Elf_Internal_Rela *rel,
bfd_vma symval,
bfd_vma max_alignment,
bfd_vma reserve_size,
bfd_boolean *again ATTRIBUTE_UNUSED,
riscv_pcgp_relocs *pcgp_relocs,
bfd_boolean undefined_weak)
_bfd_riscv_relax_pc (bfd *abfd ATTRIBUTE_UNUSED,
asection *sec,
asection *sym_sec,
struct bfd_link_info *link_info,
Elf_Internal_Rela *rel,
bfd_vma symval,
bfd_vma max_alignment,
bfd_vma reserve_size,
bfd_boolean *again ATTRIBUTE_UNUSED,
riscv_pcgp_relocs *pcgp_relocs,
bfd_boolean undefined_weak)
{
bfd_byte *contents = elf_section_data (sec)->this_hdr.contents;
bfd_vma gp = riscv_global_pointer_value (link_info);
@ -4588,10 +4587,10 @@ _bfd_riscv_relax_delete (bfd *abfd,
riscv_pcgp_relocs *pcgp_relocs ATTRIBUTE_UNUSED,
bfd_boolean undefined_weak ATTRIBUTE_UNUSED)
{
if (!riscv_relax_delete_bytes(abfd, sec, rel->r_offset, rel->r_addend,
link_info))
if (!riscv_relax_delete_bytes (abfd, sec, rel->r_offset, rel->r_addend,
link_info))
return FALSE;
rel->r_info = ELFNN_R_INFO(0, R_RISCV_NONE);
rel->r_info = ELFNN_R_INFO (0, R_RISCV_NONE);
return TRUE;
}
@ -4677,7 +4676,7 @@ _bfd_riscv_relax_section (bfd *abfd, asection *sec,
continue;
}
else if (info->relax_pass == 1
&& !bfd_link_pic(info)
&& !bfd_link_pic (info)
&& (type == R_RISCV_PCREL_HI20
|| type == R_RISCV_PCREL_LO12_I
|| type == R_RISCV_PCREL_LO12_S))
@ -4860,7 +4859,7 @@ _bfd_riscv_relax_section (bfd *abfd, asection *sec,
fail:
if (relocs != data->relocs)
free (relocs);
riscv_free_pcgp_relocs(&pcgp_relocs, abfd, sec);
riscv_free_pcgp_relocs (&pcgp_relocs, abfd, sec);
return ret;
}
@ -4975,57 +4974,57 @@ riscv_elf_obj_attrs_arg_type (int tag)
return (tag & 1) != 0 ? ATTR_TYPE_FLAG_STR_VAL : ATTR_TYPE_FLAG_INT_VAL;
}
#define TARGET_LITTLE_SYM riscv_elfNN_vec
#define TARGET_LITTLE_NAME "elfNN-littleriscv"
#define TARGET_BIG_SYM riscv_elfNN_be_vec
#define TARGET_BIG_NAME "elfNN-bigriscv"
#define TARGET_LITTLE_SYM riscv_elfNN_vec
#define TARGET_LITTLE_NAME "elfNN-littleriscv"
#define TARGET_BIG_SYM riscv_elfNN_be_vec
#define TARGET_BIG_NAME "elfNN-bigriscv"
#define elf_backend_reloc_type_class riscv_reloc_type_class
#define elf_backend_reloc_type_class riscv_reloc_type_class
#define bfd_elfNN_bfd_reloc_name_lookup riscv_reloc_name_lookup
#define bfd_elfNN_bfd_link_hash_table_create riscv_elf_link_hash_table_create
#define bfd_elfNN_bfd_reloc_type_lookup riscv_reloc_type_lookup
#define bfd_elfNN_bfd_reloc_name_lookup riscv_reloc_name_lookup
#define bfd_elfNN_bfd_link_hash_table_create riscv_elf_link_hash_table_create
#define bfd_elfNN_bfd_reloc_type_lookup riscv_reloc_type_lookup
#define bfd_elfNN_bfd_merge_private_bfd_data \
_bfd_riscv_elf_merge_private_bfd_data
#define elf_backend_copy_indirect_symbol riscv_elf_copy_indirect_symbol
#define elf_backend_create_dynamic_sections riscv_elf_create_dynamic_sections
#define elf_backend_check_relocs riscv_elf_check_relocs
#define elf_backend_adjust_dynamic_symbol riscv_elf_adjust_dynamic_symbol
#define elf_backend_size_dynamic_sections riscv_elf_size_dynamic_sections
#define elf_backend_relocate_section riscv_elf_relocate_section
#define elf_backend_finish_dynamic_symbol riscv_elf_finish_dynamic_symbol
#define elf_backend_finish_dynamic_sections riscv_elf_finish_dynamic_sections
#define elf_backend_gc_mark_hook riscv_elf_gc_mark_hook
#define elf_backend_plt_sym_val riscv_elf_plt_sym_val
#define elf_backend_grok_prstatus riscv_elf_grok_prstatus
#define elf_backend_grok_psinfo riscv_elf_grok_psinfo
#define elf_backend_object_p riscv_elf_object_p
#define elf_info_to_howto_rel NULL
#define elf_info_to_howto riscv_info_to_howto_rela
#define bfd_elfNN_bfd_relax_section _bfd_riscv_relax_section
#define bfd_elfNN_mkobject elfNN_riscv_mkobject
#define elf_backend_copy_indirect_symbol riscv_elf_copy_indirect_symbol
#define elf_backend_create_dynamic_sections riscv_elf_create_dynamic_sections
#define elf_backend_check_relocs riscv_elf_check_relocs
#define elf_backend_adjust_dynamic_symbol riscv_elf_adjust_dynamic_symbol
#define elf_backend_size_dynamic_sections riscv_elf_size_dynamic_sections
#define elf_backend_relocate_section riscv_elf_relocate_section
#define elf_backend_finish_dynamic_symbol riscv_elf_finish_dynamic_symbol
#define elf_backend_finish_dynamic_sections riscv_elf_finish_dynamic_sections
#define elf_backend_gc_mark_hook riscv_elf_gc_mark_hook
#define elf_backend_plt_sym_val riscv_elf_plt_sym_val
#define elf_backend_grok_prstatus riscv_elf_grok_prstatus
#define elf_backend_grok_psinfo riscv_elf_grok_psinfo
#define elf_backend_object_p riscv_elf_object_p
#define elf_info_to_howto_rel NULL
#define elf_info_to_howto riscv_info_to_howto_rela
#define bfd_elfNN_bfd_relax_section _bfd_riscv_relax_section
#define bfd_elfNN_mkobject elfNN_riscv_mkobject
#define elf_backend_init_index_section _bfd_elf_init_1_index_section
#define elf_backend_init_index_section _bfd_elf_init_1_index_section
#define elf_backend_can_gc_sections 1
#define elf_backend_can_refcount 1
#define elf_backend_want_got_plt 1
#define elf_backend_plt_readonly 1
#define elf_backend_plt_alignment 4
#define elf_backend_want_plt_sym 1
#define elf_backend_got_header_size (ARCH_SIZE / 8)
#define elf_backend_want_dynrelro 1
#define elf_backend_rela_normal 1
#define elf_backend_default_execstack 0
#define elf_backend_can_gc_sections 1
#define elf_backend_can_refcount 1
#define elf_backend_want_got_plt 1
#define elf_backend_plt_readonly 1
#define elf_backend_plt_alignment 4
#define elf_backend_want_plt_sym 1
#define elf_backend_got_header_size (ARCH_SIZE / 8)
#define elf_backend_want_dynrelro 1
#define elf_backend_rela_normal 1
#define elf_backend_default_execstack 0
#undef elf_backend_obj_attrs_vendor
#define elf_backend_obj_attrs_vendor "riscv"
#define elf_backend_obj_attrs_vendor "riscv"
#undef elf_backend_obj_attrs_arg_type
#define elf_backend_obj_attrs_arg_type riscv_elf_obj_attrs_arg_type
#define elf_backend_obj_attrs_arg_type riscv_elf_obj_attrs_arg_type
#undef elf_backend_obj_attrs_section_type
#define elf_backend_obj_attrs_section_type SHT_RISCV_ATTRIBUTES
#define elf_backend_obj_attrs_section_type SHT_RISCV_ATTRIBUTES
#undef elf_backend_obj_attrs_section
#define elf_backend_obj_attrs_section ".riscv.attributes"
#define elf_backend_obj_attrs_section ".riscv.attributes"
#include "elfNN-target.h"

View File

@ -1,3 +1,9 @@
2021-01-15 Nelson Chu <nelson.chu@sifive.com>
* config/tc-riscv.c: Indent and GNU coding standards tidy,
also aligned the code.
* config/tc-riscv.h: Likewise.
2021-01-15 Nelson Chu <nelson.chu@sifive.com>
* config/tc-riscv.c: Error and warning messages tidy.

View File

@ -85,7 +85,8 @@ static enum riscv_priv_spec_class default_priv_spec = PRIV_SPEC_CLASS_NONE;
static unsigned xlen = 0; /* The width of an x-register. */
static unsigned abi_xlen = 0; /* The width of a pointer in the ABI. */
static bfd_boolean rve_abi = FALSE;
enum float_abi {
enum float_abi
{
FLOAT_ABI_DEFAULT = -1,
FLOAT_ABI_SOFT,
FLOAT_ABI_SINGLE,
@ -274,7 +275,7 @@ init_ext_version_hash (const struct riscv_ext_version *table)
i++;
while (table[i].name
&& strcmp (table[i].name, name) == 0)
&& strcmp (table[i].name, name) == 0)
i++;
}
@ -709,14 +710,14 @@ riscv_init_csr_hash (const char *name,
while (need_enrty && entry != NULL)
{
if (entry->csr_class == class
&& entry->address == address
&& entry->define_version == define_version
&& entry->abort_version == abort_version)
need_enrty = FALSE;
&& entry->address == address
&& entry->define_version == define_version
&& entry->abort_version == abort_version)
need_enrty = FALSE;
pre_entry = entry;
entry = entry->next;
}
/* Duplicate CSR. */
if (!need_enrty)
return;
@ -969,31 +970,31 @@ validate_riscv_insn (const struct riscv_opcode *opc, int length)
case ',': break;
case '(': break;
case ')': break;
case '<': USE_BITS (OP_MASK_SHAMTW, OP_SH_SHAMTW); break;
case '>': USE_BITS (OP_MASK_SHAMT, OP_SH_SHAMT); break;
case '<': USE_BITS (OP_MASK_SHAMTW, OP_SH_SHAMTW); break;
case '>': USE_BITS (OP_MASK_SHAMT, OP_SH_SHAMT); break;
case 'A': break;
case 'D': USE_BITS (OP_MASK_RD, OP_SH_RD); break;
case 'Z': USE_BITS (OP_MASK_RS1, OP_SH_RS1); break;
case 'E': USE_BITS (OP_MASK_CSR, OP_SH_CSR); break;
case 'D': USE_BITS (OP_MASK_RD, OP_SH_RD); break;
case 'Z': USE_BITS (OP_MASK_RS1, OP_SH_RS1); break;
case 'E': USE_BITS (OP_MASK_CSR, OP_SH_CSR); break;
case 'I': break;
case 'R': USE_BITS (OP_MASK_RS3, OP_SH_RS3); break;
case 'S': USE_BITS (OP_MASK_RS1, OP_SH_RS1); break;
case 'U': USE_BITS (OP_MASK_RS1, OP_SH_RS1);
case 'R': USE_BITS (OP_MASK_RS3, OP_SH_RS3); break;
case 'S': USE_BITS (OP_MASK_RS1, OP_SH_RS1); break;
case 'U': USE_BITS (OP_MASK_RS1, OP_SH_RS1);
/* Fall through. */
case 'T': USE_BITS (OP_MASK_RS2, OP_SH_RS2); break;
case 'd': USE_BITS (OP_MASK_RD, OP_SH_RD); break;
case 'm': USE_BITS (OP_MASK_RM, OP_SH_RM); break;
case 's': USE_BITS (OP_MASK_RS1, OP_SH_RS1); break;
case 't': USE_BITS (OP_MASK_RS2, OP_SH_RS2); break;
case 'r': USE_BITS (OP_MASK_RS3, OP_SH_RS3); break;
case 'P': USE_BITS (OP_MASK_PRED, OP_SH_PRED); break;
case 'Q': USE_BITS (OP_MASK_SUCC, OP_SH_SUCC); break;
case 'T': USE_BITS (OP_MASK_RS2, OP_SH_RS2); break;
case 'd': USE_BITS (OP_MASK_RD, OP_SH_RD); break;
case 'm': USE_BITS (OP_MASK_RM, OP_SH_RM); break;
case 's': USE_BITS (OP_MASK_RS1, OP_SH_RS1); break;
case 't': USE_BITS (OP_MASK_RS2, OP_SH_RS2); break;
case 'r': USE_BITS (OP_MASK_RS3, OP_SH_RS3); break;
case 'P': USE_BITS (OP_MASK_PRED, OP_SH_PRED); break;
case 'Q': USE_BITS (OP_MASK_SUCC, OP_SH_SUCC); break;
case 'o':
case 'j': used_bits |= ENCODE_ITYPE_IMM (-1U); break;
case 'a': used_bits |= ENCODE_UJTYPE_IMM (-1U); break;
case 'p': used_bits |= ENCODE_SBTYPE_IMM (-1U); break;
case 'q': used_bits |= ENCODE_STYPE_IMM (-1U); break;
case 'u': used_bits |= ENCODE_UTYPE_IMM (-1U); break;
case 'a': used_bits |= ENCODE_UJTYPE_IMM (-1U); break;
case 'p': used_bits |= ENCODE_SBTYPE_IMM (-1U); break;
case 'q': used_bits |= ENCODE_STYPE_IMM (-1U); break;
case 'u': used_bits |= ENCODE_UTYPE_IMM (-1U); break;
case 'z': break;
case '[': break;
case ']': break;
@ -1254,10 +1255,6 @@ macro_build (expressionS *ep, const char *name, const char *fmt, ...)
INSERT_OPERAND (RS2, insn, va_arg (args, int));
continue;
case '>':
INSERT_OPERAND (SHAMT, insn, va_arg (args, int));
continue;
case 'j':
case 'u':
case 'q':
@ -2184,11 +2181,11 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
"field, value must be 0...64"));
break;
}
INSERT_OPERAND (CFUNCT6, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent;
s = expr_end;
continue;
case '4':
if (my_getSmallExpression (imm_expr, imm_reloc, s, p)
|| imm_expr->X_op != O_constant
@ -2199,11 +2196,11 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
"field, value must be 0...15"));
break;
}
INSERT_OPERAND (CFUNCT4, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent;
s = expr_end;
continue;
case '3':
if (my_getSmallExpression (imm_expr, imm_reloc, s, p)
|| imm_expr->X_op != O_constant
@ -2218,6 +2215,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
imm_expr->X_op = O_absent;
s = expr_end;
continue;
case '2':
if (my_getSmallExpression (imm_expr, imm_reloc, s, p)
|| imm_expr->X_op != O_constant
@ -2232,6 +2230,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
imm_expr->X_op = O_absent;
s = expr_end;
continue;
default:
as_bad (_("internal: unknown compressed funct "
"field specifier `CF%c'"), *args);
@ -2392,7 +2391,6 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
}
continue;
}
break;
case 'I':
@ -2462,7 +2460,6 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
|| imm_expr->X_add_number < -(signed)RISCV_IMM_REACH/2)
break;
}
s = expr_end;
continue;
@ -2508,6 +2505,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
else
*imm_reloc = BFD_RELOC_RISCV_CALL;
continue;
case 'O':
switch (*++args)
{
@ -2523,11 +2521,11 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
"lower 2 bits must be 0x3"));
break;
}
INSERT_OPERAND (OP, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent;
s = expr_end;
continue;
case '2':
if (my_getOpcodeExpression (imm_expr, imm_reloc, s, p)
|| imm_expr->X_op != O_constant
@ -2538,11 +2536,11 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
"value must be 0...2"));
break;
}
INSERT_OPERAND (OP2, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent;
s = expr_end;
continue;
default:
as_bad (_("internal: unknown opcode field "
"specifier `O%c'"), *args);
@ -2562,11 +2560,11 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
"value must be 0...127"));
break;
}
INSERT_OPERAND (FUNCT7, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent;
s = expr_end;
continue;
case '3':
if (my_getSmallExpression (imm_expr, imm_reloc, s, p)
|| imm_expr->X_op != O_constant
@ -2577,11 +2575,11 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
"value must be 0...7"));
break;
}
INSERT_OPERAND (FUNCT3, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent;
s = expr_end;
continue;
case '2':
if (my_getSmallExpression (imm_expr, imm_reloc, s, p)
|| imm_expr->X_op != O_constant
@ -2592,7 +2590,6 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
"value must be 0...3"));
break;
}
INSERT_OPERAND (FUNCT2, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent;
s = expr_end;
@ -3646,7 +3643,7 @@ riscv_write_out_attrs (void)
/* Re-write architecture elf attribute. */
arch_str = riscv_arch_str (xlen, &riscv_subsets);
bfd_elf_add_proc_attr_string (stdoutput, Tag_RISCV_arch, arch_str);
xfree ((void *)arch_str);
xfree ((void *) arch_str);
/* For the file without any instruction, we don't set the default_priv_spec
according to the privileged elf attributes since the md_assemble isn't
@ -3711,28 +3708,27 @@ riscv_convert_symbolic_attribute (const char *name)
{
static const struct
{
const char * name;
const int tag;
const char *name;
const int tag;
}
attribute_table[] =
{
/* When you modify this table you should
also modify the list in doc/c-riscv.texi. */
#define T(tag) {#tag, Tag_RISCV_##tag}, {"Tag_RISCV_" #tag, Tag_RISCV_##tag}
T(arch),
T(priv_spec),
T(priv_spec_minor),
T(priv_spec_revision),
T(unaligned_access),
T(stack_align),
{
/* When you modify this table you should
also modify the list in doc/c-riscv.texi. */
#define T(tag) {#tag, Tag_RISCV_##tag}, {"Tag_RISCV_" #tag, Tag_RISCV_##tag}
T(arch),
T(priv_spec),
T(priv_spec_minor),
T(priv_spec_revision),
T(unaligned_access),
T(stack_align),
#undef T
};
unsigned int i;
};
if (name == NULL)
return -1;
unsigned int i;
for (i = 0; i < ARRAY_SIZE (attribute_table); i++)
if (strcmp (name, attribute_table[i].name) == 0)
return attribute_table[i].tag;

View File

@ -67,16 +67,16 @@ extern void riscv_handle_align (fragS *);
#define MAX_MEM_FOR_RS_ALIGN_CODE (3 + 4)
/* The ISA of the target may change based on command-line arguments. */
#define TARGET_FORMAT riscv_target_format()
#define TARGET_FORMAT riscv_target_format ()
extern const char * riscv_target_format (void);
#define md_after_parse_args() riscv_after_parse_args()
#define md_after_parse_args() riscv_after_parse_args ()
extern void riscv_after_parse_args (void);
#define md_parse_long_option(arg) riscv_parse_long_option (arg)
extern int riscv_parse_long_option (const char *);
#define md_pre_output_hook riscv_pre_output_hook()
#define md_pre_output_hook riscv_pre_output_hook ()
extern void riscv_pre_output_hook (void);
/* Let the linker resolve all the relocs due to relaxation. */

View File

@ -1,3 +1,8 @@
2021-01-15 Nelson Chu <nelson.chu@sifive.com>
* opcode/riscv.h: Indent and GNU coding standards tidy,
also aligned the code.
2021-01-15 Nelson Chu <nelson.chu@sifive.com>
* elf/riscv.h: Comments tidy and improvement.

View File

@ -228,33 +228,33 @@ static const char * const riscv_pred_succ[16] =
#define OP_MASK_CSR 0xfffU
#define OP_SH_CSR 20
#define OP_MASK_FUNCT3 0x7
#define OP_SH_FUNCT3 12
#define OP_MASK_FUNCT7 0x7fU
#define OP_SH_FUNCT7 25
#define OP_MASK_FUNCT2 0x3
#define OP_SH_FUNCT2 25
#define OP_MASK_FUNCT3 0x7
#define OP_SH_FUNCT3 12
#define OP_MASK_FUNCT7 0x7fU
#define OP_SH_FUNCT7 25
#define OP_MASK_FUNCT2 0x3
#define OP_SH_FUNCT2 25
/* RVC fields. */
#define OP_MASK_OP2 0x3
#define OP_SH_OP2 0
#define OP_MASK_OP2 0x3
#define OP_SH_OP2 0
#define OP_MASK_CRS2 0x1f
#define OP_SH_CRS2 2
#define OP_MASK_CRS1S 0x7
#define OP_SH_CRS1S 7
#define OP_MASK_CRS2S 0x7
#define OP_SH_CRS2S 2
#define OP_MASK_CRS2 0x1f
#define OP_SH_CRS2 2
#define OP_MASK_CRS1S 0x7
#define OP_SH_CRS1S 7
#define OP_MASK_CRS2S 0x7
#define OP_SH_CRS2S 2
#define OP_MASK_CFUNCT6 0x3f
#define OP_SH_CFUNCT6 10
#define OP_MASK_CFUNCT4 0xf
#define OP_SH_CFUNCT4 12
#define OP_MASK_CFUNCT3 0x7
#define OP_SH_CFUNCT3 13
#define OP_MASK_CFUNCT2 0x3
#define OP_SH_CFUNCT2 5
#define OP_MASK_CFUNCT6 0x3f
#define OP_SH_CFUNCT6 10
#define OP_MASK_CFUNCT4 0xf
#define OP_SH_CFUNCT4 12
#define OP_MASK_CFUNCT3 0x7
#define OP_SH_CFUNCT3 13
#define OP_MASK_CFUNCT2 0x3
#define OP_SH_CFUNCT2 5
/* ABI names for selected x-registers. */
@ -296,52 +296,59 @@ static const char * const riscv_pred_succ[16] =
/* All RISC-V instructions belong to at least one of these classes. */
enum riscv_insn_class
{
INSN_CLASS_NONE,
{
INSN_CLASS_NONE,
INSN_CLASS_I,
INSN_CLASS_C,
INSN_CLASS_A,
INSN_CLASS_M,
INSN_CLASS_F,
INSN_CLASS_D,
INSN_CLASS_Q,
INSN_CLASS_F_AND_C,
INSN_CLASS_D_AND_C,
INSN_CLASS_ZICSR,
INSN_CLASS_ZIFENCEI,
INSN_CLASS_ZIHINTPAUSE,
INSN_CLASS_ZBA,
INSN_CLASS_ZBB,
INSN_CLASS_ZBC,
INSN_CLASS_ZBA_OR_ZBB,
};
INSN_CLASS_I,
INSN_CLASS_C,
INSN_CLASS_A,
INSN_CLASS_M,
INSN_CLASS_F,
INSN_CLASS_D,
INSN_CLASS_Q,
INSN_CLASS_F_AND_C,
INSN_CLASS_D_AND_C,
INSN_CLASS_ZICSR,
INSN_CLASS_ZIFENCEI,
INSN_CLASS_ZIHINTPAUSE,
INSN_CLASS_ZBA,
INSN_CLASS_ZBB,
INSN_CLASS_ZBC,
INSN_CLASS_ZBA_OR_ZBB,
};
/* This structure holds information for a particular instruction. */
struct riscv_opcode
{
/* The name of the instruction. */
const char *name;
/* The requirement of xlen for the instruction, 0 if no requirement. */
unsigned xlen_requirement;
/* Class to which this instruction belongs. Used to decide whether or
not this instruction is legal in the current -march context. */
enum riscv_insn_class insn_class;
/* A string describing the arguments for this instruction. */
const char *args;
/* The basic opcode for the instruction. When assembling, this
opcode is modified by the arguments to produce the actual opcode
that is used. If pinfo is INSN_MACRO, then this is 0. */
insn_t match;
/* If pinfo is not INSN_MACRO, then this is a bit mask for the
relevant portions of the opcode when disassembling. If the
actual opcode anded with the match field equals the opcode field,
then we have found the correct instruction. If pinfo is
INSN_MACRO, then this field is the macro identifier. */
insn_t mask;
/* A function to determine if a word corresponds to this instruction.
Usually, this computes ((word & mask) == match). */
int (*match_func) (const struct riscv_opcode *op, insn_t word);
/* For a macro, this is INSN_MACRO. Otherwise, it is a collection
of bits describing the instruction, notably any relevant hazard
information. */

View File

@ -1,3 +1,10 @@
2021-01-15 Nelson Chu <nelson.chu@sifive.com>
* riscv-opc.c (riscv_gpr_names_abi): Aligned the code.
(riscv_fpr_names_abi): Likewise.
(riscv_opcodes): Likewise.
(riscv_insn_types): Likewise.
2021-01-15 Nelson Chu <nelson.chu@sifive.com>
* riscv-dis.c (parse_riscv_dis_option): Fix typos of message.

File diff suppressed because it is too large Load Diff