clang  3.8.0
ABIInfo.h
Go to the documentation of this file.
1 //===----- 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 
10 #ifndef LLVM_CLANG_LIB_CODEGEN_ABIINFO_H
11 #define LLVM_CLANG_LIB_CODEGEN_ABIINFO_H
12 
13 #include "clang/AST/Type.h"
14 #include "llvm/IR/CallingConv.h"
15 #include "llvm/IR/Type.h"
16 
17 namespace llvm {
18  class Value;
19  class LLVMContext;
20  class DataLayout;
21 }
22 
23 namespace clang {
24  class ASTContext;
25  class TargetInfo;
26 
27  namespace CodeGen {
28  class ABIArgInfo;
29  class Address;
30  class CGCXXABI;
31  class CGFunctionInfo;
32  class CodeGenFunction;
33  class CodeGenTypes;
34  }
35 
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.
40 
41 
42  /// ABIInfo - Target specific hooks for defining how a type should be
43  /// passed or returned from functions.
44  class ABIInfo {
45  public:
47  protected:
50  public:
52  : CGT(cgt),
53  RuntimeCC(llvm::CallingConv::C),
54  BuiltinCC(llvm::CallingConv::C) {}
55 
56  virtual ~ABIInfo();
57 
59  ASTContext &getContext() const;
60  llvm::LLVMContext &getVMContext() const;
61  const llvm::DataLayout &getDataLayout() const;
62  const TargetInfo &getTarget() const;
63 
64  /// Return the calling convention to use for system runtime
65  /// functions.
67  return RuntimeCC;
68  }
69 
70  /// Return the calling convention to use for compiler builtins
72  return BuiltinCC;
73  }
74 
75  virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const = 0;
76 
77  /// EmitVAArg - Emit the target dependent code to load a value of
78  /// \arg Ty from the va_list pointed to by \arg VAListAddr.
79 
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
83  // abstract this out.
85  CodeGen::Address VAListAddr,
86  QualType Ty) const = 0;
87 
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.
91  CodeGen::Address VAListAddr,
92  QualType Ty) const;
93 
94  virtual bool isHomogeneousAggregateBaseType(QualType Ty) const;
95 
96  virtual bool isHomogeneousAggregateSmallEnough(const Type *Base,
97  uint64_t Members) const;
98 
99  virtual bool shouldSignExtUnsignedType(QualType Ty) const;
100 
101  bool isHomogeneousAggregate(QualType Ty, const Type *&Base,
102  uint64_t &Members) const;
103 
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;
110 
112  getNaturalAlignIndirectInReg(QualType Ty, bool Realign = false) const;
113  };
114 } // end namespace clang
115 
116 #endif
A (possibly-)qualified type.
Definition: Type.h:575
const TargetInfo & getTarget() const
C Language Family Type Representation.
The base class of the type hierarchy.
Definition: Type.h:1249
virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const =0
ABIInfo(CodeGen::CodeGenTypes &cgt)
Definition: ABIInfo.h:51
llvm::CallingConv::ID getRuntimeCC() const
Return the calling convention to use for system runtime functions.
Definition: ABIInfo.h:66
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:91
llvm::CallingConv::ID BuiltinCC
Definition: ABIInfo.h:49
CodeGen::CodeGenTypes & CGT
Definition: ABIInfo.h:46
virtual CodeGen::Address EmitMSVAArg(CodeGen::CodeGenFunction &CGF, CodeGen::Address VAListAddr, QualType Ty) const
Emit the target dependent code to load a value of.
virtual CodeGen::Address EmitVAArg(CodeGen::CodeGenFunction &CGF, CodeGen::Address VAListAddr, QualType Ty) const =0
EmitVAArg - Emit the target dependent code to load a value of.
ABIArgInfo - Helper class to encapsulate information about how a specific C type should be passed to ...
ABIInfo - Target specific hooks for defining how a type should be passed or returned from functions...
Definition: ABIInfo.h:44
CodeGen::ABIArgInfo getNaturalAlignIndirectInReg(QualType Ty, bool Realign=false) const
ID
Defines the set of possible language-specific address spaces.
Definition: AddressSpaces.h:27
Exposes information about the current target.
friend class ASTContext
Definition: Type.h:4012
llvm::LLVMContext & getVMContext() const
ASTContext & getContext() const
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:228
llvm::CallingConv::ID getBuiltinCC() const
Return the calling convention to use for compiler builtins.
Definition: ABIInfo.h:71
virtual bool shouldSignExtUnsignedType(QualType Ty) const
bool isHomogeneousAggregate(QualType Ty, const Type *&Base, uint64_t &Members) const
isHomogeneousAggregate - Return true if a type is an ELFv2 homogeneous aggregate. ...
llvm::CallingConv::ID RuntimeCC
Definition: ABIInfo.h:48
An aligned address.
Definition: Address.h:25
CGFunctionInfo - Class to encapsulate the information about a function definition.
Implements C++ ABI-specific code generation functions.
Definition: CGCXXABI.h:43
This class organizes the cross-module state that is used while lowering AST types to LLVM types...
Definition: CodeGenTypes.h:120
virtual bool isHomogeneousAggregateSmallEnough(const Type *Base, uint64_t Members) const
CodeGen::CGCXXABI & getCXXABI() const
CodeGen::ABIArgInfo getNaturalAlignIndirect(QualType Ty, bool ByRef=true, bool Realign=false, llvm::Type *Padding=nullptr) const
A convenience method to return an indirect ABIArgInfo with an expected alignment equal to the ABI ali...
const llvm::DataLayout & getDataLayout() const
virtual bool isHomogeneousAggregateBaseType(QualType Ty) const