[PATCH] Teach intrinsics to report their required target features

Pete Cooper peter_cooper at apple.com
Sat May 30 09:50:31 PDT 2015


Hey Justin

LGTM with this line changed to return a StringRef.  With a constant array of strings local to a method I believe thats safe.  Otherwise move the array to be a static global then use a StringRef.

+std::string Intrinsic::getRequiredFeature(ID IntrinsicID) {

For future, it would be great to find a way to move some of the target feature strings and their generation to a td file shared with clang, the backends, and this new code you’ve written.  I don’t think what you’ve done here should in any way require that work, but it makes it clear that it would be nice to have.

In particular, clang has methods like X86TargetInfo::getDefaultFeatures which use all the same feature strings you’ve had to define here.

Cheers,
Pete
> On May 29, 2015, at 5:15 PM, Justin Bogner <mail at justinbogner.com> wrote:
> 
> This implements a way to look up the required target feature for a
> particular target-specific intrinsic so that frontends can detect and
> report unsupported target intrinsics, rather than emitting them and then
> crashing later in SelectionDAG.
> 
> I'll follow this up with a change in clang that calls into this when
> lowering intrinsics in CGBuiltin and checks if a required feature is
> available using clang::TargetInfo::hasFeature.
> 
> This ends up being a very simple and unobtrusive way to do this, and
> gives nice error messages instead of crashing and burning when somebody
> uses (for example) the wrong GCC builtin for their specific target.
> 
> The first patch is the tablegen change and the update to the intrinsics
> API, the other two are mostly-complete updates to the X86 and ARM
> intrinsics tablegen files to show what this looks like. Assuming
> everyone's happy with the approach, I'll clean those up and audit them
> for correctness before they go in.
> 
> Okay to go ahead with this?
> 
> <0001-IR-Teach-intrinsics-to-report-their-required-target-.patch><0002-wip-Categorize-IntrinsicsX86-with-TargetFeatures.patch><0003-wip-Categorize-IntrinsicsARM-with-TargetFeatures.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list