diff options
| author | Craig Topper <craig.topper@intel.com> | 2018-06-07 21:27:41 +0000 | 
|---|---|---|
| committer | Craig Topper <craig.topper@intel.com> | 2018-06-07 21:27:41 +0000 | 
| commit | e56819eb691f2e8959d77858ecb7877e1686bfcd (patch) | |
| tree | 0038208444b25b04a083e4a6625a5bebd162e976 /clang/lib/CodeGen | |
| parent | 188a619e56ac0115cb10bd9a4b7427f3e6ff2c6f (diff) | |
| download | bcm5719-llvm-e56819eb691f2e8959d77858ecb7877e1686bfcd.tar.gz bcm5719-llvm-e56819eb691f2e8959d77858ecb7877e1686bfcd.zip | |
[X86] Add builtins for VALIGNQ/VALIGND to enable proper target feature checking.
We still emit shufflevector instructions we just do it from CGBuiltin.cpp now. This ensures the intrinsics that use this are only available on CPUs that support the feature.
I also added range checking to the immediate, but only checked it is 8 bits or smaller. We should maybe be stricter since we never use all 8 bits, but gcc doesn't seem to do that.
llvm-svn: 334237
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGBuiltin.cpp | 20 | 
1 files changed, 20 insertions, 0 deletions
| diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index a126e75b19f..c911ab9fc5b 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -9222,6 +9222,26 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,                                         makeArrayRef(Indices, NumElts),                                         "palignr");    } +  case X86::BI__builtin_ia32_alignd128: +  case X86::BI__builtin_ia32_alignd256: +  case X86::BI__builtin_ia32_alignd512: +  case X86::BI__builtin_ia32_alignq128: +  case X86::BI__builtin_ia32_alignq256: +  case X86::BI__builtin_ia32_alignq512: { +    unsigned NumElts = Ops[0]->getType()->getVectorNumElements(); +    unsigned ShiftVal = cast<llvm::ConstantInt>(Ops[2])->getZExtValue(); + +    // Mask the shift amount to width of two vectors. +    ShiftVal &= (2 * NumElts) - 1; + +    uint32_t Indices[16]; +    for (unsigned i = 0; i != NumElts; ++i) +      Indices[i] = i + ShiftVal; + +    return Builder.CreateShuffleVector(Ops[1], Ops[0], +                                       makeArrayRef(Indices, NumElts), +                                       "valign"); +  }    case X86::BI__builtin_ia32_vperm2f128_pd256:    case X86::BI__builtin_ia32_vperm2f128_ps256: | 

