Commit 8b409eab authored by Sander de Smalen's avatar Sander de Smalen
Browse files

[SVE] Auto-generate builtins and header for svld1.

This is a first patch in a series for the SveEmitter to generate the arm_sve.h
header file and builtins.

I've tried my best to strip down this patch as best as I could, but there
are still a few changes that are not necessarily exercised by the load intrinsics
in this patch, mostly around the SVEType class which has some common logic to
represent types from a type and prototype string. I thought it didn't make
much sense to remove that from this patch and split it up.

Reviewers: efriedma, rovka, SjoerdMeijer, rsandifo-arm, rengolin

Reviewed By: SjoerdMeijer

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75470
parent c9365251
Loading
Loading
Loading
Loading
+67 −0
Original line number Diff line number Diff line
//===- AArch64SVETypeFlags.h - Flags used to generate ACLE builtins- C++ -*-===//
//
//  Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
//  See https://llvm.org/LICENSE.txt for license information.
//  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_BASIC_AARCH64SVETYPEFLAGS_H
#define LLVM_CLANG_BASIC_AARCH64SVETYPEFLAGS_H

#include <stdint.h>

namespace clang {

/// Flags to identify the types for overloaded SVE builtins.
class SVETypeFlags {
  uint64_t Flags;

public:
  /// These must be kept in sync with the flags in
  /// include/clang/Basic/arm_sve.td.
  static const uint64_t MemEltTypeOffset = 4; // Bit offset of MemEltTypeMask
  static const uint64_t EltTypeMask      = 0x00000000000f;
  static const uint64_t MemEltTypeMask   = 0x000000000070;
  static const uint64_t IsLoad           = 0x000000000080;

  enum EltType {
    Invalid,
    Int8,
    Int16,
    Int32,
    Int64,
    Float16,
    Float32,
    Float64,
    Bool8,
    Bool16,
    Bool32,
    Bool64
  };

  enum MemEltTy {
    MemEltTyDefault,
    MemEltTyInt8,
    MemEltTyInt16,
    MemEltTyInt32,
    MemEltTyInt64
  };

  SVETypeFlags(uint64_t F) : Flags(F) { }
  SVETypeFlags(EltType ET, bool IsUnsigned) : Flags(ET) { }

  EltType getEltType() const { return (EltType)(Flags & EltTypeMask); }
  MemEltTy getMemEltType() const {
    return (MemEltTy)((Flags & MemEltTypeMask) >> MemEltTypeOffset);
  }

  bool isLoad() const { return Flags & IsLoad; }

  uint64_t getBits() const { return Flags; }
  bool isFlagSet(uint64_t Flag) const { return Flags & Flag; }
};

} // end namespace clang

#endif
+0 −13
Original line number Diff line number Diff line
@@ -99,19 +99,6 @@ BUILTIN(__builtin_arm_tcommit, "v", "n")
BUILTIN(__builtin_arm_tcancel, "vWUIi", "n")
BUILTIN(__builtin_arm_ttest, "WUi", "nc")

// SVE
BUILTIN(__builtin_sve_svld1_s16, "q8sq16bSsC*", "n")
BUILTIN(__builtin_sve_svld1_s32, "q4iq16bSiC*", "n")
BUILTIN(__builtin_sve_svld1_s64, "q2Wiq16bSWiC*", "n")
BUILTIN(__builtin_sve_svld1_s8, "q16Scq16bScC*", "n")
BUILTIN(__builtin_sve_svld1_u16, "q8Usq16bUsC*", "n")
BUILTIN(__builtin_sve_svld1_u32, "q4Uiq16bUiC*", "n")
BUILTIN(__builtin_sve_svld1_u64, "q2UWiq16bUWiC*", "n")
BUILTIN(__builtin_sve_svld1_u8, "q16Ucq16bUcC*", "n")
BUILTIN(__builtin_sve_svld1_f64, "q2dq16bdC*", "n")
BUILTIN(__builtin_sve_svld1_f32, "q4fq16bfC*", "n")
BUILTIN(__builtin_sve_svld1_f16, "q8hq16bhC*", "n")

TARGET_HEADER_BUILTIN(_BitScanForward, "UcUNi*UNi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
TARGET_HEADER_BUILTIN(_BitScanReverse, "UcUNi*UNi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
TARGET_HEADER_BUILTIN(_BitScanForward64, "UcUNi*ULLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
+20 −0
Original line number Diff line number Diff line
//===--- BuiltinsSVE.def - SVE Builtin function database --------*- C++ -*-===//
//
//  Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
//  See https://llvm.org/LICENSE.txt for license information.
//  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines the SVE-specific builtin function database.  Users of
// this file must define the BUILTIN macro to make use of this information.
//
//===----------------------------------------------------------------------===//

// The format of this database matches clang/Basic/Builtins.def.

#define GET_SVE_BUILTINS
#include "clang/Basic/arm_sve_builtins.inc"
#undef GET_SVE_BUILTINS

#undef BUILTIN
+6 −1
Original line number Diff line number Diff line
@@ -60,7 +60,12 @@ clang_tablegen(arm_mve_builtin_sema.inc -gen-arm-mve-builtin-sema
clang_tablegen(arm_mve_builtin_aliases.inc -gen-arm-mve-builtin-aliases
  SOURCE arm_mve.td
  TARGET ClangARMMveBuiltinAliases)

clang_tablegen(arm_sve_builtins.inc -gen-arm-sve-builtins
  SOURCE arm_sve.td
  TARGET ClangARMSveBuiltins)
clang_tablegen(arm_sve_codegenmap.inc -gen-arm-sve-codegenmap
  SOURCE arm_sve.td
  TARGET ClangARMSveCodeGenMap)
clang_tablegen(arm_cde_builtins.inc -gen-arm-cde-builtin-def
  SOURCE arm_cde.td
  TARGET ClangARMCdeBuiltinsDef)
+11 −0
Original line number Diff line number Diff line
@@ -41,11 +41,22 @@ namespace clang {
    };
  }

  namespace SVE {
  enum {
    LastNEONBuiltin = NEON::FirstTSBuiltin - 1,
#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
#include "clang/Basic/BuiltinsSVE.def"
    FirstTSBuiltin,
  };
  }

  /// AArch64 builtins
  namespace AArch64 {
  enum {
    LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
    LastNEONBuiltin = NEON::FirstTSBuiltin - 1,
    FirstSVEBuiltin = NEON::FirstTSBuiltin,
    LastSVEBuiltin = SVE::FirstTSBuiltin - 1,
  #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
  #include "clang/Basic/BuiltinsAArch64.def"
    LastTSBuiltin
Loading