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

Andrea_DiBiagio at sn.scee.net Andrea_DiBiagio at sn.scee.net
Tue Jul 2 11:26:48 PDT 2013


Hi Bill,

> From: Bill Wendling <wendling at apple.com>
> So...ping?
> 
> Anyone else have a problems with or comments on the patch? (Other 
> than the cleanup that Stefanus mentioned.)
> 
> -bw

I've done some small experiments with attributes generating x86-64 code 
and everything was working as expected.
The change looks good to me. This feature will be extremely useful for a 
piece of work that I plan to do soon so I'd certainly be interested to see 
it committed.

Andrea Di Biagio
SN Systems - Sony Computer Entertainment Group

> 
> 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


**********************************************************************
This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed. 
If you have received this email in error please notify postmaster at scee.net
This footnote also confirms that this email message has been checked for 
all known viruses.
Sony Computer Entertainment Europe Limited
Registered Office: 10 Great Marlborough Street, London W1F 7LP, United 
Kingdom
Registered in England: 3277793
**********************************************************************

P Please consider the environment before printing this e-mail



More information about the llvm-commits mailing list