Index: include/llvm/IR/IntrinsicsSystemZ.td =================================================================== --- include/llvm/IR/IntrinsicsSystemZ.td +++ include/llvm/IR/IntrinsicsSystemZ.td @@ -38,32 +38,36 @@ : Intrinsic<[result, llvm_i32_ty], [arg, arg], [IntrNoMem]>; class SystemZBinaryConvIntCC - : Intrinsic<[result, llvm_i32_ty], [arg, llvm_i32_ty], [IntrNoMem]>; + : Intrinsic<[result, llvm_i32_ty], [arg, llvm_i32_ty], + [IntrNoMem, ImmArg<1>]>; class SystemZBinaryCC : SystemZBinaryConvCC; -class SystemZTernaryConv +class SystemZTernaryConv intr_properties = []> : GCCBuiltin<"__builtin_s390_" ## name>, - Intrinsic<[result], [arg, arg, result], [IntrNoMem]>; + Intrinsic<[result], [arg, arg, result], !listconcat([IntrNoMem], intr_properties)>; -class SystemZTernary - : SystemZTernaryConv; +class SystemZTernary intr_properties = []> + : SystemZTernaryConv; -class SystemZTernaryInt +class SystemZTernaryInt intr_properties = []> : GCCBuiltin<"__builtin_s390_" ## name>, - Intrinsic<[type], [type, type, llvm_i32_ty], [IntrNoMem]>; + Intrinsic<[type], [type, type, llvm_i32_ty], !listconcat([IntrNoMem], intr_properties)>; class SystemZTernaryIntCC - : Intrinsic<[type, llvm_i32_ty], [type, type, llvm_i32_ty], [IntrNoMem]>; + : Intrinsic<[type, llvm_i32_ty], [type, type, llvm_i32_ty], + [IntrNoMem, ImmArg<2>]>; -class SystemZQuaternaryInt +class SystemZQuaternaryInt intr_properties = []> : GCCBuiltin<"__builtin_s390_" ## name>, - Intrinsic<[type], [type, type, type, llvm_i32_ty], [IntrNoMem]>; + Intrinsic<[type], [type, type, type, llvm_i32_ty], + !listconcat([IntrNoMem], intr_properties)>; class SystemZQuaternaryIntCC : Intrinsic<[type, llvm_i32_ty], [type, type, type, llvm_i32_ty], - [IntrNoMem]>; + [IntrNoMem, ImmArg<3>]>; multiclass SystemZUnaryExtBHF { def b : SystemZUnaryConv; @@ -161,10 +165,10 @@ def f : SystemZTernary; } -multiclass SystemZTernaryIntBHF { - def b : SystemZTernaryInt; - def h : SystemZTernaryInt; - def f : SystemZTernaryInt; +multiclass SystemZTernaryIntBHF intr_properties = []> { + def b : SystemZTernaryInt; + def h : SystemZTernaryInt; + def f : SystemZTernaryInt; } multiclass SystemZTernaryIntCCBHF { @@ -173,14 +177,16 @@ def fs : SystemZTernaryIntCC; } -multiclass SystemZQuaternaryIntBHF { - def b : SystemZQuaternaryInt; - def h : SystemZQuaternaryInt; - def f : SystemZQuaternaryInt; +multiclass SystemZQuaternaryIntBHF intr_properties = []> { + def b : SystemZQuaternaryInt; + def h : SystemZQuaternaryInt; + def f : SystemZQuaternaryInt; } -multiclass SystemZQuaternaryIntBHFG : SystemZQuaternaryIntBHF { - def g : SystemZQuaternaryInt; +multiclass SystemZQuaternaryIntBHFG intr_properties = []> : + SystemZQuaternaryIntBHF { + def g : SystemZQuaternaryInt; } multiclass SystemZQuaternaryIntCCBHF { @@ -231,11 +237,11 @@ let TargetPrefix = "s390" in { def int_s390_lcbb : GCCBuiltin<"__builtin_s390_lcbb">, Intrinsic<[llvm_i32_ty], [llvm_ptr_ty, llvm_i32_ty], - [IntrNoMem]>; + [IntrNoMem, ImmArg<1>]>; def int_s390_vlbb : GCCBuiltin<"__builtin_s390_vlbb">, Intrinsic<[llvm_v16i8_ty], [llvm_ptr_ty, llvm_i32_ty], - [IntrReadMem, IntrArgMemOnly]>; + [IntrReadMem, IntrArgMemOnly, ImmArg<1>]>; def int_s390_vll : GCCBuiltin<"__builtin_s390_vll">, Intrinsic<[llvm_v16i8_ty], [llvm_i32_ty, llvm_ptr_ty], @@ -244,7 +250,7 @@ def int_s390_vpdi : GCCBuiltin<"__builtin_s390_vpdi">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_i32_ty], - [IntrNoMem]>; + [IntrNoMem, ImmArg<2>]>; def int_s390_vperm : GCCBuiltin<"__builtin_s390_vperm">, Intrinsic<[llvm_v16i8_ty], @@ -298,7 +304,7 @@ defm int_s390_verllv : SystemZBinaryBHFG<"verllv">; defm int_s390_verll : SystemZBinaryIntBHFG<"verll">; - defm int_s390_verim : SystemZQuaternaryIntBHFG<"verim">; + defm int_s390_verim : SystemZQuaternaryIntBHFG<"verim", [ImmArg<3>]>; def int_s390_vsl : SystemZBinary<"vsl", llvm_v16i8_ty>; def int_s390_vslb : SystemZBinary<"vslb", llvm_v16i8_ty>; @@ -310,7 +316,7 @@ def int_s390_vsldb : GCCBuiltin<"__builtin_s390_vsldb">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i32_ty], - [IntrNoMem]>; + [IntrNoMem, ImmArg<2>]>; defm int_s390_vscbi : SystemZBinaryBHFG<"vscbi">; @@ -338,9 +344,9 @@ defm int_s390_vch : SystemZCompareBHFG<"vch">; defm int_s390_vchl : SystemZCompareBHFG<"vchl">; - defm int_s390_vfae : SystemZTernaryIntBHF<"vfae">; + defm int_s390_vfae : SystemZTernaryIntBHF<"vfae", [ImmArg<2>]>; defm int_s390_vfae : SystemZTernaryIntCCBHF; - defm int_s390_vfaez : SystemZTernaryIntBHF<"vfaez">; + defm int_s390_vfaez : SystemZTernaryIntBHF<"vfaez", [ImmArg<2>]>; defm int_s390_vfaez : SystemZTernaryIntCCBHF; defm int_s390_vfee : SystemZBinaryBHF<"vfee">; @@ -356,9 +362,9 @@ defm int_s390_vistr : SystemZUnaryBHF<"vistr">; defm int_s390_vistr : SystemZUnaryCCBHF; - defm int_s390_vstrc : SystemZQuaternaryIntBHF<"vstrc">; + defm int_s390_vstrc : SystemZQuaternaryIntBHF<"vstrc", [ImmArg<3>]>; defm int_s390_vstrc : SystemZQuaternaryIntCCBHF; - defm int_s390_vstrcz : SystemZQuaternaryIntBHF<"vstrcz">; + defm int_s390_vstrcz : SystemZQuaternaryIntBHF<"vstrcz", [ImmArg<3>]>; defm int_s390_vstrcz : SystemZQuaternaryIntCCBHF; def int_s390_vfcedbs : SystemZBinaryConvCC; @@ -369,7 +375,7 @@ def int_s390_vfidb : Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_i32_ty, llvm_i32_ty], - [IntrNoMem]>; + [IntrNoMem, ImmArg<1>, ImmArg<2>]>; // Instructions from the Vector Enhancements Facility 1 def int_s390_vbperm : SystemZBinaryConv<"vbperm", llvm_v2i64_ty, @@ -378,20 +384,20 @@ def int_s390_vmslg : GCCBuiltin<"__builtin_s390_vmslg">, Intrinsic<[llvm_v16i8_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_v16i8_ty, - llvm_i32_ty], [IntrNoMem]>; + llvm_i32_ty], [IntrNoMem, ImmArg<3>]>; def int_s390_vfmaxdb : Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty, llvm_i32_ty], - [IntrNoMem]>; + [IntrNoMem, ImmArg<2>]>; def int_s390_vfmindb : Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty, llvm_i32_ty], - [IntrNoMem]>; + [IntrNoMem, ImmArg<2>]>; def int_s390_vfmaxsb : Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_i32_ty], - [IntrNoMem]>; + [IntrNoMem, ImmArg<2>]>; def int_s390_vfminsb : Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_i32_ty], - [IntrNoMem]>; + [IntrNoMem, ImmArg<2>]>; def int_s390_vfcesbs : SystemZBinaryConvCC; def int_s390_vfchsbs : SystemZBinaryConvCC; @@ -401,7 +407,7 @@ def int_s390_vfisb : Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_i32_ty, llvm_i32_ty], - [IntrNoMem]>; + [IntrNoMem, ImmArg<2>]>; // Instructions from the Vector Packed Decimal Facility def int_s390_vlrl : GCCBuiltin<"__builtin_s390_vlrl">, Index: test/Verifier/SystemZ/intrinsic-immarg.ll =================================================================== --- /dev/null +++ test/Verifier/SystemZ/intrinsic-immarg.ll @@ -0,0 +1,160 @@ +; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s + +declare <2 x double> @llvm.s390.vfidb(<2 x double>, i32, i32) +define void @test_vfidb(<2 x double> %arg0, i32 %arg1, i32 %arg2) { + ; CHECK: immarg operand has non-immediate parameter + ; CHECK-NEXT: i32 %arg1 + ; CHECK-NEXT: %ret0 = call <2 x double> @llvm.s390.vfidb(<2 x double> %arg0, i32 %arg1, i32 0) + ; CHECK: immarg operand has non-immediate parameter + ; CHECK-NEXT: i32 %arg2 + ; CHECK-NEXT: %ret1 = call <2 x double> @llvm.s390.vfidb(<2 x double> %arg0, i32 0, i32 %arg2) + %ret0 = call <2 x double> @llvm.s390.vfidb(<2 x double> %arg0, i32 %arg1, i32 0) + %ret1 = call <2 x double> @llvm.s390.vfidb(<2 x double> %arg0, i32 0, i32 %arg2) + ret void +} + +declare <2 x double> @llvm.s390.vfmaxdb(<2 x double>, <2 x double>, i32) +define <2 x double> @test_vfmaxdb(<2 x double> %arg0, <2 x double> %arg1, i32 %arg2) { + ; CHECK: immarg operand has non-immediate parameter + ; CHECK-NEXT: i32 %arg2 + ; CHECK-NEXT: %ret = call <2 x double> @llvm.s390.vfmaxdb(<2 x double> %arg0, <2 x double> %arg1, i32 %arg2) + %ret = call <2 x double> @llvm.s390.vfmaxdb(<2 x double> %arg0, <2 x double> %arg1, i32 %arg2) + ret <2 x double> %ret +} + +declare <2 x double> @llvm.s390.vfmindb(<2 x double>, <2 x double>, i32) +define <2 x double> @test_vfmindb(<2 x double> %arg0, <2 x double> %arg1, i32 %arg2) { + ; CHECK: immarg operand has non-immediate parameter + ; CHECK-NEXT: i32 %arg2 + ; CHECK-NEXT: %ret = call <2 x double> @llvm.s390.vfmindb(<2 x double> %arg0, <2 x double> %arg1, i32 %arg2) + %ret = call <2 x double> @llvm.s390.vfmindb(<2 x double> %arg0, <2 x double> %arg1, i32 %arg2) + ret <2 x double> %ret +} + +declare <2 x float> @llvm.s390.vfmaxsb(<2 x float>, <2 x float>, i32) +define <2 x float> @test_vfmaxsb(<2 x float> %arg0, <2 x float> %arg1, i32 %arg2) { + ; CHECK: immarg operand has non-immediate parameter + ; CHECK-NEXT: i32 %arg2 + ; CHECK-NEXT: %ret = call <2 x float> @llvm.s390.vfmaxsb(<2 x float> %arg0, <2 x float> %arg1, i32 %arg2) + %ret = call <2 x float> @llvm.s390.vfmaxsb(<2 x float> %arg0, <2 x float> %arg1, i32 %arg2) + ret <2 x float> %ret +} + +declare <2 x float> @llvm.s390.vfminsb(<2 x float>, <2 x float>, i32) +define <2 x float> @test_vfminsb(<2 x float> %arg0, <2 x float> %arg1, i32 %arg2) { + ; CHECK: immarg operand has non-immediate parameter + ; CHECK-NEXT: i32 %arg2 + ; CHECK-NEXT: %ret = call <2 x float> @llvm.s390.vfminsb(<2 x float> %arg0, <2 x float> %arg1, i32 %arg2) + %ret = call <2 x float> @llvm.s390.vfminsb(<2 x float> %arg0, <2 x float> %arg1, i32 %arg2) + ret <2 x float> %ret +} + +declare <4 x float> @llvm.s390.vfisb(<4 x float>, i32, i32) +define <4 x float> @test_vfisb(<4 x float> %arg0, i32 %arg1, i32 %arg2) { + ; CHECK: immarg operand has non-immediate parameter + ; CHECK-NEXT: i32 %arg2 + ; CHECK-NEXT: %ret = call <4 x float> @llvm.s390.vfisb(<4 x float> %arg0, i32 %arg1, i32 %arg2) + %ret = call <4 x float> @llvm.s390.vfisb(<4 x float> %arg0, i32 %arg1, i32 %arg2) + ret <4 x float> %ret +} + +declare <16 x i8> @llvm.s390.vstrcb(<16 x i8>, <16 x i8>, <16 x i8>, i32) +define <16 x i8> @test_vstrcb(<16 x i8> %arg0, <16 x i8> %arg1, <16 x i8> %arg2, i32 %arg3) { + ; CHECK: immarg operand has non-immediate parameter + ; CHECK-NEXT: i32 %arg3 + ; CHECK-NEXT: %ret = call <16 x i8> @llvm.s390.vstrcb(<16 x i8> %arg0, <16 x i8> %arg1, <16 x i8> %arg2, i32 %arg3) + %ret = call <16 x i8> @llvm.s390.vstrcb(<16 x i8> %arg0, <16 x i8>%arg1, <16 x i8> %arg2, i32 %arg3) + ret <16 x i8> %ret +} + +declare <8 x i16> @llvm.s390.vstrch(<8 x i16>, <8 x i16>, <8 x i16>, i32) +define <8 x i16> @test_vstrch(<8 x i16> %arg0, <8 x i16> %arg1, <8 x i16> %arg2, i32 %arg3) { + ; CHECK: immarg operand has non-immediate parameter + ; CHECK-NEXT: i32 %arg3 + ; CHECK-NEXT: %ret = call <8 x i16> @llvm.s390.vstrch(<8 x i16> %arg0, <8 x i16> %arg1, <8 x i16> %arg2, i32 %arg3) + %ret = call <8 x i16> @llvm.s390.vstrch(<8 x i16> %arg0, <8 x i16>%arg1, <8 x i16> %arg2, i32 %arg3) + ret <8 x i16> %ret +} + +declare <4 x i32> @llvm.s390.vstrcf(<4 x i32>, <4 x i32>, <4 x i32>, i32) +define <4 x i32> @test_vstrcf(<4 x i32> %arg0, <4 x i32> %arg1, <4 x i32> %arg2, i32 %arg3) { + ; CHECK: immarg operand has non-immediate parameter + ; CHECK-NEXT: i32 %arg3 + ; CHECK-NEXT: %ret = call <4 x i32> @llvm.s390.vstrcf(<4 x i32> %arg0, <4 x i32> %arg1, <4 x i32> %arg2, i32 %arg3) + %ret = call <4 x i32> @llvm.s390.vstrcf(<4 x i32> %arg0, <4 x i32>%arg1, <4 x i32> %arg2, i32 %arg3) + ret <4 x i32> %ret +} + +declare <16 x i8> @llvm.s390.verimb(<16 x i8>, <16 x i8>, <16 x i8>, i32) +define <16 x i8> @test_verimb(<16 x i8> %a, <16 x i8> %b, <16 x i8> %c, i32 %d) { + ; CHECK: immarg operand has non-immediate parameter + ; CHECK-NEXT: i32 %d + ; CHECK-NEXT: %res = call <16 x i8> @llvm.s390.verimb(<16 x i8> %a, <16 x i8> %b, <16 x i8> %c, i32 %d) + %res = call <16 x i8> @llvm.s390.verimb(<16 x i8> %a, <16 x i8> %b, <16 x i8> %c, i32 %d) + ret <16 x i8> %res +} + +declare <8 x i16> @llvm.s390.verimh(<8 x i16>, <8 x i16>, <8 x i16>, i32) +define <8 x i16> @test_verimh(<8 x i16> %a, <8 x i16> %b, <8 x i16> %c, i32 %d) { + ; CHECK: immarg operand has non-immediate parameter + ; CHECK-NEXT: i32 %d + ; CHECK-NEXT: %res = call <8 x i16> @llvm.s390.verimh(<8 x i16> %a, <8 x i16> %b, <8 x i16> %c, i32 %d) + %res = call <8 x i16> @llvm.s390.verimh(<8 x i16> %a, <8 x i16> %b, <8 x i16> %c, i32 %d) + ret <8 x i16> %res +} + +declare <4 x i32> @llvm.s390.verimf(<4 x i32>, <4 x i32>, <4 x i32>, i32) +define <4 x i32> @test_verimf(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c, i32 %d) { + ; CHECK: immarg operand has non-immediate parameter + ; CHECK-NEXT: i32 %d + ; CHECK-NEXT: %res = call <4 x i32> @llvm.s390.verimf(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c, i32 %d) + %res = call <4 x i32> @llvm.s390.verimf(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c, i32 %d) + ret <4 x i32> %res +} + +declare <2 x i64> @llvm.s390.verimg(<2 x i64>, <2 x i64>, <2 x i64>, i32) +define <2 x i64> @test_verimg(<2 x i64> %a, <2 x i64> %b, <2 x i64> %c, i32 %d) { + ; CHECK: immarg operand has non-immediate parameter + ; CHECK-NEXT: i32 %d + ; CHECK-NEXT: %res = call <2 x i64> @llvm.s390.verimg(<2 x i64> %a, <2 x i64> %b, <2 x i64> %c, i32 %d) + %res = call <2 x i64> @llvm.s390.verimg(<2 x i64> %a, <2 x i64> %b, <2 x i64> %c, i32 %d) + ret <2 x i64> %res +} + +declare {<2 x i64>, i32} @llvm.s390.vftcidb(<2 x double>, i32) +define i32 @test_vftcidb(<2 x double> %a, i32 %b) { + ; CHECK: immarg operand has non-immediate parameter + ; CHECK-NEXT: i32 %b + ; CHECK-NEXT: %call = call { <2 x i64>, i32 } @llvm.s390.vftcidb(<2 x double> %a, i32 %b) + %call = call {<2 x i64>, i32} @llvm.s390.vftcidb(<2 x double> %a, i32 %b) + %res = extractvalue {<2 x i64>, i32} %call, 1 + ret i32 %res +} + +declare {<4 x i32>, i32} @llvm.s390.vftcisb(<4 x float>, i32) +define i32 @test_vftcisb(<4 x float> %a, i32 %b) { + ; CHECK: immarg operand has non-immediate parameter + ; CHECK-NEXT: i32 %b + ; CHECK-NEXT: %call = call { <4 x i32>, i32 } @llvm.s390.vftcisb(<4 x float> %a, i32 %b) + %call = call {<4 x i32>, i32} @llvm.s390.vftcisb(<4 x float> %a, i32 %b) + %res = extractvalue {<4 x i32>, i32} %call, 1 + ret i32 %res +} + +declare <16 x i8> @llvm.s390.vfaeb(<16 x i8>, <16 x i8>, i32) +define <16 x i8> @test_vfaeb(<16 x i8> %a, <16 x i8> %b, i32 %c) { + ; CHECK: immarg operand has non-immediate parameter + ; CHECK-NEXT: i32 %c + ; CHECK-NEXT: %res = call <16 x i8> @llvm.s390.vfaeb(<16 x i8> %a, <16 x i8> %b, i32 %c) + %res = call <16 x i8> @llvm.s390.vfaeb(<16 x i8> %a, <16 x i8> %b, i32 %c) + ret <16 x i8> %res +} + +declare <16 x i8> @llvm.s390.vfaezb(<16 x i8>, <16 x i8>, i32) +define <16 x i8> @test_vfaezb(<16 x i8> %a, <16 x i8> %b, i32 %c) { + ; CHECK: immarg operand has non-immediate parameter + ; CHECK-NEXT: i32 %c + ; CHECK-NEXT: %res = call <16 x i8> @llvm.s390.vfaezb(<16 x i8> %a, <16 x i8> %b, i32 %c) + %res = call <16 x i8> @llvm.s390.vfaezb(<16 x i8> %a, <16 x i8> %b, i32 %c) + ret <16 x i8> %res +} Index: test/Verifier/SystemZ/lit.local.cfg =================================================================== --- /dev/null +++ test/Verifier/SystemZ/lit.local.cfg @@ -0,0 +1,2 @@ +if not 'SystemZ' in config.root.targets: + config.unsupported = True