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

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Mon Jan 1 06:10:22 PST 2018

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.



More information about the llvm-dev mailing list