How to rebase each element of an array? #2097
Unanswered
John-K
asked this question in
Pattern Language Q&A
Replies: 2 comments
-
To create an array of pointers: /**** First create a struct to represent a pointer ****/
struct Ptr {
group *groups : u32 [[pointer_base("block_to_byte_offset")]];
};
/****** Then you can create arrays of them inside other patterns ****/
struct ArrayOfPtrs {
Ptr ptrs[num_groups];
};
ArrayOfPtrs array@0;
/******* Or simply create and place the array ******/
Ptr ptrs[num_groups]@0;
what you are creating in your code is a pointer to an array, not an array of pointers |
Beta Was this translation helpful? Give feedback.
0 replies
-
Aha, this makes sense. I will try it
…On Thu, Jan 30, 2025 at 9:14 PM paxcut ***@***.***> wrote:
To create an array of pointers:
/**** First create a struct to represent a pointer ****/struct Ptr {
group *groups : u32 [[pointer_base("block_to_byte_offset")]];
};/****** Then you can create arrays of them inside other patterns ****/struct ArrayOfPtrs {
Ptr ptrs[num_groups];
};
ArrayOfPtrs ***@***.***;
/******* Or simply create and place the array ******/Ptr ***@***.***;
what you are creating in your code is a pointer to an array, not an array
of pointers
—
Reply to this email directly, view it on GitHub
<#2097 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADCSVRY3OFHICHDG23JOX32NLMBZAVCNFSM6AAAAABWGSSQQ6VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTEMBRGMZTEMI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey folks, I have data that looks like:
Where it gives the number of elements (4) and the block indexes of each of the elements. Specifying a
pointer_base
function for the array, only rebases based on the 0th element and not for each subsequent one.How can I read in the N pointers, apply the transform (* 512 in this case) and then capture that in the array?
I tried creating a new array using
for
inside of the array brackets like howwhile
is shown in the documentation, but this isn't valid.This is a trivial example, there are more complex structs that need the same treatment in this file.
Beta Was this translation helpful? Give feedback.
All reactions