ABIInfo.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #ifndef LLVM_CLANG_LIB_CODEGEN_ABIINFO_H
  10. #define LLVM_CLANG_LIB_CODEGEN_ABIINFO_H
  11. #include "clang/AST/Type.h"
  12. #include "llvm/IR/CallingConv.h"
  13. #include "llvm/IR/Type.h"
  14. namespace llvm {
  15. class Value;
  16. class LLVMContext;
  17. class DataLayout;
  18. }
  19. namespace clang {
  20. class ASTContext;
  21. class TargetInfo;
  22. namespace CodeGen {
  23. class CGCXXABI;
  24. class CGFunctionInfo;
  25. class CodeGenFunction;
  26. class CodeGenTypes;
  27. }
  28. // FIXME: All of this stuff should be part of the target interface
  29. // somehow. It is currently here because it is not clear how to factor
  30. // the targets to support this, since the Targets currently live in a
  31. // layer below types n'stuff.
  32. /// ABIInfo - Target specific hooks for defining how a type should be
  33. /// passed or returned from functions.
  34. class ABIInfo {
  35. public:
  36. CodeGen::CodeGenTypes &CGT;
  37. protected:
  38. llvm::CallingConv::ID RuntimeCC;
  39. llvm::CallingConv::ID BuiltinCC;
  40. public:
  41. ABIInfo(CodeGen::CodeGenTypes &cgt)
  42. : CGT(cgt),
  43. RuntimeCC(llvm::CallingConv::C),
  44. BuiltinCC(llvm::CallingConv::C) {}
  45. virtual ~ABIInfo();
  46. CodeGen::CGCXXABI &getCXXABI() const;
  47. ASTContext &getContext() const;
  48. llvm::LLVMContext &getVMContext() const;
  49. const llvm::DataLayout &getDataLayout() const;
  50. const TargetInfo &getTarget() const;
  51. /// Return the calling convention to use for system runtime
  52. /// functions.
  53. llvm::CallingConv::ID getRuntimeCC() const {
  54. return RuntimeCC;
  55. }
  56. /// Return the calling convention to use for compiler builtins
  57. llvm::CallingConv::ID getBuiltinCC() const {
  58. return BuiltinCC;
  59. }
  60. virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const = 0;
  61. /// EmitVAArg - Emit the target dependent code to load a value of
  62. /// \arg Ty from the va_list pointed to by \arg VAListAddr.
  63. // FIXME: This is a gaping layering violation if we wanted to drop
  64. // the ABI information any lower than CodeGen. Of course, for
  65. // VAArg handling it has to be at this level; there is no way to
  66. // abstract this out.
  67. virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
  68. CodeGen::CodeGenFunction &CGF) const = 0;
  69. virtual bool isHomogeneousAggregateBaseType(QualType Ty) const;
  70. virtual bool isHomogeneousAggregateSmallEnough(const Type *Base,
  71. uint64_t Members) const;
  72. virtual bool shouldSignExtUnsignedType(QualType Ty) const;
  73. bool isHomogeneousAggregate(QualType Ty, const Type *&Base,
  74. uint64_t &Members) const;
  75. };
  76. } // end namespace clang
  77. #endif