[cfe-commits] [PATCH] use templates instead of creating a new class for each OS/Target combination

Török Edwin edwintorok at gmail.com
Tue Jun 30 09:25:58 PDT 2009


On 2009-06-30 08:45, Chris Lattner wrote:
>
> On Jun 29, 2009, at 12:19 PM, Török Edwin wrote:
>
>> Hi,
>>
>> The attached patch changes the Linux and FreeBSD targetinfo classes to
>> be templates,
>> allowing them to be instantiated with any target.
>>
>> Besides avoiding code duplication (the LinuxX86_32TargetInfo wasn't much
>> different from LinuxX64_TargetInfo except it inherited from a different
>> class),
>> it also makes it easier to add support for a new target for an already
>> supported OS.
>> It also avoids the need to create a new class for each OS / Target
>> combination.
>>
>> Please review.
>
> This looks good to me.  If you care, you could go for a fully
> policy-based design by making the architecture be a template argument
> and use one template class for all the instantiations.
>


Thanks, attached new patch that templatizes most of the OS specific
targetinfos (except win32, which support one target only anyway).

It also unifies the darwin targets. Also definining __LP64__ for *BSD is
not needed, the x86-64 targets themselves already define it.

The change looks big, because of all the code moved around, sorry about
that, it might be easier to review the changes by applying the patch to
the file and reading that ;)

Best regards,
--Edwin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: targets.patch
Type: text/x-diff
Size: 21980 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20090630/6a5a714f/attachment.patch>


More information about the cfe-commits mailing list