This is an archive of the discontinued LLVM Phabricator instance.

SystemZ: Add ImmArg to intrinsics
ClosedPublic

Authored by arsenm on Feb 18 2019, 8:02 AM.

Details

Reviewers
uweigand
Summary

I found these by asserting in clang for any GCCBuiltin that doesn't
require mangling and requires a constant for the builtin. This means
that intrinsics are missing which don't use GCCBuiltin, don't have
builtins defined in clang, or were missing the constant annotation in
the builtin definition.

Diff Detail

Event Timeline

arsenm created this revision.Feb 18 2019, 8:02 AM

I'm not quite sure I understand the logic why some intrinsics that require immediate arguments are marked with ImmArg, but others are not?

Shouldn't we mark all of them? The ones I see missing in your patch are:

defm int_s390_vfae  : SystemZTernaryIntCCBHF;
defm int_s390_vfaez : SystemZTernaryIntCCBHF;
defm int_s390_vstrc  : SystemZQuaternaryIntCCBHF;
defm int_s390_vstrcz : SystemZQuaternaryIntCCBHF;
def int_s390_vfmaxdb : Intrinsic<[llvm_v2f64_ty],
def int_s390_vfmindb : Intrinsic<[llvm_v2f64_ty],
def int_s390_vfmaxsb : Intrinsic<[llvm_v4f32_ty],
def int_s390_vfminsb : Intrinsic<[llvm_v4f32_ty],
def int_s390_vftcidb : SystemZBinaryConvIntCC<llvm_v2i64_ty, llvm_v2f64_ty>;
def int_s390_vftcisb : SystemZBinaryConvIntCC<llvm_v4i32_ty, llvm_v4f32_ty>;
def int_s390_vfidb : Intrinsic<[llvm_v2f64_ty],
def int_s390_vfisb : Intrinsic<[llvm_v4f32_ty],

Maybe it would actually make more sense to add the ImmArg directly in the SystemZ*Int* helper macros; those intrinsics really all need immediate arguments. (The sole exception I can see is verll, but that probably should use a different helper then.)

I'm not quite sure I understand the logic why some intrinsics that require immediate arguments are marked with ImmArg, but others are not?

Shouldn't we mark all of them? The ones I see missing in your patch are:

defm int_s390_vfae  : SystemZTernaryIntCCBHF;
defm int_s390_vfaez : SystemZTernaryIntCCBHF;
defm int_s390_vstrc  : SystemZQuaternaryIntCCBHF;
defm int_s390_vstrcz : SystemZQuaternaryIntCCBHF;
def int_s390_vfmaxdb : Intrinsic<[llvm_v2f64_ty],
def int_s390_vfmindb : Intrinsic<[llvm_v2f64_ty],
def int_s390_vfmaxsb : Intrinsic<[llvm_v4f32_ty],
def int_s390_vfminsb : Intrinsic<[llvm_v4f32_ty],
def int_s390_vftcidb : SystemZBinaryConvIntCC<llvm_v2i64_ty, llvm_v2f64_ty>;
def int_s390_vftcisb : SystemZBinaryConvIntCC<llvm_v4i32_ty, llvm_v4f32_ty>;
def int_s390_vfidb : Intrinsic<[llvm_v2f64_ty],
def int_s390_vfisb : Intrinsic<[llvm_v4f32_ty],

Maybe it would actually make more sense to add the ImmArg directly in the SystemZ*Int* helper macros; those intrinsics really all need immediate arguments. (The sole exception I can see is verll, but that probably should use a different helper then.)

I'm doing this blindly based on the definitions here https://github.com/llvm-mirror/clang/blob/master/include/clang/Basic/BuiltinsSystemZ.def
Are these accurate and complete?

I'm not quite sure I understand the logic why some intrinsics that require immediate arguments are marked with ImmArg, but others are not?

Shouldn't we mark all of them? The ones I see missing in your patch are:

