1 //===----- ABIInfo.h - ABI information access & encapsulation ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_CLANG_LIB_CODEGEN_ABIINFO_H
11 #define LLVM_CLANG_LIB_CODEGEN_ABIINFO_H
13 #include "clang/AST/Type.h"
14 #include "llvm/IR/CallingConv.h"
15 #include "llvm/IR/Type.h"
32 class CodeGenFunction;
36 // FIXME: All of this stuff should be part of the target interface
37 // somehow. It is currently here because it is not clear how to factor
38 // the targets to support this, since the Targets currently live in a
39 // layer below types n'stuff.
42 /// ABIInfo - Target specific hooks for defining how a type should be
43 /// passed or returned from functions.
46 CodeGen::CodeGenTypes &CGT;
48 llvm::CallingConv::ID RuntimeCC;
49 llvm::CallingConv::ID BuiltinCC;
51 ABIInfo(CodeGen::CodeGenTypes &cgt)
53 RuntimeCC(llvm::CallingConv::C),
54 BuiltinCC(llvm::CallingConv::C) {}
58 CodeGen::CGCXXABI &getCXXABI() const;
59 ASTContext &getContext() const;
60 llvm::LLVMContext &getVMContext() const;
61 const llvm::DataLayout &getDataLayout() const;
62 const TargetInfo &getTarget() const;
64 /// Return the calling convention to use for system runtime
66 llvm::CallingConv::ID getRuntimeCC() const {
70 /// Return the calling convention to use for compiler builtins
71 llvm::CallingConv::ID getBuiltinCC() const {
75 virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const = 0;
77 /// EmitVAArg - Emit the target dependent code to load a value of
78 /// \arg Ty from the va_list pointed to by \arg VAListAddr.
80 // FIXME: This is a gaping layering violation if we wanted to drop
81 // the ABI information any lower than CodeGen. Of course, for
82 // VAArg handling it has to be at this level; there is no way to
84 virtual CodeGen::Address EmitVAArg(CodeGen::CodeGenFunction &CGF,
85 CodeGen::Address VAListAddr,
86 QualType Ty) const = 0;
88 /// Emit the target dependent code to load a value of
89 /// \arg Ty from the \c __builtin_ms_va_list pointed to by \arg VAListAddr.
90 virtual CodeGen::Address EmitMSVAArg(CodeGen::CodeGenFunction &CGF,
91 CodeGen::Address VAListAddr,
94 virtual bool isHomogeneousAggregateBaseType(QualType Ty) const;
96 virtual bool isHomogeneousAggregateSmallEnough(const Type *Base,
97 uint64_t Members) const;
99 virtual bool shouldSignExtUnsignedType(QualType Ty) const;
101 bool isHomogeneousAggregate(QualType Ty, const Type *&Base,
102 uint64_t &Members) const;
104 /// A convenience method to return an indirect ABIArgInfo with an
105 /// expected alignment equal to the ABI alignment of the given type.
107 getNaturalAlignIndirect(QualType Ty, bool ByRef = true,
108 bool Realign = false,
109 llvm::Type *Padding = nullptr) const;
112 getNaturalAlignIndirectInReg(QualType Ty, bool Realign = false) const;
114 } // end namespace clang