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

Dan Gohman dan433584 at gmail.com
Tue Jul 2 11:40:58 PDT 2013


This patch still has the placement new thing I was initially concerned
about, but if it isn't worth holding up progress for, that's fine.

Dan


On Wed, Jun 26, 2013 at 11:42 AM, Bill Wendling <wendling at apple.com> wrote:

> So...ping?
>
> Anyone else have a problems with or comments on the patch? (Other than the
> cleanup that Stefanus mentioned.)
>
> -bw
>
>
>
>
> 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
>
>
> _______________________________________________
> 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/20130702/95427201/attachment.html>


More information about the llvm-commits mailing list