llvm-project/clang/lib/Sema/SemaSystemZ.cpp
Ulrich Weigand 8424bf207e [SystemZ] Add support for new cpu architecture - arch15
This patch adds support for the next-generation arch15
CPU architecture to the SystemZ backend.

This includes:
- Basic support for the new processor and its features.
- Detection of arch15 as host processor.
- Assembler/disassembler support for new instructions.
- Exploitation of new instructions for code generation.
- New vector (signed|unsigned|bool) __int128 data types.
- New LLVM intrinsics for certain new instructions.
- Support for low-level builtins mapped to new LLVM intrinsics.
- New high-level intrinsics in vecintrin.h.
- Indicate support by defining  __VEC__ == 10305.

Note: No currently available Z system supports the arch15
architecture.  Once new systems become available, the
official system name will be added as supported -march name.
2025-01-20 19:30:21 +01:00

96 lines
4.1 KiB
C++

//===------ SemaSystemZ.cpp ------ SystemZ target-specific routines -------===//
//
// 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 implements semantic analysis functions specific to SystemZ.
//
//===----------------------------------------------------------------------===//
#include "clang/Sema/SemaSystemZ.h"
#include "clang/Basic/DiagnosticSema.h"
#include "clang/Basic/TargetBuiltins.h"
#include "clang/Sema/Sema.h"
#include "llvm/ADT/APSInt.h"
#include <optional>
namespace clang {
SemaSystemZ::SemaSystemZ(Sema &S) : SemaBase(S) {}
bool SemaSystemZ::CheckSystemZBuiltinFunctionCall(unsigned BuiltinID,
CallExpr *TheCall) {
if (BuiltinID == SystemZ::BI__builtin_tabort) {
Expr *Arg = TheCall->getArg(0);
if (std::optional<llvm::APSInt> AbortCode =
Arg->getIntegerConstantExpr(getASTContext()))
if (AbortCode->getSExtValue() >= 0 && AbortCode->getSExtValue() < 256)
return Diag(Arg->getBeginLoc(), diag::err_systemz_invalid_tabort_code)
<< Arg->getSourceRange();
}
// For intrinsics which take an immediate value as part of the instruction,
// range check them here.
unsigned i = 0, l = 0, u = 0;
switch (BuiltinID) {
default: return false;
case SystemZ::BI__builtin_s390_lcbb: i = 1; l = 0; u = 15; break;
case SystemZ::BI__builtin_s390_veval:
case SystemZ::BI__builtin_s390_verimb:
case SystemZ::BI__builtin_s390_verimh:
case SystemZ::BI__builtin_s390_verimf:
case SystemZ::BI__builtin_s390_verimg: i = 3; l = 0; u = 255; break;
case SystemZ::BI__builtin_s390_vfaeb:
case SystemZ::BI__builtin_s390_vfaeh:
case SystemZ::BI__builtin_s390_vfaef:
case SystemZ::BI__builtin_s390_vfaebs:
case SystemZ::BI__builtin_s390_vfaehs:
case SystemZ::BI__builtin_s390_vfaefs:
case SystemZ::BI__builtin_s390_vfaezb:
case SystemZ::BI__builtin_s390_vfaezh:
case SystemZ::BI__builtin_s390_vfaezf:
case SystemZ::BI__builtin_s390_vfaezbs:
case SystemZ::BI__builtin_s390_vfaezhs:
case SystemZ::BI__builtin_s390_vfaezfs: i = 2; l = 0; u = 15; break;
case SystemZ::BI__builtin_s390_vfisb:
case SystemZ::BI__builtin_s390_vfidb:
return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 15) ||
SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 15);
case SystemZ::BI__builtin_s390_vftcisb:
case SystemZ::BI__builtin_s390_vftcidb: i = 1; l = 0; u = 4095; break;
case SystemZ::BI__builtin_s390_vlbb: i = 1; l = 0; u = 15; break;
case SystemZ::BI__builtin_s390_vpdi: i = 2; l = 0; u = 15; break;
case SystemZ::BI__builtin_s390_vsldb: i = 2; l = 0; u = 15; break;
case SystemZ::BI__builtin_s390_vstrcb:
case SystemZ::BI__builtin_s390_vstrch:
case SystemZ::BI__builtin_s390_vstrcf:
case SystemZ::BI__builtin_s390_vstrczb:
case SystemZ::BI__builtin_s390_vstrczh:
case SystemZ::BI__builtin_s390_vstrczf:
case SystemZ::BI__builtin_s390_vstrcbs:
case SystemZ::BI__builtin_s390_vstrchs:
case SystemZ::BI__builtin_s390_vstrcfs:
case SystemZ::BI__builtin_s390_vstrczbs:
case SystemZ::BI__builtin_s390_vstrczhs:
case SystemZ::BI__builtin_s390_vstrczfs: i = 3; l = 0; u = 15; break;
case SystemZ::BI__builtin_s390_vmslg: i = 3; l = 0; u = 15; break;
case SystemZ::BI__builtin_s390_vfminsb:
case SystemZ::BI__builtin_s390_vfmaxsb:
case SystemZ::BI__builtin_s390_vfmindb:
case SystemZ::BI__builtin_s390_vfmaxdb: i = 2; l = 0; u = 15; break;
case SystemZ::BI__builtin_s390_vsld: i = 2; l = 0; u = 7; break;
case SystemZ::BI__builtin_s390_vsrd: i = 2; l = 0; u = 7; break;
case SystemZ::BI__builtin_s390_vclfnhs:
case SystemZ::BI__builtin_s390_vclfnls:
case SystemZ::BI__builtin_s390_vcfn:
case SystemZ::BI__builtin_s390_vcnf: i = 1; l = 0; u = 15; break;
case SystemZ::BI__builtin_s390_vcrnfs: i = 2; l = 0; u = 15; break;
}
return SemaRef.BuiltinConstantArgRange(TheCall, i, l, u);
}
} // namespace clang