blob: 7e7f7fa2067927e2ed3b3de749f8f58f2ab5c699 [file] [log] [blame]
Daniel Dunbar9eb5c6d2009-02-03 01:05:53 +00001//===----- ABIInfo.h - ABI information access & encapsulation ---*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
Stephen Hines176edba2014-12-01 14:53:08 -080010#ifndef LLVM_CLANG_LIB_CODEGEN_ABIINFO_H
11#define LLVM_CLANG_LIB_CODEGEN_ABIINFO_H
Daniel Dunbar9eb5c6d2009-02-03 01:05:53 +000012
Anton Korobeynikovc4a59eb2009-06-05 22:08:42 +000013#include "clang/AST/Type.h"
John McCallbd7370a2013-02-28 19:01:20 +000014#include "llvm/IR/CallingConv.h"
Stephen Hines651f13c2014-04-23 16:59:28 -070015#include "llvm/IR/Type.h"
Anton Korobeynikovc4a59eb2009-06-05 22:08:42 +000016
Daniel Dunbar88c2fa92009-02-03 05:31:23 +000017namespace llvm {
Anton Korobeynikovc4a59eb2009-06-05 22:08:42 +000018 class Value;
Benjamin Kramerf21efe92009-08-11 17:46:57 +000019 class LLVMContext;
Micah Villmow25a6a842012-10-08 16:25:52 +000020 class DataLayout;
Daniel Dunbar88c2fa92009-02-03 05:31:23 +000021}
22
Daniel Dunbar9eb5c6d2009-02-03 01:05:53 +000023namespace clang {
Daniel Dunbar6bad2652009-02-03 06:51:18 +000024 class ASTContext;
John McCall64aa4b32013-04-16 22:48:15 +000025 class TargetInfo;
Daniel Dunbar6bad2652009-02-03 06:51:18 +000026
Daniel Dunbar6bad2652009-02-03 06:51:18 +000027 namespace CodeGen {
Mark Lacey23630722013-10-06 01:33:34 +000028 class CGCXXABI;
Daniel Dunbar6bad2652009-02-03 06:51:18 +000029 class CGFunctionInfo;
Daniel Dunbarb53e3e72009-02-10 21:44:36 +000030 class CodeGenFunction;
Chris Lattnerea044322010-07-29 02:01:43 +000031 class CodeGenTypes;
Daniel Dunbar6bad2652009-02-03 06:51:18 +000032 }
33
Chris Lattner2eb9cdd2010-07-28 23:46:15 +000034 // FIXME: All of this stuff should be part of the target interface
35 // somehow. It is currently here because it is not clear how to factor
36 // the targets to support this, since the Targets currently live in a
37 // layer below types n'stuff.
Daniel Dunbar9eb5c6d2009-02-03 01:05:53 +000038
Daniel Dunbar9eb5c6d2009-02-03 01:05:53 +000039
40 /// ABIInfo - Target specific hooks for defining how a type should be
41 /// passed or returned from functions.
42 class ABIInfo {
43 public:
Chris Lattnerea044322010-07-29 02:01:43 +000044 CodeGen::CodeGenTypes &CGT;
John McCallbd7370a2013-02-28 19:01:20 +000045 protected:
46 llvm::CallingConv::ID RuntimeCC;
Stephen Hines0e2c34f2015-03-23 12:09:02 -070047 llvm::CallingConv::ID BuiltinCC;
John McCallbd7370a2013-02-28 19:01:20 +000048 public:
49 ABIInfo(CodeGen::CodeGenTypes &cgt)
Stephen Hines0e2c34f2015-03-23 12:09:02 -070050 : CGT(cgt),
51 RuntimeCC(llvm::CallingConv::C),
52 BuiltinCC(llvm::CallingConv::C) {}
Michael J. Spencer9cac4942010-10-19 06:39:39 +000053
Daniel Dunbar9eb5c6d2009-02-03 01:05:53 +000054 virtual ~ABIInfo();
Michael J. Spencer9cac4942010-10-19 06:39:39 +000055
Mark Lacey23630722013-10-06 01:33:34 +000056 CodeGen::CGCXXABI &getCXXABI() const;
Chris Lattnerea044322010-07-29 02:01:43 +000057 ASTContext &getContext() const;
58 llvm::LLVMContext &getVMContext() const;
Micah Villmow25a6a842012-10-08 16:25:52 +000059 const llvm::DataLayout &getDataLayout() const;
John McCall64aa4b32013-04-16 22:48:15 +000060 const TargetInfo &getTarget() const;
Daniel Dunbar6bad2652009-02-03 06:51:18 +000061
John McCallbd7370a2013-02-28 19:01:20 +000062 /// Return the calling convention to use for system runtime
63 /// functions.
64 llvm::CallingConv::ID getRuntimeCC() const {
65 return RuntimeCC;
66 }
67
Stephen Hines0e2c34f2015-03-23 12:09:02 -070068 /// Return the calling convention to use for compiler builtins
69 llvm::CallingConv::ID getBuiltinCC() const {
70 return BuiltinCC;
71 }
72
Chris Lattneree5dcd02010-07-29 02:31:05 +000073 virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const = 0;
Daniel Dunbarb53e3e72009-02-10 21:44:36 +000074
75 /// EmitVAArg - Emit the target dependent code to load a value of
76 /// \arg Ty from the va_list pointed to by \arg VAListAddr.
Anton Korobeynikovc4a59eb2009-06-05 22:08:42 +000077
Daniel Dunbarb53e3e72009-02-10 21:44:36 +000078 // FIXME: This is a gaping layering violation if we wanted to drop
79 // the ABI information any lower than CodeGen. Of course, for
80 // VAArg handling it has to be at this level; there is no way to
81 // abstract this out.
82 virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
83 CodeGen::CodeGenFunction &CGF) const = 0;
Stephen Hines176edba2014-12-01 14:53:08 -080084
85 virtual bool isHomogeneousAggregateBaseType(QualType Ty) const;
86
87 virtual bool isHomogeneousAggregateSmallEnough(const Type *Base,
88 uint64_t Members) const;
89
90 bool isHomogeneousAggregate(QualType Ty, const Type *&Base,
91 uint64_t &Members) const;
92
Daniel Dunbar9eb5c6d2009-02-03 01:05:53 +000093 };
94} // end namespace clang
95
96#endif