Hi Mikhail, What is mentioned in the reference manual is this: // Evaluates to "cmdline1" if the option "-A" is provided on the // command line; to "cmdline2" if "-B" is provided; // otherwise to "cmdline3". (case (switch_on "A"), "cmdline1", (switch_on "B"), "cmdline2", (default), "cmdline3") What is generated is this: if (A) { ... } if (B) { .... } else { .... } IMO, What should be generated is below: if (A) { ... } else if (B) { .... } else { .... } BTW, to give you more details, I am using append_cmd on each switch_on. - Sanjiv
Sanjiv Gupta wrote:> Hi Mikhail, > > What is mentioned in the reference manual is this: > > // Evaluates to "cmdline1" if the option "-A" is provided on the > // command line; to "cmdline2" if "-B" is provided; > // otherwise to "cmdline3". > > (case > (switch_on "A"), "cmdline1", > (switch_on "B"), "cmdline2", > (default), "cmdline3") > > > What is generated is this: > > if (A) { > ... > } > > if (B) { > .... > } else { > .... > } > > > IMO, What should be generated is below: > > if (A) { > ... > } else if (B) { > .... > } else { > .... > } > > BTW, to give you more details, I am using append_cmd on each switch_on. > > > - Sanjiv > > _______________________________________________ >Is the patch below ok? Index: LLVMCConfigurationEmitter.cpp ==================================================================--- LLVMCConfigurationEmitter.cpp (revision 80668) +++ LLVMCConfigurationEmitter.cpp (working copy) @@ -1141,6 +1141,7 @@ Callback, EmitElseIf, OptDescs, O); } else { + EmitElseIf = true; Callback(arg, (std::string(IndentLevel) + Indent1).c_str(), O); } O << IndentLevel << "}\n"; - Sanjiv> LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Mikhail Glushenkov
2009-Sep-05 20:32 UTC
[LLVMdev] tblgen bug in handling case , switch_on
Hi, On Sat, Sep 5, 2009 at 9:12 PM, Sanjiv Gupta<sanjiv.gupta at microchip.com> wrote:> Is the patch below ok? > > Index: LLVMCConfigurationEmitter.cpp > ==================================================================> --- LLVMCConfigurationEmitter.cpp (revision 80668) > +++ LLVMCConfigurationEmitter.cpp (working copy) > @@ -1141,6 +1141,7 @@ > Callback, EmitElseIf, OptDescs, O); > } > else { > + EmitElseIf = true; > Callback(arg, (std::string(IndentLevel) + Indent1).c_str(), O); > } > O << IndentLevel << "}\n";No, this is not OK - EmitCaseConstructHandler is supposed to be able to generate both 'if (...) ... if (...) ... if (...) ...' and 'if (...) ... else if (...) ... else ...' forms. That's what the EmitElseIf argument controls. BTW, the example in the documentation generates the 'if (...) ... else if (...) ... else ...' form since the 'case' there is assumed to be inside the 'cmd_line' property. Can you provide a small TableGen code example of what you're trying to do which is not working? -- () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments