abrown opened Issue #1401:
<!-- Please try to describe precisely what you would like to do in Cranelift and/or
expect from it. You can answer the questions below if they're relevant and
delete this text before submitting. Thanks for opening an issue! -->Feature
<!-- What is the feature or code improvement you would like to do in Cranelift? -->
The types
i16
,i32
, andi64
currently cannot be parsed from a hexadecimal integer;i8
can by using thematch_uimm8
function inparser.rs
butmatch_imm16
,match_imm32
, andmatch_imm64
do not allow this.Benefit
<!-- What is the value of adding this in Cranelift? -->
At times we are forced to use strange negative numbers to represent values more naturally expressed with a hexadecimal number; e.g. when preparing a value for checking overflow semantics in a 16-bit vector lane, it is more convenient to use
0xffff
than-32768
.Implementation
<!-- Do you have an implementation plan, and/or ideas for data structures or algorithms to use? -->
- Add hexadecimal parsing to
match_imm16
,match_imm32
, andmatch_imm64
(seematch_uimm8
)- Modify tests using strange negative numbers (e.g. like this comment), replacing these with the more clear hexadecimal syntax
Alternatives
<!-- Have you considered alternative implementations? If so, how are they better or worse than your proposal? -->
We could leave this as is; it makes sense that the
match_imm*
functions are concerned primarily with parsing signed integers. However, adding hexadecimal parsing would not break anything as long as we include checks that the number has no more bits than necessary (e.g. a hex number parsed to anImm64
should have no more than 64 bits).
alexcrichton transferred Issue #1401:
<!-- Please try to describe precisely what you would like to do in Cranelift and/or
expect from it. You can answer the questions below if they're relevant and
delete this text before submitting. Thanks for opening an issue! -->Feature
<!-- What is the feature or code improvement you would like to do in Cranelift? -->
The types
i16
,i32
, andi64
currently cannot be parsed from a hexadecimal integer;i8
can by using thematch_uimm8
function inparser.rs
butmatch_imm16
,match_imm32
, andmatch_imm64
do not allow this.Benefit
<!-- What is the value of adding this in Cranelift? -->
At times we are forced to use strange negative numbers to represent values more naturally expressed with a hexadecimal number; e.g. when preparing a value for checking overflow semantics in a 16-bit vector lane, it is more convenient to use
0xffff
than-32768
.Implementation
<!-- Do you have an implementation plan, and/or ideas for data structures or algorithms to use? -->
- Add hexadecimal parsing to
match_imm16
,match_imm32
, andmatch_imm64
(seematch_uimm8
)- Modify tests using strange negative numbers (e.g. like this comment), replacing these with the more clear hexadecimal syntax
Alternatives
<!-- Have you considered alternative implementations? If so, how are they better or worse than your proposal? -->
We could leave this as is; it makes sense that the
match_imm*
functions are concerned primarily with parsing signed integers. However, adding hexadecimal parsing would not break anything as long as we include checks that the number has no more bits than necessary (e.g. a hex number parsed to anImm64
should have no more than 64 bits).
Last updated: Nov 22 2024 at 16:03 UTC