defm int_s390_vfae  : SystemZTernaryIntCCBHF;
defm int_s390_vfaez : SystemZTernaryIntCCBHF;
defm int_s390_vstrc  : SystemZQuaternaryIntCCBHF;
defm int_s390_vstrcz : SystemZQuaternaryIntCCBHF;
def int_s390_vfmaxdb : Intrinsic<[llvm_v2f64_ty],
def int_s390_vfmindb : Intrinsic<[llvm_v2f64_ty],
def int_s390_vfmaxsb : Intrinsic<[llvm_v4f32_ty],
def int_s390_vfminsb : Intrinsic<[llvm_v4f32_ty],
def int_s390_vftcidb : SystemZBinaryConvIntCC<llvm_v2i64_ty, llvm_v2f64_ty>;
def int_s390_vftcisb : SystemZBinaryConvIntCC<llvm_v4i32_ty, llvm_v4f32_ty>;
def int_s390_vfidb : Intrinsic<[llvm_v2f64_ty],
def int_s390_vfisb : Intrinsic<[llvm_v4f32_ty],

Maybe it would actually make more sense to add the ImmArg directly in the SystemZ*Int* helper macros; those intrinsics really all need immediate arguments. (The sole exception I can see is verll, but that probably should use a different helper then.)

I'm doing this blindly based on the definitions here https://github.com/llvm-mirror/clang/blob/master/include/clang/Basic/BuiltinsSystemZ.def
Are these accurate and complete?

Yes, they are ... but note that all the intrinsics I listed above are actually marked as requiring immediates there too. (E.g. int_s390_vfmaxdb gets emitted from __builtin_s390_vfmaxdb, which has an "Ii" marker.)

I'm not quite sure I understand the logic why some intrinsics that require immediate arguments are marked with ImmArg, but others are not?

Shouldn't we mark all of them? The ones I see missing in your patch are:

defm int_s390_vfae  : SystemZTernaryIntCCBHF;
defm int_s390_vfaez : SystemZTernaryIntCCBHF;
defm int_s390_vstrc  : SystemZQuaternaryIntCCBHF;
defm int_s390_vstrcz : SystemZQuaternaryIntCCBHF;
def int_s390_vfmaxdb : Intrinsic<[llvm_v2f64_ty],
def int_s390_vfmindb : Intrinsic<[llvm_v2f64_ty],
def int_s390_vfmaxsb : Intrinsic<[llvm_v4f32_ty],
def int_s390_vfminsb : Intrinsic<[llvm_v4f32_ty],
def int_s390_vftcidb : SystemZBinaryConvIntCC<llvm_v2i64_ty, llvm_v2f64_ty>;
def int_s390_vftcisb : SystemZBinaryConvIntCC<llvm_v4i32_ty, llvm_v4f32_ty>;
def int_s390_vfidb : Intrinsic<[llvm_v2f64_ty],
def int_s390_vfisb : Intrinsic<[llvm_v4f32_ty],

Maybe it would actually make more sense to add the ImmArg directly in the SystemZ*Int* helper macros; those intrinsics really all need immediate arguments. (The sole exception I can see is verll, but that probably should use a different helper then.)

I'm doing this blindly based on the definitions here https://github.com/llvm-mirror/clang/blob/master/include/clang/Basic/BuiltinsSystemZ.def
Are these accurate and complete?

Yes, they are ... but note that all the intrinsics I listed above are actually marked as requiring immediates there too. (E.g. int_s390_vfmaxdb gets emitted from __builtin_s390_vfmaxdb, which has an "Ii" marker.)

These ones aren't using GCCBuiltin, so that's why they were missed

arsenm updated this revision to Diff 187267.Feb 18 2019, 12:09 PM

Handle missed intrinsics

Thanks, this should now cover all intrinsics with immediate arguments. Some additional comments inline (mostly cosmetic, with one real fix for int_s390_vfisb).

include/llvm/IR/IntrinsicsSystemZ.td
46

There should be no need to change this.

51

Or this.

55

Just hard-code ImmArg<2> here, it will be needed by all users.

64

Likewise just hard-code ImmArg<3>.

166–169

This change can then go away.

178–181

And this.

184–187

And this too.

305

This would be covered by the default.

345

And those two.

363

Likewise.

408

This should have both ImmArg<1> and ImmArg<2>.

arsenm updated this revision to Diff 187583.Feb 20 2019, 7:20 AM
arsenm marked 11 inline comments as done.

Address comments

uweigand accepted this revision.Feb 20 2019, 7:29 AM

LGTM, thanks!

This revision is now accepted and ready to land.Feb 20 2019, 7:29 AM
arsenm closed this revision.Mar 13 2019, 12:46 PM

r356091