[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/3] pkl: Add RAS macro zero_extend_64
From: |
Mohammad-Reza Nabipoor |
Subject: |
[PATCH 1/3] pkl: Add RAS macro zero_extend_64 |
Date: |
Sat, 8 Jan 2022 21:44:50 +0330 |
2022-01-08 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* libpoke/pkl-gen.pks (zero_extend_64): Add new macro.
---
ChangeLog | 4 ++++
libpoke/pkl-gen.pks | 30 ++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index e2d27f4d..8150754b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2022-01-08 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
+
+ * libpoke/pkl-gen.pks (zero_extend_64): Add new macro.
+
2022-01-08 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* libpoke/pvm-val.c (pvm_print_val_1): Add `0x` prefix to
diff --git a/libpoke/pkl-gen.pks b/libpoke/pkl-gen.pks
index 526be994..080d2305 100644
--- a/libpoke/pkl-gen.pks
+++ b/libpoke/pkl-gen.pks
@@ -430,6 +430,36 @@
raise
.end
+;;; RAS_MACRO_ZERO_EXTEND_64 @from_int_type
+;;; ( IVAL -- IVAL_U64 )
+;;;
+;;; Cast the integer on stack as ulong<64> without perserving the
+;;; sign bit.
+;;;
+;;; Macro arguments:
+;;;
+;;; @from_int_type is the type of integer on stack.
+
+ ;; XXX This must be a PVM instruction instead
+ .macro zero_extend_64 @from_int_type
+ .let @uint64_type = pkl_ast_make_integral_type (PKL_PASS_AST, 64, 0)
+ .c if (PKL_AST_TYPE_I_SIGNED_P (@from_int_type))
+ .c {
+ .let @utype = \
+ pkl_ast_make_integral_type (PKL_PASS_AST, \
+ PKL_AST_TYPE_I_SIZE (@from_int_type), \
+ 0);
+ nton @from_int_type, @utype
+ nton @utype, @uint64_type
+ nip2
+ .c }
+ .c else
+ .c {
+ nton @from_int_type, @uint64_type
+ nip
+ .c }
+ .end
+
;;; RAS_MACRO_HANDLE_STRUCT_FIELD_LABEL @field
;;; ( BOFF SBOFF - BOFF )
;;;
--
2.34.1
- [PATCH 1/3] pkl: Add RAS macro zero_extend_64,
Mohammad-Reza Nabipoor <=