LLVM 23.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"
19#include <cassert>
20
21namespace llvm {
22namespace abi {
23
25 /// Pass it using the normal C aggregate rules for the ABI, potentially
26 /// introducing extra copies and passing some or all of it in registers.
28
29 /// Pass it on the stack using its defined layout. The argument must be
30 /// evaluated directly into the correct stack position in the arguments area,
31 /// and the call machinery must not move it or introduce extra copies.
33
34 /// Pass it as a pointer to temporary memory.
36};
37
38/// Flags controlling target-specific ABI compatibility behaviour.
39/// Construct with the default constructor for the current ABI, or use
40/// fromVersion() to get the flags that match a specific Clang version.
46 bool Clang11Compat : 1;
47
52
53 /// Return flags matching the ABI emitted by the given Clang major version.
54 // TODO: fill in per-version flag overrides.
55 static ABICompatInfo fromVersion(unsigned /*ClangMajor*/) {
56 return ABICompatInfo();
57 }
58};
59
61private:
62 ABICompatInfo CompatInfo;
63
64public:
65 TargetInfo() : CompatInfo() {}
66 explicit TargetInfo(const ABICompatInfo &Info) : CompatInfo(Info) {}
67
68 virtual ~TargetInfo() = default;
69
70 /// Populate FI with the target's ABI-lowering decisions for each argument
71 /// and return value.
72 virtual void computeInfo(FunctionInfo &FI) const = 0;
73 virtual bool isPassByRef(const Type *Ty) const { return false; }
74 const ABICompatInfo &getABICompatInfo() const { return CompatInfo; }
75
76protected:
78 RecordArgABI getRecordArgABI(const Type *Ty) const;
79 bool isPromotableInteger(const IntegerType *IT) const;
80 ArgInfo getNaturalAlignIndirect(const Type *Ty, bool ByVal = true) const;
81 bool isAggregateTypeForABI(const Type *Ty) const;
82};
83
84std::unique_ptr<TargetInfo> createBPFTargetInfo(TypeBuilder &TB);
85
86} // namespace abi
87} // namespace llvm
88
89#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")))
Helper class to encapsulate information about how a specific type should be passed to or returned fro...
ArgInfo getNaturalAlignIndirect(const Type *Ty, bool ByVal=true) const
const ABICompatInfo & getABICompatInfo() const
Definition TargetInfo.h:74
virtual void computeInfo(FunctionInfo &FI) const =0
Populate FI with the target's ABI-lowering decisions for each argument and return value.
bool isPromotableInteger(const IntegerType *IT) const
virtual ~TargetInfo()=default
virtual bool isPassByRef(const Type *Ty) const
Definition TargetInfo.h:73
bool isAggregateTypeForABI(const Type *Ty) const
RecordArgABI getRecordArgABI(const RecordType *RT) const
TargetInfo(const ABICompatInfo &Info)
Definition TargetInfo.h:66
Represents the ABI-specific view of a type in LLVM.
Definition Types.h:43
This file defines the type system for the LLVMABI library, which mirrors ABI-relevant aspects of fron...
std::unique_ptr< TargetInfo > createBPFTargetInfo(TypeBuilder &TB)
Definition BPF.cpp:84
@ RAA_Indirect
Pass it as a pointer to temporary memory.
Definition TargetInfo.h:35
@ RAA_DirectInMemory
Pass it on the stack using its defined layout.
Definition TargetInfo.h:32
@ RAA_Default
Pass it using the normal C aggregate rules for the ABI, potentially introducing extra copies and pass...
Definition TargetInfo.h:27
This is an optimization pass for GlobalISel generic memory operations.
Flags controlling target-specific ABI compatibility behaviour.
Definition TargetInfo.h:41
static ABICompatInfo fromVersion(unsigned)
Return flags matching the ABI emitted by the given Clang major version.
Definition TargetInfo.h:55
bool ReturnCXXRecordGreaterThan128InMem
Definition TargetInfo.h:43