Commit 6e8ff106 authored by Hans Wennborg's avatar Hans Wennborg
Browse files

Merging r243642, r243643, and r243644:

------------------------------------------------------------------------
r243642 | uweigand | 2015-07-30 07:08:36 -0700 (Thu, 30 Jul 2015) | 29 lines

Add support for System z vector language extensions

The z13 vector facility has an associated language extension,
closely modeled on AltiVec/VSX.  The main differences are:

- vector long, vector float and vector pixel are not supported

- vector long long and vector double are supported (like VSX)

- comparison operators return a vector rather than a scalar integer

- shift operators behave like the OpenCL shift operators

- vector bool is only supported as argument to certain operators;
  some operators allow mixing a bool with a non-bool vector 

This patch adds clang support for the extension.  It is closely modelled
on the AltiVec support.  Similarly to the -faltivec option, there's a
new -fzvector option to enable the extensions (as well as an -mzvector
alias for compatibility with GCC).  There's also a separate LangOpt.

The extension as implemented here is intended to be compatible with
the -mzvector extension recently implemented by GCC.

Based on a patch by Richard Sandiford.

Differential Revision: http://reviews.llvm.org/D11001
------------------------------------------------------------------------

------------------------------------------------------------------------
r243643 | uweigand | 2015-07-30 07:10:43 -0700 (Thu, 30 Jul 2015) | 18 lines

[SystemZ] Add support for vecintrin.h vector built-in functions

This patch adds support for the System Z vector built-in functions.
The API-defined header file has the name vecintrin.h.

The user-level functions are defined in the same style as the clang
version of altivec.h, making heavy use of the __overloadable__ and
__always_inline__ attributes.  Where possible the functions expand to
generic operations rather than specific built-in functions, in the hope
that that form can be optimised better.

Where a built-in routine is specified to require an immediate integer
argument, the __enable_if__ attribute is used to verify the argument is
in fact constant and in the appropriate range.

Based on a patch by Richard Sandiford.
------------------------------------------------------------------------

------------------------------------------------------------------------
r243644 | uweigand | 2015-07-30 08:53:58 -0700 (Thu, 30 Jul 2015) | 21 lines

Fix sanitizer fallout from r243642

The memory-sanitizer build bot reported:

