blob: 9ca576630be8b3d532a94173d641345e7a142050 [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;
47 public:
48 ABIInfo(CodeGen::CodeGenTypes &cgt)
49 : CGT(cgt), RuntimeCC(llvm::CallingConv::C) {}
Michael J. Spencerf5a1fbc2010-10-19 06:39:39 +000050
Daniel Dunbar6d6b0d32009-02-03 01:05:53 +000051 virtual ~ABIInfo();
Michael J. Spencerf5a1fbc2010-10-19 06:39:39 +000052
Mark Lacey3825e832013-10-06 01:33:34 +000053 CodeGen::CGCXXABI &getCXXABI() const;
Chris Lattner2b037972010-07-29 02:01:43 +000054 ASTContext &getContext() const;
55 llvm::LLVMContext &getVMContext() const;
Micah Villmowdd31ca12012-10-08 16:25:52 +000056 const llvm::DataLayout &getDataLayout() const;
John McCallc8e01702013-04-16 22:48:15 +000057 const TargetInfo &getTarget() const;
Daniel Dunbar32931eb2009-02-03 06:51:18 +000058
John McCall882987f2013-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 Lattner22326a12010-07-29 02:31:05 +000065 virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const = 0;
Daniel Dunbare46506e2009-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 Korobeynikov244360d2009-06-05 22:08:42 +000069
Daniel Dunbare46506e2009-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;
Daniel Dunbar6d6b0d32009-02-03 01:05:53 +000076 };
77} // end namespace clang
78
79#endif