<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 19, 2014 at 9:22 PM, Craig Topper <span dir="ltr"><<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ctopper<br>
Date: Wed Nov 19 23:22:32 2014<br>
New Revision: 222410<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=222410&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=222410&view=rev</a><br>
Log:<br>
Use array_lengthof instead of sizeof(array)/sizeof(element) in a tablegen output.<br></blockquote><div><br>I can't quite tell from just the diff here, but another option that might be relevant is to use ArrayRef - has the same template argument deduction trick and gives the higher level API of the array.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified:<br>
    llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp<br>
<br>
Modified: llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp?rev=222410&r1=222409&r2=222410&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp?rev=222410&r1=222409&r2=222410&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp (original)<br>
+++ llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Wed Nov 19 23:22:32 2014<br>
@@ -379,9 +379,9 @@ RegisterInfoEmitter::EmitRegMappingTable<br>
       OS << "extern const unsigned " << Namespace<br>
          << (j == 0 ? "DwarfFlavour" : "EHFlavour") << i << "Dwarf2LSize";<br>
       if (!isCtor)<br>
-        OS << " = sizeof(" << Namespace<br>
+        OS << " = array_lengthof(" << Namespace<br>
            << (j == 0 ? "DwarfFlavour" : "EHFlavour") << i<br>
-           << "Dwarf2L)/sizeof(MCRegisterInfo::DwarfLLVMRegPair);\n\n";<br>
+           << "Dwarf2L);\n\n";<br>
       else<br>
         OS << ";\n\n";<br>
     }<br>
@@ -427,9 +427,8 @@ RegisterInfoEmitter::EmitRegMappingTable<br>
       OS << "extern const unsigned " << Namespace<br>
          << (j == 0 ? "DwarfFlavour" : "EHFlavour") << i << "L2DwarfSize";<br>
       if (!isCtor)<br>
-        OS << " = sizeof(" << Namespace<br>
-           << (j == 0 ? "DwarfFlavour" : "EHFlavour") << i<br>
-           << "L2Dwarf)/sizeof(MCRegisterInfo::DwarfLLVMRegPair);\n\n";<br>
+        OS << " = array_lengthof(" << Namespace<br>
+           << (j == 0 ? "DwarfFlavour" : "EHFlavour") << i << "L2Dwarf);\n\n";<br>
       else<br>
         OS << ";\n\n";<br>
     }<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>