[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[COMMITTED] libpoke, testsuite: support big/little annotations in all ki
From: |
Jose E. Marchesi |
Subject: |
[COMMITTED] libpoke, testsuite: support big/little annotations in all kind of fields |
Date: |
Sat, 3 Apr 2021 12:00:28 +0200 |
This patch generalizes the endianness annotations in struct type
fields, to allow them in fields of any type. The little/big
annotations are propagated lexically. See the documentation part of
the patch for more information.
2021-04-03 Jose E. Marchesi <jemarch@gnu.org>
* libpoke/pkl-trans.h (struct pkl_trans_payload): Add endianness
stack.
(pkl_trans_init_payload): Initialize endian.
* libpoke/pkl-trans.c (PKL_TRANS_ENDIAN): Define.
(PKL_TRANS_PUSH_ENDIAN): Likewise.
(PKL_TRANS_POP_ENDIAN): Likewise.
(pkl_trans1_pr_struct_type_field): New handler.
(pkl_trans1_ps_struct_type_field): Likewise.
(pkl_phase_trans1): Register new handlers.
* libpoke/pkl-anal.c (pkl_anal2_ps_struct_type_field): Remove
error check and add warning.
* testsuite/poke.map/maps-structs-endian-3.pk: New test.
* testsuite/poke.map/maps-structs-endian-4.pk: Likewise.
* testsuite/poke.map/maps-structs-endian-5.pk: Likewise.
* testsuite/poke.map/maps-structs-endian-6.pk: Likewise.
* doc/poke.texi (Field Endianness): Note that `little' and `big'
are valid for any kind of field.
* testsuite/poke.map/maps-structs-endian-7.pk: Likewise.
* testsuite/poke.map/maps-structs-endian-8.pk: Likewise.
* testsuite/poke.map/maps-structs-endian-9.pk: Likewise.
* testsuite/poke.map/maps-structs-endian-10.pk: Likewise.
* testsuite/poke.map/maps-structs-endian-diag-1.pk: Likewise.
* testsuite/poke.map/maps-structs-endian-11.pk: Likewise.
* testsuite/poke.pkl/struct-types-endian-diag-1.pk: Remove test.
* testsuite/poke.pkl/struct-types-endian-diag-2.pk: Likewise.
---
ChangeLog | 28 +++++++++++
doc/poke.texi | 50 ++++++++++++++++++-
libpoke/pkl-anal.c | 16 +++---
libpoke/pkl-gen.h | 8 +--
libpoke/pkl-gen.pks | 8 +--
libpoke/pkl-trans.c | 49 ++++++++++++++++++
libpoke/pkl-trans.h | 12 ++++-
testsuite/poke.map/maps-structs-endian-10.pk | 23 +++++++++
testsuite/poke.map/maps-structs-endian-11.pk | 25 ++++++++++
testsuite/poke.map/maps-structs-endian-3.pk | 19 +++++++
testsuite/poke.map/maps-structs-endian-4.pk | 19 +++++++
testsuite/poke.map/maps-structs-endian-5.pk | 13 +++++
testsuite/poke.map/maps-structs-endian-6.pk | 13 +++++
testsuite/poke.map/maps-structs-endian-7.pk | 24 +++++++++
testsuite/poke.map/maps-structs-endian-8.pk | 18 +++++++
testsuite/poke.map/maps-structs-endian-9.pk | 17 +++++++
.../poke.map/maps-structs-endian-diag-1.pk | 15 ++++++
.../poke.pkl/struct-types-endian-diag-1.pk | 7 ---
.../poke.pkl/struct-types-endian-diag-2.pk | 7 ---
19 files changed, 338 insertions(+), 33 deletions(-)
create mode 100644 testsuite/poke.map/maps-structs-endian-10.pk
create mode 100644 testsuite/poke.map/maps-structs-endian-11.pk
create mode 100644 testsuite/poke.map/maps-structs-endian-3.pk
create mode 100644 testsuite/poke.map/maps-structs-endian-4.pk
create mode 100644 testsuite/poke.map/maps-structs-endian-5.pk
create mode 100644 testsuite/poke.map/maps-structs-endian-6.pk
create mode 100644 testsuite/poke.map/maps-structs-endian-7.pk
create mode 100644 testsuite/poke.map/maps-structs-endian-8.pk
create mode 100644 testsuite/poke.map/maps-structs-endian-9.pk
create mode 100644 testsuite/poke.map/maps-structs-endian-diag-1.pk
delete mode 100644 testsuite/poke.pkl/struct-types-endian-diag-1.pk
delete mode 100644 testsuite/poke.pkl/struct-types-endian-diag-2.pk
diff --git a/ChangeLog b/ChangeLog
index 4166ca10..f6a7c09c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2021-04-03 Jose E. Marchesi <jemarch@gnu.org>
+
+ * libpoke/pkl-trans.h (struct pkl_trans_payload): Add endianness
+ stack.
+ (pkl_trans_init_payload): Initialize endian.
+ * libpoke/pkl-trans.c (PKL_TRANS_ENDIAN): Define.
+ (PKL_TRANS_PUSH_ENDIAN): Likewise.
+ (PKL_TRANS_POP_ENDIAN): Likewise.
+ (pkl_trans1_pr_struct_type_field): New handler.
+ (pkl_trans1_ps_struct_type_field): Likewise.
+ (pkl_phase_trans1): Register new handlers.
+ * libpoke/pkl-anal.c (pkl_anal2_ps_struct_type_field): Remove
+ error check and add warning.
+ * testsuite/poke.map/maps-structs-endian-3.pk: New test.
+ * testsuite/poke.map/maps-structs-endian-4.pk: Likewise.
+ * testsuite/poke.map/maps-structs-endian-5.pk: Likewise.
+ * testsuite/poke.map/maps-structs-endian-6.pk: Likewise.
+ * doc/poke.texi (Field Endianness): Note that `little' and `big'
+ are valid for any kind of field.
+ * testsuite/poke.map/maps-structs-endian-7.pk: Likewise.
+ * testsuite/poke.map/maps-structs-endian-8.pk: Likewise.
+ * testsuite/poke.map/maps-structs-endian-9.pk: Likewise.
+ * testsuite/poke.map/maps-structs-endian-10.pk: Likewise.
+ * testsuite/poke.map/maps-structs-endian-diag-1.pk: Likewise.
+ * testsuite/poke.map/maps-structs-endian-11.pk: Likewise.
+ * testsuite/poke.pkl/struct-types-endian-diag-1.pk: Remove test.
+ * testsuite/poke.pkl/struct-types-endian-diag-2.pk: Likewise.
+
2021-04-01 Jose E. Marchesi <jemarch@gnu.org>
* libpoke/libpoke.h: pk_ios_size now reports size in bytes.
diff --git a/doc/poke.texi b/doc/poke.texi
index f1f80a9d..f86c0cda 100644
--- a/doc/poke.texi
+++ b/doc/poke.texi
@@ -10207,8 +10207,8 @@ The struct values are compares recursively.
@subsection Field Endianness
By default fields are accessed in IO space using the current default
-endianness. However, it is possible to annotate integral fields with
-an explicit endianness, like in:
+endianness. However, it is possible to annotate fields with an
+explicit endianness, like in:
@example
type Foo =
@@ -10224,6 +10224,52 @@ In the example above, the field @code{a} will be
stored using
little-endian, the field @code{b} will be stored using big-endian, and
the field @code{c} will be stored using whatever current endianness.
+The endianness annotations can be used in any kind of fields, like
+offsets, arrays and structs, and will impact the storage ofintegral fields
defined in them.
+
+When endianness annotations are used in struct fields which are
+themselves structs, they effectively change the default endianness in
+the contained struct. Therefore, in the following struct type:
+
+@example
+type Bar =
+ struct
+ @{
+ little struct
+ @{
+ big int a;
+ int b;
+ @} f;
+ int c;
+ @}
+@end example
+
+@noindent
+@code{a} is big endian, but @code{b} is little endian.
+
+However, note that the scope of the @code{big} and @code{little}
+annotations is lexical. Therefore, in these types:
+
+@example
+type Foo =
+ struct
+ @{
+ int a;
+ int b;
+ @};
+
+type Bar =
+ struct
+ @{
+ big Foo f;
+ int c;
+ @};
+@end example
+
+@noindent
+The endianness of the @code{a} and @code{b} fields stored in @code{f}
+is the default endianness, not @code{big}.
+
@node Accessing Fields
@subsection Accessing Fields
diff --git a/libpoke/pkl-anal.c b/libpoke/pkl-anal.c
index cd4046d4..fe05a63e 100644
--- a/libpoke/pkl-anal.c
+++ b/libpoke/pkl-anal.c
@@ -824,8 +824,8 @@ PKL_PHASE_BEGIN_HANDLER (pkl_anal2_ps_funcall)
}
PKL_PHASE_END_HANDLER
-/* Endianness specifiers in struct fields are only valid when applied
- to integral types. */
+/* Emit a warning when an endianness field annotation is useless due
+ to lexical structure of the code. */
PKL_PHASE_BEGIN_HANDLER (pkl_anal2_ps_struct_type_field)
{
@@ -833,13 +833,11 @@ PKL_PHASE_BEGIN_HANDLER (pkl_anal2_ps_struct_type_field)
pkl_ast_node type = PKL_AST_STRUCT_TYPE_FIELD_TYPE (field);
if (PKL_AST_STRUCT_TYPE_FIELD_ENDIAN (field) != PKL_AST_ENDIAN_DFL
- && PKL_AST_TYPE_CODE (type) != PKL_TYPE_INTEGRAL)
- {
- PKL_ERROR (PKL_AST_LOC (field),
- "endianness can only be specified in integral fields");
- PKL_ANAL_PAYLOAD->errors++;
- PKL_PASS_ERROR;
- }
+ && (PKL_AST_TYPE_CODE (type) == PKL_TYPE_STRUCT
+ || PKL_AST_TYPE_CODE (type) == PKL_TYPE_ARRAY)
+ && PKL_AST_TYPE_NAME (type))
+ PKL_WARNING (PKL_AST_LOC (field),
+ "useless endianness annotation in field");
}
PKL_PHASE_END_HANDLER
diff --git a/libpoke/pkl-gen.h b/libpoke/pkl-gen.h
index bf308c1e..49330460 100644
--- a/libpoke/pkl-gen.h
+++ b/libpoke/pkl-gen.h
@@ -53,6 +53,9 @@
functions. Assemblers in PASM2 are used for compiling struct
constructors.
+ ENDIAN is the endianness to be used when mapping and writing
+ integral types.
+
CUR_PASM and CUR_PASM2 are the pointers to the top of PASM and
PASM2, respectively.
@@ -67,9 +70,6 @@
CUR_CONTEXT is the index to CONTEXT and marks the top of the stack
of contexts. Initially 0.
- ENDIAN is the endianness to be used when mapping and writing
- integral types.
-
MAPPER_DEPTH and CONSTRUCTOR_DEPTH are used in the array mapper and
constructor generation handlers.
@@ -83,11 +83,11 @@ struct pkl_gen_payload
pkl_asm pasm[PKL_GEN_MAX_PASM];
pkl_asm pasm2[PKL_GEN_MAX_PASM];
uint32_t context[PKL_GEN_MAX_CTX];
+ enum pkl_ast_endian endian;
int cur_pasm;
int cur_pasm2;
int cur_context;
pvm_program program;
- int endian;
int constructor_depth;
int mapper_depth;
int in_file_p;
diff --git a/libpoke/pkl-gen.pks b/libpoke/pkl-gen.pks
index f26d301f..b344ea4a 100644
--- a/libpoke/pkl-gen.pks
+++ b/libpoke/pkl-gen.pks
@@ -702,8 +702,9 @@
.c { int endian = PKL_AST_STRUCT_TYPE_FIELD_ENDIAN (@field);
.c PKL_GEN_PAYLOAD->endian = PKL_AST_STRUCT_TYPE_FIELD_ENDIAN (@field);
.c PKL_PASS_SUBPASS (PKL_AST_STRUCT_TYPE_FIELD_TYPE (@field));
- .c PKL_GEN_PAYLOAD->endian = endian; }
- ; STRICT BOFF VAL
+ .c PKL_GEN_PAYLOAD->endian = endian;
+ .c }
+ ; STRICT BOFF VAL
pope
pope
ba .val_ok
@@ -1539,7 +1540,8 @@
.c PKL_GEN_SET_CONTEXT (PKL_GEN_CTX_IN_WRITER);
.c PKL_PASS_SUBPASS (PKL_AST_STRUCT_TYPE_FIELD_TYPE (@field));
.c PKL_GEN_POP_CONTEXT;
- .c PKL_GEN_PAYLOAD->endian = endian; }
+ .c PKL_GEN_PAYLOAD->endian = endian;
+ .c }
ba .next
.omitted_field:
drop ; IOS SCT I
diff --git a/libpoke/pkl-trans.c b/libpoke/pkl-trans.c
index 4a0b365f..2170ac50 100644
--- a/libpoke/pkl-trans.c
+++ b/libpoke/pkl-trans.c
@@ -62,6 +62,25 @@
#define PKL_TRANS_PAYLOAD ((pkl_trans_payload) PKL_PASS_PAYLOAD)
+
+#define PKL_TRANS_ENDIAN \
+ (PKL_TRANS_PAYLOAD->endian[PKL_TRANS_PAYLOAD->cur_endian])
+
+#define PKL_TRANS_PUSH_ENDIAN(ENDIAN) \
+ do \
+ { \
+ assert (PKL_TRANS_PAYLOAD->cur_endian < PKL_TRANS_MAX_ENDIAN); \
+ PKL_TRANS_PAYLOAD->endian[++PKL_TRANS_PAYLOAD->cur_endian] = (ENDIAN); \
+ } while (0)
+
+#define PKL_TRANS_POP_ENDIAN \
+ do \
+ { \
+ assert (PKL_TRANS_PAYLOAD->cur_endian > 0); \
+ PKL_TRANS_PAYLOAD->cur_endian--; \
+ } \
+ while (0)
+
static int pkl_trans_in_functions (pkl_ast_node functions[],
int next_function,
pkl_ast_node function)
@@ -1105,6 +1124,34 @@ PKL_PHASE_BEGIN_HANDLER (pkl_trans1_ps_comp_stmt)
}
PKL_PHASE_END_HANDLER
+/* Push current endianness annotation. */
+
+PKL_PHASE_BEGIN_HANDLER (pkl_trans1_pr_struct_type_field)
+{
+ pkl_ast_node field = PKL_PASS_NODE;
+ int endian = PKL_AST_STRUCT_TYPE_FIELD_ENDIAN (field);
+
+ if (endian != PKL_AST_ENDIAN_DFL)
+ PKL_TRANS_PUSH_ENDIAN (PKL_AST_STRUCT_TYPE_FIELD_ENDIAN (field));
+}
+PKL_PHASE_END_HANDLER
+
+/* Annotate struct type fields with the current endiannes annotation
+ if necessary. And also pop endianness. */
+
+PKL_PHASE_BEGIN_HANDLER (pkl_trans1_ps_struct_type_field)
+{
+ pkl_ast_node field = PKL_PASS_NODE;
+ int endian = PKL_AST_STRUCT_TYPE_FIELD_ENDIAN (field);
+
+ if (endian == PKL_AST_ENDIAN_DFL)
+ PKL_AST_STRUCT_TYPE_FIELD_ENDIAN (field) = PKL_TRANS_ENDIAN;
+
+ if (endian != PKL_AST_ENDIAN_DFL)
+ PKL_TRANS_POP_ENDIAN;
+}
+PKL_PHASE_END_HANDLER
+
struct pkl_phase pkl_phase_trans1 =
{
PKL_PHASE_PS_HANDLER (PKL_AST_SRC, pkl_trans_ps_src),
@@ -1124,6 +1171,8 @@ struct pkl_phase pkl_phase_trans1 =
PKL_PHASE_PS_HANDLER (PKL_AST_COMP_STMT, pkl_trans1_ps_comp_stmt),
PKL_PHASE_PS_HANDLER (PKL_AST_LOOP_STMT_ITERATOR,
pkl_trans1_ps_loop_stmt_iterator),
PKL_PHASE_PS_HANDLER (PKL_AST_LOOP_STMT, pkl_trans1_ps_loop_stmt),
+ PKL_PHASE_PR_HANDLER (PKL_AST_STRUCT_TYPE_FIELD,
pkl_trans1_pr_struct_type_field),
+ PKL_PHASE_PS_HANDLER (PKL_AST_STRUCT_TYPE_FIELD,
pkl_trans1_ps_struct_type_field),
PKL_PHASE_PS_OP_HANDLER (PKL_AST_OP_ATTR, pkl_trans1_ps_op_attr),
PKL_PHASE_PS_TYPE_HANDLER (PKL_TYPE_STRUCT, pkl_trans1_ps_type_struct),
PKL_PHASE_PS_TYPE_HANDLER (PKL_TYPE_FUNCTION, pkl_trans1_ps_type_function),
diff --git a/libpoke/pkl-trans.h b/libpoke/pkl-trans.h
index 30d0f2b4..675d2cb3 100644
--- a/libpoke/pkl-trans.h
+++ b/libpoke/pkl-trans.h
@@ -36,9 +36,16 @@
depth relative to the current function.
NEXT_FUNCTION - 1 is the index for the enclosing function in
- FUNCTIONS. NEXT_FUNCTION is 0 if not in a function. */
+ FUNCTIONS. NEXT_FUNCTION is 0 if not in a function.
+
+ ENDIAN is a stack whose top indicates the endianness to be used
+ when mapping and writing integral types.
+
+ CUR_ENDIAN is the index to ENDIAN and marks the top of the stack of
+ endianness. Initially PKL_AST_ENDIAN_DFL. */
#define PKL_TRANS_MAX_FUNCTION_NEST 32
+#define PKL_TRANS_MAX_ENDIAN 25
struct pkl_trans_payload
{
@@ -47,6 +54,8 @@ struct pkl_trans_payload
pkl_ast_node functions[PKL_TRANS_MAX_FUNCTION_NEST];
int function_back[PKL_TRANS_MAX_FUNCTION_NEST];
int next_function;
+ enum pkl_ast_endian endian[PKL_TRANS_MAX_ENDIAN];
+ int cur_endian;
};
typedef struct pkl_trans_payload *pkl_trans_payload;
@@ -60,6 +69,7 @@ static inline void
pkl_trans_init_payload (pkl_trans_payload payload)
{
memset (payload, 0, sizeof (struct pkl_trans_payload));
+ payload->endian[0] = PKL_AST_ENDIAN_DFL;
}
#endif /* PKL_TRANS_H */
diff --git a/testsuite/poke.map/maps-structs-endian-10.pk
b/testsuite/poke.map/maps-structs-endian-10.pk
new file mode 100644
index 00000000..4aac27aa
--- /dev/null
+++ b/testsuite/poke.map/maps-structs-endian-10.pk
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+/* { dg-data {c*} {0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0
0xc0} } */
+
+type Foo =
+ struct
+ {
+ big struct
+ {
+ little struct
+ {
+ big int<16> a;
+ int<16> b;
+ } s3;
+
+ int<16> c;
+ } s2;
+ int<16> d;
+ };
+
+/* { dg-command {.set obase 16 } } */
+/* { dg-command {.set endian little} } */
+/* { dg-command {Foo @ 0#B} } */
+/* { dg-output "Foo \{s2=struct \{s3=struct
\{a=0x1020H,b=0x4030H\},c=0x5060H\},d=0x8070H\}" }*/
diff --git a/testsuite/poke.map/maps-structs-endian-11.pk
b/testsuite/poke.map/maps-structs-endian-11.pk
new file mode 100644
index 00000000..542462d3
--- /dev/null
+++ b/testsuite/poke.map/maps-structs-endian-11.pk
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+
+type Foo =
+ struct
+ {
+ big struct
+ {
+ little struct
+ {
+ big int<16> a = 0x1020;
+ int<16> b = 0x3040;
+ } s3;
+
+ int<16> c = 0x5060;
+ } s2;
+ int<16> d = 0x7080;
+ };
+
+/* { dg-command {.set obase 16 } } */
+/* { dg-command {.set endian little} } */
+/* { dg-command {var s1 = Foo {} } } */
+/* { dg-command {.mem foo} } */
+/* { dg-command {Foo @ 0#B = s1} } */
+/* { dg-command {byte[8] @ 0#B} } */
+/* { dg-output
"\\\[0x10UB,0x20UB,0x40UB,0x30UB,0x50UB,0x60UB,0x80UB,0x70UB\\\]" } */
diff --git a/testsuite/poke.map/maps-structs-endian-3.pk
b/testsuite/poke.map/maps-structs-endian-3.pk
new file mode 100644
index 00000000..6bf6d619
--- /dev/null
+++ b/testsuite/poke.map/maps-structs-endian-3.pk
@@ -0,0 +1,19 @@
+/* { dg-do run } */
+/* { dg-data {c*} {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00} } */
+
+type Foo =
+ struct {
+ little offset<int,B> a;
+ big offset<int,B> b;
+ offset<int,B> c;
+ };
+
+/* { dg-command {.set obase 16 } } */
+/* { dg-command {.set endian little} } */
+/* { dg-command {var f = Foo @ 0#B} } */
+/* { dg-command { f.a = 0x10203040#B} } */
+/* { dg-command { byte[4] @ 0#B } } */
+/* { dg-output "\\\[0x40UB,0x30UB,0x20UB,0x10UB\\\]" } */
+/* { dg-command { f.b = 0x10203040#B } } */
+/* { dg-command { byte[4] @ 4#B } } */
+/* { dg-output "\n\\\[0x10UB,0x20UB,0x30UB,0x40UB\\\]" } */
diff --git a/testsuite/poke.map/maps-structs-endian-4.pk
b/testsuite/poke.map/maps-structs-endian-4.pk
new file mode 100644
index 00000000..8ab273c9
--- /dev/null
+++ b/testsuite/poke.map/maps-structs-endian-4.pk
@@ -0,0 +1,19 @@
+/* { dg-do run } */
+/* { dg-data {c*} {0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0
0xc0} } */
+
+type Foo =
+ struct {
+ little offset<int,B> a;
+ big offset<int,B> b;
+ offset<int,B> c;
+ };
+
+/* { dg-command {.set obase 16 } } */
+/* { dg-command {.set endian little} } */
+/* { dg-command {var f = Foo @ 0#B} } */
+/* { dg-command { f.a } } */
+/* { dg-output "0x40302010#B" } */
+/* { dg-command { f.b } } */
+/* { dg-output "\n0x50607080#B" } */
+/* { dg-command { f.c } } */
+/* { dg-output "\n0xc0b0a090#B" } */
diff --git a/testsuite/poke.map/maps-structs-endian-5.pk
b/testsuite/poke.map/maps-structs-endian-5.pk
new file mode 100644
index 00000000..3e8e01e3
--- /dev/null
+++ b/testsuite/poke.map/maps-structs-endian-5.pk
@@ -0,0 +1,13 @@
+/* { dg-do run } */
+/* { dg-data {c*} {0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0
0xc0} } */
+
+type Foo =
+ struct {
+ little offset<int,B>[2] a;
+ };
+
+/* { dg-command {.set obase 16 } } */
+/* { dg-command {.set endian little} } */
+/* { dg-command {var f = Foo @ 0#B} } */
+/* { dg-command { f.a } } */
+/* { dg-output "\\\[0x40302010#B,0x80706050#B\\\]" } */
diff --git a/testsuite/poke.map/maps-structs-endian-6.pk
b/testsuite/poke.map/maps-structs-endian-6.pk
new file mode 100644
index 00000000..ae421715
--- /dev/null
+++ b/testsuite/poke.map/maps-structs-endian-6.pk
@@ -0,0 +1,13 @@
+/* { dg-do run } */
+/* { dg-data {c*} {0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0
0xc0} } */
+
+type Foo =
+ struct {
+ big offset<int,B>[2] a;
+ };
+
+/* { dg-command {.set obase 16 } } */
+/* { dg-command {.set endian little} } */
+/* { dg-command {var f = Foo @ 0#B} } */
+/* { dg-command { f.a } } */
+/* { dg-output "\\\[0x10203040#B,0x50607080#B\\\]" } */
diff --git a/testsuite/poke.map/maps-structs-endian-7.pk
b/testsuite/poke.map/maps-structs-endian-7.pk
new file mode 100644
index 00000000..bc97c127
--- /dev/null
+++ b/testsuite/poke.map/maps-structs-endian-7.pk
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+/* { dg-data {c*} {0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0
0xc0} } */
+
+/* Note that the endianness of `c' is big, because of lexical scope of
+ endianness annotations. */
+
+type Foo =
+ struct {
+ little offset<int<16>,B> l;
+ big int<16> b;
+ int16 c;
+ };
+
+type Bar =
+ struct {
+ little Foo f;
+ big int16 d;
+ };
+
+/* { dg-command {.set obase 16 } } */
+/* { dg-command {.set endian big} } */
+/* { dg-command {var bar = Bar @ 0#B} } */
+/* { dg-command { bar } } */
+/* { dg-output "Bar \{f=Foo \{l=0x2010H#B,b=0x3040H,c=0x5060H\},d=0x7080H\}" }
*/
diff --git a/testsuite/poke.map/maps-structs-endian-8.pk
b/testsuite/poke.map/maps-structs-endian-8.pk
new file mode 100644
index 00000000..d45a0219
--- /dev/null
+++ b/testsuite/poke.map/maps-structs-endian-8.pk
@@ -0,0 +1,18 @@
+/* { dg-do run } */
+/* { dg-data {c*} {0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0
0xc0} } */
+
+type Bar =
+ struct {
+ little struct {
+ little offset<int<16>,B> l;
+ big int<16> b;
+ int16 c;
+ } f;
+ big int16 d;
+ };
+
+/* { dg-command {.set obase 16 } } */
+/* { dg-command {.set endian big} } */
+/* { dg-command {var bar = Bar @ 0#B} } */
+/* { dg-command { bar } } */
+/* { dg-output "Bar \{f=struct
\{l=0x2010H#B,b=0x3040H,c=0x6050H\},d=0x7080H\}" } */
diff --git a/testsuite/poke.map/maps-structs-endian-9.pk
b/testsuite/poke.map/maps-structs-endian-9.pk
new file mode 100644
index 00000000..048923e5
--- /dev/null
+++ b/testsuite/poke.map/maps-structs-endian-9.pk
@@ -0,0 +1,17 @@
+/* { dg-do run } */
+/* { dg-data {c*} {0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0
0xc0} } */
+
+type Bar =
+ struct {
+ little struct
+ {
+ int<16>[3] a;
+ } s;
+ int<16>[3] b;
+ };
+
+/* { dg-command {.set obase 16 } } */
+/* { dg-command {.set endian big} } */
+/* { dg-command {var bar = Bar @ 0#B} } */
+/* { dg-command { bar } } */
+/* { dg-output "Bar \{s=struct
\{a=\\\[0x2010H,0x4030H,0x6050H\\\]\},b=\\\[0x7080H,0x90a0H,0xb0c0H\\\]\}" } */
diff --git a/testsuite/poke.map/maps-structs-endian-diag-1.pk
b/testsuite/poke.map/maps-structs-endian-diag-1.pk
new file mode 100644
index 00000000..dbcf700f
--- /dev/null
+++ b/testsuite/poke.map/maps-structs-endian-diag-1.pk
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+type Foo =
+ struct
+ {
+ int a;
+ int b;
+ };
+
+type Bar =
+ struct
+ {
+ big Foo f; /* { dg-warning "useless" } */
+ int c;
+ };
diff --git a/testsuite/poke.pkl/struct-types-endian-diag-1.pk
b/testsuite/poke.pkl/struct-types-endian-diag-1.pk
deleted file mode 100644
index 7e6b0473..00000000
--- a/testsuite/poke.pkl/struct-types-endian-diag-1.pk
+++ /dev/null
@@ -1,7 +0,0 @@
-/* { dg-do compile } */
-
-type Packet = struct
- {
- big string foo; /* { dg-error "" } */
- long bar;
- };
diff --git a/testsuite/poke.pkl/struct-types-endian-diag-2.pk
b/testsuite/poke.pkl/struct-types-endian-diag-2.pk
deleted file mode 100644
index 0e4fef06..00000000
--- a/testsuite/poke.pkl/struct-types-endian-diag-2.pk
+++ /dev/null
@@ -1,7 +0,0 @@
-/* { dg-do compile } */
-
-type Packet = struct
- {
- little string foo; /* { dg-error "" } */
- long bar;
- };
--
2.25.0.2.g232378479e
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [COMMITTED] libpoke, testsuite: support big/little annotations in all kind of fields,
Jose E. Marchesi <=