aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-08-23 08:56:13 +0930
committerAlan Modra <amodra@gmail.com>2023-08-23 11:03:52 +0930
commit36a52ab3bf46183e89c5ab01bb446fc6f94ce67d (patch)
treef1b7853bce01c8eda85905ca07dc14b34e8afa98 /gas
parent990f9a1d13e3e6fa9443d23fdd146528d4f21159 (diff)
downloadgdb-36a52ab3bf46183e89c5ab01bb446fc6f94ce67d.zip
gdb-36a52ab3bf46183e89c5ab01bb446fc6f94ce67d.tar.gz
gdb-36a52ab3bf46183e89c5ab01bb446fc6f94ce67d.tar.bz2
kvx: O_pseudo_fixup
O_pseudo_fixup was defined as O_max+1, missing the fact that O_md1 through O_md32 enums are for use by target code. Worse, kvx-parse.c used 64 rather than O_pseudo_fixup. Fix this, and wrap some overlong lines. * config/tc-kvx.h (O_pseudo_fixup): Define. * config/tc-kvx.c (O_pseudo_fixup): Don't define here. (insert_operand): Delete bogus comment and cast. * config/kvx-parse.c (promote_token): Use O_pseudo_fixup rather than hardcoded value. Wrap overlong lines. (get_token_class): Likewise. (parse_with_restarts): Wrap overlong line.
Diffstat (limited to 'gas')
-rw-r--r--gas/config/kvx-parse.c49
-rw-r--r--gas/config/tc-kvx.c8
-rw-r--r--gas/config/tc-kvx.h2
3 files changed, 36 insertions, 23 deletions
diff --git a/gas/config/kvx-parse.c b/gas/config/kvx-parse.c
index fe0e2ae..af207be 100644
--- a/gas/config/kvx-parse.c
+++ b/gas/config/kvx-parse.c
@@ -416,9 +416,17 @@ promote_token (struct token_s tok)
input_line_pointer = ilp_save;
long long new_class_id = tok.class_id;
long long old_class_id = tok.class_id;
- while ((new_class_id = env.promote_immediate (old_class_id)) != old_class_id
- && ((exp.X_op == O_symbol && !has_relocation_of_size (str_hash_find (env.reloc_hash, TOKEN_NAME (new_class_id))))
- || (exp.X_op == 64 && !kvx_get_pseudo_func2 (exp.X_op_symbol, str_hash_find (env.reloc_hash, TOKEN_NAME (new_class_id))))))
+ while (((new_class_id = env.promote_immediate (old_class_id))
+ != old_class_id)
+ && ((exp.X_op == O_symbol
+ && !(has_relocation_of_size
+ (str_hash_find (env.reloc_hash,
+ TOKEN_NAME (new_class_id)))))
+ || (exp.X_op == O_pseudo_fixup
+ && !(kvx_get_pseudo_func2
+ (exp.X_op_symbol,
+ str_hash_find (env.reloc_hash,
+ TOKEN_NAME (new_class_id)))))))
old_class_id = new_class_id;
return new_class_id;
}
@@ -500,7 +508,7 @@ get_token_class (struct token_s *token, struct token_classes *classes, int insn_
/* If the symbol can be resolved easily takes it value now. Otherwise it
means that is either a symbol which will need a real relocation or an
internal fixup (ie, a pseudo-function, or a computation on symbols). */
- if (exp.X_op != O_symbol && exp.X_op != 64)
+ if (exp.X_op != O_symbol && exp.X_op != O_pseudo_fixup)
{
token->val = exp.X_add_number;
token_val_p = 1;
@@ -511,22 +519,31 @@ get_token_class (struct token_s *token, struct token_classes *classes, int insn_
if (class == classes->imm_classes)
{
- unsigned long long uval = token_val_p
- ? token->val
- : strtoull (tok + (tok[0] == '-') + (tok[0] == '+'), NULL, 0);
+ unsigned long long uval
+ = (token_val_p
+ ? token->val
+ : strtoull (tok + (tok[0] == '-') + (tok[0] == '+'), NULL, 0));
long long val = uval;
long long pval = val < 0 ? -uval : uval;
int neg_power2_p = val < 0 && !(uval & (uval - 1));
unsigned len = pval ? 8 * sizeof (pval) - __builtin_clzll (pval) : 0;
- for (; class[cur].class_id != -1
- && ((unsigned int) (class[cur].sz < 0 ? - class[cur].sz - !neg_power2_p : class[cur].sz) < len
- || (exp.X_op == O_symbol && !has_relocation_of_size (str_hash_find (env.reloc_hash, TOKEN_NAME (class[cur].class_id))))
- || (exp.X_op == 64 && !kvx_get_pseudo_func2 (exp.X_op_symbol, str_hash_find (env.reloc_hash, TOKEN_NAME (class[cur].class_id)))))
- ; ++cur)
- ;
+ while (class[cur].class_id != -1
+ && ((unsigned) (class[cur].sz < 0
+ ? -class[cur].sz - !neg_power2_p
+ : class[cur].sz) < len
+ || (exp.X_op == O_symbol
+ && !(has_relocation_of_size
+ (str_hash_find (env.reloc_hash,
+ TOKEN_NAME (class[cur].class_id)))))
+ || (exp.X_op == O_pseudo_fixup
+ && !(kvx_get_pseudo_func2
+ (exp.X_op_symbol,
+ str_hash_find (env.reloc_hash,
+ TOKEN_NAME (class[cur].class_id)))))))
+ ++cur;
token->val = uval;
-// if (exp.X_op == 64)
+// if (exp.X_op == O_pseudo_fixup)
// token->val = (uintptr_t) !kvx_get_pseudo_func2 (exp.X_op_symbol, str_hash_find (env.reloc_hash, TOKEN_NAME (class[cur].class_id)));
found = 1;
}
@@ -757,8 +774,8 @@ parse_with_restarts (struct token_s tok, int jump_target, struct rule rules[],
return NULL;
}
- printf_debug (1, "\nEntering rule: %d (Trying to match: (%s)[%d])\n", jump_target,
- TOKEN_NAME (CLASS_ID (tok)), CLASS_ID (tok));
+ printf_debug (1, "\nEntering rule: %d (Trying to match: (%s)[%d])\n",
+ jump_target, TOKEN_NAME (CLASS_ID (tok)), CLASS_ID (tok));
/* 1. Find a rule that can be used with the current token. */
int i = 0;
diff --git a/gas/config/tc-kvx.c b/gas/config/tc-kvx.c
index 0e67ead..c5c8312 100644
--- a/gas/config/tc-kvx.c
+++ b/gas/config/tc-kvx.c
@@ -41,8 +41,6 @@
static void supported_cores (char buf[], size_t buflen);
-#define O_pseudo_fixup (O_max + 1)
-
#define NELEMS(a) ((int) (sizeof (a)/sizeof ((a)[0])))
#define STREQ(x,y) !strcmp(((x) ? (x) : ""), ((y) ? (y) : ""))
@@ -495,11 +493,7 @@ insert_operand (struct kvxinsn *insn, struct kvx_operand *opdef,
/* try to resolve the value */
- /* The cast is used to silence GCC about the abuse done with the enum.
- O_pseudo_fixup is not part of the enum, so enum checks raise an error.
- */
-
- switch ((int) tok->category)
+ switch (tok->category)
{
case CAT_REGISTER:
op = S_GET_VALUE (str_hash_find (env.reg_hash, tok->tok));
diff --git a/gas/config/tc-kvx.h b/gas/config/tc-kvx.h
index 85344cb..efb5725 100644
--- a/gas/config/tc-kvx.h
+++ b/gas/config/tc-kvx.h
@@ -37,6 +37,8 @@
#define KVX_RA_REGNO (67)
#define KVX_SP_REGNO (12)
+#define O_pseudo_fixup O_md1
+
#define TOKEN_NAME(tok) \
((tok) <= 0 ? "unknown token" : env.tokens_names[(tok) - 1])