-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/int widths #96
base: master
Are you sure you want to change the base?
Conversation
TODO: check how megaparsec works with this because it appears very incorrect
@@ -126,8 +126,8 @@ codeGenBlock_ = fmap snd . codeGenBlock | |||
codeGenSimpleType :: SimpleType -> CG IR.Reg | |||
codeGenSimpleType = \case | |||
T_Unit -> newRegWithSimpleType (-1) | |||
T_Int64 -> newRegWithSimpleType (-2) | |||
T_Word64 -> newRegWithSimpleType (-3) | |||
-- T_Int width -> newRegWithSimpleType (-2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@csabahruska do you have an existing plan how to implement this in these abstract interpretations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering a bit while I was writing this why a mapping from types to registers wasn't handled by Data.Map
or something similar. Maybe assigning a unique type to the next available register would work?
= T_Int64 | ||
| T_Word64 | ||
= T_Int Word32 | ||
| T_Word Word32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use Word32 as a parameter to define the concrete width of these types. Some ADT which is better aligned with the LLVM types would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally used Word
but llvm-hs-pure
uses Word32
; I got compile errors trying to use Word
because of that. However, the maximum width in the LLVM spec is (2^24) - 1 bits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah got it, if LLVM-hs uses in the API than no objections from my side anymore :)
It is a good practice to write tests for the changed code paths. |
What is your objective? Maybe we can lay out an implementation path that makes your experiment easier. |
My objective here is to be able to have more number types than RE: Tests, as far as I know I need to get it compiling first before I can start testing. The current commit does not compile. |
FFI sounds great! Do you see a way how HPT analysis will be able to handle these additions? |
What do you mean by "handle"? What would be different between |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All in all, seems nice although, I would prefer merging it after #32 is done.
_ -> error $ "invalid arguments: " ++ show params ++ " " ++ show args ++ " for " ++ unpackName name | ||
|
||
int_str = case args of | ||
[RT_Lit (LInt64 a)] -> string $ fromString $ show a | ||
[RT_Lit (LInt 64 a)] -> string $ fromString $ show a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intended to use a specific width in each of these functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far, I have converted primops from T_Int64
to T_Int 64
, but the end goal is to generalize them (part of checkbox three, I should probably specify that). Note that operations will only be defined for numbers of the same width, i.e. add :: i8 -> i7 -> i9
should be invalid (same as how LLVM does it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks!
#32 Looks awesome! I'll be sure to [merge/rebase, whichever one it is] my fork once its merged. I definitely agree with merging after it, because this being merged first would probably make your work harder, and that being merged first will most likely make my work easier. |
The code rewriting is almost done for #32. What is left is to merge the changes, and address any concerns. Feel free to review the PRs :) |
TODO:
123u8
,1i12345
)Opening this as a draft PR. It's my first time ever working on a major Haskell project, so thorough reviews would be very very appreciated 😄