Skip to content

Commit 1e9d41d

Browse files
Sheldon Lobojemarch
authored andcommitted
opcodes,gas: associate SPARC ASIs with an architecture level.
With this change an architecture level bump due to assembly ASIs will show up as a warning/error depending on options passed to gas. Tested with sparc64-linux-gnu, and it does not introduce any regressions. gas/ChangeLog: Add support for associating SPARC ASIs with an architecture level. * config/tc-sparc.c (parse_sparc_asi): New encode SPARC ASIs. opcodes/ChangeLog: Add support for associating SPARC ASIs with an architecture level. * include/opcode/sparc.h (sparc_asi): New sparc_asi struct. * opcodes/sparc-opc.c (asi_table): Updated asi_table and encoding/ decoding of SPARC ASIs.
1 parent 8eaf532 commit 1e9d41d

5 files changed

Lines changed: 256 additions & 203 deletions

File tree

‎gas/ChangeLog‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2017-02-23 Sheldon Lobo <sheldon.lobo@oracle.com>
2+
3+
Add support for associating SPARC ASIs with an architecture level.
4+
* config/tc-sparc.c (parse_sparc_asi): New encode SPARC ASIs.
5+
16
2017-02-23 Jan Beulich <jbeulich@suse.com>
27

38
* testsuite/gas/all/err-sizeof.s: Don't use sums or differences

‎gas/config/tc-sparc.c‎

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#define U0x80000000 ((((unsigned long) 1 << 16) << 15))
3737

3838
static int sparc_ip (char *, const struct sparc_opcode **);
39+
static int parse_sparc_asi (char **, const sparc_asi **);
3940
static int parse_keyword_arg (int (*) (const char *), char **, int *);
4041
static int parse_const_expr_arg (char **, int *);
4142
static int get_expression (char *);
@@ -1764,6 +1765,7 @@ sparc_ip (char *str, const struct sparc_opcode **pinsn)
17641765
int comma = 0;
17651766
int v9_arg_p;
17661767
int special_case = SPECIAL_CASE_NONE;
1768+
const sparc_asi *sasi = NULL;
17671769

17681770
s = str;
17691771
if (ISLOWER (*s))
@@ -2969,11 +2971,12 @@ sparc_ip (char *str, const struct sparc_opcode **pinsn)
29692971
/* Parse an asi. */
29702972
if (*s == '#')
29712973
{
2972-
if (! parse_keyword_arg (sparc_encode_asi, &s, &asi))
2974+
if (! parse_sparc_asi (&s, &sasi))
29732975
{
29742976
error_message = _(": invalid ASI name");
29752977
goto error;
29762978
}
2979+
asi = sasi->value;
29772980
}
29782981
else
29792982
{
@@ -3147,8 +3150,18 @@ sparc_ip (char *str, const struct sparc_opcode **pinsn)
31473150
else
31483151
{
31493152
/* We have a match. Now see if the architecture is OK. */
3153+
/* String to use in case of architecture warning. */
3154+
const char *msg_str = str;
31503155
int needed_arch_mask = insn->architecture;
3151-
bfd_uint64_t hwcaps
3156+
3157+
/* Include the ASI architecture needed as well */
3158+
if (sasi && needed_arch_mask > sasi->architecture)
3159+
{
3160+
needed_arch_mask = sasi->architecture;
3161+
msg_str = sasi->name;
3162+
}
3163+
3164+
bfd_uint64_t hwcaps
31523165
= (((bfd_uint64_t) insn->hwcaps2) << 32) | insn->hwcaps;
31533166

31543167
#if defined(OBJ_ELF) && !defined(TE_SOLARIS)
@@ -3183,7 +3196,7 @@ sparc_ip (char *str, const struct sparc_opcode **pinsn)
31833196
as_warn (_("architecture bumped from \"%s\" to \"%s\" on \"%s\""),
31843197
sparc_opcode_archs[current_architecture].name,
31853198
sparc_opcode_archs[needed_architecture].name,
3186-
str);
3199+
msg_str);
31873200
warn_after_architecture = needed_architecture;
31883201
}
31893202
current_architecture = needed_architecture;
@@ -3247,6 +3260,35 @@ sparc_ip (char *str, const struct sparc_opcode **pinsn)
32473260
return special_case;
32483261
}
32493262

3263+
static char *
3264+
skip_over_keyword (char *q)
3265+
{
3266+
for (q = q + (*q == '#' || *q == '%');
3267+
ISALNUM (*q) || *q == '_';
3268+
++q)
3269+
continue;
3270+
return q;
3271+
}
3272+
3273+
static int
3274+
parse_sparc_asi (char **input_pointer_p, const sparc_asi **value_p)
3275+
{
3276+
const sparc_asi *value;
3277+
char c, *p, *q;
3278+
3279+
p = *input_pointer_p;
3280+
q = skip_over_keyword(p);
3281+
c = *q;
3282+
*q = 0;
3283+
value = sparc_encode_asi (p);
3284+
*q = c;
3285+
if (value == NULL)
3286+
return 0;
3287+
*value_p = value;
3288+
*input_pointer_p = q;
3289+
return 1;
3290+
}
3291+
32503292
/* Parse an argument that can be expressed as a keyword.
32513293
(eg: #StoreStore or %ccfr).
32523294
The result is a boolean indicating success.
@@ -3261,10 +3303,7 @@ parse_keyword_arg (int (*lookup_fn) (const char *),
32613303
char c, *p, *q;
32623304

32633305
p = *input_pointerP;
3264-
for (q = p + (*p == '#' || *p == '%');
3265-
ISALNUM (*q) || *q == '_';
3266-
++q)
3267-
continue;
3306+
q = skip_over_keyword(p);
32683307
c = *q;
32693308
*q = 0;
32703309
value = (*lookup_fn) (p);

‎include/opcode/sparc.h‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ typedef struct sparc_opcode
117117
short architecture; /* Bitmask of sparc_opcode_arch_val's. */
118118
} sparc_opcode;
119119

120+
/* Struct for ASIs - to handle ASIs introduced in a specific architecture */
121+
typedef struct
122+
{
123+
int value;
124+
const char *name;
125+
short architecture;
126+
} sparc_asi;
127+
120128
/* FIXME: Add F_ANACHRONISTIC flag for v9. */
121129
#define F_DELAYED 0x00000001 /* Delayed branch. */
122130
#define F_ALIAS 0x00000002 /* Alias for a "real" instruction. */
@@ -296,7 +304,7 @@ typedef struct sparc_opcode
296304
extern const struct sparc_opcode sparc_opcodes[];
297305
extern const int sparc_num_opcodes;
298306

299-
extern int sparc_encode_asi (const char *);
307+
extern const sparc_asi *sparc_encode_asi (const char *);
300308
extern const char *sparc_decode_asi (int);
301309
extern int sparc_encode_membar (const char *);
302310
extern const char *sparc_decode_membar (int);

‎opcodes/ChangeLog‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2017-02-23 Sheldon Lobo <sheldon.lobo@oracle.com>
2+
3+
Add support for associating SPARC ASIs with an architecture level.
4+
* include/opcode/sparc.h (sparc_asi): New sparc_asi struct.
5+
* opcodes/sparc-opc.c (asi_table): Updated asi_table and encoding/
6+
decoding of SPARC ASIs.
7+
18
2017-02-23 Jan Beulich <jbeulich@suse.com>
29

310
* i386-dis.c (get_valid_dis386): Don't special case VEX opcode

0 commit comments

Comments
 (0)