blob: 9e80081429cc6767e793bbbce7b8cfc10f8284fc [file] [log] [blame]
Anton Korobeynikov55bcea12010-01-10 12:58:08 +00001//===---- 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
18namespace llvm {
19 class GlobalValue;
John McCalld4f4b7f2010-03-03 04:15:11 +000020 class Value;
Anton Korobeynikov55bcea12010-01-10 12:58:08 +000021}
22
23namespace clang {
24 class ABIInfo;
25 class Decl;
26
27 namespace CodeGen {
28 class CodeGenModule;
John McCalld4f4b7f2010-03-03 04:15:11 +000029 class CodeGenFunction;
Anton Korobeynikov55bcea12010-01-10 12:58:08 +000030 }
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 Gregor0599df12010-01-22 15:41:14 +000039 TargetCodeGenInfo(ABIInfo *info = 0):Info(info) { }
Anton Korobeynikov55bcea12010-01-10 12:58:08 +000040 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 Gregor0599df12010-01-22 15:41:14 +000048 CodeGen::CodeGenModule &M) const { }
John McCallb6cc2c042010-03-02 03:50:12 +000049
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 McCalld4f4b7f2010-03-03 04:15:11 +000058
59 /// Performs the code-generation required to convert a return
60 /// address as stored by the system into the actual address of the
61 /// next instruction that will be executed.
62 ///
63 /// Used by __builtin_extract_return_addr().
64 virtual llvm::Value *decodeReturnAddress(CodeGen::CodeGenFunction &CGF,
65 llvm::Value *Address) const {
66 return Address;
67 }
68
69 /// Performs the code-generation required to convert the address
70 /// of an instruction into a return address suitable for storage
71 /// by the system in a return slot.
72 ///
73 /// Used by __builtin_frob_return_addr().
74 virtual llvm::Value *encodeReturnAddress(CodeGen::CodeGenFunction &CGF,
75 llvm::Value *Address) const {
76 return Address;
77 }
Anton Korobeynikov55bcea12010-01-10 12:58:08 +000078 };
79}
80
81#endif // CLANG_CODEGEN_TARGETINFO_H