LLVM 24.0.0git
TargetInfo.h
Go to the documentation of this file.
1//===----- TargetInfo.h - Target ABI information ------------------- 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/// \file
10/// Target-specific ABI information and factory functions.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_ABI_TARGETINFO_H
15#define LLVM_ABI_TARGETINFO_H
16
18#include "llvm/ABI/Types.h"
20#include <cassert>
21#include <memory>
22
23namespace llvm {
24namespace abi {
25
27 /// Pass it using the normal C aggregate rules for the ABI, potentially
28 /// introducing extra copies and passing some or all of it in registers.
30
31 /// Pass it on the stack using its defined layout. The argument must be
32 /// evaluated directly into the correct stack position in the arguments area,
33 /// and the call machinery must not move it or introduce extra copies.
35
36 /// Pass it as a pointer to temporary memory.
38};
39
40/// Flags controlling target-specific ABI compatibility behaviour.
41/// Construct with the default constructor for the current ABI, or use
42/// fromVersion() to get the flags that match a specific Clang version.
48 bool Clang11Compat : 1;
50
55
56 /// Return flags matching the ABI emitted by the given Clang major version.
57 // TODO: fill in per-version flag overrides.
58 static ABICompatInfo fromVersion(unsigned /*ClangMajor*/) {
59 return ABICompatInfo();
60 }
61};
62
64private:
65 ABICompatInfo CompatInfo;
66
67public:
68 TargetInfo() : CompatInfo() {}
69 explicit TargetInfo(const ABICompatInfo &Info) : CompatInfo(Info) {}
70
71 virtual ~TargetInfo() = default;
72
73 /// Populate FI with the target's ABI-lowering decisions for each argument
74 /// and return value.
75 virtual void computeInfo(FunctionInfo &FI) const = 0;
76 virtual bool isPassByRef(const Type *Ty) const { return false; }
77 const ABICompatInfo &getABICompatInfo() const { return CompatInfo; }
78
79protected:
82 LLVM_ABI bool isPromotableInteger(const IntegerType *IT) const;
84 bool ByVal = true) const;
85 LLVM_ABI bool isAggregateTypeForABI(const Type *Ty) const;
86
87 /// If Ty is a transparent union, return its first field type; otherwise
88 /// return Ty unchanged.
89 LLVM_ABI const Type *useFirstFieldIfTransparentUnion(const Type *Ty) const;
90
91 /// Apply rules for classifying return types that are common to all targets.
93};
94
95LLVM_ABI std::unique_ptr<TargetInfo> createBPFTargetInfo(TypeBuilder &TB);
96
97/// The AVX ABI level for X86 targets.
98enum class X86AVXABILevel {
102 Last = AVX512 // must be last
103};
104
105LLVM_ABI std::unique_ptr<TargetInfo>
106createX86_64TargetInfo(TypeBuilder &TB, X86AVXABILevel AVXLevel,
107 bool Has64BitPointers, const ABICompatInfo &Compat);
108
115
116LLVM_ABI std::unique_ptr<TargetInfo>
117createAArch64TargetInfo(TypeBuilder &TB, AArch64ABIKind Kind);
118
119} // namespace abi
120} // namespace llvm
121
122#endif // LLVM_ABI_TARGETINFO_H
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
#define LLVM_ABI
Definition Compiler.h:215
Helper class to encapsulate information about how a specific type should be passed to or returned fro...
LLVM_ABI ArgInfo getNaturalAlignIndirect(const Type *Ty, bool ByVal=true) const
const ABICompatInfo & getABICompatInfo() const
Definition TargetInfo.h:77
virtual void computeInfo(FunctionInfo &FI) const =0
Populate FI with the target's ABI-lowering decisions for each argument and return value.
LLVM_ABI bool isPromotableInteger(const IntegerType *IT) const
virtual ~TargetInfo()=default
virtual bool isPassByRef(const Type *Ty) const
Definition TargetInfo.h:76
LLVM_ABI bool maybeCommonClassifyReturnType(FunctionInfo &FI) const
Apply rules for classifying return types that are common to all targets.
LLVM_ABI bool isAggregateTypeForABI(const Type *Ty) const
LLVM_ABI const Type * useFirstFieldIfTransparentUnion(const Type *Ty) const
If Ty is a transparent union, return its first field type; otherwise return Ty unchanged.
LLVM_ABI RecordArgABI getRecordArgABI(const RecordType *RT) const
TargetInfo(const ABICompatInfo &Info)
Definition TargetInfo.h:69
Represents the ABI-specific view of a type in LLVM.
Definition Types.h:44
This file defines the type system for the LLVMABI library, which mirrors ABI-relevant aspects of fron...
LLVM_ABI std::unique_ptr< TargetInfo > createBPFTargetInfo(TypeBuilder &TB)
Definition BPF.cpp:84
LLVM_ABI std::unique_ptr< TargetInfo > createAArch64TargetInfo(TypeBuilder &TB, AArch64ABIKind Kind)
Definition AArch64.cpp:52
X86AVXABILevel
The AVX ABI level for X86 targets.
Definition TargetInfo.h:98
LLVM_ABI std::unique_ptr< TargetInfo > createX86_64TargetInfo(TypeBuilder &TB, X86AVXABILevel AVXLevel, bool Has64BitPointers, const ABICompatInfo &Compat)
Definition X86.cpp:1454
@ RAA_Indirect
Pass it as a pointer to temporary memory.
Definition TargetInfo.h:37
@ RAA_DirectInMemory
Pass it on the stack using its defined layout.
Definition TargetInfo.h:34
@ RAA_Default
Pass it using the normal C aggregate rules for the ABI, potentially introducing extra copies and pass...
Definition TargetInfo.h:29
This is an optimization pass for GlobalISel generic memory operations.
Flags controlling target-specific ABI compatibility behaviour.
Definition TargetInfo.h:43
static ABICompatInfo fromVersion(unsigned)
Return flags matching the ABI emitted by the given Clang major version.
Definition TargetInfo.h:58
bool ReturnCXXRecordGreaterThan128InMem
Definition TargetInfo.h:45