<div class="socmaildefaultfont" dir="ltr" style="font-family:Arial, Helvetica, sans-serif;font-size:10pt" ><div dir="ltr" ><p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" >Hi All,</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" > </p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" >While processing an inline asm block, within AsmPrinterInlineAsm.cpp, the inline asm dialect is forcibly set by the AsmParser. </p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" > </p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" >```<br style="outline: none;" >void AsmPrinter::emitInlineAsm(StringRef Str, const MCSubtargetInfo &STI,</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" > const MCTargetOptions &MCOptions,</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" > const MDNode *LocMDNode,</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" > InlineAsm::AsmDialect Dialect) const {</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" >....</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" > if (!TAP)</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" > report_fatal_error("Inline asm not supported by this streamer because"</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" > " we don't have an asm parser for this target\n");</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" > Parser->setAssemblerDialect(Dialect); // —> SETTING DIALECT HERE</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" > Parser->setTargetParser(*TAP.get());</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" > // Enable lexing Masm binary and hex integer literals in intel inline</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" > // assembly.</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" > if (Dialect == InlineAsm::AD_Intel)</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" > Parser->getLexer().setLexMasmIntegers(true);</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" >....</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" >}<br style="outline: none;" >```</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" > </p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" >The overridden getAssemblerDialect method in AsmParser.cpp is set up as follows.</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" > </p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" >```<br style="outline: none;" > unsigned getAssemblerDialect() override {</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" > if (AssemblerDialect == ~0U)</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" > return MAI.getAssemblerDialect();</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" > else</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" > return AssemblerDialect;</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" > }<br style="outline: none;" >```</p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue";" ><br style="outline: none;" >Because of setting the inline asm dialect in AsmPrinterInlineAsm.cpp, any queries to the overridden getAssemblerDialect() method elsewhere, will return the set inline assembler dialect in AsmParser, and not the assembler dialect field in the MachineAsmInfo.<br style="outline: none;" ><br style="outline: none;" >My question is, is this strictly necessary? EmitGCCInlineAsmStr and EmitMSInlineAsmStr is already set up to deal with GNU asm and Intel asm flavours, and within the EmitMSInlineAsmStr function, the .intel_syntax directive is explicitly emitted. Couldn’t we do away with setting the dialect in AsmPrinterInlineAsm.cpp? (and subsequently change the overridden function to just return the AssemblerDialect field of the MachineAsmInfo instance). Are there other case(s) as to why we’re setting it?<br style="outline: none;" ><br style="outline: none;" >Because otherwise, if we introduce another assembler dialect/variant within the respective MCAsmInfo instance (that might be based off the standard two inline asm dialects from the frontend), and we want to make use of it in the backend (Target)AsmParser, we would have to explicitly query MCAsmInfo to get the dialect (for any reasons) and not the dialect set in the Parser. I'm not too sure if this is "correct" to do or if there's another way of going about it. </p>
<p style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" ><br style="outline: none;" >Thanks! <br style="outline: none;" ><br style="outline: none;" >Best Regards,</p>
<div style="outline: none; caret-color: rgb(18, 18, 18); color: rgb(18, 18, 18); margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; min-height: 14px;" >Anirudh Prasad</div></div></div><BR>