Index: lib/Target/PowerPC/PPC.td =================================================================== --- lib/Target/PowerPC/PPC.td +++ lib/Target/PowerPC/PPC.td @@ -124,6 +124,9 @@ def FeatureP8Vector : SubtargetFeature<"power8-vector", "HasP8Vector", "true", "Enable POWER8 vector instructions", [FeatureVSX, FeatureP8Altivec]>; +def FeatureP9 : SubtargetFeature<"power9", "IsP9", "true", + "Enable POWER9 instructions", + [FeatureP8Crypto, FeatureP8Vector]>; def FeatureDirectMove : SubtargetFeature<"direct-move", "HasDirectMove", "true", "Enable Power8 direct move instructions", Index: lib/Target/PowerPC/PPCInstrAltivec.td =================================================================== --- lib/Target/PowerPC/PPCInstrAltivec.td +++ lib/Target/PowerPC/PPCInstrAltivec.td @@ -1213,3 +1213,38 @@ int_ppc_altivec_crypto_vncipherlast, v2i64>; def VSBOX : VXBX_Int_Ty<1480, "vsbox", int_ppc_altivec_crypto_vsbox, v2i64>; } // HasP8Crypto + +// The following altivec instructions were introduced in Power ISA 3.0 +def P9Instrs : Predicate<"PPCSubTarget->isP9()">; +let Predicates = [P9Instrs] in { + +// TODO: use VCMP/VCMPo and write test cases for intrinsic and llvm ir +class P9VCMP xo, string asmstr, ValueType Ty> + : VXRForm_1; +class P9VCMPo xo, string asmstr, ValueType Ty> + : VXRForm_1 { + let Defs = [CR6]; + let RC = 1; +} + +// Vector Compare Not Equal (Zero) +// i8 element comparisons. +def VCMPNEB : P9VCMP < 7, "vcmpneb $vD, $vA, $vB" , v16i8>; +def VCMPNEBo : P9VCMPo< 7, "vcmpneb. $vD, $vA, $vB" , v16i8>; +def VCMPNEZB : P9VCMP <263, "vcmpnezb $vD, $vA, $vB" , v16i8>; +def VCMPNEZBo : P9VCMPo<263, "vcmpnezb. $vD, $vA, $vB", v16i8>; + +// i16 element comparisons. +def VCMPNEH : P9VCMP < 71, "vcmpneh $vD, $vA, $vB" , v8i16>; +def VCMPNEHo : P9VCMPo< 71, "vcmpneh. $vD, $vA, $vB" , v8i16>; +def VCMPNEZH : P9VCMP <327, "vcmpnezh $vD, $vA, $vB" , v8i16>; +def VCMPNEZHo : P9VCMPo<327, "vcmpnezh. $vD, $vA, $vB", v8i16>; + +// i32 element comparisons. +def VCMPNEW : P9VCMP <135, "vcmpnew $vD, $vA, $vB" , v4i32>; +def VCMPNEWo : P9VCMPo<135, "vcmpnew. $vD, $vA, $vB" , v4i32>; +def VCMPNEZW : P9VCMP <391, "vcmpnezw $vD, $vA, $vB" , v4i32>; +def VCMPNEZWo : P9VCMPo<391, "vcmpnezw. $vD, $vA, $vB", v4i32>; +} // end P9Instrs Index: lib/Target/PowerPC/PPCSubtarget.h =================================================================== --- lib/Target/PowerPC/PPCSubtarget.h +++ lib/Target/PowerPC/PPCSubtarget.h @@ -111,6 +111,7 @@ bool IsE500; bool IsPPC4xx; bool IsPPC6xx; + bool IsP9; bool FeatureMFTB; bool DeprecatedDST; bool HasLazyResolverStubs; @@ -241,6 +242,7 @@ bool isPPC4xx() const { return IsPPC4xx; } bool isPPC6xx() const { return IsPPC6xx; } bool isE500() const { return IsE500; } + bool isP9() const { return IsP9; } bool isFeatureMFTB() const { return FeatureMFTB; } bool isDeprecatedDST() const { return DeprecatedDST; } bool hasICBT() const { return HasICBT; } Index: lib/Target/PowerPC/PPCSubtarget.cpp =================================================================== --- lib/Target/PowerPC/PPCSubtarget.cpp +++ lib/Target/PowerPC/PPCSubtarget.cpp @@ -92,6 +92,7 @@ IsPPC4xx = false; IsPPC6xx = false; IsE500 = false; + IsP9 = false; FeatureMFTB = false; DeprecatedDST = false; HasLazyResolverStubs = false; Index: test/MC/Disassembler/PowerPC/ppc64-encoding-vmx.txt =================================================================== --- test/MC/Disassembler/PowerPC/ppc64-encoding-vmx.txt +++ test/MC/Disassembler/PowerPC/ppc64-encoding-vmx.txt @@ -672,3 +672,41 @@ # CHECK: mfvscr 2 0x10 0x40 0x06 0x04 +# Power9 instructions + +# CHECK: vcmpneb 2, 3, 4 +0x10 0x43 0x20 0x07 + +# CHECK: vcmpneb. 2, 3, 4 +0x10 0x43 0x24 0x07 + +# CHECK: vcmpnezb 2, 3, 4 +0x10 0x43 0x21 0x07 + +# CHECK: vcmpnezb. 2, 3, 4 +0x10 0x43 0x25 0x07 + +# CHECK: vcmpneh 2, 3, 4 +0x10 0x43 0x20 0x47 + +# CHECK: vcmpneh. 2, 3, 4 +0x10 0x43 0x24 0x47 + +# CHECK: vcmpnezh 2, 3, 4 +0x10 0x43 0x21 0x47 + +# CHECK: vcmpnezh. 2, 3, 4 +0x10 0x43 0x25 0x47 + +# CHECK: vcmpnew 2, 3, 4 +0x10 0x43 0x20 0x87 + +# CHECK: vcmpnew. 2, 3, 4 +0x10 0x43 0x24 0x87 + +# CHECK: vcmpnezw 2, 3, 4 +0x10 0x43 0x21 0x87 + +# CHECK: vcmpnezw. 2, 3, 4 +0x10 0x43 0x25 0x87 + Index: test/MC/PowerPC/ppc64-encoding-vmx.s =================================================================== --- test/MC/PowerPC/ppc64-encoding-vmx.s +++ test/MC/PowerPC/ppc64-encoding-vmx.s @@ -742,3 +742,42 @@ # CHECK-LE: mfvscr 2 # encoding: [0x04,0x06,0x40,0x10] mfvscr 2 +# Power9 instructions + +# CHECK-BE: vcmpneb 2, 3, 4 # encoding: [0x10,0x43,0x20,0x07] +# CHECK-LE: vcmpneb 2, 3, 4 # encoding: [0x07,0x20,0x43,0x10] + vcmpneb 2, 3, 4 +# CHECK-BE: vcmpneb. 2, 3, 4 # encoding: [0x10,0x43,0x24,0x07] +# CHECK-LE: vcmpneb. 2, 3, 4 # encoding: [0x07,0x24,0x43,0x10] + vcmpneb. 2, 3, 4 +# CHECK-BE: vcmpnezb 2, 3, 4 # encoding: [0x10,0x43,0x21,0x07] +# CHECK-LE: vcmpnezb 2, 3, 4 # encoding: [0x07,0x21,0x43,0x10] + vcmpnezb 2, 3, 4 +# CHECK-BE: vcmpnezb. 2, 3, 4 # encoding: [0x10,0x43,0x25,0x07] +# CHECK-LE: vcmpnezb. 2, 3, 4 # encoding: [0x07,0x25,0x43,0x10] + vcmpnezb. 2, 3, 4 +# CHECK-BE: vcmpneh 2, 3, 4 # encoding: [0x10,0x43,0x20,0x47] +# CHECK-LE: vcmpneh 2, 3, 4 # encoding: [0x47,0x20,0x43,0x10] + vcmpneh 2, 3, 4 +# CHECK-BE: vcmpneh. 2, 3, 4 # encoding: [0x10,0x43,0x24,0x47] +# CHECK-LE: vcmpneh. 2, 3, 4 # encoding: [0x47,0x24,0x43,0x10] + vcmpneh. 2, 3, 4 +# CHECK-BE: vcmpnezh 2, 3, 4 # encoding: [0x10,0x43,0x21,0x47] +# CHECK-LE: vcmpnezh 2, 3, 4 # encoding: [0x47,0x21,0x43,0x10] + vcmpnezh 2, 3, 4 +# CHECK-BE: vcmpnezh. 2, 3, 4 # encoding: [0x10,0x43,0x25,0x47] +# CHECK-LE: vcmpnezh. 2, 3, 4 # encoding: [0x47,0x25,0x43,0x10] + vcmpnezh. 2, 3, 4 +# CHECK-BE: vcmpnew 2, 3, 4 # encoding: [0x10,0x43,0x20,0x87] +# CHECK-LE: vcmpnew 2, 3, 4 # encoding: [0x87,0x20,0x43,0x10] + vcmpnew 2, 3, 4 +# CHECK-BE: vcmpnew. 2, 3, 4 # encoding: [0x10,0x43,0x24,0x87] +# CHECK-LE: vcmpnew. 2, 3, 4 # encoding: [0x87,0x24,0x43,0x10] + vcmpnew. 2, 3, 4 +# CHECK-BE: vcmpnezw 2, 3, 4 # encoding: [0x10,0x43,0x21,0x87] +# CHECK-LE: vcmpnezw 2, 3, 4 # encoding: [0x87,0x21,0x43,0x10] + vcmpnezw 2, 3, 4 +# CHECK-BE: vcmpnezw. 2, 3, 4 # encoding: [0x10,0x43,0x25,0x87] +# CHECK-LE: vcmpnezw. 2, 3, 4 # encoding: [0x87,0x25,0x43,0x10] + vcmpnezw. 2, 3, 4 +