Fixing PR27884: allow llvm-mc to accept numbers like 0BEDh as a valid hexadecimal number.
Does this look like a reasonable approach?
Differential D22112
Disambiguate a constant with both 0B prefix and H suffix. ygao on Jul 7 2016, 2:29 PM. Authored by
Details
Fixing PR27884: allow llvm-mc to accept numbers like 0BEDh as a valid hexadecimal number. Does this look like a reasonable approach?
Diff Detail Event TimelineComment Actions Since the parsing style is specified on the command line at startup, can a flag be attached to MCAsmInfo which specifies whether prefix-bool parsing is activated? It looks like there are similar things already put there such as CommentString and DollarIsPC Comment Actions
I did not find a command-line option to control the parsing style. I found a I think what I can do is to add a flag to MCAsmInfo, and then flip the value Current behavior: "0b00" is binary; "0bed" is syntax error; "0b00h" is syntax error; With "0b" prefix disabled, all three above are hexadecimal. Option#2: whether the "h" suffix should be supported. David asked me what is the current behavior with "0777h". So, "0777" => octal number (decimal=511) "0777h" => hexadecimal (decimal=1911) "0x77h" => hexadecimal So it appears that the "h" suffix trumps everything else at the moment. The Option#1 above does not impact the octal numbers, but if we implement Comment Actions It looks like in X86MCAsmInfo.cpp AsmWriterFlavor controls AssemblerDialect which is tied with [Intel|ATT]AsmParserVariant in X86.td My gut feel is allowing both suffix and prefix to coexist with one winning out in certain circumstances is error prone in addition to expanding the accepted syntax beyond what other assemblers accept. It seems like the MCAsmInfo flag would control whether the parser would accept either the prefix or postfix radix specifications though not both and when the Intel/ATT syntax variant is chosen it would pick the appropriate radix parsing function. What do you think? Comment Actions I think what you said makes a lot of sense to me... The practical difficulty .text 1: add rax, 20 .data .long 1b In this example, it would appear ambiguous to me whether the "1b" in data Comment Actions Hi, I am updating the patch based on the latest feedback on PR27884.
Comment Actions There's probably not a really clean way to do this with our one-lexer-rules-them-all model for llvm-mc but I think if we can keep hex output where it was before we at least didn't make things worse.
Comment Actions Pretty close
|
Will CurPtr ever be at the beginning of the buffer, making index -1 invalid?