==5574== WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x7f03089e15f6 in
clang::Parser::TryAltiVecTokenOutOfLine(clang::DeclSpec&,
clang::SourceLocation, char const*&, unsigned int&, bool&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:6290:11

This is because the "Ident_pixel" variable was uninitialized
in the getLangOpts().ZVector case, but we'd still call into
clang::Parser::TryAltiVecTokenOutOfLine, which uses the variable.

The simplest fix for this without sprinkling !getLangOpts().ZVector
checks all over the code seems to be to just initialize the variable
to nullptr; this will then do the right thing on ZVector.

Checked in to unbreak the build bots.
------------------------------------------------------------------------

llvm-svn: 243699
parent 6b7585ca
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -358,6 +358,10 @@ def err_invalid_pixel_decl_spec_combination : Error<
  "'%0' declaration specifier not allowed here">;
def err_invalid_vector_bool_decl_spec : Error<
  "cannot use '%0' with '__vector bool'">;
def err_invalid_vector_long_decl_spec : Error<
  "cannot use 'long' with '__vector'">;
def err_invalid_vector_float_decl_spec : Error<
  "cannot use 'float' with '__vector'">;
def err_invalid_vector_double_decl_spec : Error <
  "use of 'double' with '__vector' requires VSX support to be enabled "
  "(available on POWER7 or later)">;
+1 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ LANGOPT(WritableStrings , 1, 0, "writable string support")
LANGOPT(ConstStrings      , 1, 0, "const-qualified string support")
LANGOPT(LaxVectorConversions , 1, 1, "lax vector conversions")
LANGOPT(AltiVec           , 1, 0, "AltiVec-style vector initializers")
LANGOPT(ZVector           , 1, 0, "System z vector extensions")
LANGOPT(Exceptions        , 1, 0, "exception handling")
LANGOPT(ObjCExceptions    , 1, 0, "Objective-C exceptions")
LANGOPT(CXXExceptions     , 1, 0, "C++ exceptions")
+5 −3
Original line number Diff line number Diff line
@@ -239,6 +239,8 @@ PUNCTUATOR(greatergreatergreater, ">>>")
//   KEYOPENCL  - This is a keyword in OpenCL
//   KEYNOOPENCL  - This is a keyword that is not supported in OpenCL
//   KEYALTIVEC - This is a keyword in AltiVec
//   KEYZVECTOR - This is a keyword for the System z vector extensions,
//                which are heavily based on AltiVec
//   KEYBORLAND - This is a keyword if Borland extensions are enabled
//   BOOLSUPPORT - This is a keyword if 'bool' is a built-in type
//   HALFSUPPORT - This is a keyword if 'half' is a built-in type
@@ -501,7 +503,7 @@ ALIAS("write_only", __write_only , KEYOPENCL)
ALIAS("read_write", __read_write    , KEYOPENCL)
// OpenCL builtins
KEYWORD(__builtin_astype            , KEYOPENCL)
KEYWORD(vec_step                    , KEYOPENCL|KEYALTIVEC)
KEYWORD(vec_step                    , KEYOPENCL|KEYALTIVEC|KEYZVECTOR)

// OpenMP Type Traits
KEYWORD(__builtin_omp_required_simd_align, KEYALL)
@@ -510,9 +512,9 @@ KEYWORD(__builtin_omp_required_simd_align, KEYALL)
KEYWORD(__pascal                    , KEYALL)

// Altivec Extension.
KEYWORD(__vector                    , KEYALTIVEC)
KEYWORD(__vector                    , KEYALTIVEC|KEYZVECTOR)
KEYWORD(__pixel                     , KEYALTIVEC)
KEYWORD(__bool                      , KEYALTIVEC)
KEYWORD(__bool                      , KEYALTIVEC|KEYZVECTOR)

// ARM NEON extensions.
ALIAS("__fp16", half                , KEYALL)
+7 −0
Original line number Diff line number Diff line
@@ -1351,6 +1351,13 @@ def mno_altivec : Flag<["-"], "mno-altivec">, Alias<fno_altivec>;
def mvx : Flag<["-"], "mvx">, Group<m_Group>;
def mno_vx : Flag<["-"], "mno-vx">, Group<m_Group>;

def fzvector : Flag<["-"], "fzvector">, Group<f_Group>, Flags<[CC1Option]>,
  HelpText<"Enable System z vector language extension">;
def fno_zvector : Flag<["-"], "fno-zvector">, Group<f_Group>,
  Flags<[CC1Option]>;
def mzvector : Flag<["-"], "mzvector">, Alias<fzvector>;
def mno_zvector : Flag<["-"], "mno-zvector">, Alias<fno_zvector>;

def mno_warn_nonportable_cfstrings : Flag<["-"], "mno-warn-nonportable-cfstrings">, Group<m_Group>;
def mno_omit_leaf_frame_pointer : Flag<["-"], "mno-omit-leaf-frame-pointer">, Group<m_Group>;
def momit_leaf_frame_pointer : Flag<["-"], "momit-leaf-frame-pointer">, Group<m_Group>,
+12 −9
Original line number Diff line number Diff line
@@ -108,12 +108,13 @@ class Parser : public CodeCompletionHandler {
  /// Ident_super - IdentifierInfo for "super", to support fast
  /// comparison.
  IdentifierInfo *Ident_super;
  /// Ident_vector, Ident_pixel, Ident_bool - cached IdentifierInfo's
  /// for "vector", "pixel", and "bool" fast comparison.  Only present
  /// if AltiVec enabled.
  /// Ident_vector, Ident_bool - cached IdentifierInfos for "vector" and
  /// "bool" fast comparison.  Only present if AltiVec or ZVector are enabled.
  IdentifierInfo *Ident_vector;
  IdentifierInfo *Ident_pixel;
  IdentifierInfo *Ident_bool;
  /// Ident_pixel - cached IdentifierInfos for "pixel" fast comparison.
  /// Only present if AltiVec enabled.
  IdentifierInfo *Ident_pixel;

  /// Objective-C contextual keywords.
  mutable IdentifierInfo *Ident_instancetype;
@@ -605,10 +606,12 @@ private:
  bool TryAltiVecToken(DeclSpec &DS, SourceLocation Loc,
                       const char *&PrevSpec, unsigned &DiagID,
                       bool &isInvalid) {
    if (!getLangOpts().AltiVec ||
        (Tok.getIdentifierInfo() != Ident_vector &&
         Tok.getIdentifierInfo() != Ident_pixel &&
         Tok.getIdentifierInfo() != Ident_bool))
    if (!getLangOpts().AltiVec && !getLangOpts().ZVector)
      return false;

    if (Tok.getIdentifierInfo() != Ident_vector &&
        Tok.getIdentifierInfo() != Ident_bool &&
        (!getLangOpts().AltiVec || Tok.getIdentifierInfo() != Ident_pixel))
      return false;

    return TryAltiVecTokenOutOfLine(DS, Loc, PrevSpec, DiagID, isInvalid);
@@ -618,7 +621,7 @@ private:
  /// identifier token, replacing it with the non-context-sensitive __vector.
  /// This returns true if the token was replaced.
  bool TryAltiVecVectorToken() {
    if (!getLangOpts().AltiVec ||
    if ((!getLangOpts().AltiVec && !getLangOpts().ZVector) ||
        Tok.getIdentifierInfo() != Ident_vector) return false;
    return TryAltiVecVectorTokenOutOfLine();
  }
Loading