From: Paul Iannetta <piannetta@kalrayinc.com>
To: binutils@sourceware.org
Cc: Paul Iannetta <piannetta@kalrayinc.com>
Subject: [PATCH 3/4] kvx: use {u,}int32_t and {u,}int64_t
Date: Wed, 23 Aug 2023 16:39:22 +0200 [thread overview]
Message-ID: <20230823143923.10105-4-piannetta@kalrayinc.com> (raw)
In-Reply-To: <20230823143923.10105-1-piannetta@kalrayinc.com>
gas/ChangeLog:
2023-08-23 Paul Iannetta <piannetta@kalrayinc.com>
* config/kvx-parse.c (promote_token): use {u,}int32_t and
{u,}int64_t.
(get_token_class): Likewise.
* config/tc-kvx.c (insert_operand): Likewise.
* config/tc-kvx.h (struct token_s): Likewise.
(struct token_list): Likewise.
opcodes/ChangeLog:
2023-08-23 Paul Iannetta <piannetta@kalrayinc.com>
* kvx-dis.c (struct decoded_insn): use {u,}int32_t and
{u,}int64_t.
(decode_insn): Likewise.
(print_insn_kvx): Likewise.
(decode_prologue_epilogue_bundle): Likewise.
* kvx-dis.h (struct kvx_prologue_epilogue_insn): Likewise.
---
gas/config/kvx-parse.c | 20 ++++++++++----------
gas/config/tc-kvx.c | 8 ++++----
gas/config/tc-kvx.h | 10 +++++-----
opcodes/kvx-dis.c | 32 ++++++++++++++++----------------
opcodes/kvx-dis.h | 2 +-
5 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/gas/config/kvx-parse.c b/gas/config/kvx-parse.c
index af207be285b..bb51c861625 100644
--- a/gas/config/kvx-parse.c
+++ b/gas/config/kvx-parse.c
@@ -396,10 +396,10 @@ print_token (struct token_s token, char *buf, int bufsz)
buf[i] = 0;
}
-static long long
+static int64_t
promote_token (struct token_s tok)
{
- long long cur_class = tok.class_id & -tok.class_id;
+ int64_t cur_class = tok.class_id & -tok.class_id;
switch (tok.category)
{
case CAT_REGISTER:
@@ -414,8 +414,8 @@ promote_token (struct token_s tok)
input_line_pointer = tok.insn + tok.begin;
expression (&exp);
input_line_pointer = ilp_save;
- long long new_class_id = tok.class_id;
- long long old_class_id = tok.class_id;
+ int64_t new_class_id = tok.class_id;
+ int64_t old_class_id = tok.class_id;
while (((new_class_id = env.promote_immediate (old_class_id))
!= old_class_id)
&& ((exp.X_op == O_symbol
@@ -451,7 +451,7 @@ is_insn (const struct token_s *token, struct token_class *classes)
return res;
}
-static long long
+static int64_t
get_token_class (struct token_s *token, struct token_classes *classes, int insn_p, int modifier_p)
{
int cur = 0;
@@ -519,12 +519,12 @@ get_token_class (struct token_s *token, struct token_classes *classes, int insn_
if (class == classes->imm_classes)
{
- unsigned long long uval
+ uint64_t 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;
+ int64_t val = uval;
+ int64_t pval = val < 0 ? -uval : uval;
int neg_power2_p = val < 0 && !(uval & (uval - 1));
unsigned len = pval ? 8 * sizeof (pval) - __builtin_clzll (pval) : 0;
while (class[cur].class_id != -1
@@ -821,7 +821,7 @@ retry:;
parse_with_restarts (tok, cur_rule[i].jump_target, rules, errs);
/* While parsing fails but there is hope since the current token can be
promoted. */
- while (!fst_part && tok.class_id != (long long) promote_token (tok))
+ while (!fst_part && tok.class_id != (int64_t) promote_token (tok))
{
free_token_list (fst_part);
tok.class_id = promote_token (tok);
@@ -871,7 +871,7 @@ retry:;
printf_debug (1, "snd_part: Trying to match: %s\n", TOKEN_NAME (CLASS_ID (tok)));
struct token_list *snd_part = parse_with_restarts (tok, cur_rule[i].stack_it, rules, errs);
- while (!snd_part && tok.class_id != (long long) promote_token (tok))
+ while (!snd_part && tok.class_id != (int64_t) promote_token (tok))
{
tok.class_id = promote_token (tok);
printf_debug (1, ">> Restart with %s?\n", TOKEN_NAME (CLASS_ID (tok)));
diff --git a/gas/config/tc-kvx.c b/gas/config/tc-kvx.c
index be8bc7da923..c9cb8adbb3d 100644
--- a/gas/config/tc-kvx.c
+++ b/gas/config/tc-kvx.c
@@ -458,7 +458,7 @@ static int
insert_operand (struct kvxinsn *insn, struct kvx_operand *opdef,
struct token_list *tok)
{
- unsigned long long op = 0;
+ uint64_t op = 0;
struct kvx_bitfield *bfields = opdef->bfield;
int bf_nb = opdef->bitfields;
int immx_ready = 0;
@@ -570,7 +570,7 @@ insert_operand (struct kvxinsn *insn, struct kvx_operand *opdef,
{
/* This is a immediate: either a regular immediate, or an
immediate that was saved in a variable through `.equ'. */
- unsigned long long sval = (long long) tok->val;
+ uint64_t sval = (int64_t) tok->val;
op = opdef->flags & kvxSIGNED ? sval : tok->val;
op >>= opdef->shift;
}
@@ -661,8 +661,8 @@ insert_operand (struct kvxinsn *insn, struct kvx_operand *opdef,
for (int bf_idx = 0; bf_idx < bf_nb; bf_idx++)
{
- unsigned long long value =
- ((unsigned long long) op >> bfields[bf_idx].from_offset);
+ uint64_t value =
+ ((uint64_t) op >> bfields[bf_idx].from_offset);
int j = 0;
int to_offset = bfields[bf_idx].to_offset;
value &= (1LL << bfields[bf_idx].size) - 1;
diff --git a/gas/config/tc-kvx.h b/gas/config/tc-kvx.h
index efb57251541..4d29f015c09 100644
--- a/gas/config/tc-kvx.h
+++ b/gas/config/tc-kvx.h
@@ -46,15 +46,15 @@ struct token_s {
char *insn;
int begin, end;
int category;
- long long class_id;
- unsigned long long val;
+ int64_t class_id;
+ uint64_t val;
};
struct token_list
{
char *tok;
- unsigned long long val;
- long long class_id;
+ uint64_t val;
+ int64_t class_id;
int category;
int loc;
struct token_list *next;
@@ -64,7 +64,7 @@ struct token_list
struct token_class {
const char ** class_values;
- long long class_id;
+ int64_t class_id;
int sz;
};
diff --git a/opcodes/kvx-dis.c b/opcodes/kvx-dis.c
index d7b86791c30..e63430a9e57 100644
--- a/opcodes/kvx-dis.c
+++ b/opcodes/kvx-dis.c
@@ -539,7 +539,7 @@ struct decoded_insn
CAT_IMMEDIATE,
} type;
/* The value of the operands. */
- unsigned long long val;
+ uint64_t val;
/* If it is an immediate, its sign. */
int sign;
/* If it is an immediate, is it pc relative. */
@@ -593,20 +593,20 @@ decode_insn (bfd_vma memaddr, insn_t * insn, struct decoded_insn *res)
int flags = op->format[i]->flags;
int shift = op->format[i]->shift;
int bias = op->format[i]->bias;
- unsigned long long value = 0;
+ uint64_t value = 0;
for (int bf_idx = 0; bf_idx < bf_nb; bf_idx++)
{
int insn_idx = (int) bf[bf_idx].to_offset / 32;
int to_offset = bf[bf_idx].to_offset % 32;
- unsigned long long encoded_value =
+ uint64_t encoded_value =
insn->syllables[insn_idx] >> to_offset;
encoded_value &= (1LL << bf[bf_idx].size) - 1;
value |= encoded_value << bf[bf_idx].from_offset;
}
if (flags & kvxSIGNED)
{
- unsigned long long signbit = 1LL << (width - 1);
+ uint64_t signbit = 1LL << (width - 1);
value = (value ^ signbit) - signbit;
}
value = (value << shift) + bias;
@@ -1126,13 +1126,13 @@ print_insn_kvx (bfd_vma memaddr, struct disassemble_info *info)
{
if (dec.operands[i].width <= 32)
{
- (*info->fprintf_func) (info->stream, "%d (0x%x)",
- (int) dec.operands[i].val,
- (int) dec.operands[i].val);
+ (*info->fprintf_func) (info->stream, "%" PRId32 " (0x%" PRIx32 ")",
+ (int32_t) dec.operands[i].val,
+ (int32_t) dec.operands[i].val);
}
else
{
- (*info->fprintf_func) (info->stream, "%lld (0x%llx)",
+ (*info->fprintf_func) (info->stream, "%" PRId64 " (0x%" PRIx64 ")",
dec.operands[i].val,
dec.operands[i].val);
}
@@ -1141,18 +1141,18 @@ print_insn_kvx (bfd_vma memaddr, struct disassemble_info *info)
{
if (dec.operands[i].width <= 32)
{
- (*info->fprintf_func) (info->stream, "%u (0x%x)",
- (unsigned int) dec.operands[i].
+ (*info->fprintf_func) (info->stream, "%" PRIu32 " (0x%" PRIx32 ")",
+ (uint32_t) dec.operands[i].
val,
- (unsigned int) dec.operands[i].
+ (uint32_t) dec.operands[i].
val);
}
else
{
- (*info->fprintf_func) (info->stream, "%llu (0x%llx)",
- (unsigned long long) dec.
+ (*info->fprintf_func) (info->stream, "%" PRIu64 " (0x%" PRIx64 ")",
+ (uint64_t) dec.
operands[i].val,
- (unsigned long long) dec.
+ (uint64_t) dec.
operands[i].val);
}
}
@@ -1317,7 +1317,7 @@ decode_prologue_epilogue_bundle (bfd_vma memaddr,
int flags = fmt->flags;
int shift = fmt->shift;
int bias = fmt->bias;
- unsigned long long encoded_value, value = 0;
+ uint64_t encoded_value, value = 0;
for (int bf_idx = 0; bf_idx < bf_nb; bf_idx++)
{
@@ -1329,7 +1329,7 @@ decode_prologue_epilogue_bundle (bfd_vma memaddr,
}
if (flags & kvxSIGNED)
{
- unsigned long long signbit = 1LL << (width - 1);
+ uint64_t signbit = 1LL << (width - 1);
value = (value ^ signbit) - signbit;
}
value = (value << shift) + bias;
diff --git a/opcodes/kvx-dis.h b/opcodes/kvx-dis.h
index e82538b623a..435fe7d9fe9 100644
--- a/opcodes/kvx-dis.h
+++ b/opcodes/kvx-dis.h
@@ -45,7 +45,7 @@ enum kvx_prologue_epilogue_insn_type
struct kvx_prologue_epilogue_insn
{
enum kvx_prologue_epilogue_insn_type insn_type;
- unsigned long long immediate;
+ uint64_t immediate;
int gpr_reg[3];
int nb_gprs;
};
--
2.35.1.500.gb896f729e2
next prev parent reply other threads:[~2023-08-23 14:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-22 16:01 [PATCH] kvx: fix 32-bit build and validation Paul Iannetta
2023-08-23 0:27 ` Alan Modra
2023-08-23 7:44 ` Paul Iannetta
2023-08-23 12:14 ` Alan Modra
2023-08-23 14:39 ` [PATCH 0/4] kvx: various fixes Paul Iannetta
2023-08-23 14:39 ` [PATCH 1/4] kvx: remove kvx_elf64_linux_vec Paul Iannetta
2023-08-23 14:39 ` [PATCH 2/4] kvx: fix handling of STB_GNU_UNIQUE symbols Paul Iannetta
2023-08-23 14:39 ` Paul Iannetta [this message]
2023-08-23 14:39 ` [PATCH 4/4] kvx: bfd/config.bfd & ld/configure.tgt Paul Iannetta
2023-08-24 3:12 ` [PATCH 0/4] kvx: various fixes Alan Modra
2023-08-24 6:26 ` Paul Iannetta
2023-08-24 8:49 ` [PATCH] kvx: fix kvx_reassemble_bundle index 8 out of bounds Paul Iannetta
2023-08-24 9:08 ` Alan Modra
2023-08-24 9:26 ` Paul Iannetta
2023-09-07 12:46 ` Alan Modra
2023-09-07 15:27 ` Paul Iannetta
2023-08-23 14:40 ` [PATCH] kvx: fix 32-bit build and validation Paul Iannetta
2023-08-23 3:16 ` Alan Modra
2023-08-23 13:39 ` Luis Machado
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230823143923.10105-4-piannetta@kalrayinc.com \
--to=piannetta@kalrayinc.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).