[llvm-dev] Inspecting 'Triple' from arbitrary source files

Martin J. O'Riordan via llvm-dev llvm-dev at lists.llvm.org
Mon Jan 1 12:56:58 PST 2018


Haha :-)

-----Original Message-----
From: Tim Northover [mailto:t.p.northover at gmail.com] 
Sent: 01 January 2018 18:09
To: Martin J. O'Riordan <MartinO at theheart.ie>
Cc: LLVM Developers <llvm-dev at lists.llvm.org>
Subject: Re: [llvm-dev] Inspecting 'Triple' from arbitrary source files

There's always the hypothetical

    template<typename T> llvm::Triple giveMeATripleDamnYou(const T &);

Just keep adding implementations until you stop needing to. ;-)

Cheers.

Tim.

On 1 January 2018 at 17:00, Martin J. O'Riordan <MartinO at theheart.ie> wrote:
> Thanks Tim,
>
> Sometimes my hacks last longer than I want as it isn't always apparent how I can implement it properly.  At the moment I am looking at changes I need to 'MachineBasicBlock::ReplaceUsesOfBlockWith'.  It is most likely that I need to handle the issue in a different way, but the change I need works here for my target for the time being, but breaks X86 which I also build for (single clang, multiple targets).
>
> But eventually I retire these hacks as the correct solution becomes apparent, I personally hate messing around with the target-independent code for a target-specific purpose as it breaks the abstractions.
>
> All the best and thanks again,
>
>         MartinO
>
> -----Original Message-----
> From: Tim Northover [mailto:t.p.northover at gmail.com]
> Sent: 01 January 2018 14:10
> To: Martin J. O'Riordan <MartinO at theheart.ie>
> Cc: LLVM Developers <llvm-dev at lists.llvm.org>
> Subject: Re: [llvm-dev] Inspecting 'Triple' from arbitrary source 
> files
>
> Hi Martin,
>
> On 1 January 2018 at 12:42, Martin J. O'Riordan via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>> Is there a general purpose way of accessing the current 'Triple' from 
>> any where in the code so that I can add these checks?  In many 
>> places, I can access it via some argument to a function, or from a 
>> member of the class to which the function belongs, but this is not always possible.
>
> Normally this would be handled by adding target-specific hooks describing the behaviour or optimization rather than inspecting the triple directly. There are various classes dotted through the pipeline designed to provide this information (TargetTransformInfo and TargetMachine being the most obvious).
>
>> During prototyping and exploring, making temporary changes to the 
>> target-independent code is the best way until I understand how to 
>> best implement the final version.
>
> For purely personal hacks I'd go via Module::getTargetTriple myself, but then for personal hacks I probably wouldn't even bother checking the target.
>
> Cheers.
>
> Tim.
>



More information about the llvm-dev mailing list