If `true`, colons in ASM parameters will be placed after line breaks.
true:
asm volatile("string", : : val);
false: asm volatile("string", : : val);
Differential D91950
[clang-format] Add BreakBeforeInlineASMColon configuration anastasiia_lukianenko on Nov 23 2020, 2:04 AM. Authored by
Details If `true`, colons in ASM parameters will be placed after line breaks. asm volatile("string", : : val); false: asm volatile("string", : : val);
Diff Detail
Event TimelineComment Actions
Comment Actions Do you think we should show what it looks like with more complex asm examples in the tests? what would the following look like? asm volatile("rbit %[aVal], %[aVal]" : [aVal] "+r"(val) : "[aVal]"(val)); asm ("mov %1, %0\n\t" "add $1, %0" : "=r" (dst) : "r" (src)); For the "purpose of the tape" is there a reason or group of people who prefer this style? (gcc, linux kernel) Comment Actions Nothing will happen with your examples, because the line length is less than column limit. But if I make parameters longer results will be: BreakBeforeInlineASMColon = false; asm volatile("rbffffit %[aVal], %[aVal]" : [aVal] "+r"(val) : "[aVaffffl]"(val)); __asm__ __volatile__("str fffffx0, %0" : "=fffffffffffffffffffffm"(regs->regs[0])); asm volatile("get\t%0,rffffffffsl" stringify(id) : "=dfffffffffffffffffffffff"(val)) BreakBeforeInlineASMColon = true; asm volatile("rbffffit %[aVal], %[aVal]" : [aVal] "+r"(val) : "[aVaffffl]"(val)); __asm__ __volatile__("str fffffx0, %0" : "=fffffffffffffffffffffm"(regs->regs[0])); asm volatile("get\t%0,rffffffffsl" stringify(id) : "=dfffffffffffffffffffffff"(val)) And asking the question who will use this configuration: [1] - https://xenproject.org/ Comment Actions
FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { ... LLVMStyle.BreakBeforeInlineASMColon = false; ...
CHECK_PARSE_BOOL(BreakBeforeInlineASMColon ); Comment Actions My understanding is that the following current behavour asm("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : "DEF" : "GHI"); asm volatile( "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : "DEF" : "GHI"); asm("AAAAAAAAAAAAAAAAAAA" : "DEF" : "GHI"); asm volatile("AAAAAAAAAAAAA" : "DEF" : "GHI"); asm volatile("AAAAAAAAAAAAA" : "DEF"(dst) : "GHI"(src)); asm volatile("AAAAAAAAAAAAA" : "DEF"(dst)); asm volatile("AAAAAAAAAAAAA" : [Foo] "DEF"(dst) : [Foo] "GHI"(src)); asm volatile("AAAAAAAAAAAAA" : % [Foo] "DEF"(dst) : % [Foo] "GHI"(src)); should generate as the following (with the option set to true) correct? asm("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : "DEF" : "GHI"); asm volatile( "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : "DEF" : "GHI"); asm("AAAAAAAAAAAAAAAAAAA" : "DEF" : "GHI"); asm volatile("AAAAAAAAAAAAA" : "DEF" : "GHI"); asm volatile("AAAAAAAAAAAAA" : "DEF"(dst) : "GHI"(src)); asm volatile("AAAAAAAAAAAAA" : "DEF"(dst)); asm volatile("AAAAAAAAAAAAA" : [Foo] "DEF"(dst) : [Foo] "GHI"(src)); asm volatile("AAAAAAAAAAAAA" : %[Foo] "DEF"(dst) : %[Foo] "GHI"(src)); is that correct? I highly recommend adding a few more examples in the test to show this behavior isn't just for "loooong" strings NOTE: there is a bug in the way '%[Foo]' would get formatted to be '% [Foo]' Comment Actions For now without my patch current behavior is the following: asm("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : "DEF" : "GHI"); asm volatile( "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : "DEF" : "GHI"); asm("AAAAAAAAAAAAAAAAAAA" : "DEF" : "GHI"); asm volatile("AAAAAAAAAAAAA" : "DEF" : "GHI"); asm volatile("AAAAAAAAAAAAA" : "DEF"(dst) : "GHI"(src)); asm volatile("AAAAAAAAAAAAA" : "DEF"(dst)); asm volatile("AAAAAAAAAAAAA" : [Foo] "DEF"(dst) : [Foo] "GHI"(src)); asm volatile("AAAAAAAAAAAAA" : % [Foo] "DEF"(dst) : % [Foo] "GHI"(src)); Formatted with clang-format in this way: asm("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : "DEF" : "GHI"); asm volatile( "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : "DEF" : "GHI"); asm("AAAAAAAAAAAAAAAAAAA" : "DEF" : "GHI"); asm volatile("AAAAAAAAAAAAA" : "DEF" : "GHI"); asm volatile("AAAAAAAAAAAAA" : "DEF"(dst) : "GHI"(src)); asm volatile("AAAAAAAAAAAAA" : "DEF"(dst)); asm volatile("AAAAAAAAAAAAA" : [Foo] "DEF"(dst) : [Foo] "GHI"(src)); asm volatile("AAAAAAAAAAAAA" : % [Foo] "DEF"(dst) : % [Foo] "GHI"(src)); So that's why my patch is breaking only long strings. If this is a bug, I can try to fix it. Then I update my patch so the configuration will be as @MyDeveloperDay expected. Comment Actions Maybe I'm confused, if you set this setting isn't it to break before ever ASM Colon is that not what is required? Comment Actions BreakBeforeInlineASMColon configuration was created to have an option of removing this break, because without my patch it breaks before ASM colon in long lines. That's why I saved the behavior of BreakBeforeInlineASMColon=true as it was initially. Comment Actions I think my expectation would be that if you are going to have an option BreakBeforeInlineASMColon then it should do it for all case long and short, otherwise its not going to be clear.
Comment Actions Then we can push it, do you need some one to do that? If yes please post name and email.
Comment Actions Then I am sorry that I've missed that before. But you need to change your bool to an enum and also model the current behavior, so that there is no change in formatting without adapting the .clang-format. A option names maybe Always, Never, and OnlyMultiline? Comment Actions And format what clang-format says. Then it looks good to me.
Comment Actions @MyDeveloperDay @owenpan What shall we do?
Comment Actions IMO we should either commit it with her name only or also include the email you found. |
Are we happy that is the correct default? didn't it always break before?