clang 24.0.0git
TargetUtils.h
Go to the documentation of this file.
1//===--- TargetUtils.h - Shared target-specific AST queries -----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file holds the target-specific AST queries that both classic CodeGen
10// and CIR CodeGen need.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_CODEGENUTILS_TARGETUTILS_H
15#define LLVM_CLANG_CODEGENUTILS_TARGETUTILS_H
16
18#include "llvm/ADT/StringRef.h"
19
20#include <cstdint>
21
22namespace llvm {
23class Triple;
24} // namespace llvm
25
26namespace clang {
27class Decl;
28class FunctionDecl;
29class QualType;
30class TargetInfo;
31} // namespace clang
32
33namespace clang::CodeGenUtils {
34
35//===----------------------------------------------------------------------===//
36// Arm and AArch64
37//===----------------------------------------------------------------------===//
38
39/// The Arm SME ABI issues that can prevent inlining one function into another.
52
53/// Determines if there are any Arm SME ABI issues with inlining \p Callee into
54/// \p Caller. Returns the issue (if any) in the ArmSMEInlinability bit enum.
56 const FunctionDecl *Callee);
57
58/// Returns whether the Neon builtin \p BuiltinID takes a trailing argument
59/// that discriminates the operand type. This should be kept consistent with
60/// the logic in Sema.
61/// TODO: Make this return false for SISD builtins.
62bool hasExtraNeonArgument(unsigned BuiltinID);
63
64/// Helper method to check if the underlying ABI is AAPCS
65bool isAAPCS(const TargetInfo &TargetInfo);
66
67//===----------------------------------------------------------------------===//
68// Library builtins (PowerPC64 and AIX)
69//===----------------------------------------------------------------------===//
70
71/// Returns the library function name that should be called for the library
72/// builtin \p BuiltinID when the target's library does not use the name derived
73/// from the builtin (e.g. PPC64 IEEE 128-bit long double libcalls, or AIX with
74/// 64-bit long double), or an empty StringRef if there is no such override.
75llvm::StringRef getTargetBuiltinLibFunctionName(unsigned BuiltinID,
76 const TargetInfo &Target);
77
78//===----------------------------------------------------------------------===//
79// AMDGPU
80//===----------------------------------------------------------------------===//
81
82/// Returns whether \p D must be given protected visibility on AMDGPU.
83/// \p HasHiddenVisibility is whether the emitted global currently has hidden
84/// visibility.
85bool requiresAMDGPUProtectedVisibility(const Decl *D, bool HasHiddenVisibility);
86
87//===----------------------------------------------------------------------===//
88// SPIR-V
89//===----------------------------------------------------------------------===//
90
91/// Return true if a SPIR(-V) null pointer of type \p QT must be materialized
92/// as an addrspacecast from a generic null pointer, as the null bit pattern in
93/// non-generic address spaces is unspecified.
94bool spirNullPointerNeedsGenericCast(QualType QT, const llvm::Triple &Triple);
95
96} // namespace clang::CodeGenUtils
97
98#endif // LLVM_CLANG_CODEGENUTILS_TARGETUTILS_H
Provides LLVM's BitmaskEnum facility to enumeration types declared in namespace clang.
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
Represents a function declaration or definition.
Definition Decl.h:2071
A (possibly-)qualified type.
Definition TypeBase.h:938
Exposes information about the current target.
Definition TargetInfo.h:228
bool isAAPCS(const TargetInfo &TargetInfo)
Helper method to check if the underlying ABI is AAPCS.
bool requiresAMDGPUProtectedVisibility(const Decl *D, bool HasHiddenVisibility)
Returns whether D must be given protected visibility on AMDGPU.
bool hasExtraNeonArgument(unsigned BuiltinID)
Returns whether the Neon builtin BuiltinID takes a trailing argument that discriminates the operand t...
bool spirNullPointerNeedsGenericCast(QualType QT, const llvm::Triple &Triple)
Return true if a SPIR(-V) null pointer of type QT must be materialized as an addrspacecast from a gen...
llvm::StringRef getTargetBuiltinLibFunctionName(unsigned BuiltinID, const TargetInfo &Target)
Returns the library function name that should be called for the library builtin BuiltinID when the ta...
ArmSMEInlinability
The Arm SME ABI issues that can prevent inlining one function into another.
Definition TargetUtils.h:40
ArmSMEInlinability getArmSMEInlinability(const FunctionDecl *Caller, const FunctionDecl *Callee)
Determines if there are any Arm SME ABI issues with inlining Callee into Caller.
Top level wrappers for InstallAPI frontend operations.
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
__builtin_bitreverse32 uint32_t __builtin_riscv_aaddu_u32 __builtin_riscv_asubu_u32 __builtin_elementwise_add_sat __builtin_elementwise_sub_sat int32_t uint32_t uint32_t __builtin_riscv_mhacc_i32 __builtin_riscv_mhaccu_u32 __builtin_riscv_mhaccsu_i32 __builtin_riscv_mulq_i32 __builtin_riscv_mqwacc_i64 uint8_t