[PATCH] Changing the Back-end when Target Options Change

Bill Wendling wendling at apple.com
Wed Jun 26 11:42:37 PDT 2013


So...ping?

Anyone else have a problems with or comments on the patch? (Other than the cleanup that Stefanus mentioned.)

-bw

-------------- next part --------------
A non-text attachment was scrubbed...
Name: changing-target-options.2.patch
Type: application/octet-stream
Size: 89807 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130626/c217d244/attachment.obj>
-------------- next part --------------


On Jun 21, 2013, at 11:14 AM, Bill Wendling <wendling at apple.com> wrote:

> On Jun 20, 2013, at 6:48 AM, "Du Toit, Stefanus" <stefanus.du.toit at intel.com> wrote:
> 
>> Hi Bill,
>> 
>> From:  Bill Wendling <wendling at apple.com>
>>> For those not interested in slugging their way through a ton of
>>> refactoring code, here's a cleaner patch.
>>> 
>>> The executive summary:
>>> 
>>> This regenerates the TargetMachine object if the any of the values in
>>> TargetOptions changes. The regeneration is recursive, because creating
>>> TargetMachine pretty much creates all of the other back-end objects that
>>> are needed for code generation.
>> 
>> You could use the "curiously recurring template pattern" and add an
>> instance of a class template in the middle of the inheritance hierarchy,
>> e.g. something alone the lines of:
>> 
>> template<typename Derived>
>> class TargetMachineHelper : public TargetMachine {
>> TargetMachine *
>> regenerateWithOptionsImpl(const TargetOptions &Opts,
>>                           Reloc::Model RM,
>>                           CodeModel::Model CM,
>>                           CodeGenOpt::Level OptLvl,
>>                           std::string &targetTriple,
>>                           std::string &targetCPU,
>>                           std::string &targetFS) {
>>   TargetPassConfig *TPC = PassConfig;
>> 
>>   this->~Derived();
>>   Derived *NewTM = new (this)
>>     Derived(TheTarget, targetTriple, targetCPU, targetFS,
>>             Opts, RM, CM, OptLvl);
>> 
>>   if (TPC)
>>     NewTM->PassConfig = TPC->regenerateWithTargetMachine(NewTM);
>> 
>>   return NewTM;
>> }
>> };
>> 
>> // Then, for each backend, change the inheritance like so:
>> 
>> class MyTargetMachine : public TargetMachineHelper<MyTargetMachine> {
>> // ...
>> 
>> (I'm sure there are errors in the above, but hopefully it gets the idea
>> across)
>> 
>> This would remove the need to define all of these similar-looking
>> functions in the backends. Should work for PassConfig too.
>> 
> Not a bad idea. I'll look into it. Thanks!
> 
> -bw
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list