1 //===---- TargetInfo.h - Encapsulate target details -------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // These classes wrap the information about a call or function
11 // definition used to handle ABI compliancy.
13 //===----------------------------------------------------------------------===//
15 #ifndef CLANG_CODEGEN_TARGETINFO_H
16 #define CLANG_CODEGEN_TARGETINFO_H
18 #include "llvm/ADT/StringRef.h"
32 class CodeGenFunction;
35 /// TargetCodeGenInfo - This class organizes various target-specific
36 /// codegeneration issues, like target-specific attributes, builtins and so
38 class TargetCodeGenInfo {
41 // WARNING: Acquires the ownership of ABIInfo.
42 TargetCodeGenInfo(ABIInfo *info = 0):Info(info) { }
43 virtual ~TargetCodeGenInfo();
45 /// getABIInfo() - Returns ABI info helper for the target.
46 const ABIInfo& getABIInfo() const { return *Info; }
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,
51 CodeGen::CodeGenModule &M) const { }
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;
61 unsigned getSizeOfUnwindException() const { return 32; }
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; }
72 /// Determines the DWARF register number for the stack pointer, for
73 /// exception-handling purposes. Implements __builtin_dwarf_sp_column.
75 /// Returns -1 if the operation is unsupported by this target.
76 virtual int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const {
80 /// Initializes the given DWARF EH register-size table, a char*.
81 /// Implements __builtin_init_dwarf_reg_size_table.
83 /// Returns true if the operation is unsupported by this target.
84 virtual bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
85 llvm::Value *Address) const {
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.
93 /// Used by __builtin_extract_return_addr().
94 virtual llvm::Value *decodeReturnAddress(CodeGen::CodeGenFunction &CGF,
95 llvm::Value *Address) const {
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.
103 /// Used by __builtin_frob_return_addr().
104 virtual llvm::Value *encodeReturnAddress(CodeGen::CodeGenFunction &CGF,
105 llvm::Value *Address) const {
109 virtual llvm::Type* adjustInlineAsmType(CodeGen::CodeGenFunction &CGF,
110 llvm::StringRef Constraint,
111 llvm::Type* Ty) const {
115 /// Retrieve the address of a function to call immediately before
116 /// calling objc_retainAutoreleasedReturnValue. The
117 /// implementation of objc_autoreleaseReturnValue sniffs the
118 /// instruction stream following its return address to decide
119 /// whether it's a call to objc_retainAutoreleasedReturnValue.
120 /// This can be prohibitively expensive, depending on the
121 /// relocation model, and so on some targets it instead sniffs for
122 /// a particular instruction sequence. This functions returns
123 /// that instruction sequence in inline assembly, which will be
124 /// empty if none is required.
125 virtual llvm::StringRef getARCRetainAutoreleasedReturnValueMarker() const {
131 #endif // CLANG_CODEGEN_TARGETINFO_H