blob: cc8652e169d887fc2bcc819550878710719f95be [file] [log] [blame]
Daniel Dunbar6d6b0d32009-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
Benjamin Kramer2f5db8b2014-08-13 16:25:19 +000010#ifndef LLVM_CLANG_LIB_CODEGEN_ABIINFO_H
11#define LLVM_CLANG_LIB_CODEGEN_ABIINFO_H
Daniel Dunbar6d6b0d32009-02-03 01:05:53 +000012
Anton Korobeynikov244360d2009-06-05 22:08:42 +000013#include "clang/AST/Type.h"
John McCall882987f2013-02-28 19:01:20 +000014#include "llvm/IR/CallingConv.h"
Chandler Carruth5553d0d2014-01-07 11:51:46 +000015#include "llvm/IR/Type.h"
Anton Korobeynikov244360d2009-06-05 22:08:42 +000016
Daniel Dunbar313321e2009-02-03 05:31:23 +000017namespace llvm {
Anton Korobeynikov244360d2009-06-05 22:08:42 +000018 class Value;
Benjamin Kramer9cd050a2009-08-11 17:46:57 +000019 class LLVMContext;
Micah Villmowdd31ca12012-10-08 16:25:52 +000020 class DataLayout;
Daniel Dunbar313321e2009-02-03 05:31:23 +000021}
22
Daniel Dunbar6d6b0d32009-02-03 01:05:53 +000023namespace clang {
Daniel Dunbar32931eb2009-02-03 06:51:18 +000024 class ASTContext;
John McCallc8e01702013-04-16 22:48:15 +000025 class TargetInfo;
Daniel Dunbar32931eb2009-02-03 06:51:18 +000026
Daniel Dunbar32931eb2009-02-03 06:51:18 +000027 namespace CodeGen {
Mark Lacey3825e832013-10-06 01:33:34 +000028 class CGCXXABI;
Daniel Dunbar32931eb2009-02-03 06:51:18 +000029 class CGFunctionInfo;
Daniel Dunbare46506e2009-02-10 21:44:36 +000030 class CodeGenFunction;
Chris Lattner2b037972010-07-29 02:01:43 +000031 class CodeGenTypes;
Daniel Dunbar32931eb2009-02-03 06:51:18 +000032 }
33
Chris Lattner4b8585e2010-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 Dunbar6d6b0d32009-02-03 01:05:53 +000038
Daniel Dunbar6d6b0d32009-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 Lattner2b037972010-07-29 02:01:43 +000044 CodeGen::CodeGenTypes &CGT;
John McCall882987f2013-02-28 19:01:20 +000045 protected:
46 llvm::CallingConv::ID RuntimeCC;
Anton Korobeynikovd90dd792014-12-02 16:04:58 +000047 llvm::CallingConv::ID BuiltinCC;
John McCall882987f2013-02-28 19:01:20 +000048 public:
49 ABIInfo(CodeGen::CodeGenTypes &cgt)
Anton Korobeynikovd90dd792014-12-02 16:04:58 +000050 : CGT(cgt),
51 RuntimeCC(llvm::CallingConv::C),
52 BuiltinCC(llvm::CallingConv::C) {}
Michael J. Spencerf5a1fbc2010-10-19 06:39:39 +000053
Daniel Dunbar6d6b0d32009-02-03 01:05:53 +000054 virtual ~ABIInfo();
Michael J. Spencerf5a1fbc2010-10-19 06:39:39 +000055
Mark Lacey3825e832013-10-06 01:33:34 +000056 CodeGen::CGCXXABI &getCXXABI() const;
Chris Lattner2b037972010-07-29 02:01:43 +000057 ASTContext &getContext() const;
58 llvm::LLVMContext &getVMContext() const;
Micah Villmowdd31ca12012-10-08 16:25:52 +000059 const llvm::DataLayout &getDataLayout() const;
John McCallc8e01702013-04-16 22:48:15 +000060 const TargetInfo &getTarget() const;
Daniel Dunbar32931eb2009-02-03 06:51:18 +000061
John McCall882987f2013-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
Anton Korobeynikovd90dd792014-12-02 16:04:58 +000068 /// Return the calling convention to use for compiler builtins
69 llvm::CallingConv::ID getBuiltinCC() const {
70 return BuiltinCC;
71 }
72
Chris Lattner22326a12010-07-29 02:31:05 +000073 virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const = 0;
Daniel Dunbare46506e2009-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 Korobeynikov244360d2009-06-05 22:08:42 +000077
Daniel Dunbare46506e2009-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;
Reid Klecknere9f6a712014-10-31 17:10:41 +000084
85 virtual bool isHomogeneousAggregateBaseType(QualType Ty) const;
86
87 virtual bool isHomogeneousAggregateSmallEnough(const Type *Base,
88 uint64_t Members) const;
89
Petar Jovanovic1a3f9652015-05-26 21:07:19 +000090 virtual bool shouldSignExtUnsignedType(QualType Ty) const;
91
Reid Klecknere9f6a712014-10-31 17:10:41 +000092 bool isHomogeneousAggregate(QualType Ty, const Type *&Base,
93 uint64_t &Members) const;
94
Daniel Dunbar6d6b0d32009-02-03 01:05:53 +000095 };
96} // end namespace clang
97
98#endif