[PATCH] D22112: Disambiguate a constant with both 0B prefix and H suffix.

Colin LeMahieu via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 25 09:48:39 PDT 2016


colinl added a comment.

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 at: tools/clang/test/CodeGenCXX/ms-inline-asm-return.cpp:88
@@ -87,3 +87,3 @@
 // CHECK-LABEL: define i64 @f_s8()
-// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$0x01010101\0A\09mov edx, $$0x01010101", "=A,~{eax},{{.*}}"
+// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$16843009\0A\09mov edx, $$16843009", "=A,~{eax},{{.*}}"
 // CHECK: store i64 %[[r]], i64* %{{.*}}
----------------
ygao wrote:
> colinl wrote:
> > What made these switch from printing hex to decimal?
> I was curious about it my own self...
> 
> X86AsmParser::ParseIntelOperand() makes this decision by comparing the following
> two sizes: (search for a comment "rewrite the complex expression as a single immediate" to
> locate the codes)
> 1. size of the token, which is "next token position - current token position".
>    e.g., given "0b0101U", the size would be 7.
> 2. size of the string passed as the first argument to the constructor of intToken(). It is the "Result"
>    string used in several places of the LexDigit() function. e.g., given "0b0101U", the
>    "Result" string would be 6; the "U" suffix is not counted.
> 
> If these two sizes are equal, the original expression is printed, otherwise the
> expression is rewritten as a decimal integer. In this case, "01010101h" will get rewritten with or
> without my changes, because the two sizes are 9 vs 8; on the other hand, my
> changes disallow "0x" prefix for MS-Intel inline assembly.
It looks like this is under a call to isParsingInlineAsm() which will has the prefix disallowed; does the AOK_ImmPrefix rewrite ever get used at this point?  It seems like we need a AOK_ImmSuffix rewrite and place it here which should return it to hex output but in the correct format for MS inline asm.


https://reviews.llvm.org/D22112





More information about the llvm-commits mailing list