[llvm-commits] [llvm] r78802 - in /llvm/trunk: include/llvm/Target/ lib/CodeGen/ lib/Target/ARM/ lib/Target/Alpha/ lib/Target/Blackfin/ lib/Target/CellSPU/ lib/Target/MSP430/ lib/Target/Mips/ lib/Target/PIC16/ lib/Target/PowerPC/ lib/Target/Sparc
Daniel Dunbar
daniel at zuster.org
Wed Aug 12 20:31:20 PDT 2009
On Wed, Aug 12, 2009 at 12:22 AM, Chris Lattner<sabre at nondot.org> wrote:
> Author: lattner
> Date: Wed Aug 12 02:22:17 2009
> New Revision: 78802
>
> URL: http://llvm.org/viewvc/llvm-project?rev=78802&view=rev
> Log:
> Change TargetAsmInfo to be constructed via TargetRegistry from a Target+Triple
> pair instead of from a virtual method on TargetMachine. This cuts the final
> ties of TargetAsmInfo to TargetMachine, meaning that MC can now use
> TargetAsmInfo.
Nice! One comment...
> + /// RegisterAsmInfoFn - Helper template for registering a target assembly info
> + /// implementation. This invokes the specified function to do the
> + /// construction. Usage:
> + ///
> + /// extern "C" void LLVMInitializeFooTarget() {
> + /// extern Target TheFooTarget;
> + /// RegisterAsmInfoFn X(TheFooTarget, TheFunction);
> + /// }
> + struct RegisterAsmInfoFn {
> + RegisterAsmInfoFn(Target &T, Target::AsmInfoCtorFnTy Fn) {
> + TargetRegistry::RegisterAsmInfo(T, Fn);
> + }
> + };
I find this more confusing than helpful, why not just have targets
that need to implement their own constructor call TargetRegistry
directly, instead of wrapping the call in a struct?
Alternately, if this is something we expect many clients to need to
do, perhaps we should find a way to have the TargetRegistry help out.
- Daniel
More information about the llvm-commits
mailing list