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#include <optional>
22
23namespace llvm {
24class Triple;
25} // namespace llvm
26
27namespace clang {
28class Decl;
29class FunctionDecl;
30class QualType;
31class TargetInfo;
32} // namespace clang
33
34namespace clang::CodeGenUtils {
35
36//===----------------------------------------------------------------------===//
37// Arm and AArch64
38//===----------------------------------------------------------------------===//
39
40/// The Arm SME ABI issues that can prevent inlining one function into another.
53
54/// Determines if there are any Arm SME ABI issues with inlining \p Callee into
55/// \p Caller. Returns the issue (if any) in the ArmSMEInlinability bit enum.
57 const FunctionDecl *Callee);
58
59/// Returns whether the Neon builtin \p BuiltinID takes a trailing argument
60/// that discriminates the operand type. This should be kept consistent with
61/// the logic in Sema.
62/// TODO: Make this return false for SISD builtins.
63bool hasExtraNeonArgument(unsigned BuiltinID);
64
65/// Helper method to check if the underlying ABI is AAPCS
66bool isAAPCS(const TargetInfo &TargetInfo);
67
68//===----------------------------------------------------------------------===//
69// X86
70//===----------------------------------------------------------------------===//
114
115std::optional<MSVCIntrin> translateX86ToMsvcIntrin(unsigned BuiltinID);
116
117// Library builtins (PowerPC64 and AIX)
118//===----------------------------------------------------------------------===//
119
120/// Returns the library function name that should be called for the library
121/// builtin \p BuiltinID when the target's library does not use the name derived
122/// from the builtin (e.g. PPC64 IEEE 128-bit long double libcalls, or AIX with
123/// 64-bit long double), or an empty StringRef if there is no such override.
124llvm::StringRef getTargetBuiltinLibFunctionName(unsigned BuiltinID,
125 const TargetInfo &Target);
126
127//===----------------------------------------------------------------------===//
128// AMDGPU
129//===----------------------------------------------------------------------===//
130
131/// Returns whether \p D must be given protected visibility on AMDGPU.
132/// \p HasHiddenVisibility is whether the emitted global currently has hidden
133/// visibility.
134bool requiresAMDGPUProtectedVisibility(const Decl *D, bool HasHiddenVisibility);
135
136//===----------------------------------------------------------------------===//
137// SPIR-V
138//===----------------------------------------------------------------------===//
139
140/// Return true if a SPIR(-V) null pointer of type \p QT must be materialized
141/// as an addrspacecast from a generic null pointer, as the null bit pattern in
142/// non-generic address spaces is unspecified.
143bool spirNullPointerNeedsGenericCast(QualType QT, const llvm::Triple &Triple);
144
145} // namespace clang::CodeGenUtils
146
147#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:2082
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...
std::optional< MSVCIntrin > translateX86ToMsvcIntrin(unsigned BuiltinID)
ArmSMEInlinability
The Arm SME ABI issues that can prevent inlining one function into another.
Definition TargetUtils.h:41
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
int32_t uint32_t uint32_t __builtin_riscv_mhracc_i32 __builtin_riscv_mhraccu_u32 __builtin_riscv_mhraccsu_i32 __builtin_riscv_mhacc_h1_i32 __builtin_riscv_mhaccsu_h1_i32 __builtin_riscv_mulqr_i32 __builtin_riscv_mqrwacc_i64 __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 uint8_t