[llvm] r222410 - Use array_lengthof instead of sizeof(array)/sizeof(element) in a tablegen output.

David Blaikie dblaikie at gmail.com
Wed Nov 19 21:54:50 PST 2014


On Wed, Nov 19, 2014 at 9:22 PM, Craig Topper <craig.topper at gmail.com>
wrote:

> Author: ctopper
> Date: Wed Nov 19 23:22:32 2014
> New Revision: 222410
>
> URL: http://llvm.org/viewvc/llvm-project?rev=222410&view=rev
> Log:
> Use array_lengthof instead of sizeof(array)/sizeof(element) in a tablegen
> output.
>

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.


>
> Modified:
>     llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp
>
> Modified: llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp?rev=222410&r1=222409&r2=222410&view=diff
>
> ==============================================================================
> --- llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp (original)
> +++ llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Wed Nov 19 23:22:32
> 2014
> @@ -379,9 +379,9 @@ RegisterInfoEmitter::EmitRegMappingTable
>        OS << "extern const unsigned " << Namespace
>           << (j == 0 ? "DwarfFlavour" : "EHFlavour") << i << "Dwarf2LSize";
>        if (!isCtor)
> -        OS << " = sizeof(" << Namespace
> +        OS << " = array_lengthof(" << Namespace
>             << (j == 0 ? "DwarfFlavour" : "EHFlavour") << i
> -           << "Dwarf2L)/sizeof(MCRegisterInfo::DwarfLLVMRegPair);\n\n";
> +           << "Dwarf2L);\n\n";
>        else
>          OS << ";\n\n";
>      }
> @@ -427,9 +427,8 @@ RegisterInfoEmitter::EmitRegMappingTable
>        OS << "extern const unsigned " << Namespace
>           << (j == 0 ? "DwarfFlavour" : "EHFlavour") << i << "L2DwarfSize";
>        if (!isCtor)
> -        OS << " = sizeof(" << Namespace
> -           << (j == 0 ? "DwarfFlavour" : "EHFlavour") << i
> -           << "L2Dwarf)/sizeof(MCRegisterInfo::DwarfLLVMRegPair);\n\n";
> +        OS << " = array_lengthof(" << Namespace
> +           << (j == 0 ? "DwarfFlavour" : "EHFlavour") << i <<
> "L2Dwarf);\n\n";
>        else
>          OS << ";\n\n";
>      }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141119/adef972f/attachment.html>


More information about the llvm-commits mailing list