[PATCH] D11822: Resurrect RegisterAsmStreamer

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 7 12:21:06 PDT 2015


For what it is worth, WebAssembly seems to manage to just use nullptr:

  TextSection = nullptr;
    DataSection = nullptr;
    BSSSection = nullptr;
    ReadOnlySection = nullptr;

On 7 August 2015 at 15:09, Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote:
> To be clear, the idea is to avoid *creating* the sections, no avoiding
> printing them, correct?
>
> Ins't all that you need to do is overload (or add an if to) InitSections?
>
> On 6 August 2015 at 18:50, Matt Arsenault <Matthew.Arsenault at amd.com> wrote:
>> arsenm updated this revision to Diff 31486.
>> arsenm added a comment.
>>
>> Rebase to remove unrelated context from diff
>>
>>
>> http://reviews.llvm.org/D11822
>>
>> Files:
>>   include/llvm/Support/TargetRegistry.h
>>
>> Index: include/llvm/Support/TargetRegistry.h
>> ===================================================================
>> --- include/llvm/Support/TargetRegistry.h
>> +++ include/llvm/Support/TargetRegistry.h
>> @@ -142,6 +142,15 @@
>>                                              raw_pwrite_stream &OS,
>>                                              MCCodeEmitter *Emitter,
>>                                              bool RelaxAll);
>> +  typedef MCStreamer *(*AsmStreamerCtorTy)(MCContext &Ctx,
>> +                                           std::unique_ptr<formatted_raw_ostream> OS,
>> +                                           bool IsVerboseAsm,
>> +                                           bool UseDwarfDirectory,
>> +                                           MCInstPrinter *InstPrint,
>> +                                           MCCodeEmitter *CE,
>> +                                           MCAsmBackend *TAB,
>> +                                           bool ShowInst);
>> +
>>    typedef MCTargetStreamer *(*NullTargetStreamerCtorTy)(MCStreamer &S);
>>    typedef MCTargetStreamer *(*AsmTargetStreamerCtorTy)(
>>        MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint,
>> @@ -229,6 +238,10 @@
>>    MachOStreamerCtorTy MachOStreamerCtorFn;
>>    ELFStreamerCtorTy ELFStreamerCtorFn;
>>
>> +  /// AsmStreamerCtorFn - Construction function for this target's
>> +  /// AsmStreamer, if registered (default = llvm::createAsmStreamer).
>> +  AsmStreamerCtorTy AsmStreamerCtorFn;
>> +
>>    /// Construction function for this target's null TargetStreamer, if
>>    /// registered (default = nullptr).
>>    NullTargetStreamerCtorTy NullTargetStreamerCtorFn;
>> @@ -252,7 +265,8 @@
>>  public:
>>    Target()
>>        : COFFStreamerCtorFn(nullptr), MachOStreamerCtorFn(nullptr),
>> -        ELFStreamerCtorFn(nullptr), NullTargetStreamerCtorFn(nullptr),
>> +        ELFStreamerCtorFn(nullptr), AsmStreamerCtorFn(nullptr),
>> +        NullTargetStreamerCtorFn(nullptr),
>>          AsmTargetStreamerCtorFn(nullptr), ObjectTargetStreamerCtorFn(nullptr),
>>          MCRelocationInfoCtorFn(nullptr), MCSymbolizerCtorFn(nullptr) {}
>>
>> @@ -472,9 +486,18 @@
>>                                  MCInstPrinter *InstPrint, MCCodeEmitter *CE,
>>                                  MCAsmBackend *TAB, bool ShowInst) const {
>>      formatted_raw_ostream &OSRef = *OS;
>> -    MCStreamer *S = llvm::createAsmStreamer(Ctx, std::move(OS), IsVerboseAsm,
>> -                                            UseDwarfDirectory, InstPrint, CE,
>> -                                            TAB, ShowInst);
>> +
>> +    MCStreamer *S;
>> +    if (AsmStreamerCtorFn) {
>> +      S = AsmStreamerCtorFn(Ctx, std::move(OS), IsVerboseAsm,
>> +                            UseDwarfDirectory, InstPrint, CE,
>> +                            TAB, ShowInst);
>> +    } else {
>> +      S = llvm::createAsmStreamer(Ctx, std::move(OS), IsVerboseAsm,
>> +                                  UseDwarfDirectory, InstPrint, CE,
>> +                                  TAB, ShowInst);
>> +    }
>> +
>>      createAsmTargetStreamer(*S, OSRef, InstPrint, IsVerboseAsm);
>>      return S;
>>    }
>> @@ -808,6 +831,19 @@
>>      T.ELFStreamerCtorFn = Fn;
>>    }
>>
>> +  /// RegisterAsmStreamer - Register an assembly MCStreamer implementation
>> +  /// for the given target.
>> +  ///
>> +  /// Clients are responsible for ensuring that registration doesn't occur
>> +  /// while another thread is attempting to access the registry. Typically
>> +  /// this is done by initializing all targets at program startup.
>> +  ///
>> +  /// @param T - The target being registered.
>> +  /// @param Fn - A function to construct an MCStreamer for the target.
>> +  static void RegisterAsmStreamer(Target &T, Target::AsmStreamerCtorTy Fn) {
>> +    T.AsmStreamerCtorFn = Fn;
>> +  }
>> +
>>    static void RegisterNullTargetStreamer(Target &T,
>>                                           Target::NullTargetStreamerCtorTy Fn) {
>>      T.NullTargetStreamerCtorFn = Fn;
>>
>>


More information about the llvm-commits mailing list