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;
49
54
55 /// Return flags matching the ABI emitted by the given Clang major version.
56 // TODO: fill in per-version flag overrides.
57 static ABICompatInfo fromVersion(unsigned /*ClangMajor*/) {
58 return ABICompatInfo();
59 }
60};
61
63private:
64 ABICompatInfo CompatInfo;
65
66public:
67 TargetInfo() : CompatInfo() {}
68 explicit TargetInfo(const ABICompatInfo &Info) : CompatInfo(Info) {}
69
70 virtual ~TargetInfo() = default;
71
72 /// Populate FI with the target's ABI-lowering decisions for each argument
73 /// and return value.
74 virtual void computeInfo(FunctionInfo &FI) const = 0;
75 virtual bool isPassByRef(const Type *Ty) const { return false; }
76 const ABICompatInfo &getABICompatInfo() const { return CompatInfo; }
77
78protected:
81 LLVM_ABI bool isPromotableInteger(const IntegerType *IT) const;
83 bool ByVal = true) const;
84 LLVM_ABI bool isAggregateTypeForABI(const Type *Ty) const;
85};
86
87LLVM_ABI std::unique_ptr<TargetInfo> createBPFTargetInfo(TypeBuilder &TB);
88
89/// The AVX ABI level for X86 targets.
95
96LLVM_ABI std::unique_ptr<TargetInfo>
97createX86_64TargetInfo(TypeBuilder &TB, X86AVXABILevel AVXLevel,
98 bool Has64BitPointers, const ABICompatInfo &Compat);
99
100} // namespace abi
101} // namespace llvm
102
103#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:76
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:75
LLVM_ABI bool isAggregateTypeForABI(const Type *Ty) const
LLVM_ABI RecordArgABI getRecordArgABI(const RecordType *RT) const
TargetInfo(const ABICompatInfo &Info)
Definition TargetInfo.h:68
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
X86AVXABILevel
The AVX ABI level for X86 targets.
Definition TargetInfo.h:90
LLVM_ABI std::unique_ptr< TargetInfo > createX86_64TargetInfo(TypeBuilder &TB, X86AVXABILevel AVXLevel, bool Has64BitPointers, const ABICompatInfo &Compat)
Definition X86.cpp:1494
@ 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:57
bool ReturnCXXRecordGreaterThan128InMem
Definition TargetInfo.h:45