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