blob: 2976b605d39780b60a031382fcd595f27245360c [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;
47 public:
48 ABIInfo(CodeGen::CodeGenTypes &cgt)
49 : CGT(cgt), RuntimeCC(llvm::CallingConv::C) {}
Michael J. Spencer9cac4942010-10-19 06:39:39 +000050
Daniel Dunbar9eb5c6d2009-02-03 01:05:53 +000051 virtual ~ABIInfo();
Michael J. Spencer9cac4942010-10-19 06:39:39 +000052
Mark Lacey23630722013-10-06 01:33:34 +000053 CodeGen::CGCXXABI &getCXXABI() const;
Chris Lattnerea044322010-07-29 02:01:43 +000054 ASTContext &getContext() const;
55 llvm::LLVMContext &getVMContext() const;
Micah Villmow25a6a842012-10-08 16:25:52 +000056 const llvm::DataLayout &getDataLayout() const;
John McCall64aa4b32013-04-16 22:48:15 +000057 const TargetInfo &getTarget() const;
Daniel Dunbar6bad2652009-02-03 06:51:18 +000058
John McCallbd7370a2013-02-28 19:01:20 +000059 /// Return the calling convention to use for system runtime
60 /// functions.
61 llvm::CallingConv::ID getRuntimeCC() const {
62 return RuntimeCC;
63 }
64
Chris Lattneree5dcd02010-07-29 02:31:05 +000065 virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const = 0;
Daniel Dunbarb53e3e72009-02-10 21:44:36 +000066
67 /// EmitVAArg - Emit the target dependent code to load a value of
68 /// \arg Ty from the va_list pointed to by \arg VAListAddr.
Anton Korobeynikovc4a59eb2009-06-05 22:08:42 +000069
Daniel Dunbarb53e3e72009-02-10 21:44:36 +000070 // FIXME: This is a gaping layering violation if we wanted to drop
71 // the ABI information any lower than CodeGen. Of course, for
72 // VAArg handling it has to be at this level; there is no way to
73 // abstract this out.
74 virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
75 CodeGen::CodeGenFunction &CGF) const = 0;
Stephen Hines176edba2014-12-01 14:53:08 -080076
77 virtual bool isHomogeneousAggregateBaseType(QualType Ty) const;
78
79 virtual bool isHomogeneousAggregateSmallEnough(const Type *Base,
80 uint64_t Members) const;
81
82 bool isHomogeneousAggregate(QualType Ty, const Type *&Base,
83 uint64_t &Members) const;
84
Daniel Dunbar9eb5c6d2009-02-03 01:05:53 +000085 };
86} // end namespace clang
87
88#endif