Skip to content

Commit

Permalink
Allow integer values (e.g., in config files) to come with type inform…
Browse files Browse the repository at this point in the history
…ation

Also update the RISC-V configuration, where one of the new primops needs
a 64-bit integer.
  • Loading branch information
bacam committed Oct 2, 2024
1 parent 90da0f8 commit 43bd80e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions configs/riscv64.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ sys_enable_next = false
sys_enable_vext = false
sys_enable_writable_fiom = true
sys_enable_writable_misa = true
sys_enable_bext = false
sys_pmp_count = "0 : %i64"
plat_enable_pmp = false
plat_enable_dirty_update = false
plat_enable_misaligned_access = false
Expand Down
22 changes: 22 additions & 0 deletions isla-lib/src/value_parser.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,27 @@ pub Val: Val<B> = {
"false" => Val::Bool(false),
<n:Nat> => Val::I128(i128::from_str(&n).unwrap()),
"-" <n:Nat> => Val::I128(- i128::from_str(&n).unwrap()),
<n:Nat> ":" "%i" <sz:Nat> => {
let sz = u32::from_str(&sz).unwrap();
if sz == 64 {
Val::I64(i64::from_str(&n).unwrap())
} else if sz == 128 {
Val::I128(i128::from_str(&n).unwrap())
} else {
panic!("Cannot parse integer size {}", sz)
}
},
"-" <n:Nat> ":" "%i" <sz:Nat> => {
let sz = u32::from_str(&sz).unwrap();
let nn = format!("-{}", &n);
if sz == 64 {
Val::I64(i64::from_str(&nn).unwrap())
} else if sz == 128 {
Val::I128(i128::from_str(&nn).unwrap())
} else {
panic!("Cannot parse integer size {}", sz)
}
},
<hex:Hex> => {
Val::Bits(B::from_str(&hex)
.unwrap_or_else(|| panic!("Unable to parse bitvector literal {}", hex)))
Expand Down Expand Up @@ -124,6 +145,7 @@ extern {
"hex" => Tok::Hex(<&'input str>),
"bin" => Tok::Bin(<&'input str>),
"cap" => Tok::Cap(<&'input str>),
"%i" => Tok::TyI,
"()" => Tok::Unit,
"," => Tok::Comma,
"-" => Tok::Minus,
Expand Down

0 comments on commit 43bd80e

Please sign in to comment.