Anton Korobeynikov | 82d0a41 | 2010-01-10 12:58:08 +0000 | [diff] [blame] | 1 | //===---- TargetInfo.h - Encapsulate target details -------------*- 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 | // These classes wrap the information about a call or function |
| 11 | // definition used to handle ABI compliancy. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef CLANG_CODEGEN_TARGETINFO_H |
| 16 | #define CLANG_CODEGEN_TARGETINFO_H |
| 17 | |
Peter Collingbourne | ef9a1d0 | 2011-02-18 02:24:56 +0000 | [diff] [blame^] | 18 | #include "llvm/ADT/StringRef.h" |
| 19 | |
Anton Korobeynikov | 82d0a41 | 2010-01-10 12:58:08 +0000 | [diff] [blame] | 20 | namespace llvm { |
| 21 | class GlobalValue; |
Peter Collingbourne | ef9a1d0 | 2011-02-18 02:24:56 +0000 | [diff] [blame^] | 22 | class Type; |
John McCall | 492c4f9 | 2010-03-03 04:15:11 +0000 | [diff] [blame] | 23 | class Value; |
Anton Korobeynikov | 82d0a41 | 2010-01-10 12:58:08 +0000 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | namespace clang { |
| 27 | class ABIInfo; |
| 28 | class Decl; |
| 29 | |
| 30 | namespace CodeGen { |
| 31 | class CodeGenModule; |
John McCall | 492c4f9 | 2010-03-03 04:15:11 +0000 | [diff] [blame] | 32 | class CodeGenFunction; |
Anton Korobeynikov | 82d0a41 | 2010-01-10 12:58:08 +0000 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | /// TargetCodeGenInfo - This class organizes various target-specific |
| 36 | /// codegeneration issues, like target-specific attributes, builtins and so |
| 37 | /// on. |
| 38 | class TargetCodeGenInfo { |
| 39 | ABIInfo *Info; |
| 40 | public: |
| 41 | // WARNING: Acquires the ownership of ABIInfo. |
Douglas Gregor | 568bb2d | 2010-01-22 15:41:14 +0000 | [diff] [blame] | 42 | TargetCodeGenInfo(ABIInfo *info = 0):Info(info) { } |
Anton Korobeynikov | 82d0a41 | 2010-01-10 12:58:08 +0000 | [diff] [blame] | 43 | virtual ~TargetCodeGenInfo(); |
| 44 | |
| 45 | /// getABIInfo() - Returns ABI info helper for the target. |
| 46 | const ABIInfo& getABIInfo() const { return *Info; } |
| 47 | |
| 48 | /// SetTargetAttributes - Provides a convenient hook to handle extra |
| 49 | /// target-specific attributes for the given global. |
| 50 | virtual void SetTargetAttributes(const Decl *D, llvm::GlobalValue *GV, |
Douglas Gregor | 568bb2d | 2010-01-22 15:41:14 +0000 | [diff] [blame] | 51 | CodeGen::CodeGenModule &M) const { } |
John McCall | d0b76ca | 2010-03-02 03:50:12 +0000 | [diff] [blame] | 52 | |
John McCall | 204b075 | 2010-07-20 22:17:55 +0000 | [diff] [blame] | 53 | /// Determines the size of struct _Unwind_Exception on this platform, |
| 54 | /// in 8-bit units. The Itanium ABI defines this as: |
| 55 | /// struct _Unwind_Exception { |
| 56 | /// uint64 exception_class; |
| 57 | /// _Unwind_Exception_Cleanup_Fn exception_cleanup; |
| 58 | /// uint64 private_1; |
| 59 | /// uint64 private_2; |
| 60 | /// }; |
| 61 | unsigned getSizeOfUnwindException() const { return 32; } |
| 62 | |
John McCall | d0b76ca | 2010-03-02 03:50:12 +0000 | [diff] [blame] | 63 | /// Controls whether __builtin_extend_pointer should sign-extend |
| 64 | /// pointers to uint64_t or zero-extend them (the default). Has |
| 65 | /// no effect for targets: |
| 66 | /// - that have 64-bit pointers, or |
| 67 | /// - that cannot address through registers larger than pointers, or |
| 68 | /// - that implicitly ignore/truncate the top bits when addressing |
| 69 | /// through such registers. |
| 70 | virtual bool extendPointerWithSExt() const { return false; } |
John McCall | 492c4f9 | 2010-03-03 04:15:11 +0000 | [diff] [blame] | 71 | |
John McCall | 6374c33 | 2010-03-06 00:35:14 +0000 | [diff] [blame] | 72 | /// Determines the DWARF register number for the stack pointer, for |
| 73 | /// exception-handling purposes. Implements __builtin_dwarf_sp_column. |
| 74 | /// |
| 75 | /// Returns -1 if the operation is unsupported by this target. |
| 76 | virtual int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const { |
| 77 | return -1; |
| 78 | } |
| 79 | |
| 80 | /// Initializes the given DWARF EH register-size table, a char*. |
| 81 | /// Implements __builtin_init_dwarf_reg_size_table. |
| 82 | /// |
| 83 | /// Returns true if the operation is unsupported by this target. |
| 84 | virtual bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF, |
| 85 | llvm::Value *Address) const { |
| 86 | return true; |
| 87 | } |
| 88 | |
John McCall | 492c4f9 | 2010-03-03 04:15:11 +0000 | [diff] [blame] | 89 | /// Performs the code-generation required to convert a return |
| 90 | /// address as stored by the system into the actual address of the |
| 91 | /// next instruction that will be executed. |
| 92 | /// |
| 93 | /// Used by __builtin_extract_return_addr(). |
| 94 | virtual llvm::Value *decodeReturnAddress(CodeGen::CodeGenFunction &CGF, |
| 95 | llvm::Value *Address) const { |
| 96 | return Address; |
| 97 | } |
| 98 | |
| 99 | /// Performs the code-generation required to convert the address |
| 100 | /// of an instruction into a return address suitable for storage |
| 101 | /// by the system in a return slot. |
| 102 | /// |
| 103 | /// Used by __builtin_frob_return_addr(). |
| 104 | virtual llvm::Value *encodeReturnAddress(CodeGen::CodeGenFunction &CGF, |
| 105 | llvm::Value *Address) const { |
| 106 | return Address; |
| 107 | } |
Peter Collingbourne | ef9a1d0 | 2011-02-18 02:24:56 +0000 | [diff] [blame^] | 108 | |
| 109 | virtual const llvm::Type* adjustInlineAsmType(CodeGen::CodeGenFunction &CGF, |
| 110 | llvm::StringRef Constraint, |
| 111 | const llvm::Type* Ty) const { |
| 112 | return Ty; |
| 113 | } |
Anton Korobeynikov | 82d0a41 | 2010-01-10 12:58:08 +0000 | [diff] [blame] | 114 | }; |
| 115 | } |
| 116 | |
| 117 | #endif // CLANG_CODEGEN_TARGETINFO_H |